MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.133.138.129
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/uttamnagarproperties.com/../biocareaqua.org/admin/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/uttamnagarproperties.com/../biocareaqua.org/admin/addedit-product.php
<?php
require_once("../includes/dbsmain.inc.php");
ob_start();
$category_id=$_REQUEST['finalcat_id'];
$category_parent_id=$_REQUEST['category_parent_id'];
$ppid=db_scalar("select category_parent_id from tbl_category where 1 and category_id='$category_parent_id'");
if(is_post_back()){
//*************** UPDATE EXISTING CATEGORY START ************************//
if($_REQUEST['category_id']!='0') {
$category_url=ami_crete_url($category_name);
////////////****************** IMAGE RESIZING START HERE *****************************//
//********** Code Created By Amitabh Kumar Sinha : Web Developer : Webkey Network Pvt. Ltd. *****************//
//**********  DATE : 31:07:2014 *****************//
//------------FUNCTION TO GET IMAGE EXTENSION START---------------//
 function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }
 //------------FUNCTION TO GET IMAGE EXTENSION END---------------//
 if($_SERVER["REQUEST_METHOD"] == "POST")
 {
 	$image =$_FILES["file"]["name"];
	$uploadedfile = $_FILES['file']['tmp_name']; 
 	if ($image) { 	
	    $DelImage=db_scalar("select category_image_name from tbl_category where 1 and category_id = '$category_id'");
	    @unlink("../uploaded_files/$DelImage");
 		$filename = stripslashes($_FILES['file']['name']); 	
  		$extension = getExtension($filename);
 		$extension = strtolower($extension);
		$imgNAME = $category_url.".".$extension;		

 $size=filesize($_FILES['file']['tmp_name']);
if($extension=="jpg" || $extension=="jpeg" ){
  $uploadedfile = $_FILES['file']['tmp_name'];
  $src = imagecreatefromjpeg($uploadedfile);
}else if($extension=="png"){
  $uploadedfile = $_FILES['file']['tmp_name'];
  $src = imagecreatefrompng($uploadedfile);
}else{
$src = imagecreatefromgif($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if($width >= 400){
$newwidth=400;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "../uploaded_files/". $imgNAME;
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}else{
move_uploaded_file($_FILES['file']['tmp_name'],"../uploaded_files/$imgNAME");
}
}else{
$imgNAME=db_scalar("select category_image_name from tbl_category where 1 and category_id = '$category_id'");
}
}

////////////****************** IMAGE RESIZING END HERE *****************************//
$sql = "update tbl_category set        
				category_name='$category_name',
				category_image_name='$imgNAME',
				category_image_alt_title ='$category_image_alt_title',
				category_description = '$category_description', 	
				category_is_hot='$category_is_hot',
				category_is_featured='$category_is_featured',
				category_for_falsh='$category_for_falsh',
				category_meta_title='$category_meta_title',
				category_meta_description='$category_meta_description',
				category_meta_keywords='$category_meta_keywords',
				category_is_product='$category_is_product',
				category_url='$category_url',
				category_add_date=now(),
				category_status='$category_status'
				where category_id = '$category_id' ";

db_query($sql);
set_session_msg("Category Updated Successfully !");
header("Location:addedit-product.php?finalcat_id=$_REQUEST[finalcat_id]&category_parent_id=$_REQUEST[category_parent_id]");
exit;
//*************** UPDATE EXISTING CATEGORY END ************************//
}else{
$category_url=ami_crete_url($category_name);
//*************** INSERT NEW CATEGORY START ************************//
////////////****************** IMAGE RESIZING START HERE *****************************//
//********** Code Created By Amitabh Kumar Sinha : Web Developer : Webkey Network Pvt. Ltd. *****************//
//**********  DATE : 31:07:2014 *****************//
//------------FUNCTION TO GET IMAGE EXTENSION START---------------//
 function getExtension($str) {
         $i = strrpos($str,".");
         if (!$i) { return ""; }
         $l = strlen($str) - $i;
         $ext = substr($str,$i+1,$l);
         return $ext;
 }
 //------------FUNCTION TO GET IMAGE EXTENSION END---------------//
 if($_SERVER["REQUEST_METHOD"] == "POST")
 {
 	$image =$_FILES["file"]["name"];
	$uploadedfile = $_FILES['file']['tmp_name']; 
 	if ($image) { 	
 		$filename = stripslashes($_FILES['file']['name']); 	
  		$extension = getExtension($filename);
 		$extension = strtolower($extension);
		$imgNAME = $category_url.".".$extension;		

 $size=filesize($_FILES['file']['tmp_name']);
if($extension=="jpg" || $extension=="jpeg" ){
  $uploadedfile = $_FILES['file']['tmp_name'];
  $src = imagecreatefromjpeg($uploadedfile);
}else if($extension=="png"){
  $uploadedfile = $_FILES['file']['tmp_name'];
  $src = imagecreatefrompng($uploadedfile);
}else{
$src = imagecreatefromgif($uploadedfile);
}
list($width,$height)=getimagesize($uploadedfile);
if($width >= 400){
$newwidth=400;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = "../uploaded_files/". $imgNAME;
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
}else{
move_uploaded_file($_FILES['file']['tmp_name'],"../uploaded_files/$imgNAME");
}
}
}

////////////****************** IMAGE RESIZING END HERE *****************************//
$sql = "insert into tbl_category set 
                category_name='$category_name',
                	category_image_alt_title ='$category_image_alt_title',
				category_parent_id='$category_parent_id',
				category_image_name='$imgNAME',
				category_description='$category_description', 	
				category_is_hot='$category_is_hot',
				category_is_featured='$category_is_featured',
				category_for_falsh='$category_for_falsh',
				category_meta_title='$category_meta_title',
				category_meta_description='$category_meta_description',
				category_meta_keywords='$category_meta_keywords',
				category_is_product='$category_is_product',
				category_url='$category_url',
				category_add_date=now(),
				category_status='$category_status'";

db_query($sql);
set_session_msg("Category Added Successfully !");
header("Location:addedit-product.php?finalcat_id=$_REQUEST[finalcat_id]&category_parent_id=$_REQUEST[category_parent_id]");
exit;
//*************** INSERT NEW CATEGORY END ************************//
 }
}

if($category_id!='') {
	$result = db_query("select * from tbl_category where category_id = '$category_id'");
	if ($line_raw = mysqli_fetch_array($result)) {
	 @extract($line_raw);
	}
}
?>
<script src="ckeditor/ckeditor.js"></script>
<style>
p.fck {
    width: 90%;
	float:left;
    margin: 0 auto;
 }
</style>
<link href="styles.css" rel="stylesheet" type="text/css">
<?php include("top.inc.php");?>
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td id="pageHead"><div id="txtPageHead">Add/Edit Product</div></td>
              </tr>
            </table>
            <div align="right"><a href="product_list.php?category_id=<?=$category_parent_id?>&category_parent_id=<?=$ppid?>" style="font-size:12px; font-weight:bold; margin-right:15px;">Back to Product Category List</a>&nbsp;</div>
            <form name="form1" method="post" enctype="multipart/form-data">
              <table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0" class="tableForm">
                <tr>
                  <td width="20%" class="tdLabel">&nbsp;</td>
                  <td width="80%" class="tdData" style="padding-left:7px;"><strong><font color="red">
                    <?=display_sess_msg();?>
                    </font></strong></td>
                </tr>
                <tr>
                  <td width="20%" class="tdLabel" style="font-size:12px; padding:7px;">Product Name:</td>
                  <td width="80%" class="tdData" style="font-size:12px; padding:7px;"><input name="category_name" style="width:350px; height:28px;" type="text" id="category_name"  value="<?=$category_name?>" class="textfield"  ></td>
                </tr>
                <?php if($category_image_name){ ?>
                <tr>
                  <td width="177" class="tdLabel" style="font-size:12px; padding:5px;">Current Image  :</td>
                  <td width="721" class="tdData" style="font-size:12px; padding:5px;"><img src="../uploaded_files/<?=$category_image_name?>" height="70" width="70"  border="0"> </td>
                </tr>
                <? } ?>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:5px;">Product Image :</td>
                  <td class="tdData" style="font-size:12px; padding:5px;"><input type="file" name="file" id="file"></td>
                </tr>
                
                 <tr>
                  <td class="tdLabel" style="font-size:12px; padding:5px;">Image Alt Title :</td>
                  <td class="tdData" style="font-size:12px; padding:5px;"><input type="text" name="category_image_alt_title" style="width:350px; height:28px;" id="category_image_alt_title" value="<?=$category_image_alt_title?>" class="textfield"></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Meta Title:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><input name="category_meta_title" style="width:350px; height:28px;" type="text" id="category_meta_title"  value="<?=$category_meta_title?>" class="textfield" /></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Meta Keyword:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><textarea rows="5" cols="66" name="category_meta_keywords"><?=$category_meta_keywords?>
</textarea></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Meta Description:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><textarea rows="5" cols="66" name="category_meta_description"><?=$category_meta_description?>
</textarea></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Product Description:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><p class="fck">
                      <textarea cols="80" id="editor1" name="category_description" rows="10"><?=$category_description?>
</textarea>
                      <script>

			// Replace the <textarea id="editor"> with an CKEditor
			// instance, using default configurations.
			CKEDITOR.replace( 'editor1', {
				uiColor: '#ACACAC',
				toolbar: [
					[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink' ],
					[ 'FontSize', 'TextColor', 'BGColor' ]
				]
			});

		</script>
                    </p></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Product Is Hot ?:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><select name="category_is_hot" style="width:200px; height:26px;">
                      <option value="Yes" <?php if($category_is_hot=='Yes'){ ?> selected="selected" <? } ?>>Yes</option>
                      <option value="No" <?php if($category_is_hot=='No'){ ?> selected="selected" <? } ?>>No</option>
                    </select></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Product Is Featured ?:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><select name="category_is_featured" style="width:200px; height:26px;">
                      
                      
                      <option value="Yes" <?php if($category_is_featured=='Yes'){ ?> selected="selected" <? } ?>>Yes</option>
                      <option value="No" <?php if($category_is_featured=='No'){ ?> selected="selected" <? } ?>>No</option>
                      
                      
                    </select></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Product Is ?:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><select name="category_is_product" style="width:200px; height:26px;">
                     
                     
                    <?php
                        $product_option=db_scalar("select admin_product_option from tbl_admin where admin_user_type='Admin' ");
                        if($product_option=="Both")
                    {?>
                    <option value="Yes" <?php if($category_is_product=='Yes'){ ?> selected="selected" <? } ?>>Product</option>
                      <option value="No" <?php if($category_is_product=='No'){ ?> selected="selected" <? } ?>>Service</option>
                    <?php }
                    elseif($product_option=="Yes")
                    {?>
                      <option value="Yes" <?php if($category_is_product=='Yes'){ ?> selected="selected" <? } ?>>Product</option>
                     <?php }
                    else 
                    {?>
                      <option value="No" <?php if($category_is_product=='No'){ ?> selected="selected" <? } ?>>Service</option>
                    <? } ?>
                      
                      
                      
                    </select></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">Status:</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><select name="category_status" style="width:200px; height:26px;">
                      <option value="Active" <?php if($category_status=='Active'){ ?> selected="selected" <? } ?>>Active</option>
                      <option value="Inactive" <?php if($category_status=='Inactive'){ ?> selected="selected" <? } ?>>Inactive</option>
                    </select></td>
                </tr>
                <tr>
                  <td class="tdLabel" style="font-size:12px; padding:7px;">&nbsp;</td>
                  <td class="tdData" style="font-size:12px; padding:7px;"><input type="hidden" name="category_id" value="<?=$category_id?>" />
                    <input type="image" name="imageField" src="images/buttons/submit.gif" style="width:100px; margin-bottom:25px;" /></td>
                </tr>
              </table>
            </form>
            <? include("bottom.inc.php");?>

MMCT - 2023