Archive for the 'Programming' Category...
Filed under Programming, PHP
This is quite a unique little function. It came in handy when I had to check a "global" array holding all key elements already loaded.
CODE:
-
$foo = array('test1'=>"This is test 1",
-
-
'test2'=>"This is test 2");
-
-
$global_bar = array('test1'=>'yep its loaded');
-
-
foreach($foo as $fkey=>$f){
-
-
if(!array_key_exists($fkey, $global_bar)){
-
-
// not there - keep going.
-
-
}else{
-
-
// Yep its there.
-
-
}
-
-
}
Very simple example above - for more information check php.net: http://www.php.net/manual/en/function.array-key-exists.php
Filed under Programming, PHP
Well, here I was again doing a fast freelance job for a friend - He wanted a full functioning forum up and ready to go as fast as possible. I of course thought of the very nice free system - phpbb(http://phpbb.com). To make things interesting we had already put in place a custom made membership system, the phpbb forum would now have to integrate into our Registration and Login process seamlessly.
My first instinct was to go to the boards on PHPBB and do a quick search to find my solution - It turns out the solution is not fully laid out... Or atleast to me it didn't seem to be layed out.
So after about 30-45 minutes looking over threads and replies I decided to just look at how PHPBB initiated its sessions and cookies and go for it myself.
Here are my easy steps to accomplish this login / registration task (I have no error checking/hack prevention in place for my example, I don't want to do everything for you now
)
STEP 1 - REGISTRATION
CODE:
-
//Query to select the max number of users in the table
-
$sql = "SELECT MAX(user_id) AS total FROM phpbb_users";
-
$select=mysql_query($sql);
-
$row=mysql_fetch_array($select);
-
-
//Taking the max number of records and adding 1 for the next user_id
-
$user_id=$row['total']+1;
-
-
//Query to insert the basics into the users table.
-
//NOTE - Take validation into your own hands, this is just an example.
-
$sql = "INSERT INTO phpbb_users (user_id, username, user_regdate,
-
user_password, user_email,user_active)
-
VALUES ($user_id, '$username',".time().",'$password','$email','1')";
-
-
//Insert the user
-
$insert=mysql_query($sql);
-
-
//Setup the users group so he/she has posting ability.
-
//Why group_id=3?
-
//On a basic PHPBB installation:
-
// ID #1 = Visitor/Guest
-
// ID #2 = Admin
-
// ID #3 = Basic registered user
-
//If you have a custom user group setup,
-
//replace 3 with the id number.
-
$group_id=3;
-
-
$sql = "INSERT INTO phpbb_user_group (user_id,
-
group_id, user_pending)
-
VALUES ($user_id, $group_id, 0)";
-
-
//Insert user into the correct group.
-
$insert=mysql_query($sql);
-
-
//Add in your own registration for your own website here.
STEP 2 - LOGIN
CODE:
-
//Place this on top of your login script
-
-
define("IN_LOGIN", true);
-
define('IN_PHPBB', true);
-
-
//Be sure to update the root path to match your forum settings
-
$phpbb_root_path = './forum/';
-
include($phpbb_root_path . 'extension.inc');
-
include($phpbb_root_path . 'common.'.$phpEx);
While checking for the username/password within your own system (and succeeding) enter these few lines of code.
CODE:
-
$select=mysql_query("SELECT * FROM phpbb_users WHERE username='".$username."'");
-
$row=mysql_fetch_array($select);
-
$userdata = session_pagestart($user_ip, PAGE_LOGIN);
-
$session_id = session_begin($row['user_id'],
-
$user_ip, PAGE_INDEX, FALSE, $autologin, '0');
The above peace of code will use PHPBB's own session handler to create the cookies / sessions needed to log the user into the forum - as well as your own system.
Enjoy!
Filed under Programming, AIR
Adobes Apollo project has been provided a new breath of life, which so conveniently is named AIR (Adobe Integrated Runtime). Yes, the AIR project is the same as Apollo just with a few new (advanced) features.
The key feature to Apollo/AIR is the runtime enviorment as it allows you to take your Javascript, HTML, Flash, or Flex application and turn it into a light desktop application.
Why do I say "light"? Frankly, the AIR runtime does not handle its resources and memory access very well - hence any large system seems clunky, and slow to response.
Now, what can a light application do? What is the Runtime useful for at this stage in the game?
Lets take a real world example - Pownce.com...
"You can access all of your Pownce notes just on our website or you can download a small program for your computer.
The software is available right now for Windows and Mac users and will be available for Linux soon too. It takes advantage of a new technology from Adobe called AIR, which is super useful."
Screenshot

