$old_y) { $thumb_w=$new_w; $thumb_h=$old_y*($new_h/$old_x); } if ($old_x < $old_y) { $thumb_w=$old_x*($new_w/$old_y); $thumb_h=$new_h; } if ($old_x == $old_y) { $thumb_w=$new_w; $thumb_h=$new_h; } $tempImage = imagecreatetruecolor($thumb_w, $thumb_h); imageantialias($tempImage, true); imagecopyresampled($tempImage, $srcImage, 0, 0, 0, 0, $thumb_w, $thumb_h, $ow, $oh); imagejpeg($tempImage, $destfile, $jpegquality); } // Function : CheckLogin // Description : Check Admin Login function check_adminlogin(){ if(!(isset($_SESSION['ADMIN_USER']))){ header("Location: login.php"); } } ///////////// Draw Box /////////// function getdrp_cat($cid,$pcname,$default=''){ if($parent!='0'){ $cmdcatp=mysql_query("select * from tbl_category where c_status!='0' and c_parent='".$cid."'"); while($rscatp=mysql_fetch_array($cmdcatp)){ if($default == $rscatp['c_id']){ $output.= ""; }else{ $output.= ""; } $output.= getdrp_cat($rscatp['c_id'],$pcname." --> ".$rscatp['c_name'],$default); } } $foutput=$output1.$output; return $foutput; } function getbradcat($cat,$cname){ $sqlpcat="select c_name from tbl_category where c_id='".$cat."'"; $cmdbrad=mysql_query($sqlpcat); $rsbrad=mysql_fetch_array($cmdbrad); $output.=$rsbrad['c_name']." --> ".$cname; return $output; } function catbradcrun($default=0){ $LIST=""; if($default!=0){ $sqlcat="select * from tbl_category where c_id='".$default."'"; $cmdcat=mysql_query($sqlcat); while($row = mysql_fetch_array($cmdcat)){ if($row['c_parent']=='0'){ $LIST.= $row['c_name']; }else{ $LIST.= getbradcat($row['c_parent'],$row['c_name']); } } } return $LIST; } function view_image($image){ global $VROOT_UPLOAD_DIR1 , $PIC_DIR; $image_path=$PIC_DIR."/".$image; $image_size=getimagesize($image_path); $image=$VROOT_UPLOAD_DIR1."uploads/".$image; $image_link="View " ; return $image_link; } function draw_box($st,$ed,$sel_val){ $list =""; for($i=$st;$i<=$ed; $i++){ $var_sel=""; if($i < 10){ if("0".$i == $sel_val) $var_sel = "selected"; $list.=""; }else{ if($i == $sel_val) $var_sel = "selected"; $list.=""; } } return $list; } ///////// Draw am box ///////////// function draw_am_box($sel){ $list=""; if($sel =="AM"){ $list=" "; }else{ $list=" "; } return $list; } function month_name($val){ $list=""; switch($val){ case 1 : $list="January"; break; case 2 : $list="February"; break; case 3 : $list="March"; break; case 4 : $list="April"; break; case 5 : $list="May"; break; case 6 : $list="June"; break; case 7 : $list="July"; break; case 8 : $list="August"; break; case 9 : $list="September"; break; case 10 : $list="October"; break; case 11 : $list="November"; break; case 12 : $list="December"; break; } return $list; } function draw_month($sel_val){ $list =""; for($i=1;$i<=12; $i++){ $var_sel=""; if($i < 10){ if("0".$i == $sel_val) $var_sel = "selected"; $list.=""; }else{ if($i == $sel_val) $var_sel = "selected"; $list.=""; } } return $list; } function create_yes_no_box($fld_name , $sel_value){ $list=""; return $list; } function create_status_box($fld_name , $sel_value){ $list=""; return $list; } //////===========================================================================/////// function oldupload($file_id, $folder="", $types="") { if(!$_FILES[$file_id]['name']) return array('','No file specified'); $file_title = $_FILES[$file_id]['name']; //Get file extension $ext_arr = split("\.",basename($file_title)); $ext = strtolower($ext_arr[count($ext_arr)-1]); //Get the last extension //Not really uniqe - but for all practical reasons, it is $uniqer = substr(md5(uniqid(rand(),1)),0,5); $file_name = $uniqer . '_' . $file_title;//Get Unique Name $all_types = explode(",",strtolower($types)); if($types) { if(in_array($ext,$all_types)); else { $result = "'".$_FILES[$file_id]['name']."' is not a valid file."; //Show error if any. return array('',$result); } } //Where the file must be uploaded to if($folder) $folder .= '/';//Add a '/' at the end of the folder $uploadfile = $folder . $file_name; $result = ''; //Move the file from the stored location to the new location if (!move_uploaded_file($_FILES['uploadvideo']['tmp_name'],$uploadfile1_doc)) { $result = "Cannot upload the file '".$_FILES[$file_id]['name']."'"; //Show error if any. if(!file_exists($folder)) { $result .= " : Folder don't exist."; } elseif(!is_writable($folder)) { $result .= " : Folder not writable."; } elseif(!is_writable($uploadfile)) { $result .= " : File not writable."; } $file_name = ''; } else { if(!$_FILES[$file_id]['size']) { //Check if the file is made @unlink($uploadfile);//Delete the Empty file $file_name = ''; $result = "Empty file found - please use a valid file."; //Show the error message } else { chmod($uploadfile,0777);//Make it universally writable. } } return array($file_name,$result); } function cat_list($sel){ $list=""; $rest = mysql_query("select * from tbl_gifts_category where cat_parent='0' order by cat_sorder"); while($row = mysql_fetch_array($rest)){ if($row['cat_id'] == $sel){ $list.=""; }else{ $list.=""; } } return $list; } function prod_cat_listing($sel){ $list=""; $rest = mysql_query("select tc.cat_name , tc.cat_id , tc1.cat_name as pr_name from tbl_gifts_category tc left join tbl_gifts_category tc1 on tc.cat_parent = tc1.cat_id order by tc1.cat_sorder , tc.cat_sorder"); while($row = mysql_fetch_array($rest)){ if($row['pr_name'] != "") $cat_name = $row['pr_name'] ." » ".$row['cat_name'] ; else $cat_name = $row['cat_name'] ; if($row['cat_id'] == $sel){ $list.=""; }else{ $list.=""; } } return $list; } function upload(){ /*** check if a file was uploaded ***/ if(is_uploaded_file($_FILES['userfile']['tmp_name']) && getimagesize($_FILES['userfile']['tmp_name']) != false) { /*** get the image info. ***/ $size = getimagesize($_FILES['userfile']['tmp_name']); /*** assign our variables ***/ $type = $size['mime']; $imgfp = fopen($_FILES['userfile']['tmp_name'], 'rb'); $size = $size[3]; $name = $_FILES['userfile']['name']; $maxsize = 99999999; /*** check the file is less than the maximum file size ***/ if($_FILES['userfile']['size'] < $maxsize ) { /*** connect to db ***/ $dbh = new PDO("mysql:host=localhost;dbname=testblob", 'username', 'password'); /*** set the error mode ***/ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /*** our sql query ***/ $stmt = $dbh->prepare("INSERT INTO testblob (image_type ,image, image_size, image_name) VALUES (? ,?, ?, ?)"); /*** bind the params ***/ $stmt->bindParam(1, $type); $stmt->bindParam(2, $imgfp, PDO::PARAM_LOB); $stmt->bindParam(3, $size); $stmt->bindParam(4, $name); /*** execute the query ***/ $stmt->execute(); } else { /*** throw an exception is image is not of type ***/ throw new Exception("File Size Error"); } } else { // if the file is not less than the maximum allowed, print an error throw new Exception("Unsupported Image Format!"); } } function prod_thm_listing($sel){ $list=""; $rest = mysql_query("select * from tbl_themes order by thm_name"); while($row = mysql_fetch_array($rest)){ if($row['thm_id'] == $sel){ $list.=""; }else{ $list.=""; } } return $list; } function prod_thm_listing_array($sel, $pid){ $list=""; if($sel != ""){ $rest = mysql_query("select tt.* , tttgp.id as sel from tbl_themes tt left join tbl_themes_to_gb_prods tttgp on tt.thm_id = tttgp.thm_id and tttgp.thm_id in (".$sel.") and gb_pid ='".$pid."' order by thm_sorder"); while($row = mysql_fetch_array($rest)){ if($row['sel'] > 0 ){ $list.=""; }else{ $list.=""; } } }else{ $rest = mysql_query("select * from tbl_themes order by thm_sorder"); while($row = mysql_fetch_array($rest)){ $list.=""; } } return $list; } function list_shipping($val){ $LIST=""; $rest = mysql_query("select * from tbl_shipping_method where ship_status='1'"); while($row = mysql_fetch_array($rest)){ if($row['ship_name'] == $val){ $LIST.=""; }else{ $LIST.=""; } } return $LIST; } function list_color($val){ $LIST=""; $rest = mysql_query("select * from tbl_colors where color_status='1'"); while($row = mysql_fetch_array($rest)){ if($row['color_id'] == $val){ $LIST.=""; }else{ $LIST.=""; } } return $LIST; } function list_packing($val){ $LIST=""; $rest = mysql_query("select * from tbl_packing where pack_status='1'"); while($row = mysql_fetch_array($rest)){ if($row['pack_id'] == $val){ $LIST.=""; }else{ $LIST.=""; } } return $LIST; } function convert_to_option($arr,$sel_val){ $LIST=""; foreach($arr as $key => $value){ if($sel_val == $value) $LIST.=""; else $LIST.=""; } return $LIST; } function convert_into_options($arr,$sel_val){ $LIST=""; foreach($arr as $key =>$value){ if($sel_val == $key) $LIST.=""; else $LIST.=""; } return $LIST; } function list_customers($sel_val){ $LIST=""; $rest = mysql_query("select cust_id , cust_login from tbl_customers order by cust_login"); while($row = mysql_fetch_array($rest)){ if($sel_val == $row['cust_id']) $LIST.= ""; else $LIST.=""; } return $LIST; } function convert_2D_option($arr,$sel_val){ $LIST=""; foreach($arr as $key => $value){ if($sel_val == $key) $LIST.=""; else $LIST.=""; } return $LIST; } function pdbfx($steval){ $output=stripslashes(str_replace("'","''",$_POST[$steval])); return $output; } function gdbfx($steval){ $output=stripslashes(str_replace("'","''",$_GET[$steval])); return $output; } function redirect($location){ header("location:".$location); } function getcat($cat,$cname){ $cmdbrad=mysql_query("select c_name from tbl_category where c_id=".$cat); $rsbrad=mysql_fetch_array($cmdbrad); $output=$rsbrad['c_name']; $output.=" --> ".$cname; return $output; } function catdrp($default='nan'){ $LIST.=""; return $LIST; } function states($default){ $sql="select * from tbl_states where st_status=1 order by st_name"; $cmd=mysql_query($sql); while($rs=mysql_fetch_array($cmd)){ if($default==$rs['st_id']) $output.=""; else $output.=""; } return $output; } function districts($default,$def_dist=''){ if($default!=''){ $sql="select * from tbl_districts where st_id=".$default." order by d_name"; $cmd=mysql_query($sql); while($rs=mysql_fetch_array($cmd)){ if($def_dist==$rs['d_id']) $output.=""; else $output.=""; } return $output; } } function order_dropdown($table,$fieldname,$default='',$action=''){ $sql="select count(*) as count from ".$table.""; $cmd=mysql_query($sql); $rs=mysql_fetch_array($cmd); $counter=$rs['count']; $output.=""; return $output; } function chkstatus($default,$filename,$id,$extraparameter=''){ if($default==1){ $output="Yes"; }else { $output="No"; } return $output; } function create_dropdown($table,$fieldname,$default='',$action='',$parameter1,$parameter2,$parameter3='1'){ $sql="select ".$parameter1.",".$parameter2." from ".$table." order by ".$parameter3." asc"; $cmd=mysql_query($sql); $output.=""; return $output; } function create_multiselect($table,$fieldname,$default='',$action='',$parameter1,$parameter2,$parameter3='1'){ $sql="select ".$parameter1.",".$parameter2." from ".$table." order by ".$parameter3." asc"; if($fieldname!='zn_zone'){ $output=""; } if(($table=='tbl_products') && ($fieldname=="p_association_1[]")){ $sql="select ".$parameter1.",".$parameter2.",d_name from ".$table." inner join tbl_department on ".$table.".p_dept=tbl_department.d_id "; $output=""; return $output; } function upload_image($tempname,$filename,$id,$imagefor,$table_name,$parameter,$create_copy=''){ global $PIC_DIR; if(file_exists($_FILES[$tempname]['tmp_name'])){ $file_type=$_FILES[$tempname]['type']; if($file_type == "image/gif" || $file_type == "image/pjpeg" || $file_type == "image/jpg" || $file_type == "image/jpeg" || $file_type == "image/png"){ if($file_type=="image/gif") $ext = ".gif"; else if ($file_type=="image/png") $ext = ".png"; else $ext=".jpg"; $filename1=$filename.$id.$ext; $source=$_FILES[$tempname]['tmp_name']; $destination=$PIC_DIR.$imagefor."/".$filename1; if($create_copy!=''){ $dest_new=$PIC_DIR.$imagefor."/org_".$filename1; } //die; if(copy($source,$destination)){ if($create_copy!=''){ store_image_thumb($source,$destination,378, 402); //copy($source,$dest_new); /*store_image_thumb($source,$dest_new,516, 550);*/ $dest_thumb=$PIC_DIR.$imagefor."/th_".$filename.$id.$ext;; store_image_thumb($source,$dest_thumb,100, 107); $dest_thumb=$PIC_DIR.$imagefor."/li_".$filename.$id.$ext;; store_image_thumb($source,$dest_thumb,176, 187); } mysql_query("update tbl_gift_ideas set ".$tempname."='".$filename1 ."' where ".$parameter."='".$id."'"); } } } } function bindspecialdrp($chk="1"){ $sqlzone="select * from tbl_zones "; $cmdzone=mysql_query($sqlzone); while($rszone=mysql_fetch_array($cmdzone)){ $allcountry_string.=$rszone['zn_zone_country']; } if($allcountry_string!=''){ $array_selected_country=explode(',',$allcountry_string); } $sqlcountry="select * from tbl_countries order by countries_name asc"; $cmdcountry=mysql_query($sqlcountry); $output.=""; return $output; } function encrypt($string, $key) { $result = ''; for($i=0; $i"; $LIST.=""; $cmdcat=mysql_query("select * from tbl_category where c_status!='0' and c_parent='0'"); while($row = mysql_fetch_array($cmdcat)){ if($default == $row['c_id']){ $LIST.= ""; $LIST.= getdrp_cat($row['c_id'],$row['c_name'],$default); } else{ $LIST.=""; $LIST.= getdrp_cat($row['c_id'],$row['c_name'],$default); } } $LIST.=""; return $LIST; } ?>