M2 Download Center
Download Here ( Internal )
Hello, i created several functions for private server Santhia (czech private server). I hope it will useful for you.
Log system function:
function CreateLog ($status,$fileName,$id,$ip,$itemID = NULL,$desc = NULL) {
$sql = mysql_query("SELECT login from ".DB_ACC.".account WHERE id = ".mysql_escape($id)." ");
if(strtoupper(trim($fileName)) == 'BUY' and !is_null($itemID) )
{$opt = ' | Item: '.$itemID; }
else {$opt = ''; }
if (!is_null($desc)){ $descr = $desc; }else{ $descr = ''; }
$log = new Logging();
$log->lfile('path/logs/'.$fileName.'.txt');
$log->lwrite('STATUS: '.strtoupper(trim($status)).' | Login: '.mysql_result($sql,0,login).''.$opt.' | '.$ip.' | '.$descr );
//e.g. CreateLog ('STATUS',NAME_OF_FILE,$_SESSION['id'],$_SERVER['REMOTE_ADDR'],''ID_ITEMU,'DESCRIPTION');
}
Log system class:
<?php
class Logging {
private $log_file, $fp;
public function lfile($path) {
$this->log_file = $path;
}
public function lwrite($message) {
if (!is_resource($this->fp)) {
$this->lopen();
}
$time = @date('[Y.m.d H:i:s]');
fwrite($this->fp, "$time $message" . PHP_EOL);
}
public function lclose() {
fclose($this->fp);
}
private function lopen() {
$log_file_default = 'path/logs/login.txt';
$lfile = $this->log_file ? $this->log_file : $log_file_default;
$this->fp = fopen($lfile, 'a') or exit("Can't open $lfile!");
}
}
?>
-----------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------
Function to display the image of Items:
function ItemImg($vnum) {
$equip_length = strlen($vnum);
switch($equip_length) {
case '1':
$vnum = '0000'.$vnum;
$id = substr($vnum, 0, -1);
break;
case '2':
$vnum = '000'.$vnum;
$id = substr($vnum, 0, -1);
break;
case '3':
$vnum = '00'.$vnum;
$id = substr($vnum, 0, -1);
break;
case '4':
$vnum = '0'.$vnum;
$id = substr($vnum, 0, -1);
break;
case '5':
$vnum1 = $vnum;
break;
}
if(file_exists('template/img/isIcon/ico/'.$id.'0.png'))
{
return 'path/ico/'.$id.'0.png';
}
elseif(file_exists('path/ico/'.$vnum1.'.png'))
{
return 'path/ico/'.$vnum1.'.png';
}
else
{
return 'path/error.png'; // error image. if image is missing
}
}
I hope it will useful for you. If you have questions feel to free and contact me.
Dumik
WebDeveloper for Santhia