0) { generate_menu($Fetch['CategoryID'],$ProductID,$ProductTable,$CategoryTable,$ProductCatID); } } return $TestListArrTest; } #___________________#___________________#___________________#___________________#___________________#___________________# function myAddSlashes($string) { if (get_magic_quotes_gpc()==1) { return ( $string ); } else { return ( addslashes ( $string ) ); } } function IncrementCounter($PageID) { global $objDB,$tblpage; //$link=mysql_connect("localhost","root",""); //mysql_select_db("mysite",$link); $sql="UPDATE `".$tblpage."` SET PageCounter=PageCounter + '1' where PageID='".$PageID."'"; //echo $sql;`".$tblpage."` $result=$objDB->ddlQuery($sql) or domail("'".mysql_error()."'","INCREMENT ERROR","'".$_SERVER['SCRIPT_NAME']."'"); } function getdateformat($ModifiedDate,$TimeZone="") { $tz=split(".",$TimeZone); if(strlen($ModifiedDate>10) && $TimeZone!="") { $datetime=split(" ",$ModifiedDate); $vardate=$datetime[0]; $vartime=$datetime[1]; $newdate=split("-",$vardate); $newtime=split(":",$vartime); $str=date("d M Y H:i:s", mktime(($tz[0]+$newtime[0]),($tz[1]+$newtime[1]),$newtime[2],$newdate[1],$newdate[2],$newdate[0])); } else { $vardate=split("-",$ModifiedDate); $str = gmdate("d M Y", mktime(0,0,0,$vardate[1],$vardate[2],$vardate[0])); //$str=$vardate[1]."-".$vardate[2]."-".$vardate[0]; //$str=date("M-d-Y",mktime($tz[0],$tz[1],0,$vardate[1],$vardate[2],$vardate[0])); } //die(); return $str; } function word_count($str) { $arr=explode(" ",$str); return count($arr); } function GetUniqueCode($len) { mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up. $charid = strtoupper(md5(uniqid(rand(), true))); $hyphen = chr(45);// "-" $uuid = chr(123)// "{" .substr($charid, 0, $len) .chr(125);// "}" $uuid = str_replace('{','',$uuid); $uuid = str_replace('}','',$uuid); return $uuid; } function format_time($t_stamp){ $t_stamp=gmdate("D M d, Y g:i A",$t_stamp); return $t_stamp; } function format_time_short($t_stamp){ $t_stamp=gmdate("d M Y",$t_stamp); return $t_stamp; } function add_time($date, $numberofdays) { $datetime = explode(" ",$date); $newdate = explode("-", $datetime[0]); $newtime = explode(":", $datetime[1]); $comingdate = date("d M Y", mktime($newtime[0], $newtime[1], $newtime[2], $newdate[1], $newdate[2]+$numberofdays, $newdate[0])); return $comingdate; } /* ========================================================================================================== # The parameters for type are : 'image', 'pdf' , 'plaintext', 'docs', 'misc'. * 'Image' : jpeg, pjpeg, bmp, png , and gif files (it is default) * 'pdf' : .pdf files * 'plaintext' : .txt files * 'docs' : .txt, .pdf, .rtf, .doc, .sxw files * 'misc' : hopefully files with any known/widely used extension * 'flash' : .swf * 'zip' : .zip # The parameters for overwrite (over) are : 'N', 'Y' ========================================================================================================== */ function upload_file($source,$destination,$type,$over,$thumb=false) { global $CMD_AV; $file=$source['tmp_name']; $filename=$source['name']; $filename = str_replace(" ","_",$filename); $filetype=$source['type']; $filesize=$source['size']; // Scanning the file with AV ClamAV to check if it is infected $cmd = "$CMD_AV $file"; $av_msg = system($cmd); if(!empty($msg)) { $_SESSION['MESSAGE']=$av_msg; $msg=$av_msg; return $msg; exit; } if($type=='image') { $valid = array('image/pjpeg','image/jpeg','image/jpg','image/bmp','image/png','image/gif','image/x-png'); } elseif($type == 'flash') { $valid = array('application/x-shockwave-flash'); } elseif($type == 'zip') { $valid = array('application/zip', 'application/octet-stream','application/x-zip-compressed'); } elseif($type=='pdf') { $valid = array('application/pdf'); } elseif($type=='plaintext') { $valid = array('text/plain'); } elseif($type=='docs') { $valid = array('text/plain','application/pdf','text/rtf','application/msword','application/vnd.sun.xml.writer'); } elseif($type=='misc') { $valid = array('text/plain','application/pdf','application/octet-stream','image/pjpeg', 'image/jpeg','image/jpg','image/bmp','image/png','image/gif','text/rtf','application/msword', 'application/vnd.ms-excel','application/vnd.ms-powerpoint','message/rfc822', 'application/vnd.sun.xml.calc','application/vnd.sun.xml.writer','application/vnd.sun.xml.impress', 'application/vnd.sun.xml.writer','application/vnd.sun.xml.draw'); } else { $_SESSION['MESSAGE']="Invalid Supplied Type"; $msg="Invalid Supplied Type"; return $msg; exit; } if(in_array($filetype,$valid)) { if($filesize>0) { if($over=='Y') { $file_copy_to=$destination.$filename; copy($file,$file_copy_to); if($thumb) { fi_create_thumbnail($file_copy_to); } return $filename; } elseif($over=='N') { $tm = time(); $file_copy_to=$destination.$tm.$filename; copy($file,$file_copy_to); if($thumb) { fi_create_thumbnail($file_copy_to); } return $tm.$filename; } else { $_SESSION['MESSAGE']="Invalid Parameter for Overwrite, Please Try Again"; $msg="Invalid Parameter for Overwrite, Please Try Again"; return $msg; exit; } } else { $_SESSION['MESSAGE']="File is empty, Please Try Again"; $msg="File is empty, Please Try Again"; return $msg; exit; } } else { $_SESSION['MESSAGE']="Invalid File Type, Please Try Again"; $msg="Invalid File Type, Please Try Again"; return $msg; exit; } } function fi_create_thumbnail($file_copy_to){ $destWidth = 104; $destHeight = 76; $imagesize = getimagesize($file_copy_to); $srcWidth=$imagesize[0]; $srcHeight=$imagesize[1]; if ($destWidth && ($srcWidth < $srcHeight)) { $destWidth = ($destHeight / $srcHeight) * $srcWidth; } else { $destHeight = ($destWidth / $srcWidth) * $srcHeight; } $destImage = imagecreatetruecolor($destWidth, $destHeight); $destImage=$file_copy_to."_thumb"; imagecopyresampled($destImage, $file_copy_to, 0, 0, 0, 0, $destWidth, $destHeight, $srcWidth, $srcHeight); } function now() { $today = date("Y-m-d H:i:s"); return $today; } function TitleCase($str) { //function to make the first letter of every word an upper case and all the letters a lower case $words=explode(" ",$str); $length=count($words); for($i=0;$i<$length;$i++) { $word=$words[$i]; $firstletter=substr($word,0,1); $restletters=strtolower(substr($word,1)); $firstletter=strtoupper($firstletter); $final=$final.$firstletter.$restletters." "; } return $final; } function FormatCurrency($amount, $commas=NULL) { // Formats any number into valid US currency // Inserts commas if $commas flag is set // Output should match regular expression ^-?([0-9]+|[0-9]{1,3}(,[0-9]{3})*)\.[0-9]{2}$ $amount = str_replace(",", "", $amount); // Strip out commas if ($amount == 0) return "0.00"; // Catch zero values if ($amount < 0) // If we are dealing with a negative number... { $amount = substr($amount, 1); // Cut off the minus sign $negative = "-"; // Set the $negative flag } $amount = explode(".", $amount); // Explode $amount into an array $integer = $amount[0]; // Rename left of decimal $integer $decimal = $amount[1]; //Rename right of decimal $decimal if ($integer != 0) { // If there is an integer... $zeros = strspn($integer, "0"); // Find # of leading zeros in $integer $integer = substr($integer, $zeros); // Strip leading zeros from $integer } else $integer = 0; // Else use a zero as a placeholder if ($decimal) { // If there is a decimal... if (substr($decimal, 2, 1) > 4) // If we need to round up... { $decimal = substr($decimal, 0, 2); // Truncate to 2 decimal places if ($decimal == 99) { // If the decimal is 99... $decimal = 00; // Set the decimal to 00 $integer++; // Increment the integer } elseif ($decimal < 9) // Catch decimals with leading zeros... { $decimal++; // Increment the decimal $decimal = "0".$decimal; // And manually replace the zero } else $decimal++; // Else just increment the decimal } else $decimal = substr($decimal, 0, 2); // We still need to truncate to 2 decimal places if (strlen($decimal) == 1) $decimal.= "0"; // If length is 1, add a zero } else $decimal = "00"; // Else set the decimal to 00 $length = strlen($integer); // Store the length of the integer in $length if ($commas && $length > 3) // If we need to add commas... { for ($i=3; $i<$length; $i=$i+3) // Loop $length / 3 times { $integer = substr($integer, 0, $length - $i).",".substr($integer, $length - $i); // Split $integer at $length - $i and rejoin around a comma } } $amount = $negative.$integer.".".$decimal; // Rebuild the $amount return $amount; // Return the formatted $amount } function findmember_name($MemberID) { global $objDB,$tblmember; $sql_member="SELECT * FROM `".$tblmember."` WHERE MemberID='".$MemberID."'"; $res_member=$objDB->ddlQuery($sql_member); $num_member=$objDB->numberRow($res_member); if($num_member) { $row_member=$objDB->get_row($res_member); $str=$row_member['FirstName']." ".$row_member['LastName']; } else { $str=0; } return $str; } function findmember_name_url($MemberID) { global $objDB,$tblmember; $sql_member="SELECT * FROM `".$tblmember."` WHERE MemberID='".$MemberID."'"; $res_member=$objDB->ddlQuery($sql_member); $num_member=$res_member->numberRow($res_member); if($num_member) { $row_member=$objDB->get_row($res_member); $str="".$row_member['FirstName']." ".$row_member['LastName'].""; } else { $str=0; } return $str; } function getSize($param) { if($param=="S") { return "Small"; } else if($param=="M") { return "Medium"; } else if($param=="L") { return "Large"; } else if($param=="XL") { return "Xtra Large"; } } function getStaus($mode) { global $user; if($user->getCountry()=="United States of America") { if($mode=="direct") { return ""; } elseif($mode=="express") { return "style='display:none;'"; } } else { if($mode=="direct") { return "style='display:none;'"; } elseif($mode=="express") { return ""; } } } function download_file($file){ //First, see if the file exists if (!is_file($file)) { die("404 File not found!"); } //Gather relevent info about file $len = filesize($file); $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename,"."),1)); //This will set the Content-Type to the appropriate setting for the file switch( $file_extension ) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; case "mp3": $ctype="audio/mpeg"; break; case "wav": $ctype="audio/x-wav"; break; case "mpeg": case "mpg": case "mpe": $ctype="video/mpeg"; break; case "mov": $ctype="video/quicktime"; break; case "avi": $ctype="video/x-msvideo"; break; //The following are for extensions that shouldn't be downloaded (sensitive stuff, like php files) case "php": case "htm": case "html": case "txt": die("Cannot be used for ". $file_extension ." files!"); break; default: $ctype="application/force-download"; } //Begin writing headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); //Use the switch-generated Content-Type header("Content-Type: $ctype"); //Force the download $header="Content-Disposition: attachment; filename=".$filename.";"; header($header); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".$len); @readfile($file); exit; } function notifymail_user_upload_to_admin() { /* Mail will send to admin when user Upload image */ global $user,$adminmail; $to=$adminmail; $num_images=1; $from="noreply@test.com"; $header = "From: $from ".$from."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $header .= "X-Priority: 3\r\n"; $header .= "X-MSMail-Priority: Normal\r\n"; $header .= "X-Mailer: PHP / ".phpversion()."\r\n"; $sub=$user_name."s Image Uploaded in www.fotothon.com ."; $body='
One image successfully uploaded by '.$user->getUserName().'.
'; @mail($to,$sub,$body,$header); } function notifymail_photo_purchase_to_admin($TxnID) { /* Mail will send to the customer When he buys an image */ global $cart,$user,$adminmail;//cart object declared globally and the user object //$to=$adminmail; $to=$adminmail; //$to=$user->getUserEmail(); //$to=$adminid; $TotalPrice=$cart->total_price(); $from="noreply@test.com"; $header = "From: ".$from."\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $header .= "X-Priority: 1\r\n"; $header .= "X-MSMail-Priority: Normal\r\n"; $header .= "X-Mailer: PHP / ".phpversion()."\r\n"; $sub="Photo Downloaded from test.com"; $str=''; $ImageTitleArr=$cart->ImageTitle_list(); $PhotoContributorIDArr=$cart->contributor_list(); $SizeTypeArr=$cart->type_list(); $PriceArr=$cart->price_list(); //$ThumbPathArr=$cart->PhotoThumbnailPath(); //$i=0; foreach($cart->ImageID_list() as $key => $pid) { $str .=' '; } $str .='
Customer\'s Name : '.$user->getfullusername().'
Transaction ID : '.$TxnID.'
Total Sell: $'.$TotalPrice.'
Image Title Image Size Contributor Name Price Admin %age
'.TitleCase($ImageTitleArr[$key]).' '.getSize($SizeTypeArr[$key]).' '.findmember_name($PhotoContributorIDArr[$key]).' '.FormatCurrency($PriceArr[$key],2).' '.FormatCurrency(0.2 * FormatCurrency($PriceArr[$key],2)).'
'; @mail($to,$sub,$str,$header); } function getcity($cityid) { global $objDB; $sql_city="SELECT * FROM `city` WHERE `id`='".$cityid."'"; //echo $sql; $result_city=$objDB->ddlQuery($sql_city); $row_city=$objDB->get_row($result_city); $city=$row_city['CityName']; return $city; } function getdistrict($districtid) { global $objDB; $sql_dist="SELECT * FROM `district` WHERE `id`='".$districtid."'"; $result_dist=$objDB->ddlQuery($sql_dist); $row_dist=$objDB->get_row($result_dist); $district=$row_dist['DistrictName']; return $district; } function getsuburbs($suburbid) { global $objDB; $sql_sub="SELECT * FROM `suburbs` WHERE `id`='".$suburbid."'"; $result_sub=$objDB->ddlQuery($sql_sub); $row_sub=$objDB->get_row($result_sub); $suburb=$row_sub['SuburbName']; return $suburb; } //function to get the category list of a table when calling the function initially the 1st parameter will be 0(zero). function getCategory($catid,$tbl){ global $arr,$objDB,$level; $level=0; $sql="SELECT * FROM `".$tbl."` WHERE `ParentID`=".$catid; $res=$objDB->ddlQuery($sql); while($row=$objDB->get_row($res)) { $l=getLevel($row['CatID'],$tbl); $level=0; $append_string=''; for($i=1;$i<=$l;$i++){ $append_string.=" --"; } $append_string.=" "; $arr[]=array("CatID"=>$row['CatID'],"CatName"=>$append_string.$row['CatName'],"level"=>$l); getCategory($row['CatID'],$tbl); } return $arr; } function getLevel($catid,$tbl) { global $objDB,$level; $sql="SELECT * FROM `".$tbl."` WHERE `CatID`='".$catid."'"; $result_parent=$objDB->ddlQuery($sql); $row_parent=$objDB->get_row($result_parent); if($row_parent['ParentID']!=0){ $level++; getLevel($row_parent['ParentID'],$tbl); } return $level; } //function to get the Manufacturers list of a table when calling the function initially the 1st parameter will be 0(zero). function getManufacturer($tbl){ global $arr,$objDB; $sql="SELECT * FROM `".$tbl."` "; $res=$objDB->ddlQuery($sql); while($row=$objDB->get_row($res)) { $l=getLevel($row['ManufacturerID'],$tbl); $level=0; $append_string=''; for($i=1;$i<=$l;$i++){ $append_string.=" --"; } $append_string.=" "; $arr[]=array("ManufacturerID"=>$row['ManufacturerID'],"Name"=>$append_string.$row['Name']); getCategory($row['ManufacturerID'],$tbl); } return $arr; } function isParentCategory($catid,$tbl){ global $objDB; $sql = "SELECT * FROM `".$tbl."` WHERE `CategoryID`='".$catid."' AND `ParentCategory`=0"; $res = $objDB->ddlQuery($sql); $num = $objDB->numberRow($res); if($num) { return 'true'; } else { return 'false'; } } function getMemberRating($memberId,$tab) { //echo $memberId."
"; global $objDB; // die($memberId);die(); $sql_positive_sell="SELECT COUNT(Feedback) As Totalfeedback,COUNT(DISTINCT FromMemberID) As Individual FROM $tab WHERE `FeedbackMode`='POSITIVE' AND `ReceiverRole`='SELLER' AND `ToMemberID`='".$memberId."' GROUP BY `ToMemberID`"; $res_sell = $objDB->ddlQuery($sql_positive_sell); $row_sell=$objDB->get_row($res_sell); $sql_positive_Buy="SELECT COUNT(Feedback) As Totalfeedback,COUNT(DISTINCT FromMemberID) As Individual FROM $tab WHERE `FeedbackMode`='POSITIVE' AND `ReceiverRole`='BUYER' AND `ToMemberID`='".$memberId."' GROUP BY `ToMemberID`"; $res_buy = $objDB->ddlQuery($sql_positive_Buy); $row_buy=$objDB->get_row($res_buy); $TotalPosFeedback=$row_sell['Totalfeedback']+$row_buy['Totalfeedback']; $indPosFeedback=$row_sell['Individual']+$row_buy['Individual']; $sql_negetive_sell="SELECT COUNT(Feedback) As Totalfeedback,COUNT(DISTINCT FromMemberID) As Individual FROM $tab WHERE `FeedbackMode`='NEGATIVE' AND `ReceiverRole`='SELLER' AND `ToMemberID`='".$memberId."' GROUP BY `ToMemberID`"; $res_sell_n = $objDB->ddlQuery($sql_negetive_sell); $row_sell_n=$objDB->get_row($res_sell_n); $sql_negetive_Buy="SELECT COUNT(Feedback) As Totalfeedback,COUNT(DISTINCT FromMemberID) As Individual FROM $tab WHERE `FeedbackMode`='NEGATIVE' AND `ReceiverRole`='BUYER' AND `ToMemberID`='".$memberId."' GROUP BY `ToMemberID`"; $res_buy_n = $objDB->ddlQuery($sql_negetive_Buy); $row_buy_n=$objDB->get_row($res_buy_n); $TotalNegFeedback=$row_sell_n['Totalfeedback']+$row_buy_n['Totalfeedback']; $indNegFeedback=$row_sell_n['Individual']+$row_buy_n['Individual']; $rating=$indPosFeedback-$indNegFeedback; return $rating; } function getImage($itemid,$tbl,$primary,$status,$type) { global $objDB; $sql_item_image = "SELECT * FROM `".$tbl."` WHERE `ItemType`='".$type."' AND `isPrimary`='".$primary."' AND status='".$status."' AND `ItemID`=".$itemid; //echo $sql_item_image; $res_movie_image = $objDB->ddlQuery($sql_item_image); $num_movie_image = $objDB->numberRow($res_movie_image); if($num_movie_image) { $rec_movie_image = $objDB->get_row($res_movie_image); $LargeImage = $rec_movie_image['Image']; $ThumbImage = $rec_movie_image['ThumbImage']; } else { $LargeImage = 'nopic.jpg'; $ThumbImage = 'nopic.jpg'; } return $LargeImage; } /******* function to get the num of items based on category id, include all those items in the sub category *********/ function getItemCount($CatID,$tbl,$regionid='',$level='') { //echo $regionid; global $objDB,$ItemCount; if($level=='') { $sql = "SELECT * FROM `".$tbl."` WHERE `CategoryID`=".$CatID; } else { $sql = "SELECT * FROM `".$tbl."` WHERE `ParentCategory`=".$CatID; } $res = $objDB->ddlQuery($sql); $num = $objDB->numberRow($res); if($num) { while($row = $objDB->get_row($res)) { $sql_item = "SELECT category_item_map.CategoryID AS CategoryID FROM items,category_item_map WHERE items.ItemID = category_item_map.ItemID AND category_item_map.CategoryID = ".$row['CategoryID']; if($regionid != 0) { $sql_item = "SELECT category_item_map.CategoryID AS CategoryID FROM items,category_item_map WHERE category_item_map.CategoryID=".$row['CategoryID']." AND items.LocationID='".$regionid."'"; } //echo $sql_item; $res_item = $objDB->ddlQuery($sql_item); $num_item = $objDB->numberRow($res_item); $ItemCount = $ItemCount + $num_item; getItemCount($row['CategoryID'],$tbl,$regionid,'parent'); } } return $ItemCount; } #-----------------function to get items for general section ------------------------# function getChildCategory($CatID,$tbl,$offset=0,$limit=0,$sqlsortby='Headline',$regionid='') { global $itemsDetails,$objDB,$ItemCount; global $cat; global $objTheTrade; $sql = "SELECT * FROM `".$tbl."` WHERE `ParentCategory`='".$CatID."'"; $res = $objDB->ddlQuery($sql); $num = $objDB->numberRow($res); if($cat=="") { $cat="|".$CatID; } if($num) { while($row = $objDB->get_row($res)) { $cat.=",".$row['CategoryID']; getChildCategory($row['CategoryID'],$tbl); } } $categories=ltrim(strchr($cat, '|'),"|"); $categoriesqq = ','.$categories.','; $categoriesff = str_replace(',,','',$categoriesqq); //echo '

