Thursday, October 16, 2008

A typical cms website






Those are screen shots of the current projects, im working on....see http://www.olusolaakinseye.com/ for more...but oops sorry guys...u can't see the back-end, its a content management sytem.
Contact me if you need a cms for your website or you need help on how to create a cms.
Cheers!!!

Two powerful classes developed by me in php!

Hello Guys,

Are u a PHP programmer, understand OOP. Here is a mysql database connection file for you which I developed into a class and a photo upload class just copy the codes into a php file or script named "c_common.php" and paste the codes, save the file.

This codes have been so helpful to me as I just reuse them and don't need to rewrite them...of course you know how OOP works!!!

NOTE: You need PHP 5 to run this code

So how do you use them simply call an object, something like this:
To upload a photo
require_once("c_common.php") //attach the class file
$upl=new uploadfile()
$filename=$upl->pushfile("photos",$_FILES['upload']); //the folder name is the first parameter required and the second is the name of the photo upload control

Here's the code pasted here for you.

//************the connection class to the database is created here
class connection{
var $server;
var $uname;
var $pword;
var $dbase;
function __construct($s,$u,$p,$db){
server=$s;
$this->uname=$u;
$this->pword=$p;
$this->dbase=$db;
//define the mysql connection variables
define("HOST",$this->server);
define("USER",$this->uname);
define("PASS",$this->pword);
define("DB",$this->dbase);
}
function opendatabase(){
$db=mysql_pconnect(HOST,USER,PASS);
try{
if(!$db){
$exp="Error connecting to database:
";
$exp .= mysql_errno(). ": ".mysql_error();
throw new exception($exp);
} else {
mysql_select_db(DB,$db);
}
return $db;
} catch(exception $e){ echo $e->getmessage();
} }

}//********End of the connection class


//*************the file upload class**********
class uploadfile{
function __construct(){ }
//Code handler for the file Upload function
pushfile($folder, $controlname){
if(isset($controlname['name']) && $controlname['size']>0) {
$fileName=$controlname['name'];
$tmpName=$controlname['tmp_name'];
$fileSize=$controlname['size'];
$fileType=$controlname['type'];
$random=rand();
$fileName=$random.$fileName;
$upload_dir = $folder . '/';
if (!@move_uploaded_file($tmpName, $upload_dir . $fileName )) {
//echo "Error moving the file to its destination, ";
//"please try again here.";
}
if(!get_magic_quotes_gpc()) {
$fileName=addslashes($fileName);
}
} return $fileName; }
}//********file upload class ends here
?>

so try it guys, see if its works fine!
Pls do let me know your comments and tell me how this code works for you and let me know if you need help with some other programmer problems!!!
Cheers!!!