Php
Moderator: General Moderators
Re: Understanding PHP
All you want is to understand what it does?
Unfortunately the color for comments is a dark gray, makes them a bit harder to read.
I rate this script at 6/10. Insecure, wasteful, and a bit inconsistent in places.
Unfortunately the color for comments is a dark gray, makes them a bit harder to read.
Code: Select all
// this function takes two arguments: objArray (probably an array) and
// photo_name (probably a string)
function somefunction($objArray,$photo_name)
{
// global is used to get to variables defined outside the function
// PHP won't let you do that automatically
// "objSmarty" is probably the main Smarty object
global $objSmarty;
// get the month from the objArray
$month=$objArray["month"];
// get the day number
$day=$objArray["date"];
// this will add a leading zero to the day
// if it's less than 10 (one digit) it adds a zero, otherwise it doesn't
if($day<10)
$days="0".$day;
else
$days=$objArray["date"];
// get the year
$year=$objArray["year"];
// turn those numbers into YYYY-M-DD format
// (we didn't pad the month with zeroes so it might be one digit!)
$dob=$year."-".$month."-".$days;
// if the name is not empty
if($photo_name!="")
{
// run an UPDATE query
// I added spaces here and below so it doesn't mess up the page layout
$UpQuery = "Update tbl_member set disp_name='" . addslashes($objArray['disp']) . "', first_name='" . addslashes($objArray['firstname']) . "', last_name='" . $objArray['lastname'] . "', zipcode='" . $objArray['post'] . "', user_photo_name='" . $photo_name . "', country='" . $objArray['country'] . "', state='" . $objArray['state'] . "', gender='" . $objArray['gender'] . "', date_birth='" . $dob . "' where user_id=" . $_SESSION['user_id'];
$this->ExecuteQuery($UpQuery, "update");
}
else
{
// run an almost identical query (no mention of user_photo_name in here)
$UpQuery = "Update tbl_member set disp_name='" . addslashes($objArray['disp']) . "', first_name='" . addslashes($objArray['firstname']) . "', last_name='" . $objArray['lastname'] . "', zipcode='" . $objArray['post'] . "', country='" . $objArray['country'] . "', state='" . $objArray['state'] . "', gender='" . $objArray['gender'] . "', date_birth='" . $dob . "' where user_id=" . $_SESSION['user_id'];
$this->ExecuteQuery($UpQuery, "update");
}
// finally a return value. this function will always return true
return true;
}