function checkImageTypes($t) { switch($t) { case "image/pjpeg": case "image/jpeg": case "image/jpg": case "image/pjpg": case "image/png": case "image/gif": case "image/giff": case "text/plain": case "application/msword"; case "application/pdf"; return true; default: return false; }
case "EDIT": if ($_SERVER['REQUEST_METHOD']=="POST") { $sql_image=""; $img_is_default=$_POST["img_is_default"]; $img_alt=$_POST["img_alt"]; $img_id=$_POST["id"];
if (! $_FILES['img_path']['name'] == "") {
if (checkImageTypes($_FILES['img_path']['type'])) { $rs=mysql_query("Select img_path from tbl_gallery_images where img_id='$img_id' and img_gal_id='$gal_id'"); if ($row=mysql_fetch_array($rs)) { if (file_exists("uploads/thumb_".$row["img_path"]) && $row["img_path"]!="") unlink("uploads"."/thumb_".$row["img_path"]); if (file_exists("uploads"."/big_".$row["img_path"]) && $row["img_path"]!="") unlink("uploads"."/big_".$row["img_path"]); } $img_path =time()."_".$_FILES['img_path']['name']; move_uploaded_file($_FILES['img_path']['tmp_name'],"./uploads/".$img_path) or $error = "Not A "; makeimage("uploads/".$img_path, "thumb_".$img_path ,"uploads/",$tWidth,$tHeight); makeimage("uploads/".$img_path, "big_".$img_path ,"uploads/",$bWidth,$bHeight);
unlink("uploads/".$img_path); mysql_query("update tbl_gallery_images set img_path='$img_path' where img_id='$img_id'"); } else { $msg="Image type not allowed. Please upload only JPEG/JPG images."; } } if ($msg=="") { if ($img_is_default==1) { mysql_query("update tbl_gallery_images set img_is_default='0' where img_id<>$id and img_gal_id='$gal_id' "); } mysql_query("update tbl_gallery_images set img_is_default='$img_is_default', img_alt='$img_alt', img_gal_id='$gal_id' where img_id='$img_id' ");
$msg="Image Gallery Updated successfully!"; $img_id=""; $img_alt=""; } } else { $rs=mysql_query("select * from tbl_gallery_images where img_id='$id'"); if ($row=mysql_fetch_array($rs)) { $img_id=$row["img_id"]; $img_is_default=$row["img_is_default"]; $img_path=$row["img_path"]; $img_alt=$row["img_alt"]; } $newmode="EDIT"; $msg="Change the values and Submit again to update the changes."; } $strheadline="Update Image [Go back]"; break;
function categories() { // Get all top line categories //$query='SELECT * FROM tbl_categories c LEFT JOIN tbl_pages p ON c.cat_id = p.page_cat_id where c.cat_parent=0'; $query = 'select `cat_id`,`cat_name`,`cat_href` from tbl_categories where `cat_parent` = 0'; $result = mysql_query($query); echo 'ull id="MenuBar1" class="MenuBarHorizontal MenuBarActive">'; while($r = mysql_fetch_array($result)){ extract($r); echo 'lli a cclass="MenuBarItemSubmenu" href="display.php?id='.$cat_href.'">'.$cat_name.'/a'; subcategories($cat_id, $cat_name); }}
function subcategories($parent, $cat_name) { //$query ='SELECT * FROM tbl_categories c LEFT JOIN tbl_pages p ON c.cat_id = p.page_cat_id where c.cat_parent='.$parent; $query = 'select `cat_id`,`cat_name`,`cat_href` from tbl_categories where `cat_parent` = '.$parent; $result = mysql_query($query); if ($result) { $num = mysql_num_rows($result); } if ($num != 0) { echo 'ull class="">'; while($r = mysql_fetch_array($result)){ extract($r); echo ' lli a tabindex="-1" href="display.php?id='.$cat_href.'">'.$cat_name.'/a'; subcategories($cat_id, $cat_name); echo '/lli'; } echo '/ull'; } }
function makeimage($filename,$newfilename,$path,$newwidth,$newheight=0) {
ReplyDelete$info = getimagesize($filename);
//echo ("Real width& height".$info[0]."-----".$info[1]);
$old_x=$info[0];
$old_y=$info[1];
$new_w=$newwidth;
$new_h=$newheight;
$ratio1=$old_x/$new_w;
$ratio2=$old_y/$new_h;
if($ratio1>$ratio2) {
$newwidth=$new_w;
$newheight=$old_y/$ratio1;
}
else {
$newheight=$new_h;
$newwidth=$old_x/$ratio2;
}
//echo ("
Required ".$newwidth."-----".$newheight);
//if($newwidth>$info[0])
//$newwidth=$info[0];
//if($newheight>$info[1])
//$newheight=$info[1];
//SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER . )
$image_type = strstr(str_replace("./","",str_replace("../","",$filename)), '.');
//SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
switch($image_type)
{
case '.jpg':
case '.JPG':
$source = imagecreatefromjpeg($filename);
break;
case '.png':
case '.PNG':
$source = imagecreatefrompng($filename);
break;
case '.gif':
case '.GIF':
$source = imagecreatefromgif($filename);
break;
default:
echo("Error Invalid Image Type");
die;
break;
}
//CREATES THE NAME OF THE SAVED FILE
$file = $newfilename ;
//CREATES THE PATH TO THE SAVED FILE
$fullpath = $path . $file;
//FINDS SIZE OF THE OLD FILE
list($width, $height) = getimagesize($filename);
if ($newheight==0)
{
@$newheight=$height/($width/$newwidth);
}
//CREATES IMAGE WITH NEW SIZES
@$thumb = imagecreatetruecolor($newwidth, $newheight);
//RESIZES OLD IMAGE TO NEW SIZES
//imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
@imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
//SAVES IMAGE AND SETS QUALITY || NUMERICAL VALUE = QUALITY ON SCALE OF 1-100
global $conf_img_comp;
@imagejpeg($thumb, $fullpath,100);
//CREATING FILENAME TO WRITE TO DATABSE
$filepath = $fullpath;
//RETURNS FULL FILEPATH OF IMAGE ENDS FUNCTION
return $filepath;
}
function checkImageTypes($t)
ReplyDelete{
switch($t)
{
case "image/pjpeg":
case "image/jpeg":
case "image/jpg":
case "image/pjpg":
case "image/png":
case "image/gif":
case "image/giff":
case "text/plain":
case "application/msword";
case "application/pdf";
return true;
default:
return false;
}
}
case "EDIT":
ReplyDeleteif ($_SERVER['REQUEST_METHOD']=="POST")
{
$sql_image="";
$img_is_default=$_POST["img_is_default"];
$img_alt=$_POST["img_alt"];
$img_id=$_POST["id"];
if (! $_FILES['img_path']['name'] == "")
{
if (checkImageTypes($_FILES['img_path']['type']))
{
$rs=mysql_query("Select img_path from tbl_gallery_images where img_id='$img_id' and img_gal_id='$gal_id'");
if ($row=mysql_fetch_array($rs))
{
if (file_exists("uploads/thumb_".$row["img_path"]) && $row["img_path"]!="")
unlink("uploads"."/thumb_".$row["img_path"]);
if (file_exists("uploads"."/big_".$row["img_path"]) && $row["img_path"]!="")
unlink("uploads"."/big_".$row["img_path"]);
}
$img_path =time()."_".$_FILES['img_path']['name'];
move_uploaded_file($_FILES['img_path']['tmp_name'],"./uploads/".$img_path) or $error = "Not A ";
makeimage("uploads/".$img_path, "thumb_".$img_path ,"uploads/",$tWidth,$tHeight);
makeimage("uploads/".$img_path, "big_".$img_path ,"uploads/",$bWidth,$bHeight);
unlink("uploads/".$img_path);
mysql_query("update tbl_gallery_images
set img_path='$img_path'
where img_id='$img_id'");
}
else
{
$msg="Image type not allowed. Please upload only JPEG/JPG images.";
}
}
if ($msg=="")
{
if ($img_is_default==1)
{
mysql_query("update tbl_gallery_images set img_is_default='0' where img_id<>$id and img_gal_id='$gal_id' ");
}
mysql_query("update tbl_gallery_images
set img_is_default='$img_is_default',
img_alt='$img_alt',
img_gal_id='$gal_id'
where img_id='$img_id'
");
$msg="Image Gallery Updated successfully!";
$img_id="";
$img_alt="";
}
}
else
{
$rs=mysql_query("select * from tbl_gallery_images where img_id='$id'");
if ($row=mysql_fetch_array($rs))
{
$img_id=$row["img_id"];
$img_is_default=$row["img_is_default"];
$img_path=$row["img_path"];
$img_alt=$row["img_alt"];
}
$newmode="EDIT";
$msg="Change the values and Submit again to update the changes.";
}
$strheadline="Update Image [Go back]";
break;
case "ADD":
ReplyDelete$img_alt=$_POST["img_alt"];
if ($_SERVER['REQUEST_METHOD']=="POST")
{
$img_is_default=$_POST["img_is_default"];
if (! $_FILES['img_path']['name'] == "")
{
if (checkImageTypes($_FILES['img_path']['type']))
{
$img_path =time()."_".$_FILES['img_path']['name'];
// echo $img_path . '------------ '.$_FILES['img_path']['tmp_name'] ;
move_uploaded_file($_FILES['img_path']['tmp_name'],"uploads/".$img_path) or $error = "Not A ";
// echo $_FILES['img_path']['tmp_name'] . '------------ '."uploads/"."/".$img_path ;
makeimage("uploads/".$img_path, "thumb_".$img_path ,"uploads/",$tWidth,$tHeight);
// echo "uploads/"."/".$img_path . '------------ '."thumb_".$img_path . "uploads/"."/" . '------------ '.$tWidth . "==". $tHeight;
makeimage("uploads/".$img_path, "big_".$img_path ,"uploads/",$bWidth,$bHeight);
unlink("uploads/".$img_path);
$msg="";
// die('-----------'. 'here');
}
else
{
$msg="Image type not allowed. Please upload only JPEG/JPG images.";
}
}
if ($msg=="")
{
if ($img_is_default==1) mysql_query("update tbl_gallery_images set img_is_default='0' where img_gal_id='$gal_id' ");
mysql_query("insert into tbl_gallery_images
set img_path='$img_path',
img_alt='$img_alt',
img_is_default='$img_is_default',
img_gal_id='$gal_id'
");
$msg="Image is Added Successfully!";
header("location:managegalleryimages.php?msg=$msg&gal_id=$gal_id");
}
}
else
{
$msg="Invalid Request to Add Record!";
}
break;
function categories() {
ReplyDelete// Get all top line categories
//$query='SELECT * FROM tbl_categories c LEFT JOIN tbl_pages p ON c.cat_id = p.page_cat_id where c.cat_parent=0';
$query = 'select `cat_id`,`cat_name`,`cat_href` from tbl_categories where `cat_parent` = 0';
$result = mysql_query($query);
echo 'ull id="MenuBar1" class="MenuBarHorizontal MenuBarActive">';
while($r = mysql_fetch_array($result)){
extract($r);
echo 'lli a cclass="MenuBarItemSubmenu" href="display.php?id='.$cat_href.'">'.$cat_name.'/a';
subcategories($cat_id, $cat_name);
}}
function subcategories($parent, $cat_name) {
//$query ='SELECT * FROM tbl_categories c LEFT JOIN tbl_pages p ON c.cat_id = p.page_cat_id where c.cat_parent='.$parent;
$query = 'select `cat_id`,`cat_name`,`cat_href` from tbl_categories where `cat_parent` = '.$parent;
$result = mysql_query($query);
if ($result) { $num = mysql_num_rows($result); }
if ($num != 0) {
echo 'ull class="">';
while($r = mysql_fetch_array($result)){
extract($r);
echo ' lli a tabindex="-1" href="display.php?id='.$cat_href.'">'.$cat_name.'/a';
subcategories($cat_id, $cat_name);
echo '/lli';
}
echo '/ull';
}
}
RewriteEngine on
ReplyDelete#RewriteBase /
RewriteRule ^index([\/]{0,1})$ index.php
RewriteRule ^page/(.*)([\/]{0,1})$ display.php?path=page/$1
RewriteRule ^news/(.*)([\/]{0,1})$ newsdetail.php?id=$1
RewriteRule ^([a-zA-Z0-9_\-]+)([\/]{0,1})$ displaycustom.php?path=$1
RewriteRule ^search/(.*)$ search_page.php?keyword=$1
RewriteRule ^allnews/(.*)([\/]{0,1})$ allnews.php?mode=view&type=$1
RewriteRule ^allgallerys/more$ all_imagegallery.php?more=$1
RewriteRule ^gallery/(.*)([\/]{0,1})$ imagegallery_images.php?gal_id=$1
#faq_support.php?flg=1&catg=$faq_catgid
RewriteRule ^faqhome([\/]{0,1})$ faq_support.php?catg=$1&flg=1
RewriteRule ^faqdetails/(.*)([\/]{0,1})$ faq_support.php?catg=$1&flg=1
#faq_support_cat.php?flg=1&catg=
RewriteRule ^faqcatdetails/(.*)([\/]{0,1})$ faq_support_cat.php?catg=$1&flg=1
#RewriteRule ^rss(.*)$ rssfile.php
#RewriteRule ^([a-zA-Z0-9_\-]+)([\/]{0,1})$ $1.php
function FriendlyURL($url,$include_path=false)
ReplyDelete{
//die("-----");
global $conf_friendly_url;
global $site_root;
if ($conf_friendly_url==1)
{
//$site_root=""; /* /foldername/ */
$newurl=str_replace(" ","_",$url);
$newurl=str_replace("?","/",$newurl);
$newurl=str_replace("&","/",$newurl);
$newurl=str_replace("=","/",$newurl);
$newurl=str_replace(".php","",$newurl);
//$newurl=$newurl;
$type=0; // 0 - Content Page 1 -Category 2 -Product - 3 General
$prefix="page/";
$id=0;
$name="";
$match="";
preg_match("%\\A(?:[a-zA-Z0-9\\-_]+\\/([cat_id|prod_id]+)\\/([0-9]+))\\z%",$newurl,$match);
/*for($i=0;$i count($match);$i++)
{
echo $match[$i]."br";
}*/
//echo "brbr";
if (strpos($newurl,"keyword") less 0)
{
$newurl=str_replace("keyword/","",$newurl);
$newurl=str_replace("cat_id/","",$newurl);
//echo $newurl;
}
//die();
//echo strpos("___".$newurl,"product_details/prod_id/");
if (strpos("___".$newurl,"display/cat_id/")>=1)
{
$type=0;
$prefix="page/";
$id=$match[2];
}
elseif (strpos("___".$newurl,"categories/cat_id/")>=1)
{
$type=1;
$prefix="category/";
$id=$match[2];
}
elseif (strpos("___".$newurl,"articles/art_id/")>=1)
{
$type=2;
$prefix="article/";
$id=$match[2];
}
else
{
$type=3;
$prefix="";
}
$finalurl=$newurl;
switch($type)
{
case 0:
case 1:
$code=getValue("cat_code","tbl_categories where cat_id='$id'");
$name=getCategoryPath2($code);
$name=str_replace(" ","-",$name);
$finalurl=$prefix.$name."/".$id;
break;
case 2:
$name=getValue("page_title","tbl_pages where page_id='$id'");
$cat_code=getValue("cat_code","tbl_pages_categories where page_id='$id' order by cat_default desc");
$cat_name=getValue("cat_name","tbl_categories where cat_code='$cat_code'");
$name=str_replace(" ","-",$name);
$cat_name=str_replace(" ","-",$cat_name);
$name=str_replace("?","",$name);
$cat_name=str_replace("?","",$cat_name);
$finalurl=$prefix.$cat_name."/".$name."/".$id;
break;
}
if ($include_path==true)
{
$finalurl=$site_root.$finalurl;
}
}
else
$finalurl=$url;
return $finalurl;
}