'.$categoriesff; //$categories = array_unique(explode(',',$categories)); //print_r($categories); //$categories = implode(',',$categories); if(trim($sqlsortby) == '') $sqlsortby = 'Headline'; $sql_item = "SELECT * FROM items,category_item_map WHERE items.ItemID=category_item_map.ItemID AND Status='Y' AND EndListingDate > NOW() AND category_item_map.CategoryID IN ($categories) GROUP BY items.ItemID ORDER BY $sqlsortby LIMIT $offset, $limit"; if($regionid != 0) { $sql_item = "SELECT * FROM items,category_item_map WHERE items.ItemID=category_item_map.ItemID AND Status='Y' AND EndListingDate > NOW() AND CategoryID IN ($categories) AND LocationID='".$regionid."' GROUP BY items.ItemID ORDER BY $sqlsortby LIMIT $offset, $limit"; } //echo $sql_item; $sql_item = str_replace('(,','(',$sql_item); $sql_item = str_replace(',)',')',$sql_item); $res_item = $objDB->ddlQuery($sql_item); $num_item = $objDB->numberRow($res_item); while($rec=$objDB->get_row($res_item)) { $LargeImage=getImage($rec['ItemID'],'images','Y','Y','GEN'); $Format_date=$objTheTrade->getDateformat($rec['EndBidDate']); $itemsDetails[]=array("ItemID"=>$rec['ItemID'],"CategoryID"=>$rec['CategoryID'],"Headline"=>$rec['Headline'],"Price"=>$rec['Price'],"StartBid"=>$rec['StartBid'],"Description"=>$rec['Description'],"EndBidDate"=>$Format_date,"BuyNow"=>$rec['BuyNow'],"PayNow"=>$rec['PayNow'],"LargeImage"=>$LargeImage,"ThumbImage"=>$ThumbImage); $ItemCount = $ItemCount + $num_item; } //print_r($itemsDetails); return $itemsDetails; } #---------------------Return Child categories For General-----------------# function getChild_categories($tbl,$CatID=0) { global $itemsDetails,$objDB,$ItemCount; global $cat; global $objTheTrade; if($CatID==0) { $sql = "SELECT * FROM `".$tbl."` WHERE `ParentCategory`=0"; } $sql = "SELECT * FROM `".$tbl."` WHERE `ParentCategory`='".$CatID."'"; $res = $objDB->ddlQuery($sql); $num = $objDB->numberRow($res); if($cat=="") { $cat="|".$CatID; } if($num) { while($row = $objDB->get_row($res)) { $cat.=",".$row['CategoryID']; getChildCategory($row['CategoryID'],$tbl); } } $categories=ltrim(strchr($cat, '|'),"|"); return $categories; } #-------------------------Coont properties ------------------------# function getPropertyCount($CatID,$tbl,$locationID='',$sellType='',$DistrictId='') { //echo $CatID; global $objDB,$PropertyCount; $sql_item = "SELECT * FROM `".$tbl."` WHERE `RECategoryID`=".$CatID; if($locationID != '') { $sql_item = "SELECT * FROM `".$tbl."` WHERE `RECategoryID`='".$CatID."' AND `Location`='".$locationID."'"; if($DistrictId !='') { $sql_item.=" AND `District`='".$DistrictId."'"; } if($sellType=='sell') { $sql_item.=" AND `PropertySellType`='Sell'"; if($DistrictId !='') { $sql_item.=" AND `District`='".$DistrictId."'"; } } if($sellType=='rent') { $sql_item.=" AND `PropertySellType`='Rent'"; if($DistrictId !='') { $sql_item.=" AND `District`='".$DistrictId."'"; } } } //echo $sql_item; $res_item = $objDB->ddlQuery($sql_item); $num_item = $objDB->numberRow($res_item); return $num_item; } function getDistrictCount($CatID,$tbl,$locationID,$PropertyCategoryName,$sellType='') { //echo $sellType; global $Districtarray; global $objDB,$TotalNumRows,$PerColoumn,$temp; global $objDistrict; $sql_item = "SELECT *,COUNT(DISTINCT District) As IndividualDist FROM `".$tbl."` WHERE `RECategoryID`='".$CatID."' AND `Location`='".$locationID."' GROUP BY `District`"; $res_item = $objDB->ddlQuery($sql_item); $num_item = $objDB->numberRow($res_item); $TotalNumRows = $num_item; $PerColoumn = ceil($TotalNumRows/2); # 3 = three coloumn $temp=$PerColoumn; while($row= $objDB->get_row($res_item)) { $objDistrict->setDistrict($row['District']); $DistrictName=$objDistrict->getDistrictName(); //echo $DistrictName; $link='property-list-by-category.php?PropertyCatID='.$CatID.'&PropertyCategoryName='.$PropertyCategoryName.'&SortBy=Title&Location='.$locationID.'&purpose='.$sellType.'&District='.$row['District']; $Districtarray[]=array("District"=>$row['District'],"num_item"=>$num_item,"Column"=>'',"DistrictName"=>$DistrictName,"TotalItems"=>getPropertyCount($CatID,$tbl,$locationID,$sellType,$row['District']),"Link"=>$link); } for($i=0 ; $i<$TotalNumRows; $i++) { if($i == $PerColoumn) { $Districtarray[$i]["Column"]='CHANGE'; $PerColoumn=$PerColoumn + $temp; } } return $Districtarray; //echo $num_item; } function getAllImages($itemid,$tbl,$type,$status,$primary='') { //echo $itemid; global $objDB; global $otherimages; $sql_item_image = "SELECT * FROM `".$tbl."` WHERE `ItemType`='".$type."' AND `isPrimary`='".$primary."' AND status='".$status."' AND `ItemID`=".$itemid; if($primary=='') { $sql_item_image = "SELECT * FROM `".$tbl."` WHERE `ItemType`='".$type."' AND status='".$status."' AND `ItemID`=".$itemid; } //echo $sql_item_image; $res_movie_image = $objDB->ddlQuery($sql_item_image); $num_movie_image = $objDB->numberRow($res_movie_image); //echo $num_movie_image; if($num_movie_image) { while($rec_movie_image= $objDB->get_row($res_movie_image)) { $otherimages[]=array("LargeImage"=>$rec_movie_image['Image']); } } return $otherimages; } function get_mail_template ($message) { if(stristr($_SERVER['HTTP_HOST'], 'mydemozone') === false) $SiteURL = "http://www.fresherimage.net"; else $SiteURL = "http://www.mydemozone.com/fresherimage"; $message = myAddSlashes($message); $template = '
Logo

