function WriteToLog($txt, $level) { $this->logLevel = IntVal(COption::GetOptionString("mail", "smtp_log_level", "4")); if ($this->logLevel < $level) { return; } if (MicroTime(true) - $this->startPeriodTimeTruncate > 600) { if ($this->logFile) { FClose($this->logFile); } $this->logFile = null; if (File_Exists($_SERVER["DOCUMENT_ROOT"] . $this->logFileName)) { $logSize = @FileSize($_SERVER["DOCUMENT_ROOT"] . $this->logFileName); $logSize = IntVal($logSize); if ($logSize > $this->logMaxSize) { if (($fp = @FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "rb")) && ($fp1 = @FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", "wb"))) { $iSeekLen = IntVal($logSize - $this->logMaxSize / 2.0); FSeek($fp, $iSeekLen); @FWrite($fp1, "Truncated " . Date("Y-m-d H:i:s") . "\n---------------------------------\n"); do { $data = FRead($fp, 8192); if (StrLen($data) == 0) { break; } @FWrite($fp1, $data); } while (true); @FClose($fp); @FClose($fp1); @Copy($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", $_SERVER["DOCUMENT_ROOT"] . $this->logFileName); @UnLink($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_"); } } ClearStatCache(); } $this->startPeriodTimeTruncate = MicroTime(true); } if (!$this->logFile || $this->logFile == null) { $this->logFile = FOpen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "a"); } if (!$this->logFile) { echo "Can't write to log\n---------------------------------\n"; return; } FWrite($this->logFile, Date("Y-m-d H:i:s") . "\t" . trim($txt) . "\n"); FFlush($this->logFile); //if ($level > 4) echo trim($txt) . "\n---------------------------------\n"; }
function DoResize($path, $filename, $cfg) { ClearStatCache(); // change the memory limit ini_set('memory_limit', 25000000); // get the path and extension of the original file $path = $this->CorrectPath($path); $ext = $this->GetExtension($filename); // get the name and path of the new file $newPath = $this->CorrectPath($cfg['path']); $newFile = $newPath . $this->resizePrefix . $filename; // get the original file if ($ext == 'jpg' || $ext == 'jpeg') { $original = ImageCreateFromJPEG($path . $filename); } elseif ($ext == 'png') { $original = ImageCreateFromPNG($path . $filename); } else { return null; } if ($original) { // get the size of the image $size = GetImageSize($path . $filename); $imgH = $size[1]; $imgW = $size[0]; // is the image to big (get new sizes)? if ($imgW > $imgH) { $width = $imgW > $cfg['size'] ? $cfg['size'] : $imgW; $scale = $width / $imgW * 100; $height = $imgH / 100 * $scale; } else { $height = $imgH > $cfg['size'] ? $cfg['size'] : $imgH; $scale = $height / $imgH * 100; $width = $imgW / 100 * $scale; } // generate the image if (function_exists("imagecopyresampled")) { $imgResized = ImageCreateTrueColor($width, $height); ImageCopyResampled($imgResized, $original, 0, 0, 0, 0, $width, $height, $imgW, $imgH); } else { $imgResized = ImageCreate($width, $height); ImageCopyResized($imgResized, $original, 0, 0, 0, 0, $width, $height, $imgW, $imgH); } if ($ext == 'jpg' || $ext == 'jpeg') { $original = ImageJPEG($imgResized, $newFile, $cfg['quality']); } elseif ($ext == 'png') { $original = ImagePNG($imgResized, $newFile); } // clean up ImageDestroy($original); ImageDestroy($imgResized); return $this->resizePrefix . str_replace(".{$ext}", '.jpg', $filename); } }
function Skinny() { ClearStatCache(); global $skLoopCount; // スキン展開用配列 $this->skLoopCount = $skLoopCount; // global $skConf; // コンフィグ情報保持 $this->skConf = $skConf; // $this->_skStartTime = _get_microtime(); // ベンチ用に時間を取得 }
public function WriteToLog($txt, $level) { if ($this->logLevel > $level) { return; } if (time() - $this->startPeriodTimeTruncate > 600) { if ($this->logFile) { fclose($this->logFile); } $this->logFile = null; if (file_exists($_SERVER["DOCUMENT_ROOT"] . $this->logFileName)) { $logSize = @filesize($_SERVER["DOCUMENT_ROOT"] . $this->logFileName); $logSize = intval($logSize); if ($logSize > $this->logMaxSize) { if (($fp = @fopen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "rb")) && ($fp1 = @fopen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", "wb"))) { $iSeekLen = intval($logSize - $this->logMaxSize / 2.0); fseek($fp, $iSeekLen); @fwrite($fp1, "Truncated " . Date("Y-m-d H:i:s") . "\n---------------------------------\n"); do { $data = fread($fp, 8192); if (strlen($data) == 0) { break; } @fwrite($fp1, $data); } while (true); @fclose($fp); @fclose($fp1); @copy($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_", $_SERVER["DOCUMENT_ROOT"] . $this->logFileName); @unlink($_SERVER["DOCUMENT_ROOT"] . $this->logFileName . "_"); } } ClearStatCache(); } $this->startPeriodTimeTruncate = time(); } if (!$this->logFile || $this->logFile == null) { $this->logFile = fopen($_SERVER["DOCUMENT_ROOT"] . $this->logFileName, "a"); } if (!$this->logFile) { echo "Can't write to log\n---------------------------------\n"; return; } fwrite($this->logFile, date("Y-m-d H:i:s") . "\n" . $txt . "\n---------------------------------\n"); fflush($this->logFile); if ($level > 4) { echo $txt . "\n---------------------------------\n"; } }