/home/u775757334/domains/civicwelllife.com/public_html/management/admin/dataQuery
NameSizeModeActions
-process.php2952950644editdlrm
common-function.php11300644editdlrm
process.php2954410644editdlrm
Edit: /home/u775757334/domains/civicwelllife.com/public_html/management/admin/dataQuery/process.php (295441B)
0){ $price = $amount; }else{ $price = $row['direct_customer_price']; } if($gst!=''){ $gst_rate = $gst; }else{ $gst_rate = $row['gst_rate']; } /*$price = $row['direct_customer_price']; $gst_rate = $row['gst_rate'];*/ $hsn_code = $row['hsn_code']; $gst_amount= round(($price*$quantity)*($gst_rate/100)); $rm_commision_price = 0; $rm_price = 0; // ============================ $total = $quantity*$price; $order_status = 2; $order_date = date('Y-m-d'); // ============================ $sql1=mysqli_query($conn,"select * from $tableName where product_id='$product_id' and order_id='$order_id'") or die(mysqli_error($conn)); if(mysqli_num_rows($sql1)){ $sqladd = mysqli_query($conn,"update $tableName set quantity='$quantity', rm_price='$rm_price', price='$price', total='$total', hsn_code='$hsn_code', gst_rate='$gst_rate', gst_amount='$gst_amount', rm_commision_price='$rm_commision_price' where order_id = '$order_id' and product_id='$product_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } }else{ $sql = "INSERT INTO $tableName(order_date,order_id,order_type,distributor_id,product_id,quantity,price,total,rm_commision_price,order_status,hsn_code,gst_rate,gst_amount,rm_price) VALUES ('$order_date','$order_id','$order_type','$distributor_id','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$hsn_code','$gst_rate','$gst_amount','$rm_price')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } } function finalPlaceCustomerOrder($conn) { global $tblOrderDetailsTemp; global $tblOrderDetails; global $tblOrder; global $tblProduct; $returnurl = "customer-order-list.php"; $values=array(); $order_id = $_SESSION['orderid']; $totalAamount =0; $totalComission =0; $distributorID = $_POST['customer_id']; $company_id = $_POST['company_id']; $userID = $_POST['user_id']; $orderDate = $_POST['order_date']; $sql1=mysqli_query($conn,"select * from $tblOrderDetailsTemp where order_id='$order_id'") or die(mysqli_error($conn)); while($row1 = mysqli_fetch_assoc($sql1)){ extract($row1); $totalAamount+=$total; $totalComission+=$rm_commision_price; $order_date = $_POST['order_date']; $values[] = "('$order_date','$order_id','$order_type','$distributorID','$userID','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$gst_rate','$gst_amount','$hsn_code','$rm_price')"; } // ================= Final Order Insert =================== $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") ) { echo "Please use only image (.jpg , .png)"; exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; } $order_time = date("h:i:sa"); $order_status=2; $order_type=4; $utr_number = $_POST['utr_number']; // ======================================================== $sql = "INSERT INTO $tblOrderDetails(order_date,order_id,order_type,distributor_id,user_id,product_id,quantity,price,total,rm_commision_price,order_status,gst_rate,gst_amount,hsn_code,rm_price) VALUES "; $sql .= implode(', ', $values); if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { // =========================== $sql = "insert into $tblOrder(order_id,order_date,order_time,order_type,distributor_id,user_id,order_status,total_amount,total_comission,utr_number,payment_image,company_id) values('$order_id','$orderDate','$order_time','$order_type','$distributorID','$userID','$order_status','$totalAamount','$totalComission','$utr_number','$newfile1','$company_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { unset($_SESSION['orderid']); mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?m=1'); }else{ mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } // ============================ } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } } function completePickupDetails($conn){ global $tblParcelRequest; $user_id = $_GET['user_id']; $request_code = $_GET['requestcode']; $returnurl ="parcel-request-list.php"; $sqladd = mysqli_query($conn,"update $tblParcelRequest set request_status='1' where request_code = '$request_code' and user_id='$user_id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=1'); }else{ header('Location: ../'.$returnurl.'?m=1'); } } function addCallLoad($conn) { global $tblCallLog; $tableName = $tblCallLog; $date = date('Y-m-d'); $lead_id = mysqli_real_escape_string($conn,$_POST['lead_id']); $call_type = mysqli_real_escape_string($conn,$_POST['call_type']); $message = mysqli_real_escape_string($conn,$_POST['message']); $time = date("h:i:sa"); $returnurl = "view-lead.php?lead_id={$lead_id}"; $sql="insert into $tableName(date,call_type,lead_id,message,time) values('$date','$call_type','$lead_id','$message','$time')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { echo "Added"; } else { echo "Try Again"; } } function setReminder($conn) { global $tblLead; $tableName = $tblLead; $reminder_date = mysqli_real_escape_string($conn,$_POST['reminder_date']); $message = mysqli_real_escape_string($conn,$_POST['message']); $lead_id = mysqli_real_escape_string($conn,$_POST['lead_id']); $sqladd = mysqli_query($conn,"update $tableName set reminder_date='$reminder_date' , message='$message' where id = '$lead_id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { echo "Updated"; } else { echo "Already Updated"; } } function addUser($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); if(isset($_POST['add'])){$add_status=1;}else{$add_status=0;} if(isset($_POST['edit'])){$edit_status=1;}else{$edit_status=0;} if(isset($_POST['delete'])){$delete_status=1;}else{$delete_status=0;} $password = md5($_POST['password']); $master = implode(',', $_POST['master']); $menu = implode(',', $_POST['menu']); $sql="insert into $tableName(name,email,phone,password,s_password,master,menu,add_status,edit_status,delete_status) values('$name','$email','$phone','$password','$s_password','$master','$menu','$add_status','$edit_status','$delete_status')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editUser($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $password = md5($_POST['password']); if(isset($_POST['add'])){$add_status=1;}else{$add_status=0;} if(isset($_POST['edit'])){$edit_status=1;}else{$edit_status=0;} if(isset($_POST['delete'])){$delete_status=1;}else{$delete_status=0;} $master = implode(',', $_POST['master']); $menu = implode(',', $_POST['menu']); /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set add_status='$add_status' , edit_status='$edit_status' , delete_status='$delete_status' , name='$name' , email='$email' , phone='$phone' , menu='$menu' , master='$master' , password='$password' , s_password='$s_password' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addRMUser($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $add_status=1; $edit_status=1; $delete_status=1; $password = md5($_POST['password']); $master = '5,6'; $menu = '5,6'; $account_type = '2'; $type=0; $sql="insert into $tableName(name,email,phone,password,s_password,master,menu,add_status,edit_status,delete_status,account_type,type) values('$name','$email','$phone','$password','$s_password','$master','$menu','$add_status','$edit_status','$delete_status','$account_type','$type')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editRMUser($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $password = md5($_POST['password']); /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , email='$email' , phone='$phone' , password='$password' , s_password='$s_password' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addDistributorUser($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $rm_user_id = mysqli_real_escape_string($conn,$_POST['rm_user_id']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $add_status=1; $edit_status=1; $delete_status=1; $password = md5($_POST['password']); $master = '7,9'; $menu = '7,8,9,12,13,17'; $account_type = '1'; $type=0; $sql="insert into $tableName(name,email,phone,password,s_password,master,menu,add_status,edit_status,delete_status,account_type,type,rm_user_id) values('$name','$email','$phone','$password','$s_password','$master','$menu','$add_status','$edit_status','$delete_status','$account_type','$type','$rm_user_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function addRetailerUser($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $rm_user_id = mysqli_real_escape_string($conn,$_POST['rm_user_id']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $add_status=1; $edit_status=1; $delete_status=1; $password = md5($_POST['password']); $master = '8,9'; $menu = '10,11,13'; $account_type = '3'; $type=0; $sql="insert into $tableName(name,email,phone,password,s_password,master,menu,add_status,edit_status,delete_status,account_type,type,rm_user_id) values('$name','$email','$phone','$password','$s_password','$master','$menu','$add_status','$edit_status','$delete_status','$account_type','$type','$rm_user_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editDistributorUser($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $s_password = mysqli_real_escape_string($conn,$_POST['password']); $password = md5($_POST['password']); /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , email='$email' , phone='$phone' , password='$password' , s_password='$s_password' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function approveUser($conn){ global $tblManagerUser; $id = $_GET['id']; $returnurl = "manager-user-list.php"; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tblManagerUser set status = '1' where id = '$id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function addProductInOther($conn,$tableName,$returnurl) { $user_id = $_SESSION['user_id']; $product_id = mysqli_real_escape_string($conn,$_GET['id']); $category_id = mysqli_real_escape_string($conn,$_GET['categorid']); $sql="insert into $tableName(product_id,category_id,user_id) values('$product_id','$category_id','$user_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&cid='.$category_id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&cid='.$category_id); } } function deleteProduct($conn,$tableName,$tableName2,$returnurl) { $product_id = mysqli_real_escape_string($conn,$_GET['id']); $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$product_id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { $del2 = "delete from $tableName2 where product_id = '$product_id' "; if(mysqli_query($conn,$del2) or die(mysqli_error($conn))) { } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } } function removeProductInOther($conn,$tableName,$returnurl) { $product_id = mysqli_real_escape_string($conn,$_GET['id']); $category_id = mysqli_real_escape_string($conn,$_GET['categorid']); $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where product_id = '$product_id' and category_id='$category_id'"; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&cid='.$category_id); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&cid='.$category_id); } } function editLead($conn) { $returnurl = mysqli_real_escape_string($conn,$_POST['returnurl']); $tableName = mysqli_real_escape_string($conn,$_POST['tablename']); $id = mysqli_real_escape_string($conn,$_POST['txtid']); $uid = mysqli_real_escape_string($conn,$_POST['uid']); $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $lead_number = mysqli_real_escape_string($conn,$_POST['lead_number']); $generate_date = mysqli_real_escape_string($conn,$_POST['generate_date']); $generate_time = mysqli_real_escape_string($conn,$_POST['generate_time']); $university_id = mysqli_real_escape_string($conn,$_POST['university_id']); $course_id = mysqli_real_escape_string($conn,$_POST['course_id']); $sub_course_id = mysqli_real_escape_string($conn,$_POST['sub_course_id']); $dob = mysqli_real_escape_string($conn,$_POST['dob']); $lead_status = mysqli_real_escape_string($conn,$_POST['lead_status']); $user_id = mysqli_real_escape_string($conn,$_POST['user_id']); $sqls = mysqli_query($conn,"select * from tbl_user where id = '$user_id'") or die(mysqli_error($conn)); $rows = mysqli_fetch_assoc($sqls); $rm_id = $rows['referral_user_id']; if($rm_id==0){$rm_id = $user_id;} $sqladd = mysqli_query($conn,"update $tableName set uid='$uid', lead_number='$lead_number', generate_date='$generate_date', generate_time='$generate_time', university_id='$university_id', user_id='$user_id', name='$name', phone='$phone', email='$email', course_id='$course_id', sub_course_id='$sub_course_id', dob='$dob', lead_status='$lead_status', rm_id='$rm_id' where id = '$id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo $returnurl; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); // echo $returnurl; } } function deleteLead($conn) { $tableName = mysqli_real_escape_string($conn,$_GET['tablename']); $returnurl = mysqli_real_escape_string($conn,$_GET['returnurl']); $id = mysqli_real_escape_string($conn,$_GET['id']); $uid = mysqli_real_escape_string($conn,$_GET['uid']); $sql = mysqli_query($conn,"START TRANSACTION"); $sqls = mysqli_query($conn,"select * from tbl_student where lead_id='$uid'") or die(mysqli_error($conn)); if(mysqli_num_rows($sqls)>0){ header('Location: ../'.$returnurl.'?&m=15'); }else{ $del = "delete from $tableName where id = '$id'"; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } } } /*function getSubCategory($conn) { $categoryid = $_POST['categoryid']; echo ''; }*/ function getSubCategory($conn) { $categoryid = $_POST['categoryid']; $sqlr=mysqli_query($conn,"select * from tbl_course where parent_id='$categoryid' order by name")or die(mysqli_error($conn)); if(mysqli_num_rows($sqlr)>0){ echo ''; }else{ echo ''; } } function getCity($conn) { global $tblCity; $stateid = $_POST['stateid']; // echo "select * from $tblCity where state_id='$stateid' order by name"; echo ''; } function getManager($conn) { $responsee=array(); $finalJSONAry['data']=array(); global $tblManager; global $tblZone; $managerStr=""; $zoneStr=""; $cityAry = explode('-', $_POST['cityid']); $city = $cityAry[0]; $managerStr.=''; $zoneStr.=''; $responsee['manager'] = $managerStr; $responsee['zone'] = $zoneStr; array_push($finalJSONAry['data'],$responsee); echo json_encode($finalJSONAry); } function addPdf($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; /*-------------------------Image info-----------------------------*/ $imgFlag1 =0; $image = $_POST['image']; if($image==1){$imgFlag1=1;} if($image==2){$imgFlag1=1;$imgFlag2=1;} $keyAry = array(); $valueAry = array(); $keyString = ""; $valueString = ""; $value=""; foreach ($_POST['feild'] as $feild_name){ $keyAry[] = $feild_name; if($feild_name=='size'){ $value = implode(',', $_POST['size']); }else if($feild_name=='password'){ $value = md5($_POST[$feild_name]); }else{ $value = mysqli_real_escape_string($conn,$_POST[$feild_name]); } $valueAry[] = "'{$value}'"; } $keyString = implode(',', $keyAry); $valueString = implode(',', $valueAry); // ====================Image section ================ function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1000000,9999999); $tno = rand(1000000,9999999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; $imageKey=""; $imageValue=""; if($imgFlag1==1){ $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename1 = $str=preg_replace('/\s+/', '_', $imagefleimagename1); $imagefleimagename1_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename1_tmp); // ---------------------------------------- if( $imagefleimagename1!=""){ $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "pdf")) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Image 1 end------------//////////// }else{ $newfile1=""; } $imageKey=",pdf"; $imageValue=",'{$newfile1}'"; // ---------------------------------------- } if($imgFlag2==1){ $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; $imagefleimagename2 = $str=preg_replace('/\s+/', '_', $imagefleimagename2); $imagefleimagename2_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename2_tmp); // ---------------------------------------- if( $imagefleimagename2!=""){ $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$newfile2); //////---------------End Image 2 end------------//////////// }else{ $newfile2=""; } $imageKey=",pdf,image"; $imageValue=",'{$newfile1}','{$newfile2}'"; // ---------------------------------------- } // ====================Insert Section ================ $insertKey = $keyString.''.$imageKey; $insertValue = $valueString."".$imageValue; $sql="insert into $tableName($insertKey) values($insertValue)"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=1'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=1'); // echo "Not Find"; } // echo "success"; } else { if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=0'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=0'); // echo "Not Find"; } } } function addCourseInUniversity($conn) { global $tblCourseCombine; $university_id = $_POST['university_id']; $course_id = $_POST['course_id']; $sql = mysqli_query($conn,"select * from $tblCourseCombine where university_id='$university_id' and course_id='$course_id'") or die(mysqli_error($conn)); if(mysqli_num_rows($sql)>0){ echo "Already exists this course"; }else{ $sql="insert into $tblCourseCombine(course_id,university_id) values('$course_id','$university_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { echo "1"; } else { echo "Not Insert"; } } } function addData($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; /*-------------------------Image info-----------------------------*/ $imgFlag1 =0; $imgFlag2 =0; $imgFlag3 =0; $imgFlag4 =0; $imgFlag5 =0; $imgFlag6 =0; $image = $_POST['image']; if($image==1){$imgFlag1=1;} if($image==2){$imgFlag1=1;$imgFlag2=1;} if($image==3){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;} if($image==4){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;} if($image==5){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;} if($image==6){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;$imgFlag6=1;} $keyAry = array(); $valueAry = array(); $keyString = ""; $valueString = ""; $value=""; foreach ($_POST['feild'] as $feild_name){ $keyAry[] = $feild_name; if($feild_name=='size'){ $value = implode(',', $_POST['size']); }else if($feild_name=='password'){ $value = md5($_POST[$feild_name]); }else{ $value = mysqli_real_escape_string($conn,$_POST[$feild_name]); } $valueAry[] = "'{$value}'"; } $keyString = implode(',', $keyAry); $valueString = implode(',', $valueAry); // ====================Image section ================ function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1000000,9999999); $tno = rand(1000000,9999999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; $imageKey=""; $imageValue=""; if($imgFlag1==1){ $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename1 = $str=preg_replace('/\s+/', '_', $imagefleimagename1); $imagefleimagename1_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename1_tmp); // ---------------------------------------- if( $imagefleimagename1!=""){ $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 1 end------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $imageKey=",image1,thumb1"; $imageValue=",'{$newfile1}','{$imageThumbName}'"; // ---------------------------------------- } if($imgFlag2==1){ $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; $imagefleimagename2 = $str=preg_replace('/\s+/', '_', $imagefleimagename2); $imagefleimagename2_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename2_tmp); // ------------------------------------------------ if( $imagefleimagename2!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename2_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename2_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$newfile2); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $image2ThumbName = $tno.$imagefleimagename2; $imagefleimagename = "$ImageThumbPath/". $image2ThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 2 end------------//////////// }else{ $newfile2=""; $image2ThumbName=""; } $imageKey=",image1,thumb1,image2,thumb2"; $imageValue=",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}'"; // ------------------------------------------------ } if($imgFlag3==1){ $imagefleimagename3 = $_FILES['image3fleimage']['name']; $imagefleimagename3_tmp = $_FILES['image3fleimage']['tmp_name']; $imagefleimagename3 = $str=preg_replace('/\s+/', '_', $imagefleimagename3); $imagefleimagename3_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename3_tmp); // ---------------------------------------------- if( $imagefleimagename3!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename3; $uploadedfile = $imagefleimagename3; $imagefleimagename3 = stripslashes($imagefleimagename3); $extension = getExtension($imagefleimagename3); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename3_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename3_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile3=$no.$imagefleimagename3; move_uploaded_file($_FILES["image3fleimage"]['tmp_name'], "$ImagePath".$newfile3); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $image3ThumbName = $tno.$imagefleimagename3; $imagefleimagename = "$ImageThumbPath/". $image3ThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 3 end------------//////////// }else{ $newfile3=""; $image3ThumbName=""; } $imageKey=",image1,thumb1,image2,thumb2,image3,thumb3"; $imageValue=",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}'"; // ---------------------------------------------- } if($imgFlag4==1){ $imagefleimagename4 = $_FILES['image4fleimage']['name']; $imagefleimagename4_tmp = $_FILES['image4fleimage']['tmp_name']; $imagefleimagename4 = $str=preg_replace('/\s+/', '_', $imagefleimagename4); $imagefleimagename4_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename4_tmp); // ---------------------------------------------- if( $imagefleimagename4!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename4; $uploadedfile = $imagefleimagename4; $imagefleimagename4 = stripslashes($imagefleimagename4); $extension = getExtension($imagefleimagename4); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename4_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename4_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile4=$no.$imagefleimagename4; move_uploaded_file($_FILES["image4fleimage"]['tmp_name'], "$ImagePath".$newfile4); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $image4ThumbName = $tno.$imagefleimagename4; $imagefleimagename = "$ImageThumbPath/". $image4ThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 4 end------------//////////// }else{ $newfile4=""; $image4ThumbName=""; } $imageKey=",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4"; $imageValue=",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}'"; // ---------------------------------------------- } if($imgFlag5==1){ $imagefleimagename5 = $_FILES['image5fleimage']['name']; $imagefleimagename5_tmp = $_FILES['image5fleimage']['tmp_name']; $imagefleimagename5 = $str=preg_replace('/\s+/', '_', $imagefleimagename5); $imagefleimagename5_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename5_tmp); // ---------------------------------------------- if( $imagefleimagename5!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename5; $uploadedfile = $imagefleimagename5; $imagefleimagename5 = stripslashes($imagefleimagename5); $extension = getExtension($imagefleimagename5); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename5_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename5_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile5=$no.$imagefleimagename5; move_uploaded_file($_FILES["image5fleimage"]['tmp_name'], "$ImagePath".$newfile5); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $image5ThumbName = $tno.$imagefleimagename5; $imagefleimagename = "$ImageThumbPath/". $image5ThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 5 end------------//////////// }else{ $newfile5=""; $image5ThumbName=""; } $imageKey=",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5"; $imageValue=",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}'"; // ---------------------------------------------- } if($imgFlag6==1){ $imagefleimagename6 = $_FILES['image6fleimage']['name']; $imagefleimagename6_tmp = $_FILES['image6fleimage']['tmp_name']; $imagefleimagename6 = $str=preg_replace('/\s+/', '_', $imagefleimagename6); $imagefleimagename6_tmp = $str=preg_replace('/\s+/', '_', $imagefleimagename6_tmp); // ---------------------------------------------- if( $imagefleimagename6!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename6; $uploadedfile = $imagefleimagename6; $imagefleimagename6 = stripslashes($imagefleimagename6); $extension = getExtension($imagefleimagename6); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../product.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename6_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename6_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile6=$no.$imagefleimagename6; move_uploaded_file($_FILES["image6fleimage"]['tmp_name'], "$ImagePath".$newfile6); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $image6ThumbName = $tno.$imagefleimagename6; $imagefleimagename = "$ImageThumbPath/". $image6ThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Image 6 end------------//////////// }else{ $newfile6=""; $image6ThumbName=""; } $imageKey=",image1,thumb1,image2,thumb2,image3,thumb3,image4,thumb4,image5,thumb5,image6,thumb6"; $imageValue=",'{$newfile1}','{$imageThumbName}','{$newfile2}','{$image2ThumbName}','{$newfile3}','{$image3ThumbName}','{$newfile4}','{$image4ThumbName}','{$newfile5}','{$image5ThumbName}','{$newfile6}','{$image6ThumbName}'"; // ---------------------------------------------- } // ====================Insert Section ================ $insertKey = $keyString.''.$imageKey; $insertValue = $valueString."".$imageValue; $sql="insert into $tableName($insertKey) values($insertValue)"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=1'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=1'); // echo "Not Find"; } // echo "success"; } else { if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=0'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=0'); // echo "Not Find"; } } } function editData($conn) { $id = $_POST['txtid']; $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; /*-------------------------Image info-----------------------------*/ $imgFlag1 =0; $imgFlag2 =0; $imgFlag3 =0; $imgFlag4 =0; $imgFlag5 =0; $imgFlag6 =0; $image = $_POST['image']; if($image==1){$imgFlag1=1;} if($image==2){$imgFlag1=1;$imgFlag2=1;} if($image==3){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;} if($image==4){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;} if($image==5){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;} if($image==6){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;$imgFlag6=1;} $keyAry = array(); $valueAry = array(); $flag=0; $updateString = ""; foreach ($_POST['feild'] as $feild_name){ if($feild_name=='size'){ $value = implode(',', $_POST['size']); }else if($feild_name=='password'){ $value = md5($_POST[$feild_name]); }else{ $value = mysqli_real_escape_string($conn,$_POST[$feild_name]); } if($flag==0){ $flag=1; $updateString.="{$feild_name}='{$value}'"; }else{ $updateString.=",{$feild_name}='{$value}'"; } } // ====================Image section ================ function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1000000,9999999); $tno = rand(1000000,9999999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; $imageString=""; // =============================== $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); /*---------------------------*/ $flagImage1 =0; $flagImage2 =0; $flagImage3 =0; $flagImage4 =0; $flagImage5 =0; $flagImage6 =0; // ============================= if($imgFlag1==1){ $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; // ---------------------------------------- $Un_OrginalImage1 = $row['image1']; $Un_Image1 = $row['thumb1']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image1']; $InsertImagethumb1 = $row['thumb1']; if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } $imageString =" ,image1='{$InsertImage1}',thumb1='{$InsertImagethumb1}'"; // ---------------------------------------- } if($imgFlag2==1){ $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; // ------------------------------------------------ $Un_OrginalImage2 = $row['image2']; $Un_Image2 = $row['thumb2']; $InsertImage2 = $row['image2']; $InsertImagethumb2 = $row['thumb2']; if( $imagefleimagename2!=""){ $flagImage2 =2; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename2_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename2_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } /*if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight =350; }*/ $InsertImage2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$InsertImage2); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb2 = $tno.$imagefleimagename2; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb2; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } $imageString .=" ,image2='{$InsertImage2}',thumb2='{$InsertImagethumb2}'"; // ------------------------------------------------ } if($imgFlag3==1){ $imagefleimagename3 = $_FILES['image3fleimage']['name']; $imagefleimagename3_tmp = $_FILES['image3fleimage']['tmp_name']; // ---------------------------------------------- $Un_OrginalImage3 = $row['image3']; $Un_Image3 = $row['thumb3']; $InsertImage3 = $row['image3']; $InsertImagethumb3 = $row['thumb3']; if( $imagefleimagename3!=""){ $flagImage3 =3; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename3; $uploadedfile = $imagefleimagename3; $imagefleimagename3 = stripslashes($imagefleimagename3); $extension = getExtension($imagefleimagename3); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename3_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename3_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } /*if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight =350; }*/ $InsertImage3=$no.$imagefleimagename3; move_uploaded_file($_FILES["image3fleimage"]['tmp_name'], "$ImagePath".$InsertImage3); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb3 = $tno.$imagefleimagename3; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb3; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } $imageString .=" ,image3='{$InsertImage3}',thumb3='{$InsertImagethumb3}'"; // ---------------------------------------------- } if($imgFlag4==1){ $imagefleimagename4 = $_FILES['image4fleimage']['name']; $imagefleimagename4_tmp = $_FILES['image4fleimage']['tmp_name']; // ---------------------------------------------- $Un_OrginalImage4 = $row['image4']; $Un_Image4 = $row['thumb4']; $InsertImage4 = $row['image4']; $InsertImagethumb4 = $row['thumb4']; // ======================= image 4 ========================= if( $imagefleimagename4!=""){ $flagImage4 =4; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename4; $uploadedfile = $imagefleimagename4; $imagefleimagename4 = stripslashes($imagefleimagename4); $extension = getExtension($imagefleimagename4); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename4_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename4_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } /*if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight =350; }*/ $InsertImage4=$no.$imagefleimagename4; move_uploaded_file($_FILES["image4fleimage"]['tmp_name'], "$ImagePath".$InsertImage4); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb4 = $tno.$imagefleimagename4; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb4; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 4 End============================== $imageString .=" ,image4='{$InsertImage4}',thumb4='{$InsertImagethumb4}'"; // ---------------------------------------------- } if($imgFlag5==1){ $imagefleimagename5 = $_FILES['image5fleimage']['name']; $imagefleimagename5_tmp = $_FILES['image5fleimage']['tmp_name']; // ---------------------------------------------- $Un_OrginalImage5 = $row['image5']; $Un_Image5 = $row['thumb5']; $InsertImage5 = $row['image5']; $InsertImagethumb5 = $row['thumb5']; // ======================= image 5 ========================= if( $imagefleimagename5!=""){ $flagImage5 =5; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename5; $uploadedfile = $imagefleimagename5; $imagefleimagename5 = stripslashes($imagefleimagename5); $extension = getExtension($imagefleimagename5); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename5_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename5_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } /*if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight =350; }*/ $InsertImage5=$no.$imagefleimagename5; move_uploaded_file($_FILES["image5fleimage"]['tmp_name'], "$ImagePath".$InsertImage5); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb5 = $tno.$imagefleimagename5; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb5; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 5 End============================== $imageString .=" ,image5='{$InsertImage5}',thumb5='{$InsertImagethumb5}'"; // ---------------------------------------------- } if($imgFlag6==1){ $imagefleimagename6 = $_FILES['image6fleimage']['name']; $imagefleimagename6_tmp = $_FILES['image6fleimage']['tmp_name']; // ---------------------------------- $Un_OrginalImage6 = $row['image6']; $Un_Image6 = $row['thumb6']; $InsertImage6 = $row['image6']; $InsertImagethumb6 = $row['thumb6']; // ======================= image 6 ========================= if( $imagefleimagename6!=""){ $flagImage6 =6; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename6; $uploadedfile = $imagefleimagename6; $imagefleimagename6 = stripslashes($imagefleimagename6); $extension = getExtension($imagefleimagename6); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../product-list.php?m=16&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename6_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename6_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setwidth=400; $ratio=0.0; if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } /*if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight =350; }*/ $InsertImage6=$no.$imagefleimagename6; move_uploaded_file($_FILES["image6fleimage"]['tmp_name'], "$ImagePath".$InsertImage6); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb6 = $tno.$imagefleimagename6; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb6; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 6 End============================== $imageString .=" ,image6='{$InsertImage6}',thumb6='{$InsertImagethumb6}'"; // ---------------------------------------------- } $insertValue = "update {$tableName} set {$updateString} {$imageString} where id = '{$id}'"; $sqladd = mysqli_query($conn,$insertValue) or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=4&id='.$id); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "Not Find"; } // echo "success"; } else { if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=5&id='.$id); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=5&id='.$id); // echo "Not Find"; } } } function deleteData($conn) { $id =isset($_GET['id'])? $_GET['id'] : ""; $image = $_GET['image']; $tableName = $_GET['tablename']; $returnurl = $_GET['returnurl']; if(isset($_GET['product_id'])){ $returnurl = "{$returnurl}&product_id={$_GET['product_id']}"; } $imgFlag1 =0; $imgFlag2 =0; $imgFlag3 =0; $imgFlag4 =0; $imgFlag5 =0; $imgFlag6 =0; if($image==1){$imgFlag1=1;} if($image==2){$imgFlag1=1;$imgFlag2=1;} if($image==3){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;} if($image==4){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;} if($image==5){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;} if($image==6){$imgFlag1=1;$imgFlag2=1;$imgFlag3=1;$imgFlag4=1;$imgFlag5=1;$imgFlag6=1;} // =================================== if($image == 0){ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'")or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); if($imgFlag1==1){ $image1=$rowi['image1']; $thumb1=$rowi['thumb1']; } if($imgFlag2==1){ $image2=$rowi['image2']; $thumb2=$rowi['thumb2']; } if($imgFlag3==1){ $image3=$rowi['image3']; $thumb3=$rowi['thumb3']; } if($imgFlag4==1){ $image4=$rowi['image4']; $thumb4=$rowi['thumb4']; } if($imgFlag5==1){ $image5=$rowi['image5']; $thumb5=$rowi['thumb5']; } if($imgFlag6==1){ $image6=$rowi['image6']; $thumb6=$rowi['thumb6']; } //header('Location: ../product-list.php?&m=15'); //exit(); } } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($imgFlag1==1){ if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } } if($imgFlag2==2){ if($image2!=""){ unlink($ImagePath.$image2); unlink($ImageThumbPath.$thumb2); } } if($imgFlag3==1){ if($image3=""){ unlink($ImagePath.$image3); unlink($ImageThumbPath.$thumb3); } } if($imgFlag4==1){ if($image4!=""){ unlink($ImagePath.$image4); unlink($ImageThumbPath.$thumb4); } } if($imgFlag5==1){ if($image5!=""){ unlink($ImagePath.$image5); unlink($ImageThumbPath.$thumb5); } } if($imgFlag6==1){ if($image6!=""){ unlink($ImagePath.$image6); unlink($ImageThumbPath.$thumb6); } } mysqli_query($conn,"COMMIT"); if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=6'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=6'); // echo "Not Find"; } } else { mysqli_query($conn,"ROLLBACK"); if(strpos($returnurl,"?")!=""){ header('Location: ../'.$returnurl.'&m=7'); // echo "Find"; }else{ header('Location: ../'.$returnurl.'?m=7'); // echo "Not Find"; } } // =================================== } function approveAllUser($conn,$tableName,$returnurl) { $values=array(); $userid=array(); $userid = $_POST['userid']; foreach ($userid as $key => $value) { $user_id = $value; $sqladd = mysqli_query($conn,"update $tableName set status = '1' where id = '$user_id'") or die(mysqli_error($conn)); } header('Location: ../'.$returnurl.'?m=4'); } function removeAllUser($conn,$tableName1,$tableName2,$returnurl) { $values=array(); $userid=array(); $userid = $_POST['userid']; foreach ($userid as $key => $value) { $user_id = $value; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName1 where uid = '$user_id'"; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { $del = "delete from $tableName2 where uid = '$user_id'"; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { } } } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?m=7'); } function addItemDistributorToAdmin($conn) { global $tblOrderDetailsTemp; global $tblProduct; $tableName = $tblOrderDetailsTemp; $returnurl = "genrate-order.php"; $values=array(); if(isset($_SESSION['orderid'])){ $order_id = $_SESSION['orderid']; }else{ $_SESSION['orderid']=$order_id = date('ymdh').rand(10000,99999); } $amount = mysqli_real_escape_string($conn,$_POST['amount']); $userid = $_POST['userid']; // ============================ $order_type = 1; $distributor_id = $_POST['user_id']; $product_id = $_POST['product_id']; $quantity = $_POST['quantity']; // ============================ $sql=mysqli_query($conn,"select * from $tblProduct where id='$product_id'") or die(mysqli_error($conn)); $row=mysqli_fetch_assoc($sql); $price = $row['distributor_price']; $gst_rate = $row['gst_rate']; $hsn_code = $row['hsn_code']; $gst_amount= round(($price*$quantity)*($gst_rate/100)); $rm_commision_price = ($row['rm_price']*($row['rm_commision_price']/100))*$quantity; $rm_price = $row['rm_price']; // ============================ $total = $quantity*$price; $order_status = 1; $order_date = date('Y-m-d'); // ============================ $sql1=mysqli_query($conn,"select * from $tableName where product_id='$product_id' and order_id='$order_id'") or die(mysqli_error($conn)); if(mysqli_num_rows($sql1)){ $sqladd = mysqli_query($conn,"update $tableName set quantity='$quantity', rm_price='$rm_price', price='$price', total='$total', hsn_code='$hsn_code', gst_rate='$gst_rate', gst_amount='$gst_amount', rm_commision_price='$rm_commision_price' where order_id = '$order_id' and product_id='$product_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } }else{ $sql = "INSERT INTO $tableName(order_date,order_id,order_type,distributor_id,product_id,quantity,price,total,rm_commision_price,order_status,hsn_code,gst_rate,gst_amount,rm_price) VALUES ('$order_date','$order_id','$order_type','$distributor_id','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$hsn_code','$gst_rate','$gst_amount','$rm_price')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } } function finalPlaceDistributorOrder($conn) { global $tblOrderDetailsTemp; global $tblOrderDetails; global $tblOrder; global $tblProduct; $returnurl = "my-order-list.php"; $values=array(); $order_id = $_SESSION['orderid']; $totalAamount =0; $totalComission =0; $sql1=mysqli_query($conn,"select * from $tblOrderDetailsTemp where order_id='$order_id'") or die(mysqli_error($conn)); while($row1 = mysqli_fetch_assoc($sql1)){ extract($row1); $totalAamount+=$total; $totalComission+=$rm_commision_price; $values[] = "('$order_date','$order_id','$order_type','$distributor_id','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$gst_rate','$gst_amount','$hsn_code','$rm_price')"; } // ================= Final Order Insert =================== $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") ) { echo "Please use only image (.jpg , .png)"; exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; } $order_time = date("h:i:sa"); $order_status=1; $order_type=1; $utr_number = $_POST['utr_number']; // ======================================================== $sql = "INSERT INTO $tblOrderDetails(order_date,order_id,order_type,distributor_id,product_id,quantity,price,total,rm_commision_price,order_status,gst_rate,gst_amount,hsn_code,rm_price) VALUES "; $sql .= implode(', ', $values); if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { // =========================== $sql = "insert into $tblOrder(order_id,order_date,order_time,order_type,distributor_id,order_status,total_amount,total_comission,utr_number,payment_image) values('$order_id','$order_date','$order_time','$order_type','$distributor_id','$order_status','$totalAamount','$totalComission','$utr_number','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { unset($_SESSION['orderid']); mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?m=1'); }else{ mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } // ============================ } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } } function addItemRetailerToDistributor($conn) { global $tblOrderDetailsTemp; global $tblProduct; $tableName = $tblOrderDetailsTemp; $returnurl = "retailer-genrate-order.php"; $values=array(); if(isset($_SESSION['orderid'])){ $order_id = $_SESSION['orderid']; }else{ $_SESSION['orderid']=$order_id = date('ymdh').rand(10000,99999); } $amount = mysqli_real_escape_string($conn,$_POST['amount']); $userid = $_POST['userid']; // ============================ $order_type = 2; $distributor_id = $_POST['user_id']; $product_id = $_POST['product_id']; $quantity = $_POST['quantity']; // ============================ $sql=mysqli_query($conn,"select * from $tblProduct where id='$product_id'") or die(mysqli_error($conn)); $row=mysqli_fetch_assoc($sql); $price = $row['retailer_price']; $gst_rate = $row['gst_rate']; $hsn_code = $row['hsn_code']; $gst_amount= round(($price*$quantity)*($gst_rate/100)); $rm_commision_price = $row['rm_commision_price']*$quantity; // ============================ $total = $quantity*$price; $order_status = 1; $order_date = date('Y-m-d'); // ============================ $sql1=mysqli_query($conn,"select * from $tableName where product_id='$product_id' and order_id='$order_id'") or die(mysqli_error($conn)); if(mysqli_num_rows($sql1)){ $sqladd = mysqli_query($conn,"update $tableName set quantity='$quantity', price='$price', total='$total', hsn_code='$hsn_code', gst_rate='$gst_rate', gst_amount='$gst_amount', rm_commision_price='$rm_commision_price' where order_id = '$order_id' and product_id='$product_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } }else{ $sql = "INSERT INTO $tableName(order_date,order_id,order_type,distributor_id,product_id,quantity,price,total,rm_commision_price,order_status,hsn_code,gst_rate,gst_amount) VALUES ('$order_date','$order_id','$order_type','$distributor_id','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$hsn_code','$gst_rate','$gst_amount')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } } function finalPlaceRetailerOrder($conn) { global $tblOrderDetailsTemp; global $tblOrderDetails; global $tblOrder; global $tblProduct; $returnurl = "retailer-order-list.php"; $values=array(); $order_id = $_SESSION['orderid']; $totalAamount =0; $totalComission =0; $sql1=mysqli_query($conn,"select * from $tblOrderDetailsTemp where order_id='$order_id'") or die(mysqli_error($conn)); while($row1 = mysqli_fetch_assoc($sql1)){ extract($row1); $totalAamount+=$total; $totalComission+=$rm_commision_price; $values[] = "('$order_date','$order_id','$order_type','$distributor_id','$product_id','$quantity','$price','$total','$rm_commision_price','$order_status','$gst_rate','$gst_amount','$hsn_code')"; } // ================= Final Order Insert =================== $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$productPathThumb/"; if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") ) { echo "Please use only image (.jpg , .png)"; exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; } $order_time = date("h:i:sa"); $order_status=1; $order_type=2; $utr_number = $_POST['utr_number']; // ======================================================== $sql = "INSERT INTO $tblOrderDetails(order_date,order_id,order_type,distributor_id,product_id,quantity,price,total,rm_commision_price,order_status,gst_rate,gst_amount,hsn_code) VALUES "; $sql .= implode(', ', $values); if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { // =========================== $sql = "insert into $tblOrder(order_id,order_date,order_time,order_type,distributor_id,order_status,total_amount,total_comission,utr_number,payment_image) values('$order_id','$order_date','$order_time','$order_type','$distributor_id','$order_status','$totalAamount','$totalComission','$utr_number','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { unset($_SESSION['orderid']); mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?m=1'); }else{ mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } // ============================ } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=0'); } } function addExam($conn,$tableName,$returnurl) { $course_id = mysqli_real_escape_string($conn,$_GET['c']); $exam_id = mysqli_real_escape_string($conn,$_GET['e']); $sql="insert into $tableName(course_id,exam_id) values('$course_id','$exam_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&c='.$course_id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&c='.$course_id); } } function deleteCollege($conn,$tableName) { $id =isset($_GET['id'])? $_GET['id'] : ""; $course_id =isset($_GET['c'])? $_GET['c'] : ""; $returnurl =$_GET['r']; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where course_id = '$course_id' and college_id='$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&c='.$course_id); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&c='.$course_id); } //---------------------------------------------------------- } function deleteExam($conn,$tableName) { $id =isset($_GET['id'])? $_GET['id'] : ""; $course_id =isset($_GET['c'])? $_GET['c'] : ""; $returnurl =$_GET['r']; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where course_id = '$course_id' and exam_id='$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&c='.$course_id); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&c='.$course_id); } //---------------------------------------------------------- } function addStudentExam($conn,$tableName,$returnurl) { $exam_id = mysqli_real_escape_string($conn,$_GET['c']); $student_id = mysqli_real_escape_string($conn,$_GET['e']); $sql="insert into $tableName(exam_id,student_id) values('$exam_id','$student_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&c='.$exam_id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&c='.$exam_id); } } function deleteExamStudent($conn,$tableName) { $id =isset($_GET['id'])? $_GET['id'] : ""; $exam_id =isset($_GET['c'])? $_GET['c'] : ""; $returnurl =$_GET['r']; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where exam_id = '$exam_id' and id='$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&c='.$exam_id); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&c='.$exam_id); } //---------------------------------------------------------- } function changeStatus($conn,$tableName,$returnurl) { $order_id = $_POST['order_id']; $status = $_POST['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function changeOrderStatus($conn,$tableName,$returnurl) { global $tblOrderDetails; $order_id = $_GET['order_id']; $status = $_GET['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { $sqladd = mysqli_query($conn,"update $tblOrderDetails set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); } // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); // echo "Fails"; } } function changeOrderStatus2($conn,$tableName,$returnurl) { global $tblOrderDetails; $order_id = $_GET['order_id']; $status = $_GET['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { $sqladd = mysqli_query($conn,"update $tblOrderDetails set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); } // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); // echo "Fails"; } } function changeStatus2($conn,$tableName,$returnurl) { $order_id = $_POST['order_id']; $status = $_POST['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set order_status = '$status' where order_id = '$order_id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function paymentVerify($conn,$tableName,$returnurl) { $id = $_GET['id']; $status = $_GET['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set payment_status = '$status' where id = '$id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function changeWhatsupStatus($conn,$tableName,$returnurl) { $id = $_GET['id']; $status = $_GET['status']; //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set status = '$status' where id = '$id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function editPromo($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $type = mysqli_real_escape_string($conn,$_POST['seltype']); $amount = mysqli_real_escape_string($conn,$_POST['txtamount']); $status = mysqli_real_escape_string($conn,$_POST['selstatus']); //================================ Image 1 End============================== $sqladd = mysqli_query($conn,"update $tableName set name = '$name', type = '$type', status = '$status', amount='$amount' where id = '$id'") or die(mysqli_error($conn)); /*----------------------------------------------*/ if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addBroucher($conn) { global $tblBroucher; $name = mysqli_real_escape_string($conn,$_POST['name']); $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $productPath; global $productPathThumb; $ImagePath = "$productPath/"; $ImageThumbPath = "$bannerPathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") ) { header('Location: ../banner.php?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tblBroucher(name,pdf) values('$name','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../brocher-list.php?m=1'); //echo "suucess"; } else { header('Location: ../brocher-list.php?m=0'); } } function addBanner($conn) { $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $subheading = mysqli_real_escape_string($conn,$_POST['txtsubheading']); $order = mysqli_real_escape_string($conn,$_POST['txtorder']); $link = mysqli_real_escape_string($conn,$_POST['txtlink']); $banner = mysqli_real_escape_string($conn,$_POST['banner']); $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $bannerPath; global $bannerPathThumb; $ImagePath = "$bannerPath/"; $ImageThumbPath = "$bannerPathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "pdf") ) { header('Location: ../banner.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=200; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into tbl_banner(ordering, heading,sub_heading,image,thumb,link,banner_type) values('$order','$heading','$subheading','$newfile1','$imageThumbName','$link','$banner')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../banner-list.php?m=1'); //echo "suucess"; } else { //echo "fail"; header('Location: ../banner-list.php?m=0'); } } function editBanner($conn) { $id = $_POST['txtid']; $banner = mysqli_real_escape_string($conn,$_POST['banner']); $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $subheading = mysqli_real_escape_string($conn,$_POST['txtsubheading']); $order = mysqli_real_escape_string($conn,$_POST['txtorder']); $link = mysqli_real_escape_string($conn,$_POST['txtlink']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../brand-list.php?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from tbl_banner where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_Image1 = $row['thumb']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImagethumb1 = $row['thumb']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $bannerPath; global $bannerPathThumb; $ImagePath = "$bannerPath/"; $ImageThumbPath = "$bannerPathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../banner.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=667; $ratio=0.0; /* if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update tbl_banner set ordering ='$order', heading ='$heading', sub_heading ='$subheading', link ='$link', banner_type ='$banner', image='$InsertImage1' , thumb='$InsertImagethumb1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../banner-list.php?m=4'); //echo "success"; } else { header('Location: ../banner-list.php?m=5'); } } function deleteBanner($conn) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------------------- $checkSql=mysqli_query($conn,"select * from tbl_banner where id ='$id'")or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; //header('Location: ../product-list.php?&m=15'); //exit(); } //echo "value is ".$id; global $bannerPath; global $bannerPathThumb; $ImagePath = "$bannerPath/"; $ImageThumbPath = "$bannerPathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from tbl_banner where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../banner-list.php?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../banner-list.php?m=7'); } //--------------------------------------------------------------------------------------------------- } function deleteOrder($conn) { $order_id =isset($_GET['order_id'])? $_GET['order_id'] : ""; //------------------------------------------------------------------------------------------------- $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from tbl_order where order_id = '$order_id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { $del1 = "delete from tbl_order_details where order_id = '$order_id' "; if(mysqli_query($conn,$del1) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../my-order-list.php?&m=6'); } } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../my-order-list.php?m=7'); } //--------------------------------------------------------------------------------------------------- } function addNotes($conn,$tableName,$returnurl) { $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $longdescription = mysqli_real_escape_string($conn,$_POST['txtlongdescription']); $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $showonhome = mysqli_real_escape_string($conn,$_POST['selshowonhome']); $status = mysqli_real_escape_string($conn,$_POST['selstatus']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "pdf") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(course_id,subject_id,short_description,long_description,video_link,status,show_on_home,paid_status,pdf) values('$course','$subject','$shortdescription','$longdescription','$video','$status','$showonhome','$paidstatus','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editNotes($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $longdescription = mysqli_real_escape_string($conn,$_POST['txtlongdescription']); $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $showonhome = mysqli_real_escape_string($conn,$_POST['selshowonhome']); $status = mysqli_real_escape_string($conn,$_POST['selstatus']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['pdf']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['pdf']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "pdf")) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set course_id='$course' , subject_id='$subject' , long_description='$longdescription' , short_description='$shortdescription' , status='$status' , show_on_home='$showonhome' , paid_status='$paidstatus' , video_link='$video' , pdf='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteNotes($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['pdf']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addTestimonial($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtcoursename']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $post = mysqli_real_escape_string($conn,$_POST['txtpost']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,short_description,post, image) values('$name','$shortdescription','$post','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editTestimonial($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtcoursename']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $post = mysqli_real_escape_string($conn,$_POST['txtpost']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , post='$post' , short_description='$shortdescription' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addManager($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; $name = mysqli_real_escape_string($conn,$_POST['name']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $email = mysqli_real_escape_string($conn,$_POST['email']); $company_name = mysqli_real_escape_string($conn,$_POST['company_name']); $company_code = mysqli_real_escape_string($conn,$_POST['company_code']); $password = md5($_POST['s_password']); $s_password = mysqli_real_escape_string($conn,$_POST['s_password']); $location = mysqli_real_escape_string($conn,$_POST['location']); $full_address = mysqli_real_escape_string($conn,$_POST['full_address']); $state_id = 0;//mysqli_real_escape_string($conn,$_POST['state_id']); $city_id = 0;//mysqli_real_escape_string($conn,$_POST['city_id']); $sel = mysqli_query($conn,"select * from $tableName where company_code = '$company_code' "); if(mysqli_num_rows($sel)>0){ echo "This company code already exists"; }else{ // --------------------------- $sql="insert into $tableName(name,email,phone,company_name,company_code,password,s_password, location,full_address,state_id,city_id) values('$name','$email','$phone','$company_name','$company_code','$password','$s_password', '$location','$full_address','$state_id','$city_id')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { echo "1"; } else { echo "0"; } // --------------------------- } } function editManager($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['name']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $email = mysqli_real_escape_string($conn,$_POST['email']); $company_name = mysqli_real_escape_string($conn,$_POST['company_name']); $company_code = mysqli_real_escape_string($conn,$_POST['company_code']); $password = md5($_POST['s_password']); $s_password = mysqli_real_escape_string($conn,$_POST['s_password']); $location = mysqli_real_escape_string($conn,$_POST['location']); $full_address = mysqli_real_escape_string($conn,$_POST['full_address']); $state_id = 0;//mysqli_real_escape_string($conn,$_POST['state_id']); $city_id = 0;//mysqli_real_escape_string($conn,$_POST['city_id']); /*-------------------------Image info-----------------------------*/ $sel = mysqli_query($conn,"select * from $tableName where company_code = '$company_code' and id!='$id' "); if(mysqli_num_rows($sel)>0){ echo "This company code already exists"; }else{ $sqladd = mysqli_query($conn,"update $tableName set name='$name', email='$email', phone='$phone', company_name='$company_name', company_code='$company_code', password='$password', s_password='$s_password', location='$location', full_address='$full_address', state_id='$state_id', city_id='$city_id' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { echo "4"; } else { echo "5"; } } } function addApplyFresh($conn) { //========================================================================= $tableName = mysqli_real_escape_string($conn,$_POST['tablename']); $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $lead_number = mysqli_real_escape_string($conn,$_POST['lead_number']); $generate_date = mysqli_real_escape_string($conn,$_POST['generate_date']); $generate_time = mysqli_real_escape_string($conn,$_POST['generate_time']); $university_id = mysqli_real_escape_string($conn,$_POST['university_id']); $course_id = mysqli_real_escape_string($conn,$_POST['course_id']); $sub_course_id = mysqli_real_escape_string($conn,$_POST['sub_course_id']); $dob = mysqli_real_escape_string($conn,$_POST['dob']); $lead_status = mysqli_real_escape_string($conn,$_POST['lead_status']); $user_id = mysqli_real_escape_string($conn,$_POST['user_id']); $rm_id = mysqli_real_escape_string($conn,$_POST['rm_id']); $admission_session = mysqli_real_escape_string($conn,$_POST['admission_session']); $semister = mysqli_real_escape_string($conn,$_POST['semister']); $admission_type = mysqli_real_escape_string($conn,$_POST['admission_type']); $fees = mysqli_real_escape_string($conn,$_POST['fees']); $lead_id = mysqli_real_escape_string($conn,$_POST['lead_id']); $duration = mysqli_real_escape_string($conn,$_POST['duration']); $sqlr = mysqli_query($conn,"select * from $tableName where lead_id='$lead_id'") or die(mysqli_error($conn)); if(mysqli_num_rows($sqlr)>0){ echo "You have Already Applyed"; }else{ $sql="insert into $tableName(lead_number,generate_date,generate_time,university_id,user_id,name,phone,email,course_id,sub_course_id,dob,lead_status,rm_id,admission_session,semister,admission_type,fees,lead_id,duration) values('$lead_number','$generate_date','$generate_time','$university_id','$user_id','$name','$phone','$email','$course_id','$sub_course_id','$dob','$lead_status','$rm_id','$admission_session','$semister','$admission_type','$fees','$lead_id','$duration')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { echo "1"; } else { echo "Please try Again"; } } } function editApplyFresh($conn) { $id = $_POST['txtid']; $tableName = mysqli_real_escape_string($conn,$_POST['tablename']); $returnurl = mysqli_real_escape_string($conn,$_POST['returnurl']); $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $university_id = mysqli_real_escape_string($conn,$_POST['university_id']); $course_id = mysqli_real_escape_string($conn,$_POST['course_id']); $sub_course_id = mysqli_real_escape_string($conn,$_POST['sub_course_id']); $dob = mysqli_real_escape_string($conn,$_POST['dob']); $admission_session = mysqli_real_escape_string($conn,$_POST['admission_session']); $semister = mysqli_real_escape_string($conn,$_POST['semister']); $admission_type = mysqli_real_escape_string($conn,$_POST['admission_type']); $fees = mysqli_real_escape_string($conn,$_POST['fees']); $duration = mysqli_real_escape_string($conn,$_POST['duration']); /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set university_id='$university_id' , course_id='$course_id' , sub_course_id='$sub_course_id' , name='$name' , email='$email' , phone='$phone' , dob='$dob' , fees='$fees' , duration='$duration' , admission_session='$admission_session' , semister='$semister' , admission_type='$admission_type' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { echo 1; // echo "success"; } else { echo "Already Updated"; } /*-----------------------------*/ } function addManagerUser($conn) { global $tblManagerUser; $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; $name = mysqli_real_escape_string($conn,$_POST['name']); $user_id = mysqli_real_escape_string($conn,$_POST['user_id']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $email = mysqli_real_escape_string($conn,$_POST['email']); $branch_name = mysqli_real_escape_string($conn,$_POST['branch_name']); $branch_code = mysqli_real_escape_string($conn,$_POST['branch_code']); $password = md5($_POST['s_password']); $s_password = mysqli_real_escape_string($conn,$_POST['s_password']); $manager_id = mysqli_real_escape_string($conn,$_POST['manager_id']); $zone_id = mysqli_real_escape_string($conn,$_POST['zone_id']); $address_type = mysqli_real_escape_string($conn,$_POST['address_type']); $address = mysqli_real_escape_string($conn,$_POST['address']); $cityAry = explode('-', $_POST['city_id']); $city_id = $cityAry[0]; $state_id = $cityAry[1]; $flag=1; $sel = mysqli_query($conn,"select * from $tblManagerUser where user_id = '$user_id' "); if(mysqli_num_rows($sel)>0){ echo "This User ID already exists"; $flag=0; } $sel = mysqli_query($conn,"select * from $tblManagerUser where branch_code = '$branch_code' "); if(mysqli_num_rows($sel)>0){ if($flag==1){ echo "This Branch Code already exists"; } $flag=0; } if($flag==1){ // --------------------------- $sql="insert into $tableName(name,email,phone,branch_name,branch_code,password,s_password, zone_id,manager_id,state_id,city_id,user_id,address_type,address) values('$name','$email','$phone','$branch_name','$branch_code','$password','$s_password', '$zone_id','$manager_id','$state_id','$city_id','$user_id','$address_type','$address')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { echo "1"; } else { echo "0"; } // --------------------------- } } function editManagerUser($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['name']); $user_id = mysqli_real_escape_string($conn,$_POST['user_id']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $email = mysqli_real_escape_string($conn,$_POST['email']); $branch_name = mysqli_real_escape_string($conn,$_POST['branch_name']); $branch_code = mysqli_real_escape_string($conn,$_POST['branch_code']); $password = md5($_POST['s_password']); $s_password = mysqli_real_escape_string($conn,$_POST['s_password']); $manager_id = mysqli_real_escape_string($conn,$_POST['manager_id']); $zone_id = mysqli_real_escape_string($conn,$_POST['zone_id']); $address_type = mysqli_real_escape_string($conn,$_POST['address_type']); $address = mysqli_real_escape_string($conn,$_POST['address']); $cityAry = explode('-', $_POST['city_id']); $city_id = $cityAry[0]; $state_id = $cityAry[1]; /*-------------------------Image info-----------------------------*/ $sel = mysqli_query($conn,"select * from $tableName where branch_code = '$branch_code' and id!='$id' "); if(mysqli_num_rows($sel)>0){ echo "This Branch code already exists"; }else{ $sqladd = mysqli_query($conn,"update $tableName set user_id='$user_id', manager_id='$manager_id', name='$name', email='$email', phone='$phone', branch_name='$branch_name', branch_code='$branch_code', password='$password', s_password='$s_password', manager_id='$manager_id', zone_id='$zone_id', state_id='$state_id', address='$address', address_type='$address_type', city_id='$city_id' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { echo "4"; } else { echo "5"; } } } function editRequestDetails($conn) { $tableName = $_POST['tablename']; $returnurl = $_POST['returnurl']; $id = $_POST['txtid']; $file_count = mysqli_real_escape_string($conn,$_POST['file_count']); $document_count = mysqli_real_escape_string($conn,$_POST['document_count']); $weight = mysqli_real_escape_string($conn,$_POST['weight']); $courier_company_id = mysqli_real_escape_string($conn,$_POST['courier_company_id']); $consignee_name = mysqli_real_escape_string($conn,$_POST['consignee_name']); $head_office = mysqli_real_escape_string($conn,$_POST['head_office']); $destination_city_id = mysqli_real_escape_string($conn,$_POST['destination_city_id']); $pickup_date = mysqli_real_escape_string($conn,$_POST['pickup_date']); $status = mysqli_real_escape_string($conn,$_POST['status']); $gram = mysqli_real_escape_string($conn,$_POST['gram']); if($status==3){ $delivered_date = mysqli_real_escape_string($conn,$_POST['delivered_date']); }else{ $delivered_date=""; } /*-------------------------Image info-----------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set file_count='$file_count', gram = '$gram', document_count='$document_count', weight='$weight', courier_company_id='$courier_company_id', consignee_name='$consignee_name', head_office='$head_office', destination_city_id='$destination_city_id', pickup_date='$pickup_date', delivered_date='$delivered_date', status='$status' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { echo "4"; } else { echo "5"; } } function addNotice($conn,$tableName,$returnurl) { $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $date = date('Y-m-d'); $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $details = mysqli_real_escape_string($conn,$_POST['txtdetails']); $pageUrl = mysqli_real_escape_string($conn,$_POST['txturl']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(subject_id,course_id,date,heading,details,url,image) values('$subject','$course','$date','$heading','$details','$pageUrl','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editNotice($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $date = date('Y-m-d'); $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $details = mysqli_real_escape_string($conn,$_POST['txtdetails']); $pageUrl = mysqli_real_escape_string($conn,$_POST['txturl']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set heading='$heading' , details='$details' , subject_id='$subject' , course_id='$course' , url='$pageUrl' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addCourse($conn,$tableName,$returnurl) { $coursename = mysqli_real_escape_string($conn,$_POST['txtcoursename']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); $saleprice = mysqli_real_escape_string($conn,$_POST['txtsaleprice']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $syllabus = mysqli_real_escape_string($conn,$_POST['txtsyllabus']); $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(course_name,price,sale_price,short_description,syllabus,video_link, image) values('$coursename','$price','$saleprice','$shortdescription','$syllabus','$video','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editCourse($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $coursename = mysqli_real_escape_string($conn,$_POST['txtcoursename']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); $saleprice = mysqli_real_escape_string($conn,$_POST['txtsaleprice']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $syllabus = mysqli_real_escape_string($conn,$_POST['txtsyllabus']); $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set course_name='$coursename' , price='$price' , sale_price='$saleprice' , short_description='$shortdescription' , syllabus='$syllabus' , video_link='$video' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addAnswer($conn,$tableName,$returnurl) { $questionid = mysqli_real_escape_string($conn,$_POST['questionid']); $studentid = mysqli_real_escape_string($conn,$_POST['studentid']); $teacherid = mysqli_real_escape_string($conn,$_POST['teacherid']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(question_id,teacher_id,student_id,description, image) values('$questionid','$teacherid','$studentid','$description','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editAnswer($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $questionid = mysqli_real_escape_string($conn,$_POST['questionid']); $studentid = mysqli_real_escape_string($conn,$_POST['studentid']); $teacherid = mysqli_real_escape_string($conn,$_POST['teacherid']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set question_id = '$questionid', teacher_id = '$teacherid', student_id = '$studentid', description = '$description', image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&aid='.$questionid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&aid='.$questionid); } } function addSubject($conn,$tableName,$returnurl) { $course = mysqli_real_escape_string($conn,$_POST['selcourse']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,course_id,image) values('$name','$course','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editSubject($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $course = mysqli_real_escape_string($conn,$_POST['selcourse']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); //================================ Image 1 End============================== //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name = '$name', image = '$InsertImage1', course_id = '$course' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function addVideo($conn,$tableName,$returnurl) { $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $title = mysqli_real_escape_string($conn,$_POST['txttitle']); $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $showonhome = mysqli_real_escape_string($conn,$_POST['selshowonhome']); $status = mysqli_real_escape_string($conn,$_POST['selstatus']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(video_link,course_id,subject_id,status,show_on_home,paid_status,title) values('$video','$course','$subject','$status','$showonhome','$paidstatus','$title')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editVideo($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $title = mysqli_real_escape_string($conn,$_POST['txttitle']); $video = mysqli_real_escape_string($conn,$_POST['txtvideo']); $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $showonhome = mysqli_real_escape_string($conn,$_POST['selshowonhome']); $status = mysqli_real_escape_string($conn,$_POST['selstatus']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set video_link = '$video', course_id = '$course', subject_id = '$subject', status = '$status', show_on_home = '$showonhome', title='$title', status = '$status', paid_status = '$paidstatus' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteVideo($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addExamPaper($conn,$tableName,$returnurl) { $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $subject1 = mysqli_real_escape_string($conn,$_POST['txtsubject1']); $subject2 = mysqli_real_escape_string($conn,$_POST['txtsubject2']); $subject3 = mysqli_real_escape_string($conn,$_POST['txtsubject3']); $start1 = mysqli_real_escape_string($conn,$_POST['txtstart1']); $start2 = mysqli_real_escape_string($conn,$_POST['txtstart2']); $start3 = mysqli_real_escape_string($conn,$_POST['txtstart3']); $end1 = mysqli_real_escape_string($conn,$_POST['txtend1']); $end2 = mysqli_real_escape_string($conn,$_POST['txtend2']); $end3 = mysqli_real_escape_string($conn,$_POST['txtend3']); $papername = mysqli_real_escape_string($conn,$_POST['txtpapername']); $totalquation = mysqli_real_escape_string($conn,$_POST['txttotalquation']); $perquationmarks = mysqli_real_escape_string($conn,$_POST['txtperquationmarks']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $examdate = mysqli_real_escape_string($conn,$_POST['txtexamdate']); $starttime = mysqli_real_escape_string($conn,$_POST['txtstarttime']); $endtime = mysqli_real_escape_string($conn,$_POST['txtendtime']); $exam_status = mysqli_real_escape_string($conn,$_POST['exam_status']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(course_id,subject_id,paper_name,short_description,total_quation,per_quation_marks,exam_date,start_time,end_time,exam_status,subject1,subject2,subject3,start1,start2,start3,end1,end2,end3) values('$course','$subject','$papername','$shortdescription','$totalquation','$perquationmarks','$examdate','$starttime','$endtime','$exam_status','$subject1','$subject2','$subject3','$start1','$start2','$start3','$end1','$end2','$end3')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editExamPaper($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $subject1 = mysqli_real_escape_string($conn,$_POST['txtsubject1']); $subject2 = mysqli_real_escape_string($conn,$_POST['txtsubject2']); $subject3 = mysqli_real_escape_string($conn,$_POST['txtsubject3']); $start1 = mysqli_real_escape_string($conn,$_POST['txtstart1']); $start2 = mysqli_real_escape_string($conn,$_POST['txtstart2']); $start3 = mysqli_real_escape_string($conn,$_POST['txtstart3']); $end1 = mysqli_real_escape_string($conn,$_POST['txtend1']); $end2 = mysqli_real_escape_string($conn,$_POST['txtend2']); $end3 = mysqli_real_escape_string($conn,$_POST['txtend3']); $papername = mysqli_real_escape_string($conn,$_POST['txtpapername']); $totalquation = mysqli_real_escape_string($conn,$_POST['txttotalquation']); $perquationmarks = mysqli_real_escape_string($conn,$_POST['txtperquationmarks']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $examdate = mysqli_real_escape_string($conn,$_POST['txtexamdate']); $starttime = mysqli_real_escape_string($conn,$_POST['txtstarttime']); $endtime = mysqli_real_escape_string($conn,$_POST['txtendtime']); $exam_status = mysqli_real_escape_string($conn,$_POST['exam_status']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set subject1 = '$subject1', subject2 = '$subject2', subject3 = '$subject3', end1 = '$end1', end2 = '$end2', end3 = '$end3', start1 = '$start1', start2 = '$start2', start3 = '$start3', course_id = '$course', subject_id = '$subject', exam_status= '$exam_status', paper_name = '$papername', short_description = '$shortdescription', total_quation = '$totalquation', per_quation_marks = '$perquationmarks', exam_date = '$examdate', start_time = '$starttime', end_time = '$endtime' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteExamPaper($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addExamPaperFree($conn,$tableName,$returnurl) { $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $papername = mysqli_real_escape_string($conn,$_POST['txtpapername']); $totalquation = mysqli_real_escape_string($conn,$_POST['txttotalquation']); $perquationmarks = mysqli_real_escape_string($conn,$_POST['txtperquationmarks']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(course_id,subject_id,paper_name,short_description,total_quation,per_quation_marks,paid_status) values('$course','$subject','$papername','$shortdescription','$totalquation','$perquationmarks','$paidstatus')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editExamPaperFree($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $url = mysqli_real_escape_string($conn,$_POST['selcourse']); $subjectAry = explode('-', $url); $subject = $subjectAry[0]; $course = $subjectAry[1]; $paidstatus = mysqli_real_escape_string($conn,$_POST['selpaidstatus']); $papername = mysqli_real_escape_string($conn,$_POST['txtpapername']); $totalquation = mysqli_real_escape_string($conn,$_POST['txttotalquation']); $perquationmarks = mysqli_real_escape_string($conn,$_POST['txtperquationmarks']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $examdate = mysqli_real_escape_string($conn,$_POST['txtexamdate']); $starttime = mysqli_real_escape_string($conn,$_POST['txtstarttime']); $endtime = mysqli_real_escape_string($conn,$_POST['txtendtime']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set course_id = '$course', subject_id = '$subject', paper_name = '$papername', paid_status = '$paidstatus', short_description = '$shortdescription', total_quation = '$totalquation', per_quation_marks = '$perquationmarks' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteExamPaperFree($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addQuestionFree($conn,$tableName,$returnurl) { $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } if( $imagefleimagename2!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename2; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$newfile2); //////---------------End Upload Brand Image------------//////////// }else{ $newfile2=""; $imageThumbName=""; } $sql="insert into $tableName(paper_id,question,answer1,answer2,answer3,answer4,right_answer,image,image2) values('$qid','$question','$answer1','$answer2','$answer3','$answer4','$rightanswer','$newfile1','$newfile2')"; ; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&qid='.$qid); } } function editQuestionFree($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImage2 = $row['image2']; /*---------------------------*/ $flagImage1 =0; $flagImage2 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } if( $imagefleimagename2!=""){ $flagImage2 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$InsertImage2); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set paper_id = '$qid', question = '$question', answer1 = '$answer1', answer2 = '$answer2', answer3 = '$answer3', answer4 = '$answer4', image='$InsertImage1' , image2='$InsertImage2' , right_answer = '$rightanswer' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id.'&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&qid='.$qid); } } function deleteQuestionFree($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } $qid =isset($_GET['qid'])? $_GET['qid'] : ""; //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&qid='.$qid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&qid='.$qid); } //---------------------------------------------------------- } function addQuestionFree2($conn,$tableName,$returnurl) { $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(paper_id,question,answer1,answer2,answer3,answer4,right_answer) values('$qid','$question','$answer1','$answer2','$answer3','$answer4','$rightanswer')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&qid='.$qid); } } function editQuestionFree2($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set paper_id = '$qid', question = '$question', answer1 = '$answer1', answer2 = '$answer2', answer3 = '$answer3', answer4 = '$answer4', right_answer = '$rightanswer' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id.'&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&qid='.$qid); } } function deleteQuestionFree2($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $qid =isset($_GET['qid'])? $_GET['qid'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&qid='.$qid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&qid='.$qid); } //---------------------------------------------------------- } function addQuestion($conn,$tableName,$returnurl) { $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } if( $imagefleimagename2!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename2; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$newfile2); //////---------------End Upload Brand Image------------//////////// }else{ $newfile2=""; $imageThumbName=""; } $sql="insert into $tableName(paper_id,question,answer1,answer2,answer3,answer4,right_answer,image,image2) values('$qid','$question','$answer1','$answer2','$answer3','$answer4','$rightanswer','$newfile1','$newfile2')"; ; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&qid='.$qid); } } function editQuestion($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImage2 = $row['image2']; /*---------------------------*/ $flagImage1 =0; $flagImage2 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== if( $imagefleimagename2!=""){ $flagImage2 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$InsertImage2); //////---------------End Upload Brand Image------------//////////// } /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set paper_id = '$qid', question = '$question', answer1 = '$answer1', answer2 = '$answer2', answer3 = '$answer3', answer4 = '$answer4', image='$InsertImage1' , right_answer = '$rightanswer' where id = '$id'") or die(mysqli_error($conn)); $sqladd = mysqli_query($conn,"update $tableName set course_name='$coursename' , price='$price' , short_description='$shortdescription' , syllabus='$syllabus' , video_link='$video' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id.'&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&qid='.$qid); } } function deleteQuestion($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } $qid =isset($_GET['qid'])? $_GET['qid'] : ""; //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&qid='.$qid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&qid='.$qid); } //---------------------------------------------------------- } function addQuestion1($conn,$tableName,$returnurl) { $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(paper_id,question,answer1,answer2,answer3,answer4,right_answer) values('$qid','$question','$answer1','$answer2','$answer3','$answer4','$rightanswer')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&qid='.$qid); } } function editQuestion1($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $qid = mysqli_real_escape_string($conn,$_POST['txtqid']); $question = mysqli_real_escape_string($conn,$_POST['txtquestion']); $answer1 = mysqli_real_escape_string($conn,$_POST['txtanswer1']); $answer2 = mysqli_real_escape_string($conn,$_POST['txtanswer2']); $answer3 = mysqli_real_escape_string($conn,$_POST['txtanswer3']); $answer4 = mysqli_real_escape_string($conn,$_POST['txtanswer4']); $rightanswer = mysqli_real_escape_string($conn,$_POST['rightanswer']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set paper_id = '$qid', question = '$question', answer1 = '$answer1', answer2 = '$answer2', answer3 = '$answer3', answer4 = '$answer4', right_answer = '$rightanswer' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id.'&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&qid='.$qid); } } function deleteQuestion1($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $qid =isset($_GET['qid'])? $_GET['qid'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&qid='.$qid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&qid='.$qid); } //---------------------------------------------------------- } function addLive($conn,$tableName,$returnurl) { $course = mysqli_real_escape_string($conn,$_POST['selcourse']); $title = mysqli_real_escape_string($conn,$_POST['txttitle']); $video_link = mysqli_real_escape_string($conn,$_POST['txtvideolink']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $time = mysqli_real_escape_string($conn,$_POST['txttime']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(title,video_link,date,time,course_id) values('$title','$video_link','$date','$time','$course')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&qid='.$qid); } } function editLive($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $course = mysqli_real_escape_string($conn,$_POST['selcourse']); $title = mysqli_real_escape_string($conn,$_POST['txttitle']); $video_link = mysqli_real_escape_string($conn,$_POST['txtvideolink']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $time = mysqli_real_escape_string($conn,$_POST['txttime']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set title = '$title', course_id= '$course', video_link = '$video_link', date = '$date', time = '$time' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id.'&qid='.$qid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&qid='.$qid); } } function deleteLive($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $qid =isset($_GET['qid'])? $_GET['qid'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&qid='.$qid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&qid='.$qid); } //---------------------------------------------------------- } function addService($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,details, image) values('$name','$description','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editService($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , details='$description' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteService($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addSubCategory($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $category = mysqli_real_escape_string($conn,$_POST['selcategory']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,category_id, image) values('$name','$category','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editSubCategory($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $category = mysqli_real_escape_string($conn,$_POST['selcategory']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , category_id='$category' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteSubCategory($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addMenu($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); $category = mysqli_real_escape_string($conn,$_POST['selcategory']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(name,sub_category_id,price) values('$name','$category','$price')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editMenu($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); $category = mysqli_real_escape_string($conn,$_POST['selcategory']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , price='$price' , sub_category_id='$category' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteMenu($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addRooms($conn,$tableName,$returnurl) { $roomname = mysqli_real_escape_string($conn,$_POST['txtroomname']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $longdescription = mysqli_real_escape_string($conn,$_POST['txtlongdescription']); /*-------------------------Image info-----------------------------*/ $facilities = ""; //echo explode(",",$facility); foreach($_POST['facility'] as $item) { $facilities.= $item.","; } $facilities = substr($facilities,0,strlen($facilities)-1); $sql="insert into $tableName(room_name,short_description,long_description,facilities) values('$roomname','$shortdescription','$longdescription','$facilities')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editRooms($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $roomname = mysqli_real_escape_string($conn,$_POST['txtroomname']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $longdescription = mysqli_real_escape_string($conn,$_POST['txtlongdescription']); $facilities = ""; //echo explode(",",$facility); foreach($_POST['facility'] as $item) { $facilities.= $item.","; } $facilities = substr($facilities,0,strlen($facilities)-1); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set room_name='$roomname' , facilities='$facilities', short_description='$shortdescription' , long_description='$longdescription' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteRooms($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addTariff($conn,$tableName,$returnurl) { $rid = mysqli_real_escape_string($conn,$_POST['txtrid']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); $sql="insert into $tableName(room_id,name,price) values('$rid','$name','$price')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&rid='.$rid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&rid='.$rid); } } function editTariff($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $rid = mysqli_real_escape_string($conn,$_POST['txtrid']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); $price = mysqli_real_escape_string($conn,$_POST['txtprice']); //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set room_id ='$rid' , name ='$name', price ='$price' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id.'&rid='.$rid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id.'&rid='.$rid); } } function deleteRoomBooking($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $rid =isset($_GET['rid'])? $_GET['rid'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&rid='.$rid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&rid='.$rid); } //---------------------------------------------------------- } function deleteTariff($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $rid =isset($_GET['rid'])? $_GET['rid'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&rid='.$rid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&rid='.$rid); } //---------------------------------------------------------- } function addGalleryCategory($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); /*-------------------------Image info-----------------------------*/ $sql="insert into $tableName(name) values('$name')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editGalleryCategory($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); /*-------------------------Image info-----------------------------*/ //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteGalleryCategory($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addStory($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $url = strtolower(str_replace(" ","-",$name)); $url = strtolower(str_replace("&","and",$url)); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); $metatitle = mysqli_real_escape_string($conn,$_POST['txtmetatitle']); $metakeyword = mysqli_real_escape_string($conn,$_POST['txtmetakeyword']); $metadescription = mysqli_real_escape_string($conn,$_POST['txtmetadescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,url,date,short_description,full_description, image,thumb,meta_title,meta_keyword,meta_description) values('$name','$url','$date','$shortdescription','$description','$newfile1','$imageThumbName','$metatitle','$metakeyword','$metadescription')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editStory($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $url = strtolower(str_replace(" ","-",$name)); $url = strtolower(str_replace("&","and",$url)); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $shortdescription = mysqli_real_escape_string($conn,$_POST['txtshortdescription']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); $metatitle = mysqli_real_escape_string($conn,$_POST['txtmetatitle']); $metakeyword = mysqli_real_escape_string($conn,$_POST['txtmetakeyword']); $metadescription = mysqli_real_escape_string($conn,$_POST['txtmetadescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_Image1 = $row['thumb']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImagethumb1 = $row['thumb']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=350; $ratio=0.0; /* if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , url='$url' , date='$date' , short_description='$shortdescription' , full_description='$description' , image='$InsertImage1' , thumb='$InsertImagethumb1', meta_title='$metatitle', meta_keyword='$metakeyword', meta_description='$metadescription' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteStory($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function editSetting($conn,$tableName,$returnurl) { $facebook = mysqli_real_escape_string($conn,$_POST['facebook']); $tweeter = mysqli_real_escape_string($conn,$_POST['tweeter']); $instagram = mysqli_real_escape_string($conn,$_POST['instagram']); $youtube = mysqli_real_escape_string($conn,$_POST['youtube']); $whatsup_number = mysqli_real_escape_string($conn,$_POST['whatsup_number']); $phone_number = mysqli_real_escape_string($conn,$_POST['phone_number']); $email = mysqli_real_escape_string($conn,$_POST['email']); $address = mysqli_real_escape_string($conn,$_POST['address']); $heading1 = mysqli_real_escape_string($conn,$_POST['heading1']); $text1 = mysqli_real_escape_string($conn,$_POST['text1']); $heading2 = mysqli_real_escape_string($conn,$_POST['heading2']); $text2 = mysqli_real_escape_string($conn,$_POST['text2']); $heading3 = mysqli_real_escape_string($conn,$_POST['heading3']); $text3 = mysqli_real_escape_string($conn,$_POST['text3']); $heading4 = mysqli_real_escape_string($conn,$_POST['heading4']); $text4 = mysqli_real_escape_string($conn,$_POST['text4']); $opening_heading = mysqli_real_escape_string($conn,$_POST['opening_heading']); $opening = mysqli_real_escape_string($conn,$_POST['opening']); $closing_heading = mysqli_real_escape_string($conn,$_POST['closing_heading']); $closing = mysqli_real_escape_string($conn,$_POST['closing']); /*------- ------ ------- ------ -------*/ $sqladd = mysqli_query($conn,"update $tableName set opening_heading ='$opening_heading', opening ='$opening', closing_heading ='$closing_heading', closing ='$closing', facebook ='$facebook', tweeter ='$tweeter', instagram ='$instagram', youtube ='$youtube', whatsup_number ='$whatsup_number', phone_number ='$phone_number', email ='$email', address ='$address', heading1 ='$heading1', text1 ='$text1', heading2 ='$heading2', text2 ='$text2', heading3 ='$heading3', text3 ='$text3', heading4 ='$heading4', text4 ='$text4' where id = '1'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { // ================================== header('Location: ../'.$returnurl.'?m=4'); //echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function addRoomImage($conn,$tableName,$returnurl) { $rid = mysqli_real_escape_string($conn,$_POST['txtrid']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image&rid='.$rid);exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3&rid='.$rid); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(room_id,image,thumb) values('$rid','$newfile1','$imageThumbName')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1&rid='.$rid); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0&rid='.$rid); } } function deleteRoomImage($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $rid =isset($_GET['rid'])? $_GET['rid'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6&rid='.$rid); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7&rid='.$rid); } //---------------------------------------------------------- } function addGallery($conn,$tableName,$returnurl) { $categoryid = mysqli_real_escape_string($conn,$_POST['selcategory']); $youtube = mysqli_real_escape_string($conn,$_POST['txtyoutube']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(category_id,image,thumb,youtube) values('$categoryid','$newfile1','$imageThumbName','$youtube')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editGallery($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $categoryid = mysqli_real_escape_string($conn,$_POST['selcategory']); $youtube = mysqli_real_escape_string($conn,$_POST['txtyoutube']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_Image1 = $row['thumb']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImagethumb1 = $row['thumb']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /* if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set category_id='$categoryid', youtube='$youtube', image='$InsertImage1' , thumb='$InsertImagethumb1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteGallery($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addEvent($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,date,description, image) values('$name','$date','$description','$newfile1')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editEvent($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , date='$date' , description='$description' , image='$InsertImage1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteEvent($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addMedia($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(name,date, image,thumb) values('$name','$date','$newfile1','$imageThumbName')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editMedia($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $name = mysqli_real_escape_string($conn,$_POST['txtname']); $date = mysqli_real_escape_string($conn,$_POST['txtdate']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_Image1 = $row['thumb']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImagethumb1 = $row['thumb']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3&id='.$id); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=350; $ratio=0.0; /* if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name' , date='$date' , image='$InsertImage1' , thumb='$InsertImagethumb1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../'.$returnurl.'?m=4&id='.$id); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteMedia($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } function addSole($conn,$tableName,$returnurl) { $caption = mysqli_real_escape_string($conn,$_POST['txtcaption']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") ) { header('Location: ../blog.php?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=400; $ratio=0.0; /*if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $imageThumbName = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $imageThumbName; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// }else{ $newfile1=""; $imageThumbName=""; } $sql="insert into $tableName(caption,image,thumb) values('$caption','$newfile1','$imageThumbName')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); } } function editSole($conn,$tableName,$returnurl) { $id = $_POST['txtid']; $caption = mysqli_real_escape_string($conn,$_POST['txtcaption']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Brand Logo');exit(0);} //------------------------------------------------------------------ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_Image1 = $row['thumb']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImagethumb1 = $row['thumb']; /*---------------------------*/ $flagImage1 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } if($extension=="jpg" || $extension=="jpeg" ){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefromjpeg($uploadedfile); }else if($extension=="png"){ $uploadedfile = $imagefleimagename1_tmp; $src = imagecreatefrompng($uploadedfile); }else { $src = imagecreatefromgif($uploadedfile); } list($width,$height)=getimagesize($uploadedfile); $setheight=350; $ratio=0.0; /* if($width>$setwidth){ $ratio=$setwidth/$width; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; }*/ if($height>$setheight){ $ratio=$setheight/$height; $newheight = $height * $ratio; // Reset height to match scaled image $newwidth = $width * $ratio; }else{ $newheight = $height ; $newwidth = $width ; } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); $tmp=imagecreatetruecolor($newwidth,$newheight); imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight, $width,$height); $InsertImagethumb1 = $tno.$imagefleimagename1; $imagefleimagename = "$ImageThumbPath/". $InsertImagethumb1; imagejpeg($tmp,$imagefleimagename,100); imagedestroy($src); imagedestroy($tmp); //////---------------End Upload Brand Image------------//////////// } //================================ Image 1 End============================== /*----------------------------------------------*/ $sqladd = mysqli_query($conn,"update $tableName set caption ='$caption', image='$InsertImage1' , thumb='$InsertImagethumb1' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); unlink($ImageThumbPath.$Un_Image1); } } header('Location: ../'.$returnurl.'?m=4'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=5'); } } function deleteSole($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $thumb1=$rowi['thumb']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); unlink($ImageThumbPath.$thumb1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } // ===================================== /*--------Delete Category close-----------------------------------------------*/ function addCourse1($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); $sql="insert into $tableName(name,description) values('$name','$description')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); // echo "fail"; } } function editCourse1($conn,$tableName,$returnurl) { $id = mysqli_real_escape_string($conn,$_POST['txtid']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*------- ------ ------- ------ -------*/ $sqladd = mysqli_query($conn,"update $tableName set name='$name', description='$description' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { // ================================== header('Location: ../'.$returnurl.'?m=4&id='.$id); //echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteCourse1($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=6'); } else { header('Location: ../'.$returnurl.'?m=7'); } } function addTiming($conn,$tableName,$returnurl) { $name = mysqli_real_escape_string($conn,$_POST['txtname']); $sql="insert into $tableName(timing) values('$name')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); // echo "fail"; } } function editTiming($conn,$tableName,$returnurl) { $id = mysqli_real_escape_string($conn,$_POST['txtid']); $name = mysqli_real_escape_string($conn,$_POST['txtname']); /*------- ------ ------- ------ -------*/ $sqladd = mysqli_query($conn,"update $tableName set timing='$name' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { // ================================== header('Location: ../'.$returnurl.'?m=4&id='.$id); //echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteTiming($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=6'); } else { header('Location: ../'.$returnurl.'?m=7'); } } /*--------Add Category-----------------------------------------------*/ /*--------Delete Category close-----------------------------------------------*/ function addMachine($conn,$tableName,$returnurl) { $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $youtube = mysqli_real_escape_string($conn,$_POST['txtyoutube']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //---------------------condition--check dots------------------------ $dots=substr_count($imagefleimagename1, '.'); if($dots>1){header('Location: ../'.$returnurl.'?m=2&n=Rooms Image');exit(0);} //------------------------------------------------------------------ //-----------------------check compalsory image------------------------------------------- /*if($imagefleimagename1==""){ header('Location: ../add-image.php?m=3&n=Product Image&id='.$productID);exit(0); } //---------------------------------------------------------------------------------------- //-----------------------check compalsory image size-------------------------------------- list($width1,$height1)=getimagesize($imagefleimagename1_tmp); if($width1<1000){ header('Location: ../add-image.php?m=13&n=1000px Product Image&id=');exit(0); } //----------------------------------------------------------------------------------------*/ //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $machinePath; global $machinePathThumb; $ImagePath = "$machinePath/"; $ImageThumbPath = "$machinePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$newfile1); //////---------------End Image 1 end------------//////////// }else{ $newfile1=""; } //================================ Image 2 ============================== if( $imagefleimagename2!=""){ //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") ) { header('Location: ../'.$returnurl.'?m=3'); exit(); } $newfile2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$newfile2); //////---------------End Image 2 end------------//////////// }else{ $newfile2=""; } $sql="insert into $tableName(heading,youtube_link,description, image,broucher_image) values('$heading','$youtube','$description','$newfile1','$newfile2')"; if(mysqli_query($conn,$sql) or die(mysqli_error($conn))) { header('Location: ../'.$returnurl.'?m=1'); // echo "success"; } else { header('Location: ../'.$returnurl.'?m=0'); // echo "fail"; } } function editMachine($conn,$tableName,$returnurl) { $id = mysqli_real_escape_string($conn,$_POST['txtid']); $heading = mysqli_real_escape_string($conn,$_POST['txtheading']); $youtube = mysqli_real_escape_string($conn,$_POST['txtyoutube']); $description = mysqli_real_escape_string($conn,$_POST['txtdescription']); /*-------------------------Image info-----------------------------*/ //------------------brand logo-------------------------- $imagefleimagename1 = $_FILES['image1fleimage']['name']; $imagefleimagename1_tmp = $_FILES['image1fleimage']['tmp_name']; $imagefleimagename2 = $_FILES['image2fleimage']['name']; $imagefleimagename2_tmp = $_FILES['image2fleimage']['tmp_name']; //------------------brand img 1-------------------------- //------now clear all condtion is good-------------if two image not avale----- function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } // ------------- get all images name ------------------------- $sel = mysqli_query($conn,"select * from $tableName where id = '$id' "); $row = mysqli_fetch_assoc($sel); $Un_OrginalImage1 = $row['image']; $Un_OrginalImage2 = $row['broucher_image']; /*--------------insert record varible record------------*/ $InsertImage1 = $row['image']; $InsertImage2 = $row['broucher_image']; /*---------------------------*/ $flagImage1 =0; $flagImage2 =0; // ------------- get all images name ------------------------- $no = rand(1,999); $tno = rand(1,999); ///////--------------Upload Logo Image-----------------//////////// global $machinePath; global $machinePathThumb; $ImagePath = "$machinePath/"; $ImageThumbPath = "$machinePathThumb/"; //================================ Image 1 ============================== if( $imagefleimagename1!=""){ $flagImage1 =1; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename1; $uploadedfile = $imagefleimagename1; $imagefleimagename1 = stripslashes($imagefleimagename1); $extension = getExtension($imagefleimagename1); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../'.$returnurl.'?m=16&id='.$id); exit(); } $InsertImage1=$no.$imagefleimagename1; move_uploaded_file($_FILES["image1fleimage"]['tmp_name'], "$ImagePath".$InsertImage1); //////---------------End Upload Brand Image------------//////////// } // ======================= image 2 ========================= if( $imagefleimagename2!=""){ $flagImage2 =2; //check if image has 2 dot then exit program //$catfile = $imagefleimagename1; $image = $imagefleimagename2; $uploadedfile = $imagefleimagename2; $imagefleimagename2 = stripslashes($imagefleimagename2); $extension = getExtension($imagefleimagename2); $extension = strtolower($extension); /*-------------------------------*/ /*---------------------------------*/ if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png")) { header('Location: ../'.$returnurl.'?m=16&id='.$id); exit(); } $InsertImage2=$no.$imagefleimagename2; move_uploaded_file($_FILES["image2fleimage"]['tmp_name'], "$ImagePath".$InsertImage2); //////---------------End Upload Brand Image------------//////////// } /*------- ------ ------- ------ -------*/ $sqladd = mysqli_query($conn,"update $tableName set heading='$heading', youtube_link='$youtube', description='$description', image='$InsertImage1', broucher_image='$InsertImage2' where id = '$id'") or die(mysqli_error($conn)); if(mysqli_affected_rows($conn) > 0) { if($flagImage1==1){ if($Un_OrginalImage1!=""){ unlink($ImagePath.$Un_OrginalImage1); } } if($flagImage2==2){ if($Un_OrginalImage2!=""){ unlink($ImagePath.$Un_OrginalImage2); } } // ================================== header('Location: ../'.$returnurl.'?m=4&id='.$id); //echo "success"; } else { header('Location: ../'.$returnurl.'?m=5&id='.$id); } } function deleteMachine($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; $v =isset($_GET['v'])? $_GET['v'] : ""; $mainid =isset($_GET['mainid'])? $_GET['mainid'] : ""; // ====== check how many product in this group========= $flag=0; // =================================== $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'")or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; $image2=$rowi['broucher_image']; } //echo "value is ".$id; global $machinePath; global $machinePathThumb; $ImagePath = "$machinePath/"; $ImageThumbPath = "$machinePathThumb/"; // ====== check how many product in this group========= //echo "value is ".$id; $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($flag==1){ if($image1!=""){ unlink($ImagePath.$image1); } if($image2!=""){ unlink($ImagePath.$image2); } header('Location: ../'.$returnurl.'&m=6'); }else{ header('Location: ../'.$returnurl.'?m=6'); } } else { header('Location: ../'.$returnurl.'?m=7'); } } /*--------Add Category-----------------------------------------------*/ function addOrder($conn,$tableName,$returnurl){ $orderID = getUID(); $customerid = mysqli_real_escape_string($conn,$_POST['txtid']); $courseid = mysqli_real_escape_string($conn,$_POST['courseid']); $amount = mysqli_real_escape_string($conn,$_POST['amount']); $name = mysqli_real_escape_string($conn,$_POST['name']); $email = mysqli_real_escape_string($conn,$_POST['email']); $phone = mysqli_real_escape_string($conn,$_POST['phone']); $address = mysqli_real_escape_string($conn,$_POST['address']); $location = mysqli_real_escape_string($conn,$_POST['location']); $locationAry = explode('-', $location); $state = $locationAry[0]; $city = $locationAry[1]; $date = date('Y-m-d'); $sqls="insert into $tableName(order_id,order_date,user_id,email,name,phone,address,city,state,course_id,payment_status,amount) values('$orderID','$date','$customerid','$email','$name','$phone','$address','$city','$state','$courseid',1,'$amount')"; if(mysqli_query($conn,$sqls) or die(mysqli_error($conn))){ header('Location: ../'.$returnurl.'?m=1'); }else{ header('Location: ../'.$returnurl.'?m=0'); } // ================ insert product in product details =============== } function getUID(){ $time =""; $time.= date('y'); $time.= date('m'); $time.= date('d'); $time.= date('h'); $time.= date('i'); $time.= date('s'); $time.= rand(10,99); return $time; } function deleteGloble($conn,$tableName,$returnurl) { $id =isset($_GET['id'])? $_GET['id'] : ""; //------------------------------------------------------------------------------------ $checkSql=mysqli_query($conn,"select * from $tableName where id ='$id'") or die(mysqli_error($conn)); if(mysqli_num_rows($checkSql)>0) { $rowi=mysqli_fetch_assoc($checkSql); $image1=$rowi['image']; } //echo "value is ".$id; global $solePath; global $solePathThumb; $ImagePath = "$solePath/"; $ImageThumbPath = "$solePathThumb/"; $sql = mysqli_query($conn,"START TRANSACTION"); $del = "delete from $tableName where id = '$id' "; if(mysqli_query($conn,$del) or die(mysqli_error($conn))) { if($image1!=""){ unlink($ImagePath.$image1); } mysqli_query($conn,"COMMIT"); header('Location: ../'.$returnurl.'?&m=6'); } else { mysqli_query($conn,"ROLLBACK"); header('Location: ../'.$returnurl.'?m=7'); } //---------------------------------------------------------- } /*--------Delete Category close-----------------------------------------------*/ ?>