'; $template .= $message; $template .= '


Thanks
fresherImage, Admin
'; return ($template); } function send_mail($to, $sub, $body){ $email="dont-reply@fresherimage.com";//who is sending the mail $nickname="FresherImage"; //mail signature i.e receiver will see this name in from field $body = get_mail_template($body); $header = "From: $nickname <$email>\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-Type: text/html; charset=iso-8859-1\r\n"; $header .= "X-Priority: 3\r\n"; $header .= "X-MSMail-Priority: Normal\r\n"; $header .= "X-Mailer: PHP / ".phpversion()."\r\n"; // check if not running from lserver then send mail if(stristr($_SERVER['HTTP_HOST'], "lserver") === false) @mail($to,$sub,$body,$header); } /* Input : Database Field Name Returns : sort image (either asc or desc) Used for column sorting */ function viewSortImage($fieldName) { $getSortField = htmlentities($_GET['sortby'], ENT_QUOTES, 'UTF-8'); $getSortOrder = htmlentities($_GET['order'], ENT_QUOTES, 'UTF-8'); if($fieldName != $getSortField) return; if($getSortOrder == 'A') $sortImage = "../images/desc.gif"; else $sortImage = "../images/asc.gif"; $image_html = ""; return $image_html; } function viewSortImageFront($fieldName) { $getSortField = htmlentities($_GET['sortby'], ENT_QUOTES, 'UTF-8'); $getSortOrder = htmlentities($_GET['order'], ENT_QUOTES, 'UTF-8'); if($fieldName != $getSortField) return; if($getSortOrder == 'A') $sortImage = "images/icon-sort-a.gif"; else $sortImage = "images/icon-sort-d.gif"; $image_html = ""; return $image_html; } /******* this function is used for profanity blocking (bad word mgmt) **********/ function censor ( $m ) { return str_repeat( '*', strlen( $m[0] ) ); } /*******************************************************************************/ // will return formatted date of the passed mysql date time function NewDateFormat($mysqlDateTime, $format="M d Y, h:i:s A") { $date = $mysqlDateTime; $dateArr = explode(" ", $date); if(count($dateArr) > 1) { $dateArr1 = explode(":", $dateArr[1]); $dateArr2 = explode("-", $dateArr[0]); } else { $dateArr2 = explode("-", $date); } $ts = mktime($dateArr1[0], $dateArr1[1], $dateArr1[2], $dateArr2[1], $dateArr2[2], $dateArr2[0]); $formatted_date = date($format, $ts); return $formatted_date; } /* returns filesize with unit */ function GetReadableFileSize($path) { $filesize = filesize($path); $unit = "bytes"; if ($filesize > 1024) { $filesize = ($filesize / 1024); $unit = "kB"; } if ($filesize > 1024) { $filesize = ($filesize / 1024); $unit = "MB"; } if ($filesize > 1024) { $filesize = ($filesize / 1024); $unit = "GB"; } if ($filesize > 1024) { $filesize = ($filesize / 1024); $unit = "TB"; } $filesize = round($filesize, 1); return $filesize." ".$unit; } // check if redownloading enable for selected product for current user function getRedownloadStatus($OrderID) { //$sql = "SELECT * FROM `download` WHERE `UserID`='$UserID' AND `ProductID`='$ProductID' AND `Date` >= DATE_SUB(CURDATE(),INTERVAL 30 DAY) ORDER BY `DATE` LIMIT 1"; $sql = "SELECT * FROM `orders` WHERE `OrderID`='$OrderID' AND DATE_ADD(`DateTime`, INTERVAL 30 DAY) >= NOW()"; $res = mysql_query($sql) or die(mysql_error()); $NumRows = mysql_num_rows($res); //echo $sql; //exit; if($NumRows > 0) return true; return false; } /*** Function for date manipulation ***/ function getLastDayOfPrevMonth($month = '', $year = '') { if (empty($month)) { $month = date('m'); } if (empty($year)) { $year = date('Y'); } return date('Y-m-d', mktime(0, 0, 0, $month, 0, $year)); } function getFirstDayOfPrevMonth($month = '', $year = '') { if (empty($month)) { $month = date('m'); } if (empty($year)) { $year = date('Y'); } return date('Y-m-d', mktime(0, 0, 0, ($month-1), 1, $year)); } /*** /Function for date manipulation ***/ // convert a date into a string that tells how long ago that date was.... eg: 2 days ago, 3 minutes ago. // accepts date as mysql date time format YYYY-MM-DD H:M:S function ago($d) { $c = getdate(); $p = array('year', 'mon', 'mday', 'hours', 'minutes', 'seconds'); $display = array('year', 'month', 'day', 'hour', 'minute', 'second'); $factor = array(0, 12, 30, 24, 60, 60); $d = datetoarr($d); for ($w = 0; $w < 6; $w++) { if ($w > 0) { $c[$p[$w]] += $c[$p[$w-1]] * $factor[$w]; $d[$p[$w]] += $d[$p[$w-1]] * $factor[$w]; } if ($c[$p[$w]] - $d[$p[$w]] > 1) { return ($c[$p[$w]] - $d[$p[$w]]).' '.$display[$w].'s ago'; } } return ''; } // you can replace this if need be. This converts my dates returned from a mysql date string into // an array object similar to that returned by getdate(). function datetoarr($d) { preg_match("/([0-9]{4})(\\-)([0-9]{2})(\\-)([0-9]{2}) ([0-9]{2})(\\:)([0-9]{2})(\\:)([0-9]{2})/", $d, $matches); return array( 'seconds' => $matches[10], 'minutes' => $matches[8], 'hours' => $matches[6], 'mday' => $matches[5], 'mon' => $matches[3], 'year' => $matches[1], ); } /* shortens the string down to maximum length defined in $max_length */ function str_stop($string, $max_length){ if (strlen($string) > $max_length){ $string = substr($string, 0, $max_length); $pos = strrpos($string, " "); if($pos === false) { return substr($string, 0, $max_length)."..."; } return substr($string, 0, $pos)."..."; }else{ return $string; } } // check whether user bought/download this product and return bought and not buy function getCommentBubbleText($ProductID, $CommentUserID, $ProductAuthorUserID) { global $objDB; $sql = "SELECT * FROM `orders` WHERE `ProductID`='$ProductID' AND `UserID`='$CommentUserID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $rows = $objDB->ddlNumRows($sql); if($CommentUserID == $ProductAuthorUserID) $BubbleText = '
Product Author
'; else if($rows > 0) $BubbleText = '
I Bought It
'; else $BubbleText = '
Did Not Buy Yet
'; return($BubbleText); } // returns author=>1, buy=>2 or not bought=>3 function getCommentStatus($ProductID, $CommentUserID, $ProductAuthorUserID) { global $objDB; $sql = "SELECT * FROM `orders` WHERE `ProductID`='$ProductID' AND `UserID`='$CommentUserID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $rows = $objDB->ddlNumRows($sql); if($CommentUserID == $ProductAuthorUserID) $BubbleText = 1; else if($rows > 0) $BubbleText = 2; else $BubbleText = 3; return($BubbleText); } function breadcrumbsByCategory($CatID) { global $objDB; global $category; global $BreadCrumbArr; $sql = "SELECT * FROM `$category` WHERE `CatID`=".$CatID; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $no = count($BreadCrumbArr); $BreadCrumbArr[] = array("CatID"=>$row['CatID'],"CatName"=>$row['CatName']); if($row['ParentID'] == 0) { return $BreadCrumbArr; } else { $BreadCrumbArr = breadcrumbsByCategory($row['ParentID']); } $BreadCrumbArr = array_reverse($BreadCrumbArr); return $BreadCrumbArr; } // draw badges below user profile picture function getBadgeImage($BadgeID) { global $objDB; $sql = "SELECT * FROM `badges` WHERE `BadgesID`='$BadgeID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $BadgeImagePath = $row['BadgeImagePath']; return ($BadgeImagePath); } function getBadgeAltText($BadgeID) { global $objDB; $sql = "SELECT * FROM `badges` WHERE `BadgesID`='$BadgeID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $BadgeAltText = $row['BadgeAltText']; return ($BadgeAltText); } // get badge status function getBadgeStatus($BadgeID) { global $objDB; $sql = "SELECT * FROM `badges` WHERE `BadgesID`='$BadgeID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); $BadgeStatus = $row['Status']; return ($BadgeStatus); } function drawBadges($UserID) { global $objDB; $BadgesArr = array(); // will contain badgeimage and notes, ex: User has had x free products of the week /****** get free product of the week ******/ if(getBadgeStatus(1) == 'Active') { // count number of products of the user free product of week $sql = "SELECT * FROM `free_product_of_the_week` WHERE `ProductUserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(1); $BadgesArr[1]['BadgeImage'] = $BadgeImage; $Notes = "User has had $tot free products of the week"; $BadgesArr[1]['Notes'] = $Notes; } } /**************************************************/ /****** get Designer of the Week ******/ if(getBadgeStatus(2) == 'Active') { // count $sql = "SELECT * FROM `designer_of_the_week` WHERE `UserID`='$UserID' ORDER BY `Date` DESC LIMIT 1"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $res = $objDB->ddlQuery($sql); $BadgeImage = getBadgeImage(2); $BadgesArr[2]['BadgeImage'] = $BadgeImage; $row = $objDB->get_row($res); $last_featured_date = NewDateFormat($row['Date'], "M d Y"); $Notes = "User was last featured as Designer of the Week on $last_featured_date."; $BadgesArr[2]['Notes'] = $Notes; } } /**************************************************/ /****** get Featured Addition ******/ if(getBadgeStatus(3) == 'Active') { // count $sql = "SELECT * FROM `recent_featured_products` WHERE `ProductUserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(3); $BadgesArr[3]['BadgeImage'] = $BadgeImage; $Notes = "User has had $tot products listed as featured additions"; $BadgesArr[3]['Notes'] = $Notes; } } /**************************************************/ /****** get Admin ******/ if(getBadgeStatus(4) == 'Active') { // count $sql = "SELECT * FROM `badges1_administrator` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(4); $BadgesArr[4]['BadgeImage'] = $BadgeImage; //$Notes = "Administrator"; $Notes = getBadgeAltText(4); $BadgesArr[4]['Notes'] = $Notes; } } /**************************************************/ /****** get content monitor ******/ if(getBadgeStatus(5) == 'Active') { // count $sql = "SELECT * FROM `badges2_content_monitor` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(5); $BadgesArr[5]['BadgeImage'] = $BadgeImage; //$Notes = "Content Monitor"; $Notes = getBadgeAltText(5); $BadgesArr[5]['Notes'] = $Notes; } } /**************************************************/ /****** get forum moderator ******/ if(getBadgeStatus(6) == 'Active') { // count $sql = "SELECT * FROM `badges3_forum_modarator` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(6); $BadgesArr[6]['BadgeImage'] = $BadgeImage; //$Notes = "Forum Moderator"; $Notes = getBadgeAltText(6); $BadgesArr[6]['Notes'] = $Notes; } } /**************************************************/ /****** get Copyright Eagle Eye ******/ if(getBadgeStatus(7) == 'Active') { // count $sql = "SELECT * FROM `badges4_copyright_eagle_eye` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(7); $BadgesArr[7]['BadgeImage'] = $BadgeImage; //$Notes = "Copyright Eagle Eye"; $Notes = getBadgeAltText(7); $BadgesArr[7]['Notes'] = $Notes; } } /**************************************************/ /****** get project_winner ******/ if(getBadgeStatus(8) == 'Active') { // count $sql = "SELECT * FROM `badges5_project_winner` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(8); $BadgesArr[8]['BadgeImage'] = $BadgeImage; $Notes = "This user has won $tot custom projects"; $BadgesArr[8]['Notes'] = $Notes; } } /**************************************************/ /****** get tutorial author ******/ if(getBadgeStatus(9) == 'Active') { // count $sql = "SELECT * FROM `badges6_tutorial_author` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(9); $BadgesArr[9]['BadgeImage'] = $BadgeImage; //$Notes = "Tutorial Author"; $Notes = getBadgeAltText(9); $BadgesArr[9]['Notes'] = $Notes; } } /**************************************************/ /****** get Project Awarder ******/ if(getBadgeStatus(10) == 'Active') { // count $sql = "SELECT * FROM `badges7_project_awarder` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(10); $BadgesArr[10]['BadgeImage'] = $BadgeImage; //$Notes = "Project Awarder"; $Notes = "User has awarded $tot Custom Project(s)"; $BadgesArr[10]['Notes'] = $Notes; } } /**************************************************/ /****** get Referred Others ******/ if(getBadgeStatus(11) == 'Active') { // count $sql = "SELECT * FROM `badges8_referred_others` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(11); $BadgesArr[11]['BadgeImage'] = $BadgeImage; //$Notes = "Referred Others ($tot)"; $Notes = getBadgeAltText(11); $Notes .= " ($tot Referred)"; $BadgesArr[11]['Notes'] = $Notes; } } /**************************************************/ /****** get Posted Custom Project ******/ if(getBadgeStatus(12) == 'Active') { // count $sql = "SELECT * FROM `badges9_custom_project_post` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(12); $BadgesArr[12]['BadgeImage'] = $BadgeImage; //$Notes = "Referred Others ($tot)"; $Notes = "User has posted $tot Custom Projects"; $BadgesArr[12]['Notes'] = $Notes; } } /**************************************************/ /****** get Bid on Custom Project ******/ if(getBadgeStatus(13) == 'Active') { // count $sql = "SELECT * FROM `badges10_custom_project_bid` WHERE `UserID`='$UserID'"; $tot = $objDB->ddlNumRows($sql); if($tot > 0) { $BadgeImage = getBadgeImage(13); $BadgesArr[13]['BadgeImage'] = $BadgeImage; $Notes = "User has bid on $tot Custom Projects"; $BadgesArr[13]['Notes'] = $Notes; } } /**************************************************/ /********** Get all badges_download_level records *************/ $BadgesDownloadLevel = getDownloadLevelBadges($UserID); $BadgesArr = array_merge($BadgesArr, $BadgesDownloadLevel); /****************************/ $BadgesArrFinal = array(); if(count($BadgesArr) > 0) { $i = 0; foreach($BadgesArr as $key=>$val) { $BadgesArrFinal[$i] = $val; $i++; } } if($BadgesArrFinal) return($BadgesArrFinal); } // second parameter for images per row function getBadgesHTML($UserID, $NumImagesPerRow=4) { // get badges data $BadgesArr = drawBadges($UserID); if(count($BadgesArr) > 0) { $BadgesHTML = ''; $i = 1; foreach($BadgesArr as $key=>$val) { $image = $val['BadgeImage']; $notes = myAddSlashes(nl2br($val['Notes'])); $BadgesHTML .= ''."\n"; if($i%$NumImagesPerRow==0) $BadgesHTML .= ''; $i++; } $BadgesHTML .= '
'; } return ($BadgesHTML); } // get number of downloads of a product author function GetNumDownloadsOfProductAuthor($ProductUserID) { global $objDB; $sql = "SELECT COUNT(*) AS tot FROM `product`, `orders` WHERE product.ProductID=orders.ProductID AND product.UserID=$ProductUserID"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); /* AdHoc change to include/functions.php file, to function GetNumDownloadsOfProductAuthor() - special rule: since the user 'boxy' had its products and download counts imported - he has now history of orders and those downloads weren't visible. That number of downloads was 1123. The if statement in this functions adds that number to this user. */ if($ProductUserID == 1785) return $row['tot']+1123; return($row['tot']); } // get number of downloads of a product function GetNumDownloads($ProductID) { $sql = "SELECT COUNT(*) AS tot FROM `product` WHERE `ProductID`='$ProductUserID'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); return($row['tot']); } // return the badges array of the product author function getDownloadLevelBadges($ProductUserID) { global $objDB; $NumDownloads = GetNumDownloadsOfProductAuthor($ProductUserID); $BadgesArr = array(); if($NumDownloads > 0) { $sql = "SELECT * FROM `badges_download_level` WHERE `Status`='Active' ORDER BY `BadgeDldMinRecvdDld` DESC"; $res = $objDB->ddlQuery($sql); while($row = $objDB->get_row($res)) { $MinRange = $row['BadgeDldMinRecvdDld']; // same format as drawBadges() function $rand = rand(1000, 9999); if($NumDownloads >= $MinRange) { $BadgesArr[$rand]['BadgeImage'] = $row['BadgeDldImagePath']; $Notes = $row['BadgeDldAltText']."
Total downloads received: $NumDownloads"; $BadgesArr[$rand]['Notes'] = $Notes; break; } } } // return to drawBadges() function return($BadgesArr); } function getDownloadLevelBadgesID($ProductUserID) { global $objDB; $NumDownloads = GetNumDownloadsOfProductAuthor($ProductUserID); $BadgesArr = array(); if($NumDownloads > 0) { $sql = "SELECT * FROM `badges_download_level` WHERE `Status`='Active' ORDER BY `BadgeDldMinRecvdDld` DESC"; $res = $objDB->ddlQuery($sql); while($row = $objDB->get_row($res)) { $MinRange = $row['BadgeDldMinRecvdDld']; if($NumDownloads >= $MinRange) { $DownloadLevelBadge[] = $row['BadgeDldID']; $DownloadLevelBadge[] = $row['BadgeDldName']; break; } } } return($DownloadLevelBadge); } /* get action emails by ID and replace the %varname% with predefined variables */ function getActionEmail($ActionEmailID) { global $objDB; $sql = "SELECT * FROM `action_email` WHERE `ActionEmailID`='$ActionEmailID' AND `Status`='Active'"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res); if( !empty($row) ) return($row); /*$ActionEmailBody = $row['EmailBody']; if( !empty($ActionEmailBody) ) return($ActionEmailBody);*/ } // check if credit expired the change status to inactive /* if expired then update tables credit_purchase_details set status=inactive user_credit table set CreditAvailable=CreditAvailable - credit_expense.CreditRemaining `credit_expense` table set Status=Expired */ function expireCreditPurchaseDetails($CreditPurchaseDetailsID) { global $objDB, $objAction_email, $objCredit_purchase_details; //credit_purchase_details set status=inactive $tableArray = array("Status"=>"Inactive"); $objCredit_purchase_details->EditARecord($tableArray, "credit_purchase_details", "CreditPurchaseDetailsID", $CreditPurchaseDetailsID); $objCredit_purchase_details->setCredit_purchase_details($CreditPurchaseDetailsID); $CreditPrice = $objCredit_purchase_details->getCredit(); //user_credit table set CreditAvailable=CreditAvailable - credit_expense.CreditRemaining $UserID = $objCredit_purchase_details->getUserID(); // get users credit available $sql_user_credit = "SELECT * FROM `user_credit` WHERE `UserID`='$UserID'"; $res_user_credit = $objDB->ddlQuery($sql_user_credit); $row_user_credit = $objDB->get_row($res_user_credit); $CreditAvailable = $row['CreditAvailable']; // update user credit balance $CreditAvailableNow = $CreditAvailable - $CreditPrice; $sql_user_credit_update = "UPDATE `user_credit` SET `CreditAvailable` =$CreditAvailableNow WHERE `UserID`='$UserID'"; $objDB->ddlQuery($sql_user_credit_update); // update credit_expense table with status expired $sql_credit_expense_update = "UPDATE `credit_expense` SET `Status`='Expired' WHERE `CreditPurchaseDetailsID`='$CreditPurchaseDetailsID'"; $objDB->ddlQuery($sql_credit_expense_update); } /************************************************/ // update credit expense table on download (for datewise tracking of credit expense) function updateCreditExpense($CreditAmount, $UserID) { include_once("Credit_purchase_details.class.php"); include_once("Credit_expense.class.php"); global $objDB, $objCredit_purchase_details, $objCredit_expense; $sql = "SELECT * FROM `credit_expense` WHERE `UserID`='$UserID' AND (`CreditRemaining`>0 AND `Status`='Active') ORDER BY `DatePurchased`;"; $res = $objDB->ddlQuery($sql); // credit required $Required = $CreditAmount; while($row = $objDB->get_row($res)) { $CreditExpensed = $row['CreditExpensed']; $CreditRemaining = $row['CreditRemaining']; if($Required > 0) { if($Required >= $CreditRemaining) { $CreditExpensed = $CreditExpensed + $CreditRemaining; $Required = $Required - $CreditRemaining; $CreditRemaining = 0; } else { $CreditExpensed = $CreditExpensed + $Required; $CreditRemaining = $CreditRemaining - $Required; $Required = 0; } $CreditExpenseID = $row['CreditExpenseID']; // update credit_expense with new information $sql_update = "UPDATE `credit_expense` SET `CreditExpensed`='$CreditExpensed', `CreditRemaining`='$CreditRemaining' WHERE `CreditExpenseID`='$CreditExpenseID';"; $objDB->ddlQuery($sql_update); } } } // return two rows (1 for view 1 for download) of particular icon set function getIconsArray($ProductID) { include_once("Product.class.php"); global $objDB, $objProduct; $objProduct->setProduct($ProductID); $NumDownloads = $objProduct->getNumDownloads(); $NumViews = $objProduct->getNumViews(); $IconsArray = array(); // get approprate download row if($NumDownloads > 0) { $sql = "SELECT * FROM `icons` WHERE `Status`='Active' AND `IconType`='Download' ORDER BY `LowRange` DESC"; $res = $objDB->ddlQuery($sql); while($row = $objDB->get_row($res, "MYSQL_ASSOC")) { $MinRange = $row['LowRange']; if($NumDownloads >= $MinRange) { $IconsArray['Download'] = $row; break; } } } // get approprate view row if($NumViews > 0) { $sql = "SELECT * FROM `icons` WHERE `Status`='Active' AND `IconType`='View' ORDER BY `LowRange` DESC"; $res = $objDB->ddlQuery($sql); while($row = $objDB->get_row($res, "MYSQL_ASSOC")) { $MinRange = $row['LowRange']; if($NumViews >= $MinRange) { $IconsArray['View'] = $row; break; } } } return($IconsArray); } // get icons html with proper html formatting and types are of View and Download (case sensitive) function getIconsImageHTML($ProductID, $IconType="View") { global $objDB; $IconsArray = getIconsArray($ProductID); if(empty($IconsArray)) return; switch($IconType) { case "View": $IconsImageArray = $IconsArray['View']; break; case "Download": $IconsImageArray = $IconsArray['Download']; break; } if(!empty($IconsImageArray)) { $AltText = $IconsImageArray['IconAltText']; $ImagePath = 'upload/'.$IconsImageArray['IconImagePath']; if(is_file($ImagePath)) { // check if large image list($width, $height, $type, $attr) = getimagesize($ImagePath); if($width > 27 || $height > 20) //$ImagePath = 'thumb-resize.php?file='.$ImagePath.'&w=25&h=25'; $ImagePath = 'thumbview.php?file='.$ImagePath.'&w=27&h=13'; //$IconsImageHTML = ''; $IconsImageHTML = ''; return ($IconsImageHTML); } } } //function to validate ip address format function validateIpAddress($ip_addr) { //first of all the format of the ip address is matched if(preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$ip_addr)) { //now all the intger values are separated $parts=explode(".",$ip_addr); //now we need to check each part can range from 0-255 foreach($parts as $ip_parts) { if(intval($ip_parts)>255 || intval($ip_parts)<0) return false; //if number is not within range of 0-255 } return true; } else return false; //if format of ip address doesn't matches } /* * This is the encryption function * $String == The string to be encrypted * $Crypt = Encryption key, its defined in config.php * This function returns the encrypted string * To get the original string, the encrypted script is to be passed through this function, keeping * the encryption key same. */ function XorNcrypt($String,$Crypt) { // String for crypted string $StrCrypted = ""; // Integer for cipher position $IntPos = 0; // Integer for length of cipher string $IntCryptLen = strlen($Crypt); // Integer for length of passed string $IntStringLen = strlen($String); // Go through each character in passed string for ($intCur = 0; $intCur < $IntStringLen; $intCur++) { // Check key postion if ($IntPos >= $IntCryptLen) $IntPos = 0; // XOR character verse cipher $StrCrypted .= $String[$intCur] ^ $Crypt[$IntPos]; // Go to next position in key $IntPos++; } //Return crypted string return $StrCrypted; } /*************************/ /** To encode or decode filename at the time of download **/ /* $secretPass = md5(5).'kljhflk73#OO#*U$O(*YO'; // defined in config.php $encodeThis = 'This is test. This string contains a very secret information.'; > Regular Encoding $encoded = Encode($encodeThis,$secretPass); $decoded = Encode($encoded,$secretPass); > Another Encoding $encoded = bin2hex(Encode($encodeThis,$secretPass)); $decoded = Encode(hex2bin($encoded),$secretPass); */ function Encode($data,$pwd) { $pwd_length = strlen($pwd); for ($i = 0; $i < 255; $i++) { $key[$i] = ord(substr($pwd, ($i % $pwd_length)+1, 1)); $counter[$i] = $i; } for ($i = 0; $i < 255; $i++) { $x = ($x + $counter[$i] + $key[$i]) % 256; $temp_swap = $counter[$i]; $counter[$i] = $counter[$x]; $counter[$x] = $temp_swap; } for ($i = 0; $i < strlen($data); $i++) { $a = ($a + 1) % 256; $j = ($j + $counter[$a]) % 256; $temp = $counter[$a]; $counter[$a] = $counter[$j]; $counter[$j] = $temp; $k = $counter[(($counter[$a] + $counter[$j]) % 256)]; $Zcipher = ord(substr($data, $i, 1)) ^ $k; $Zcrypt .= chr($Zcipher); } return $Zcrypt; } function hex2bin($hexdata) { for ($i=0;$iddlQuery($sql); $arr = array(); while( $row = $objDB->get_row($res) ) { $arr[] = $row['RequiredFeatureID']; } return $arr; } /***** * This function calculates the difference between two dates in years, months, days, hours, minutes & seconds * The first two arguments are the two dates between which the difference will be calculated * The third argument is an optional one and allows for different outputs. By default the output will be a string but * default (not set): output will be a string * 'assoc_array' : output will be an associative array -> ("year"=>x, "month"=>x, "day"=>x, "hour"=>x, "minute"=>x, "second"=>x) 'array' : output will a normal array -> (0=>x, 1=>x, 2=>x, 3=>x, 4=>x, 5=>x); => 0==year, 1==month, etc. * */ function dateDifference($start, $end, $output="string") { // converting the dates to seconds $startSeconds = strtotime($start); $endSeconds = strtotime($end); // if start time exceeds end time then return project expired if($startSeconds >= $endSeconds) return "Project expired"; // if conversion was succesfull if ($startSeconds && $endSeconds) { // switching start and end date if start date is bigger // and converting them to 1 standard format for this function, so we know what we're dealing with if ($startSeconds > $endSeconds) { $startDate = date("Y-m-d H:i:s", $endSeconds); $endDate = date("Y-m-d H:i:s", $startSeconds); } else { $startDate = date("Y-m-d H:i:s", $startSeconds); $endDate = date("Y-m-d H:i:s", $endSeconds); } // exploding everything into seperate variabels list($startDateDate, $startDateTime) = explode(" ", $startDate); list($endDateDate, $endDateTime) = explode(" ", $endDate); list($startYear, $startMonth, $startDay) = explode("-", $startDateDate); list($endYear, $endMonth, $endDay) = explode("-", $endDateDate); list($startHour, $startMinute, $startSecond) = explode(":", $startDateTime); list($endHour, $endMinute, $endSecond) = explode(":", $endDateTime); // now we can start calculating // difference in seconds $secondDiff = $endSecond - $startSecond; if ($startSecond > $endSecond) { // if the difference is negative, we add 60 seconds and increase the starting minute $secondDiff += 60; $startMinute++; } $minuteDiff = $endMinute - $startMinute; if ($startMinute > $endMinute) { $minuteDiff += 60; $startHour++; } $hourDiff = $endHour - $startHour; if ($startHour > $endHour) { $hourDiff += 24; $startDay++; } // days in starting month if ($endMonth > $startMonth || $endYear > $startYear) { if ($startDay > $endDay) { // amount of days this month has $daysThisMonth = date("t", $startDate); // difference in days to the next month $dayDiff = ($daysThisMonth - $startDay) + $endDay; // compensating for the months $startMonth++; } else $dayDiff = $endDay - $startDay; } else { $dayDiff = $endDay - $startDay; } $monthDiff = $endMonth - $startMonth; if ($startMonth > $endMonth) { $monthDiff += 12; $startYear++; } $yearDiff = $endYear - $startYear; // we know all the differences, so we're outputting that if ($output == "string") { if ($yearDiff > 0) return $yearDiff." year, ".$monthDiff." months, ".$dayDiff." days and ".$hourDiff." hours, ".$minuteDiff." minutes, ".$secondDiff." seconds"; elseif ($monthDiff > 0) return $monthDiff." months, ".$dayDiff." days and ".$hourDiff." hours, ".$minuteDiff." minutes, ".$secondDiff." seconds"; elseif ($dayDiff > 0) return $dayDiff." days and ".$hourDiff." hours, ".$minuteDiff." minutes, ".$secondDiff." seconds"; elseif ($hourDiff > 0) return $hourDiff." hours, ".$minuteDiff." minutes, ".$secondDiff." seconds"; elseif ($minuteDiff > 0) return $minuteDiff." minutes, ".$secondDiff." seconds"; elseif ($secondDiff > 0) return $secondDiff." seconds"; else return "There is no difference!"; } elseif ($output == "assoc_array") { return array("year"=>$yearDiff, "month"=>$monthDiff, "day"=>$dayDiff, "hour"=>$hourDiff, "minute"=>$minuteDiff, "second"=>$secondDiff); } else { return array($yearDiff, $monthDiff, $dayDiff, $hourDiff, $minuteDiff, $secondDiff); } } else { return False; } } /* Works out the time since the entry post, takes a an argument in unix time (seconds) */ function time_since($original) { // array of time period chunks $chunks = array( array(60 * 60 * 24 * 365 , 'year'), array(60 * 60 * 24 * 30 , 'month'), array(60 * 60 * 24 * 7, 'week'), array(60 * 60 * 24 , 'day'), array(60 * 60 , 'hour'), array(60 , 'minute'), ); $today = time(); /* Current unix time */ $since = $today - $original; // $j saves performing the count function each time around the loop for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; // finding the biggest chunk (if the chunk fits, break) if (($count = floor($since / $seconds)) != 0) { // DEBUG print "\n"; break; } } $print = ($count == 1) ? '1 '.$name : "$count {$name}s"; if ($i + 1 < $j) { // now getting the second item $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1]; // add second item if it's greater than 0 if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) { $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s"; } } return $print; } // returns array of Custom Project Price Settings function getCustomProjectPriceSettings() { global $objDB, $custom_project_price_settings; $sql = "SELECT * FROM `$custom_project_price_settings` WHERE `ID`=1 LIMIT 1"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res, 'MYSQL_ASSOC'); return ($row); } function getCreditSharePercentageOfUser($UserID) { global $objDB, $product_commission_settings; $sql = "SELECT * FROM `$product_commission_settings` WHERE `UserID`=$UserID LIMIT 1"; $res = $objDB->ddlQuery($sql); if( $objDB->numberRow($res) ) { $row = $objDB->get_row($res, 'MYSQL_ASSOC'); return ($row['percentage_commission_seller']); } $sql = "SELECT * FROM `$product_commission_settings` WHERE `ID`=1 LIMIT 1"; $res = $objDB->ddlQuery($sql); $row = $objDB->get_row($res, 'MYSQL_ASSOC'); return ($row['percentage_commission_seller']); } // This function is used for filesystem search and the constants // defined are used as optional args with this function define('PREG_FIND_RECURSIVE', 1); define('PREG_FIND_DIRMATCH', 2); define('PREG_FIND_FULLPATH', 4); define('PREG_FIND_NEGATE', 8); define('PREG_FIND_DIRONLY', 16); define('PREG_FIND_RETURNASSOC', 32); define('PREG_FIND_SORTDESC', 64); define('PREG_FIND_SORTKEYS', 128); define('PREG_FIND_SORTBASENAME', 256); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTMODIFIED', 512); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTFILESIZE', 1024); # requires PREG_FIND_RETURNASSOC define('PREG_FIND_SORTDISKUSAGE', 2048); # requires PREG_FIND_RETURNASSOC function preg_find($pattern, $start_dir='.', $args=NULL) { static $depth = -1; ++$depth; $files_matched = array(); $fh = opendir($start_dir); while (($file = readdir($fh)) !== false) { if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue; $filepath = $start_dir . '/' . $file; if (preg_match($pattern, ($args & PREG_FIND_FULLPATH) ? $filepath : $file)) { $doadd = is_file($filepath) || (is_dir($filepath) && ($args & PREG_FIND_DIRMATCH)) || (is_dir($filepath) && ($args & PREG_FIND_DIRONLY)); if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) $doadd = false; if ($args & PREG_FIND_NEGATE) $doadd = !$doadd; if ($doadd) { if ($args & PREG_FIND_RETURNASSOC) { // return more than just the filenames $fileres = array(); if (function_exists('stat')) { $fileres['stat'] = stat($filepath); $fileres['du'] = $fileres['stat']['blocks'] * 512; } if (function_exists('fileowner')) $fileres['uid'] = fileowner($filepath); if (function_exists('filegroup')) $fileres['gid'] = filegroup($filepath); if (function_exists('filetype')) $fileres['filetype'] = filetype($filepath); if (function_exists('mime_content_type')) $fileres['mimetype'] = mime_content_type($filepath); if (function_exists('dirname')) $fileres['dirname'] = dirname($filepath); if (function_exists('basename')) $fileres['basename'] = basename($filepath); if (isset($fileres['uid']) && function_exists('posix_getpwuid')) $fileres['owner'] = posix_getpwuid ($fileres['uid']); $files_matched[$filepath] = $fileres; } else array_push($files_matched, $filepath); } } if ( is_dir($filepath) && ($args & PREG_FIND_RECURSIVE) ) { $files_matched = array_merge($files_matched, preg_find($pattern, $filepath, $args)); } } closedir($fh); // Before returning check if we need to sort the results. if (($depth==0) && ($args & (PREG_FIND_SORTKEYS|PREG_FIND_SORTBASENAME|PREG_FIND_SORTMODIFIED|PREG_FIND_SORTFILESIZE|PREG_FIND_SORTDISKUSAGE)) ) { $order = ($args & PREG_FIND_SORTDESC) ? 1 : -1; $sortby = ''; if ($args & PREG_FIND_RETURNASSOC) { if ($args & PREG_FIND_SORTMODIFIED) $sortby = "['stat']['mtime']"; if ($args & PREG_FIND_SORTBASENAME) $sortby = "['basename']"; if ($args & PREG_FIND_SORTFILESIZE) $sortby = "['stat']['size']"; if ($args & PREG_FIND_SORTDISKUSAGE) $sortby = "['du']"; } $filesort = create_function('$a,$b', "\$a1=\$a$sortby;\$b1=\$b$sortby; if (\$a1==\$b1) return 0; else return (\$a1<\$b1) ? $order : 0- $order;"); uasort($files_matched, $filesort); } --$depth; return $files_matched; } ?> ddlQuery($sql_req); $required_feature_display = array(); $c = 0; while($row_req = $objDB->get_row($res_req)) { $c++; $objRequired_feature->setRequired_feature($row_req['RequiredFeatureID']); if($c % 10 == 0) { $Change = "Change"; } else { $Change = ""; } $required_feature_display[] = array("RequiredFeatureID"=>$row_req['RequiredFeatureID'],"FeatureName"=>$row_req['FeatureName'],"Change"=>$Change); } $ThemeArr = array(); $sql_theme = "SELECT * FROM `$theme` WHERE `Status`='Active'"; $res_theme = $objDB->ddlQuery($sql_theme); while($row_theme = $objDB->get_row($res_theme)) { $ThemeArr[] = array("ThemeID"=>$row_theme['ThemeID'],"ThemeName"=>$row_theme['ThemeName']); } $OrderedArray = getCategory(0,$category); //print_r($OrderedArray); $smarty->assign("required_feature_display",$required_feature_display); $smarty->assign("OrderedArray",$OrderedArray); $smarty->assign("ThemeArr",$ThemeArr); /*********** for custom search section *************/ /** getting categories **/ $arr = array(); $Custom_OrderedArray = getCategory(0,$custom_category); $smarty->assign("Custom_OrderedArray",$Custom_OrderedArray); /***************************************************/ ?>'.$_SERVER['PHP_SELF'].'
'; if(stristr($_SERVER['PHP_SELF'], 'custom')) { $sql_cat = "SELECT * FROM `$custom_category` WHERE `ParentID`=0 AND `Status`='Active'"; $res_cat = $objDB->ddlQuery($sql_cat); $left_menu = "
View All Projects "; while($row_cat = $objDB->get_row($res_cat)) { $left_menu .= "
".$row_cat['CatName']."
"; $sql_subcat = "SELECT * FROM `$custom_category` WHERE `ParentID`=".$row_cat['CatID']." AND `Status`='Active'"; $res_subcat = $objDB->ddlQuery($sql_subcat); $num_subcat = $objDB->numberRow($res_subcat); if($num_subcat) { $left_menu .= "
"; } } }else{ $sql_cat = "SELECT * FROM `$category` WHERE `ParentID`=0 AND `Status`='Active'"; $res_cat = $objDB->ddlQuery($sql_cat); $left_menu = "
View All Products "; while($row_cat = $objDB->get_row($res_cat)) { $left_menu .= "
".$row_cat['CatName']."
"; $sql_subcat = "SELECT * FROM `$category` WHERE `ParentID`=".$row_cat['CatID']." AND `Status`='Active'"; $res_subcat = $objDB->ddlQuery($sql_subcat); $num_subcat = $objDB->numberRow($res_subcat); if($num_subcat) { $left_menu .= "
"; } } } $smarty->assign("left_menu",$left_menu); ?> getUsername(); /* Get the available credit balanace of the user */ $UserID = $objUser->getUserID(); $sql_credit_balance = "SELECT * FROM `$user_credit` WHERE `UserID`=".$UserID; $res_credit_balance = $objDB->ddlQuery($sql_credit_balance); $num_credit = $objDB->numberRow($res_credit_balance); if($num_credit) { $row_credit_balance = $objDB->get_row($res_credit_balance); $credit_balance = $row_credit_balance['CreditAvailable']; } else { $credit_balance = 0; } $smarty->assign("CreditBalance",$credit_balance); // Get number of FreshMessages (unread messages) $sql_freshmsg = "SELECT * FROM `$message` WHERE `ToUserID`='$UserID' AND `MessageStatus`='Unread' AND `InboxStatus`='Present' AND `Status`='Active'"; $num_freshmsg = $objDB->ddlNumRows($sql_freshmsg); $smarty->assign("NumFreshMsg", $num_freshmsg); // Get number of messages in inbox $sql_freshmsg = "SELECT * FROM `$message`, `$message_folder` WHERE $message.ToUserID=$UserID AND $message.`InboxStatus`='Present' AND $message.`Status`='Active' AND $message.MessageFolderID=$message_folder.MessageFolderID AND $message_folder.FolderName='inbox' AND $message_folder.UserID=".$UserID; $num_freshmsg = $objDB->ddlNumRows($sql_freshmsg); $smarty->assign("NumInboxMsg", $num_freshmsg); } else { $Logged_In = "No"; $Username = ""; } // get free product of the week //$sql = "SELECT * FROM `$product`, `$free_product_of_the_week` WHERE $free_product_of_the_week.ProductID=$product.ProductID ORDER BY $free_product_of_the_week.Date DESC LIMIT 1"; $sql = "SELECT * FROM `$product`, `$free_product_of_the_week` WHERE ($product.Status='Active' AND $free_product_of_the_week.Status='Active') AND ($free_product_of_the_week.ProductID=$product.ProductID) ORDER BY $free_product_of_the_week.Date DESC LIMIT 1"; $res = $objDB->ddlQuery($sql); $totalrecords = $objDB->numberRow($res); if($totalrecords > 0) { $row = $objDB->get_row($res, "MYSQL_ASSOC"); $FreeProductOfWeek = $row; $_SESSION['FreeProductOfWeekID'] = $row['ProductID']; $smarty->assign("FreeProductOfWeekID", $_SESSION['FreeProductOfWeekID']); } $smarty->assign("Logged_In",$Logged_In); $smarty->assign("Username",$Username); ?>