<?
class req_infoboard extends global_infoboard{
function checktb($field, $tb, $where, $value){
global $iscon;
if(!$where) $where=$field;
$query=mysql_db_query($this->dbname, "select ".$field." from ".$tb." where ".$where."='".$value."'");
if(@mysql_fetch_array($query)){
return true;
}else{
return false;
}
}
function tbinsert($tb, $field, $value){
global $iscon;
if(mysql_db_query($this->dbname, "insert into ".$tb." (".$field.") values (".$value.")")){
return mysql_insert_id();
}else{
return false;
}
}
function tbdeleteuser($cid){
global $iscon;
mysql_db_query($this->dbname, "delete from _user where _cid='".$cid."' ");
}
function tbcount($cat){
global $iscon;
$count=1;
$query=mysql_db_query($this->dbname, "select _page from _infoboardq where _cat='".$cat."' order by _page desc");
if($result = @mysql_fetch_array($query)){
$count = $result["_page"]+1;
}
return $count;
}
function ridpage($cat, $page){
global $iscon;
$nextpage=1;
$query=mysql_db_query($this->dbname, "select _reply from _infoboardq where _cat='".$cat."' and _page='".$page."'");
if($result = @mysql_fetch_array($query)){
$reply = $result["_reply"];
$nextpage=(int) ($reply / $iscon["showreply"]);
if(($reply % $iscon["showreply"]) !=0 ) $nextpage+=1;
}
return $nextpage;
}
function codewrite($cid, $target, $data){
$file="../data/code/".$target."-".$cid.".code";
$fp=fopen($file,"w");
fwrite($fp ,stripslashes($data));
fclose($fp);
}
function random($length) {
mt_srand((double)microtime() * 1000000);
$possible = 'abcdefghijklmnopqrstuvwxyz' . 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' . '0123456789';
$random = "";
while(strlen($random) < $length) {
$random .= substr($possible, mt_rand(0, strlen($possible) -1), 1);
}
return $random;
}
function mailto($to, $subject, $message){
global $iscon;
$headers = "From: ".$iscon["mailmaster"] ."\r\n" .
"Reply-To: ".$iscon["mailmaster"]."\r\n" .
"X-Mailer: PHP/".phpversion();
/*
$txt=$subject.$message;
return $txt;
*/
if(mail($to, $subject , $message, $headers)){
return true;
}else{
return false;
}
}
function checkforget($mail){
global $iscon;
$query=mysql_db_query($this->dbname, "select * from _user where _mail='".$mail."'");
if($result=mysql_fetch_array($query)){
return $result;
}else{
return false;
}
}
function geticon($string, $count){
global $iscon;
for($i=1; $i<=$count;$i++){
$string= eregi_replace ( "<img src=".Chr(34).$iscon["fullpath"]."data/icon/i".$i.".gif".Chr(34)." />", "<img src=".Chr(34)."./data/icon/i".$i.".gif".Chr(34)." />" , $string);
}
return $string;
}
function imtype($string, $tmp){
$im = "";
if($string == "image/pjpeg" || $string == "image/jpeg"){
$im = imagecreatefromjpeg($tmp);
}elseif($string == "image/x-png" || $string == "image/png"){
$im = imagecreatefrompng($tmp);
}
return $im;
}
function imgresize($im, $maxw, $maxh, $path, $name){
global $iscon;
$w = imagesx($im);
$h = imagesy($im);
$resizeheight="";
$resizewidth="";
if(($maxw && $w > $maxw) || ($maxh && $h > $maxh)){
if($maxw && $w > $maxw){
$widthratio = $maxw/$w;
$resizewidth=true;
}
if($maxh && $h > $maxh){
$heightratio = $maxh/$h;
$resizeheight=true;
}
if($resizewidth && $resizeheight){
if($widthratio < $heightratio){
$ratio = $widthratio;
}else{
$ratio = $heightratio;
}
}elseif($resizewidth){
$ratio = $widthratio;
}elseif($resizeheight){
$ratio = $heightratio;
}
$newwidth = $w * $ratio;
$newheight = $h * $ratio;
if(function_exists("imagecopyresampled")){
$newim = imagecreatetruecolor($newwidth, $newheight);
imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $w, $h);
}else{
$newim = imagecreate($newwidth, $newheight);
imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $w, $h);
}
ImageJpeg ($newim,$path.$name . ".jpg",80);
ImageDestroy ($newim);
}else{
ImageJpeg ($im,$path.$name . ".jpg",80);
}
}
function errorup($text){
global $iscon;
echo refback($text);
return;
}
function up1($picname, $uppic){
global $iscon;
if($uppic == 1){
if(!$iscon["iduser"]){
if(!$iscon["idadmin"]) return;
}
}
if($uppic == 2) if(!$iscon["idadmin"]) return;
if(isset($_FILES["image1"]["size"])){
if(!$_FILES["image1"]["size"]) return;
if($_FILES["image1"]["size"] > $iscon["maxsize"]) return $this->errorup($iscon["lang"][113]." (".$this->img2bytes($iscon["maxsize"]).")");
$getext = strtolower($this->getlast($_FILES["image1"]["name"]));
if(!$this->checkext($getext)) {
$fixext = "";
for($i=0; $i<count($iscon["fileext"]); $i++){
$fixext.= ".".$iscon["fileext"][$i].", ";
}
return $this->errorup($iscon["lang"][114]." ".$fixext);
}
if($this->gdext($getext)){
if($im = $this->imtype($_FILES["image1"]["type"], $_FILES["image1"]["tmp_name"])){
$this->imgresize($im, $iscon["image_size"], $iscon["image_size"], "../data/pic/", $picname);
ImageDestroy ($im);
if($iscon["stamppic"] > 0){
if($iscon["textstamp"]) $this->isstamp("../data/pic/", $picname.".jpg", "terminal6.gdf", $iscon["textstamp"]);
}
return $getext;
}
}else{
$getext = strtolower($this->getlast($_FILES["image1"]["name"]));
if(move_uploaded_file($_FILES["image1"]["tmp_name"], "../data/pic/".$picname.".".$getext)){
return $getext;
}
}
return $this->errorup($iscon["lang"][115]);
}
}
function up2($picname, $uppic){
global $iscon;
if($uppic == 1){
if(!$iscon["iduser"]){
if(!$iscon["idadmin"]) return;
}
}
if($uppic == 2) if(!$iscon["idadmin"]) return;
$data="";
$count=0;
for($i=2; $i<=9; $i++){
if(isset($_FILES["image".$i]["size"])){
if($_FILES["image".$i]["size"] < $iscon["maxsize"]){
$count++;
$data[] = $i;
}
}
}
if($count == 0) return;
$up=0;
for($i=0; $i<count($data); $i++){
$getext = strtolower($this->getlast($_FILES["image".$data[$i]]["name"]));
if($this->gdext($getext)){
if($im = $this->imtype($_FILES["image".$data[$i]]["type"], $_FILES["image".$data[$i]]["tmp_name"])){
$this->imgresize($im, 450, 450, "../data/pic/", $picname."-".$data[$i]);
ImageDestroy ($im);
$up++;
}
}
}
if($up > 0) return "jpg";
}
function delpic($format, $pic, $ext){
if(!$pic) return;
if($format == 1){
if(file_exists("../data/pic/".$pic.".".$ext)) unlink("../data/pic/".$pic.".".$ext);
}else{
for($i=2; $i<=9; $i++){
if(file_exists("../data/pic/".$pic."-".$i.".jpg")) unlink("../data/pic/".$pic."-".$i.".jpg");
}
}
}
function delcode($cid, $target){
if(file_exists("../data/code/".$target."-".$cid.".code")) unlink("../data/code/".$target."-".$cid.".code");
}
function delins($cat, $field){
global $iscon;
$query=mysql_db_query($this->dbname, "select * from _infoboardi where _cat='".$cat."' and ".$field."");
while($result = @mysql_fetch_array($query)){
$this->delpic($result["_picformat"], $result["_pic"], $result["_ext"]);
$this->delcode($result["_cid"], 3);
$this->deltb($result["_cid"], "_infoboardi");
}
}
function deltb($cid, $tb){
global $iscon;
if(mysql_db_query($this->dbname, "delete from ".$tb." where _cid='".$cid."'")){
return true;
}
}
function isstamp($path, $pic, $font, $txt){
if(!$txt) return;
if(!(file_exists($path.$pic))) return;
if(!(file_exists($font))) return;
$txt=strtoupper($txt);
$gdf = imageloadfont($font);
$txtw = strlen($txt)*imagefontwidth($gdf);
$txth = imagefontheight($gdf);
$im = imagecreatefromjpeg($path.$pic);
$width = imagesx($im);
$height = imagesy($im);
$xposi=$width-10-$txtw;
$yposi=$height-5-$txth;
$back = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle ($im, ($xposi-4), ($yposi-4), ($width-4), ($yposi+10), $back);
imagestring($im, $gdf, ($xposi-1), ($yposi-1), $txt, $white);
imagerectangle ($im, ($xposi-4), ($yposi-4), ($width-4), ($yposi+10), $back);
imagejpeg($im,$path.$pic,100);
imagedestroy ($im);
}
function removescript1($document=""){
$search=array (
"'<script[^>]*?>.*?</script>'si",
"'<style[^>]*?>.*?</style>'si",
"'<pre[^>]*?>.*?</pre>'si",
"'<iframe[^>]*?>.*?</iframe>'si",
"'<!DOCTYPE[^>]*?>'si",
"'<!doctype[^>]*?>'si",
"'<html[^>]*?>'si",
"'<meta[^>]*?>'si",
"'<base[^>]*?>'si",
"'<link[^>]*?>'si",
"'<head[^>]*?>.*?</head>'si",
"'<form[^>]*?>.*?</form>'si",
"'<textarea[^>]*?>.*?</textarea>'si",
"'<input[^>]*?>'si",
"'<select[^>]*?>.*?</select>'si",
"'<!--.*?-->'si");
$replace = array (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ");
if (trim(chop($document))=="") return;
$text=preg_replace($search,$replace,$document);
return $text;
}
function removescript2($document=""){
$search=array (
"'<script[^>]*?>.*?</script>'si",
"'<style[^>]*?>.*?</style>'si",
"'<pre[^>]*?>.*?</pre>'si",
"'<iframe[^>]*?>.*?</iframe>'si",
"'<!DOCTYPE[^>]*?>'si",
"'<!doctype[^>]*?>'si",
"'<html[^>]*?>'si",
"'<meta[^>]*?>'si",
"'<base[^>]*?>'si",
"'<link[^>]*?>'si",
"'<head[^>]*?>.*?</head>'si",
"'<form[^>]*?>.*?</form>'si",
"'<textarea[^>]*?>.*?</textarea>'si",
"'<input[^>]*?>'si",
"'<select[^>]*?>.*?</select>'si",
"'<!--.*?-->'si");
$replace = array (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ");
if (trim(chop($document))=="") return;
$text=preg_replace($search,$replace,$document);
return $text;
}
function removetag1($document=""){
$search=array (
"'<script[^>]*?>.*?</script>'si",
"'<style[^>]*?>.*?</style>'si",
"'<span[^>]*?>.*?</span>'si",
"'<div[^>]*?>.*?</div>'si",
"'<pre[^>]*?>.*?</pre>'si",
"'<iframe[^>]*?>.*?</iframe>'si",
"'<!DOCTYPE[^>]*?>'si",
"'<!doctype[^>]*?>'si",
"'<html[^>]*?>'si",
"'<meta[^>]*?>'si",
"'<base[^>]*?>'si",
"'<link[^>]*?>'si",
"'<head[^>]*?>.*?</head>'si",
"'<form[^>]*?>.*?</form>'si",
"'<textarea[^>]*?>.*?</textarea>'si",
"'<input[^>]*?>'si",
"'<select[^>]*?>.*?</select>'si",
"'<embed[^>]*?>.*?</embed>'si",
"'<param[^>]*?>.*?</param>'si",
"'<object[^>]*?>.*?</object>'si",
"'<!--.*?-->'si");
$replace = array (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ");
if (trim(chop($document))=="") return;
$text=preg_replace($search,$replace,$document);
return $text;
}
function removetag2($document=""){
$search=array (
"'<script[^>]*?>.*?</script>'si",
"'<style[^>]*?>.*?</style>'si",
"'<span[^>]*?>.*?</span>'si",
"'<div[^>]*?>.*?</div>'si",
"'<pre[^>]*?>.*?</pre>'si",
"'<iframe[^>]*?>.*?</iframe>'si",
"'<!DOCTYPE[^>]*?>'si",
"'<!doctype[^>]*?>'si",
"'<html[^>]*?>'si",
"'<meta[^>]*?>'si",
"'<base[^>]*?>'si",
"'<link[^>]*?>'si",
"'<head[^>]*?>.*?</head>'si",
"'<form[^>]*?>.*?</form>'si",
"'<textarea[^>]*?>.*?</textarea>'si",
"'<input[^>]*?>'si",
"'<select[^>]*?>.*?</select>'si",
"'<embed[^>]*?>.*?</embed>'si",
"'<param[^>]*?>.*?</param>'si",
"'<object[^>]*?>.*?</object>'si",
"'<!--.*?-->'si");
$replace = array (
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ");
if (trim(chop($document))=="") return;
$text=preg_replace($search,$replace,$document);
return $text;
}
function emptydetail($string){
$string=strip_tags($string);
$string = eregi_replace("\r","",$string);
$string = eregi_replace("\n","",$string);
$string = eregi_replace("<p>","",$string);
$string = eregi_replace("</p>","",$string);
$string = eregi_replace(" ","",$string);
$string = eregi_replace(" ","",$string);
if($string == " ") return false;
if(empty($string)) return false;
return true;
}
function savecache($gid, $page){
global $iscon;
$print="";
$q1=mysql_db_query($this->dbname, "select _cid, _topic, _detail from _infoboardq where _cat='".$gid."' and _page='".$page."'");
if($rs1 = @mysql_fetch_array($q1)){
$qid = $rs1["_cid"];
$title = "<title>".strip_tags(stripslashes($rs1["_topic"]))."</title>\n";
$detail=stripslashes($rs1["_detail"]);
$detail= $this->removetag1($detail);
$detail= $this->removetag2($detail);
$detail= strip_tags($detail);
$detail= "<des>".$detail."</des>";
$q2=mysql_db_query($this->dbname, "select _detail from _infoboardi where _cat='".$gid."' and _qid='".$qid."' and _target='1' order by _cid asc");
while($rs2 = @mysql_fetch_array($q2)){
$print.= stripslashes($rs2["_detail"]);
}
$q3=mysql_db_query($this->dbname, "select _cid, _detail from _infoboarda where _cat='".$gid."' and _qid='".$qid."' order by _cid asc");
while($rs3 = @mysql_fetch_array($q3)){
$print.= stripslashes($rs3["_detail"]);
$q4=mysql_db_query($this->dbname, "select _detail from _infoboardi where _cat='".$gid."' and _aid='".$rs3["_cid"]."' and _target='2' order by _cid asc");
while($rs4 = @mysql_fetch_array($q4)){
$print.= stripslashes($rs4["_detail"]);
}
}
$print = $this->removetag1($print);
$print = $this->removetag2($print);
$print = strip_tags($print);
$print = eregi_replace("\r","",$print);
$print = eregi_replace("\n","",$print);
$print = $title.$detail.$print;
$this->iswrite("../data/search/cache.".$gid.".".$page.".1.txt", $print);
}
}
function unproof($file, $cat, $page, $tb, $cid){
global $iscon;
$path="../data/".$file.".dat";
$data=$cat."_|_".$page."_|_".$tb."_|_1_|_".$cid."\n";
$add=1;
$buffer="";
$value=$cat."_|_".$page;
if(file_exists($path)){
$read=file($path);
for ($i=0;$i<count($read);$i++){
$exp = explode("_|_",$read[$i]);
$expvalue=$exp[0]."_|_".$exp[1];
if($expvalue == $value){
$num = $exp[3]+1;
$buffer.=trim($exp[0])."_|_".trim($exp[1])."_|_".trim($exp[2])."_|_".trim($num)."_|_".trim($exp[4])."\n";
$add="";
}else{
$buffer.=$read[$i];
}
}
}
$fp=fopen($path,"w");
if($add){
fwrite($fp ,$buffer.$data);
}else{
fwrite($fp ,$buffer);
}
fclose($fp);
}
function updateproof($file, $cat, $page){
global $iscon;
$path="../data/".$file.".dat";
$buffer="";
if(file_exists($path)){
$read=file($path);
for ($i=0;$i<count($read);$i++){
$exp = explode("_|_",$read[$i]);
if((trim($exp[0]) ==trim($cat)) && (trim($exp[1]) ==trim($page))){
if($exp[3] > 1){
$num = $exp[3]-1;
$buffer.=trim($exp[0])."_|_".trim($exp[1])."_|_".trim($exp[2])."_|_".trim($num)."_|_".trim($exp[4])."\n";
}
}else{
$buffer.=$read[$i];
}
}
if(trim($buffer)){
$fp=fopen($path,"w");
fwrite($fp ,$buffer);
fclose($fp);
}else{
unlink($path);
}
}
}
function writepoint($user){
global $iscon;
$ext="";
$point=0;
if($read = $this->isread("../data/user/banner/".$user.".ext.dat")){
$ex = explode("%", $read);
$ext = $ex[0];
$point=$ex[1];
}
$this->iswrite("../data/user/banner/".$user.".ext.dat", $ext."%".($point+1));
}
}
?>