View larger image
Yes... Pownce has created a very simple IM type application and integrated it to work directly with their website.
Now, however cool this might be - Is it really practical to have another system like this? I personally believe not, Pownce will not steal any facebookers just because they have a cool AIR application.
In my opinion the largest contribution this runtime offers is the ability to instantly update your users / members of new content on your website. Imagine your user having an instant notification sent right to their desktop when a user has posted a reply to their topic? Many of you will say... so... thats email? Not exactly, when it comes to automated responses email has some flaws.
Over all AIR is not fully operational, its real world examples and applications are more experiments / cool toys instead of practical applications.
I do however believe this will be quite revolutionary and will more then likely become an effective way to deliver fresh content to your users as well as communicate your users content with your website(Instant desktop updates without c++!).
More to come as I am now developing a few "Practical" applications for my employers.
RESOURCES
Adobe AIR
Adobe Showcase
O2Apps.com
Filed under Programming, Javascript, CSS
Thank you google toolbar!!
Read more: http://www.htmldog.com/ptg/archives/000017.php
Fix: http://code.jenseng.com/google/
Enjoy
Filed under Programming, CSS / Design, CSS
CODE:
-
A:active
-
{
-
outline: none;
-
}
-
A:focus
-
{
-
-moz-outline-style: none;
-
}
Enjoy
Filed under Programming, Hot or Not?
This morning right as I started working I noticed an interesting post on Digg... Manipulate images on the web?
Now, of course images can be manipulated on the web this wasn't the question; however, the way it was written made me check it out.
*Click* - FotoFlexer - *thinks: This seems like a whole lot of nothing*
FotoFlexer: FotoFlexer is the most powerful online digital photo editor in existence. (from the website)
Come to find out they use their own image manipulation system (meaning Adobes) to rotate, stretch, and attach basic filters. After a quick play with it I have to say it is not HOT, it only allows for basic manipulation and mediocre text tools. What's even worse is that you have to be registered with them to use it. If it is truly free then just let it be free
The system looks to be developed using Flex, that right there turns me off.
FotoFlexer: Not the coolest image manipulation system on the internet.
Anyways - check it out and let me know what you think about it: http://fotoflexer.com
As for me... Back to photoshop
Filed under Programming, Make you smile
While testing our new administrative panel for the company I work for I stumbled upon an interesting "validation"... error?
Now... if you want to use an alert to question a users action within the system - be sure to give them at least two options
Click to view the screenshot
Filed under Programming, Javascript
Planet Yazaar creates and maintains community-supported additions to the Yahoo User Interface (YUI) Library (Yahoo + Bazaar = Yazaar).
This is an interesting idea - I would like to see a bit better design and system though. Still something worth checking out!
Filed under Programming, Javascript
We have a function - resizeAll()
Now, what does this function do?
Quite simple, if you read in my earlier post about the issue I found with YUI's animation class you would know what the purpose of this function does.
If you know NOTHING about what I speak, read my post here:
http://simplyprogram.com/yui-interesting-find/
Back to the function -- My initial test was to take one or many images and have them animate the EXACT SAME as the containing element. I am proud to say this has been accomplished!
So when we started this our code looked a little bit like this:
JavaScript:
-
var attributes = {
-
width: { to: 0 },
-
height: { to: 0 },
-
opacity: { to: 1 },
-
fontSize: { from: 100, to: 0, unit: '%'}
-
};
-
-
var anim = new YAHOO.util.Anim(itemObj,
-
attributes, 1.0, YAHOO.util.Easing.backOut);
-
-
anim.animate();
With my new function in place our code looks like this:
JavaScript:
-
var attributes = {
-
width: { to: 0 },
-
height: { to: 0 },
-
opacity: { to: 1 },
-
fontSize: { from: 100, to: 0, unit: '%'}
-
};
-
-
var anim = new YAHOO.util.Anim(itemObj,
-
attributes, 1.0,YAHOO.util.Easing.backOut);
-
-
anim.resizeAll();
-
anim.animate();
Thats it - Simply place anim.resizeAll() within your code and ALL images will take on the same attributes and animation method as your containing element.
What is next for this function?
I am now working to make it pretty much any element you could possibly want to animate!
On the priority list:
1. Other Divs
2. Other font tags
3. OBJECT Codes (Includes Flash
)
4. Forms
I think that should do it for now.
Until my next update!
Filed under Programming
New life is being breathed into ACJavascripts.com - No, I am not redesigning it again!
However, considering the numerous errors with the website I am re-doing certain aspects as well as adding new elements and scripts.
If you have a free moment stop on bye and check out the additions and updates - http://www.acjavascripts.com.