alert('$p_sInfo'); window.location = '$p_sUrl'; "; } else { echo " "; } exit; } function upload_file() { global $arrImgPath; if ( sizeof($_FILES["col_picture"]["name"]) ) { $arrImgPath = array(); for ( $i = 0; $i < 5; $i++ ) { if ( !empty($_FILES['col_picture']['name'][$i]) ) { $arrTemp = explode(".", $_FILES['col_picture']['name'][$i]); $arrTemp[1] = strtolower($arrTemp[1]); if ( ($arrTemp[1] != "gif") && ($arrTemp[1] != "jpg") && ($arrTemp[1] != "png") ) { error_disp("gif/jpg/pngファイル以外はアップロードできません",""); } $sDir = "../upload"; $mictime = microtime(); $sFileName = substr($mictime, 11) . substr($mictime,2,6) . ".".$arrTemp[1]; if ( $_FILES['col_picture']['size'][$i] > 1000000 ) error_disp("画像サイズが1MBを超えています",""); copy($_FILES['col_picture']['tmp_name'][$i],$sDir."/".$sFileName); $arrImgPath[$i] = "upload/".$sFileName; } } } } ?> db_conn connection * edit record: * Date Name Reason * **********************************************************************/ function class_db_connect($p_sDbHost, $p_sDbUser, $p_sDbPassword, $p_sDbDatabase) { $this -> db_conn = @mysql_connect($p_sDbHost, $p_sDbUser, $p_sDbPassword) or die ("Sorry, Unable to connect database server"); $sqlDb = @mysql_select_db($p_sDbDatabase, $this -> db_conn) or die ("Sorry, Unable to connect database:$p_sDbDatabase"); } /********************************************************************** * * method name: class_db_query * date: 2004-11-30 * author: dan * describe: operate database * input param: p_sQuaryString operate type * output param: $this -> bIfQuaryOk check the operate is ok * false fault * edit record: * Date Name Reason * **********************************************************************/ function class_db_query($p_sQuaryString) { $sqlQuaryRes = mysql_query($p_sQuaryString, $this->db_conn); if (!$sqlQuaryRes) { $this -> bIfQuaryOk = false; } } /********************************************************************** * * method name: class_db_select * date: 2004-11-30 * author: dan * describe: search database * * input param: p_sSelectString search statement * output param: $this -> bIfQuaryOk check the operate is ok * false fault * arrSelRes search result(array) * edit record: * Date Name Reason * **********************************************************************/ function class_db_select($p_sSelectString) { $sqlSelectRes = mysql_query($p_sSelectString, $this->db_conn); if (!$sqlSelectRes) { $this -> bIfQuaryOk = false; } $iCount = mysql_num_rows($sqlSelectRes); $arrSelRes = array(); for ($i = 0; $i < $iCount; $i++) { $arrSelRes[$i] = mysql_fetch_array($sqlSelectRes); } return $arrSelRes; } /********************************************************************** * * method name: use_table * date: 2005-05-22 * author: dan * describe: set table * * input param: p_sTableName table name * p_sSeqTiaojian edit condition * * output param: * edit record: * Date Name Reason * **********************************************************************/ function use_table($p_sTableName, $p_sSeqTiaojian) { $this->db_table = $p_sTableName; $this->db_seq_tiaojian = $p_sSeqTiaojian; } /********************************************************************** * * method name: db_opertype * date: 2005-05-22 * author: dan * describe: operate type * * input param: p_sOpertype operate type * * output param: * edit record: * Date Name Reason * **********************************************************************/ function db_opertype($p_sOpertype) { $this->db_opertype = $p_sOpertype; if ( $p_sOpertype == "insert" ) $this->db_str = "insert into ".$this->db_table." set"; if ( $p_sOpertype == "update" ) $this->db_str = "update ".$this->db_table." set"; } /********************************************************************** * * method name: db_operate_str * date: 2005-05-22 * author: dan * describe: create string * * input param: p_sZiduan * output param: * edit record: * Date Name Reason * **********************************************************************/ function db_operate_str($p_sZiduan) { global $$p_sZiduan; $this->db_str .= " $p_sZiduan='".$$p_sZiduan."',"; } /********************************************************************** * * method name: db_delete * date: 2005-08-12 * author: dan * describe: delete record * * input param: p_sTiaojian condition * output param: * edit record: * Date Name Reason * **********************************************************************/ function db_delete() { $sSql = "delete from ".$this->db_table." where ".$this->db_seq_tiaojian; $this->class_db_query($sSql); } /********************************************************************** * * method name: db_operate * date: 2005-05-22 * author: dan * describe: database operate * * output param: * edit record: * Date Name Reason * **********************************************************************/ function db_operate() { $this->db_str .= " col_date='".date("Y-m-d")."'"; if (!empty($this->db_seq_tiaojian)) $this->db_str .= " where ".$this->db_seq_tiaojian; $this->class_db_query($this->db_str); } } class commFunc extends dbOperate { /********************************************************************** * * method name: showPages * date: 2004-11-30 * author: dan * describe: page function * * input param: p_iOrigSize oringinal array size p_iNPerPage numbers per page p_iPage page * output param: * edit record: * Date Name Reason * **********************************************************************/ function showPages($p_iOrigSize, $p_iNPerPage, $p_iPage) { global $PHP_SELF; $iArrSize = $p_iOrigSize; $iTotalPage = ceil($iArrSize / $p_iNPerPage); //first page if ($p_iPage < 2) { //only one page if ($iArrSize <= $p_iNPerPage) { $sPages = ""; } //more than one page else { $iNextPage = $p_iPage + 1; //address if (ereg("page=", $_SERVER["QUERY_STRING"])) { $sTemp = str_replace("page=".$p_iPage, "page=".$iNextPage, $_SERVER["QUERY_STRING"]); $sNextStr = $PHP_SELF."?".$sTemp; } else { $sNextStr = $PHP_SELF."?page=".$iNextPage."&".$_SERVER["QUERY_STRING"]; } $sPages = "総数".$iArrSize."件,計".$iTotalPage."頁,第".$p_iPage."頁 次の頁"; } } //middle pages if (($p_iPage < $iTotalPage) and ($p_iPage >= 2)) { $iNextPage = $p_iPage + 1; $iForePage = $p_iPage - 1; //address if (ereg("page=", $_SERVER["QUERY_STRING"])) { $sNextTemp = str_replace("page=".$p_iPage, "page=".$iNextPage, $_SERVER["QUERY_STRING"]); $sForeTemp = str_replace("page=".$p_iPage, "page=".$iForePage, $_SERVER["QUERY_STRING"]); $sNextStr = $PHP_SELF."?".$sNextTemp; $sForeStr = $PHP_SELF."?".$sForeTemp; } else { $sNextStr = $PHP_SELF."?page=".$iNextPage."&".$_SERVER["QUERY_STRING"]; $sForeStr = $PHP_SELF."?page=".$iForePage."&".$_SERVER["QUERY_STRING"]; } $sPages = "総数".$iArrSize."件,計".$iTotalPage."頁,第".$p_iPage."頁 前の頁 次の頁"; } //end page if (($p_iPage == $iTotalPage) && ($p_iPage > 1)) { $iForePage = $p_iPage - 1; //address if (ereg("page=", $_SERVER["QUERY_STRING"])) { $sTemp = str_replace("page=".$p_iPage, "page=".$iForePage, $_SERVER["QUERY_STRING"]); $sForeStr = $PHP_SELF."?".$sTemp; } else { $sForeStr = $PHP_SELF."?page=".$iForePage."&".$_SERVER["QUERY_STRING"]; } $sPages = "総数".$iArrSize."件,計".$iTotalPage."頁,第".$p_iPage."頁 前の頁"; } if (strlen($sPages)) { if (ereg("page", $_SERVER["QUERY_STRING"])) { $sTemp = str_replace("page=".$p_iPage, "", $_SERVER["QUERY_STRING"]); $sFormAction = $PHP_SELF."?".$sTemp; } else { $sFormAction = $PHP_SELF."?".$_SERVER["QUERY_STRING"]; } $sPages = "
".$sPages; $sPages .= "
"; } return $sPages; } /********************************************************************** * * method name: getPageInfo * date: 2005-05-25 * author: dan * describe: get page * * input param: p_sSearchStr search statement p_iNumPerPage the numbers of every page * output param: * edit record: * Date Name Reason * **********************************************************************/ function getPageInfo($p_sSearchStr, $p_iNumPerPage) { global $page; if ( empty($page) ) { $page = 1; $p_sSearchStr .= " limit $p_iNumPerPage"; } else { $iStart = ($page - 1) * $p_iNumPerPage; $p_sSearchStr .= " limit $iStart,$p_iNumPerPage"; } return $p_sSearchStr; } /********************************************************************** * * method name: error_disp * date: 2004-11-30 * author: dan * describe: error function * * input param: p_sInfo statement * $p_sUrl skip page * output param: * edit record: * Date Name Reason * **********************************************************************/ function error_disp($p_sInfo, $p_sUrl) { echo " "; exit; } /********************************************************************** * * method name: cnSubStr * date: 2005-08-10 * author: dan * describe: get string * * input param: string string * sublen length * output param: * edit record: * Date Name Reason * **********************************************************************/ function cnSubStr($string,$sublen) { if( $sublen >= strlen( $string ) ) { return $string; } $s = ""; for( $i=0; $i<$sublen; $i++ ) { if( ord($string{$i} ) > 127 ) { $s .= $string{$i} . $string{++$i}; continue; } else { $s .= $string{$i}; continue; } } return $s; } function getZhantai() { global $arrZhantai; $sScriptContent = " "; return $sScriptContent; } } class resizeimage { //type of picture var $type; //width var $width; //height var $height; //change with var $resize_width; //change height var $resize_height; // var $cut; //original picture var $srcimg; //target picture var $dstimg; // var $im; function resizeimage($img, $wid, $hei,$c) { $this->srcimg = $img; $this->resize_width = $wid; $this->resize_height = $hei; $this->cut = $c; //type of picture $this->type = substr(strrchr($this->srcimg,"."),1); $this->initi_img(); $this -> dst_img(); //-- $this->width = imagesx($this->im); $this->height = imagesy($this->im); $this->newimg(); ImageDestroy ($this->im); } function newimg() { $resize_ratio = ($this->resize_width)/($this->resize_height); $ratio = ($this->width)/($this->height); if(($this->cut)=="1") { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width,$this->resize_height, (($this->height)*$resize_ratio), $this->height); ImageJpeg ($newimg,$this->dstimg); } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, $this->resize_height, $this->width, (($this->width)/$resize_ratio)); ImageJpeg ($newimg,$this->dstimg); } } else { if($ratio>=$resize_ratio) { $newimg = imagecreatetruecolor($this->resize_width,($this->resize_width)/$ratio); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, $this->resize_width, ($this->resize_width)/$ratio, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); } if($ratio<$resize_ratio) { $newimg = imagecreatetruecolor(($this->resize_height)*$ratio,$this->resize_height); imagecopyresampled($newimg, $this->im, 0, 0, 0, 0, ($this->resize_height)*$ratio, $this->resize_height, $this->width, $this->height); ImageJpeg ($newimg,$this->dstimg); } } } function initi_img() { if($this->type=="jpg") { $this->im = imagecreatefromjpeg($this->srcimg); } if($this->type=="gif") { $this->im = imagecreatefromgif($this->srcimg); } if($this->type=="png") { $this->im = imagecreatefrompng($this->srcimg); } } function dst_img() { $full_length = strlen($this->srcimg); $type_length = strlen($this->type); $name_length = $full_length-$type_length; $name = substr($this->srcimg,0,$name_length-1); $this->dstimg = $name."_s.".$this->type; } } ?>