svn:eol-style got murdered on some files for whatever reason so it gets resurrected now, also set some svn:keywords

This commit is contained in:
Robert Foerster (Dessa)
2010-01-27 08:54:31 +00:00
parent 30f2de8f9e
commit 883963d2e2
190 changed files with 34136 additions and 34136 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,272 +1,272 @@
<?php
/**
* Implementation of the Application Packaging Standard from SwSoft/Parallels
* http://apsstandard.com
*
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package APS
* @version $Id$
* @todo logging
* install specific packages by name
* other solution than using url_fopen
* move url for distributionserver into panel
*/
class ApsUpdater extends ApsParser
{
private $settings = array();
private $db = false;
private $RequestDomain = '';
private $RootUrl = '';
private $RootDir = '';
/**
* constructor of class. setup some basic variables needed by class
*
* @param db instance of the database class from syscp
*/
public function __construct($db)
{
$this->db = $db;
$this->RequestDomain = 'apscatalog.com';
$this->RootUrl = '/1/';
$this->RootDir = dirname(dirname(__FILE__)) . '/';
}
/**
* Main function of class which handles all around the update mechanism
*/
public function UpdateHandler()
{
chdir($this->RootDir);
//return if allow_url_fopen is disabled
if(ini_get('allow_url_fopen') == '0')
{
echo ("The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!\n");
return;
}
//return if no task exists
$Result = $this->db->query('SELECT * FROM `' . TABLE_APS_TASKS . '` WHERE `Task` IN (' . TASK_SYSTEM_UPDATE . ', ' . TASK_SYSTEM_DOWNLOAD . ')');
if($this->db->num_rows($Result) == 0)
{
return;
}
//query first task -> updater can only do one job within a run
$Task = $this->db->fetch_array($Result);
$this->db->query('DELETE FROM `' . TABLE_APS_TASKS . '` WHERE `Task` = ' . $Task['Task']);
//fetch all vendors
$Vendors = self::FetchSubUrls($this->RootUrl);
foreach($Vendors as $Vendor)
{
//fetch all applications from vendors
$Applications = self::FetchSubUrls($this->RootUrl . $Vendor);
foreach($Applications as $Application)
{
//get newest version of package which is already installed
$CurrentVersion = '';
$Result = $this->db->query('SELECT * FROM `' . TABLE_APS_PACKAGES . '` WHERE `Name` = "' . $this->db->escape(substr($Application, 0, -1)) . '"');
while($Row = $this->db->fetch_array($Result))
{
if(version_compare($Row['Version'] . '-' . $Row['Release'], $CurrentVersion) == 1)
{
$CurrentVersion = $Row['Version'] . '-' . $Row['Release'];
}
}
if($this->db->num_rows($Result) != 0)
{
//package already installed in system, search for newer version
if($Task['Task'] != TASK_SYSTEM_UPDATE)continue;
//fetch different versions of application from distribution server
$NewerVersion = '';
$Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application);
foreach($Versions as $Version)
{
$OnlineVersion = substr($Version, 0, -1);
//is package newer than current version?
if(version_compare($OnlineVersion, $CurrentVersion) == 1)
{
//is new package newer than another one found before?
if(version_compare($OnlineVersion, $NewerVersion) == 1)
{
$NewerVersion = $OnlineVersion;
}
}
}
if($NewerVersion != '')
{
//download package as an update
self::DownloadPackage($this->RootUrl . $Vendor . $Application . $NewerVersion, substr($Application, 0, -1), $NewerVersion);
continue;
}
}
else
{
if($Task['Task'] != TASK_SYSTEM_DOWNLOAD)continue;
//new packages
$NewVersion = '';
$Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application);
foreach($Versions as $Version)
{
$OnlineVersion = substr($Version, 0, -1);
//is package newer than another one found before?
if(version_compare($OnlineVersion, $NewVersion) == 1)
{
$NewVersion = $OnlineVersion;
}
}
if($NewVersion != '')
{
//download package as a new one
self::DownloadPackage($this->RootUrl . $Vendor . $Application . $NewVersion, substr($Application, 0, -1), $NewVersion);
continue;
}
}
}
}
}
/**
* download a package from the distribution server and move the downloaded file in the temporary directory
*
* @param url url to download
* @param application string identifying the application name
* @param version string identifying the application version
* @return success true/error false
*/
private function DownloadPackage($Url, $Application, $Version)
{
$Downloads = self::FetchSubUrls($Url . '/');
//make url valid
$Url = str_replace(' ', '%20', $Url);
//get content from website url
$Content = @file_get_contents('http://' . $this->RequestDomain . $Url . '.aps' . $Downloads[0]);
if($Content != false)
{
//open file to write contents on disk
$FileHandle = fopen($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 'wb');
if($FileHandle == true)
{
//write results to disk
fwrite($FileHandle, $Content);
fclose($FileHandle);
//set right permissions
chmod($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 0664);
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
* fetch html content of distribution server and parse all information
*
* @param requestdomain domain to aps-/mirrorserver with package api
* @param url url to fetch sub links from
* @return error false/success array with relative sub links
*/
private function FetchSubUrls($Url)
{
$Return = array();
//make url valid
$Url = str_replace(' ', '%20', $Url);
//get content from website url
$Content = @file('http://' . $this->RequestDomain . $Url);
if($Content != false)
{
foreach($Content as $Temp)
{
//skip empty lines
if($Temp != "\r\n"
&& $Temp != "\r"
&& $Temp != "\n"
&& $Temp != "")
{
//remove unwanted characters
$Temp = trim($Temp);
//grep URLs which match defined format
if(preg_match("/^<a href=\"(.+)\".+class=\"(vendor|application|version|packager)\"/", $Temp, $Matches))
{
if(!in_array(urldecode($Matches[1]), $Return))$Return[] = urldecode($Matches[1]);
}
}
}
return $Return;
}
else
{
return false;
}
}
}
<?php
/**
* Implementation of the Application Packaging Standard from SwSoft/Parallels
* http://apsstandard.com
*
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package APS
* @version $Id$
* @todo logging
* install specific packages by name
* other solution than using url_fopen
* move url for distributionserver into panel
*/
class ApsUpdater extends ApsParser
{
private $settings = array();
private $db = false;
private $RequestDomain = '';
private $RootUrl = '';
private $RootDir = '';
/**
* constructor of class. setup some basic variables needed by class
*
* @param db instance of the database class from syscp
*/
public function __construct($db)
{
$this->db = $db;
$this->RequestDomain = 'apscatalog.com';
$this->RootUrl = '/1/';
$this->RootDir = dirname(dirname(__FILE__)) . '/';
}
/**
* Main function of class which handles all around the update mechanism
*/
public function UpdateHandler()
{
chdir($this->RootDir);
//return if allow_url_fopen is disabled
if(ini_get('allow_url_fopen') == '0')
{
echo ("The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!\n");
return;
}
//return if no task exists
$Result = $this->db->query('SELECT * FROM `' . TABLE_APS_TASKS . '` WHERE `Task` IN (' . TASK_SYSTEM_UPDATE . ', ' . TASK_SYSTEM_DOWNLOAD . ')');
if($this->db->num_rows($Result) == 0)
{
return;
}
//query first task -> updater can only do one job within a run
$Task = $this->db->fetch_array($Result);
$this->db->query('DELETE FROM `' . TABLE_APS_TASKS . '` WHERE `Task` = ' . $Task['Task']);
//fetch all vendors
$Vendors = self::FetchSubUrls($this->RootUrl);
foreach($Vendors as $Vendor)
{
//fetch all applications from vendors
$Applications = self::FetchSubUrls($this->RootUrl . $Vendor);
foreach($Applications as $Application)
{
//get newest version of package which is already installed
$CurrentVersion = '';
$Result = $this->db->query('SELECT * FROM `' . TABLE_APS_PACKAGES . '` WHERE `Name` = "' . $this->db->escape(substr($Application, 0, -1)) . '"');
while($Row = $this->db->fetch_array($Result))
{
if(version_compare($Row['Version'] . '-' . $Row['Release'], $CurrentVersion) == 1)
{
$CurrentVersion = $Row['Version'] . '-' . $Row['Release'];
}
}
if($this->db->num_rows($Result) != 0)
{
//package already installed in system, search for newer version
if($Task['Task'] != TASK_SYSTEM_UPDATE)continue;
//fetch different versions of application from distribution server
$NewerVersion = '';
$Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application);
foreach($Versions as $Version)
{
$OnlineVersion = substr($Version, 0, -1);
//is package newer than current version?
if(version_compare($OnlineVersion, $CurrentVersion) == 1)
{
//is new package newer than another one found before?
if(version_compare($OnlineVersion, $NewerVersion) == 1)
{
$NewerVersion = $OnlineVersion;
}
}
}
if($NewerVersion != '')
{
//download package as an update
self::DownloadPackage($this->RootUrl . $Vendor . $Application . $NewerVersion, substr($Application, 0, -1), $NewerVersion);
continue;
}
}
else
{
if($Task['Task'] != TASK_SYSTEM_DOWNLOAD)continue;
//new packages
$NewVersion = '';
$Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application);
foreach($Versions as $Version)
{
$OnlineVersion = substr($Version, 0, -1);
//is package newer than another one found before?
if(version_compare($OnlineVersion, $NewVersion) == 1)
{
$NewVersion = $OnlineVersion;
}
}
if($NewVersion != '')
{
//download package as a new one
self::DownloadPackage($this->RootUrl . $Vendor . $Application . $NewVersion, substr($Application, 0, -1), $NewVersion);
continue;
}
}
}
}
}
/**
* download a package from the distribution server and move the downloaded file in the temporary directory
*
* @param url url to download
* @param application string identifying the application name
* @param version string identifying the application version
* @return success true/error false
*/
private function DownloadPackage($Url, $Application, $Version)
{
$Downloads = self::FetchSubUrls($Url . '/');
//make url valid
$Url = str_replace(' ', '%20', $Url);
//get content from website url
$Content = @file_get_contents('http://' . $this->RequestDomain . $Url . '.aps' . $Downloads[0]);
if($Content != false)
{
//open file to write contents on disk
$FileHandle = fopen($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 'wb');
if($FileHandle == true)
{
//write results to disk
fwrite($FileHandle, $Content);
fclose($FileHandle);
//set right permissions
chmod($this->RootDir . 'temp/' . $Application . '-' . $Version . '.app.zip', 0664);
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
/**
* fetch html content of distribution server and parse all information
*
* @param requestdomain domain to aps-/mirrorserver with package api
* @param url url to fetch sub links from
* @return error false/success array with relative sub links
*/
private function FetchSubUrls($Url)
{
$Return = array();
//make url valid
$Url = str_replace(' ', '%20', $Url);
//get content from website url
$Content = @file('http://' . $this->RequestDomain . $Url);
if($Content != false)
{
foreach($Content as $Temp)
{
//skip empty lines
if($Temp != "\r\n"
&& $Temp != "\r"
&& $Temp != "\n"
&& $Temp != "")
{
//remove unwanted characters
$Temp = trim($Temp);
//grep URLs which match defined format
if(preg_match("/^<a href=\"(.+)\".+class=\"(vendor|application|version|packager)\"/", $Temp, $Matches))
{
if(!in_array(urldecode($Matches[1]), $Return))$Return[] = urldecode($Matches[1]);
}
}
}
return $Return;
}
else
{
return false;
}
}
}
?>

View File

@@ -1,345 +1,345 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Classes
* @version $Id$
*/
/**
* Class to manage the connection to the Database
* @package Functions
*/
class db
{
/**
* Link ID for every connection
* @var int
*/
var $link_id = 0;
/**
* Query ID for every query
* @var int
*/
var $query_id = 0;
/**
* Errordescription, if an error occures
* @var string
*/
var $errdesc = '';
/**
* Errornumber, if an error occures
* @var int
*/
var $errno = 0;
/**
* Servername
* @var string
*/
var $server = '';
/**
* Username
* @var string
*/
var $user = '';
/**
* Password
* @var string
*/
var $password = '';
/**
* Database
* @var string
*/
var $database = '';
/**
* Class constructor. Connects to Databaseserver and selects Database
*
* @param string Servername
* @param string Username
* @param string Password
* @param string Database
*/
function db($server, $user, $password, $database = '')
{
// check for mysql extension
if(!extension_loaded('mysql'))
{
$this->showerror('You should install the PHP MySQL extension!', false);
}
$this->server = $server;
$this->user = $user;
$this->password = $password;
$this->database = $database;
$this->link_id = @mysql_connect($this->server, $this->user, $this->password);
if(!$this->link_id)
{
//try to connect with no password an change it afterwards. only for root user
if($this->user == 'root')
{
$this->link_id = @mysql_connect($this->server, $this->user, '');
if($this->link_id)
{
$this->query("SET PASSWORD = PASSWORD('" . $this->escape($this->password) . "')");
}
else
{
$this->showerror('Establishing connection failed, exiting');
}
}
else
{
$this->showerror('Establishing connection failed, exiting');
}
}
if($this->database != '')
{
if(!@mysql_select_db($this->database, $this->link_id))
{
$this->showerror('Trying to use database ' . $this->database . ' failed, exiting');
}
}
mysql_query("SET NAMES utf8", $this->link_id);
mysql_query("SET CHARACTER SET utf8", $this->link_id);
}
/**
* Closes connection to Databaseserver
*/
function close()
{
return @mysql_close($this->link_id);
}
/**
* Escapes user input to be used in mysql queries
*
* @param string $input
* @return string escaped string
*/
function escape($input)
{
if(is_int($input))
{
return (int)$input;
}
elseif(is_float($input))
{
return (float)$input;
}
else
{
return mysql_real_escape_string($input, $this->link_id);
}
}
/**
* Query the Database
*
* @param string Querystring
* @param bool Unbuffered query?
* @return string RessourceId
*/
function query($query_str, $unbuffered = false)
{
global $numbqueries;
if(!$unbuffered)
{
$this->query_id = mysql_query($query_str, $this->link_id);
}
else
{
$this->query_id = mysql_unbuffered_query($query_str, $this->link_id);
}
if(!$this->query_id)
{
$this->showerror('Invalid SQL: ' . $query_str);
}
$numbqueries++;
//echo $query_str.' '.$numbqueries.'<br />';
return $this->query_id;
}
/**
* Fetches Row from Query and returns it as array
*
* @param string RessourceId
* @param string Datatype, num or assoc
* @return array The row
*/
function fetch_array($query_id = - 1, $datatype = 'assoc')
{
if($query_id != - 1)
{
$this->query_id = $query_id;
}
if($datatype == 'num')
{
$datatype = MYSQL_NUM;
}
else
{
$datatype = MYSQL_ASSOC;
}
$this->record = mysql_fetch_array($this->query_id, $datatype);
return $this->record;
}
/**
* Query Database and fetche the first row from Query and returns it as array
*
* @param string Querystring
* @param string Datatype, num or assoc
* @return array The first row
*/
function query_first($query_string, $datatype = 'assoc')
{
$this->query($query_string);
return $this->fetch_array($this->query_id, $datatype);
}
/**
* Returns how many rows have been selected
*
* @param string RessourceId
* @return int Number of rows
*/
function num_rows($query_id = - 1)
{
if($query_id != - 1)
{
$this->query_id = $query_id;
}
return mysql_num_rows($this->query_id);
}
/**
* Returns the auto_incremental-Value of the inserted row
*
* @return int auto_incremental-Value
*/
function insert_id()
{
return mysql_insert_id($this->link_id);
}
/**
* Returns the number of rows affected by last query
*
* @return int affected rows
*/
function affected_rows()
{
return mysql_affected_rows($this->link_id);
}
/**
* Returns errordescription and errornumber if an error occured.
*
* @return int Errornumber
*/
function geterrdescno()
{
if($this->link_id != 0)
{
$this->errdesc = mysql_error($this->link_id);
$this->errno = mysql_errno($this->link_id);
}
else
{
// Maybe we don't have any linkid so let's try to catch at least anything
$this->errdesc = mysql_error();
$this->errno = mysql_errno();
}
return $this->errno;
}
/**
* Dies with an errormessage
*
* @param string Errormessage
*/
function showerror($errormsg, $mysqlActive = true)
{
global $filename;
if($mysqlActive)
{
$this->geterrdescno();
$errormsg.= "\n";
$errormsg.= 'mysql error number: ' . $this->errno . "\n";
$errormsg.= 'mysql error desc: ' . $this->errdesc . "\n";
}
$errormsg.= 'Time/date: ' . date('d/m/Y h:i A') . "\n";
if($filename != 'cronscript.php')
{
$errormsg.= 'Script: ' . htmlspecialchars(getenv('REQUEST_URI')) . "\n";
$errormsg.= 'Referer: ' . htmlspecialchars(getenv('HTTP_REFERER')) . "\n";
die(nl2br($errormsg));
}
else
{
$errormsg.= 'Script: -- Cronscript --' . "\n";
die($errormsg);
}
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Florian Lippert <flo@syscp.org> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Classes
* @version $Id$
*/
/**
* Class to manage the connection to the Database
* @package Functions
*/
class db
{
/**
* Link ID for every connection
* @var int
*/
var $link_id = 0;
/**
* Query ID for every query
* @var int
*/
var $query_id = 0;
/**
* Errordescription, if an error occures
* @var string
*/
var $errdesc = '';
/**
* Errornumber, if an error occures
* @var int
*/
var $errno = 0;
/**
* Servername
* @var string
*/
var $server = '';
/**
* Username
* @var string
*/
var $user = '';
/**
* Password
* @var string
*/
var $password = '';
/**
* Database
* @var string
*/
var $database = '';
/**
* Class constructor. Connects to Databaseserver and selects Database
*
* @param string Servername
* @param string Username
* @param string Password
* @param string Database
*/
function db($server, $user, $password, $database = '')
{
// check for mysql extension
if(!extension_loaded('mysql'))
{
$this->showerror('You should install the PHP MySQL extension!', false);
}
$this->server = $server;
$this->user = $user;
$this->password = $password;
$this->database = $database;
$this->link_id = @mysql_connect($this->server, $this->user, $this->password);
if(!$this->link_id)
{
//try to connect with no password an change it afterwards. only for root user
if($this->user == 'root')
{
$this->link_id = @mysql_connect($this->server, $this->user, '');
if($this->link_id)
{
$this->query("SET PASSWORD = PASSWORD('" . $this->escape($this->password) . "')");
}
else
{
$this->showerror('Establishing connection failed, exiting');
}
}
else
{
$this->showerror('Establishing connection failed, exiting');
}
}
if($this->database != '')
{
if(!@mysql_select_db($this->database, $this->link_id))
{
$this->showerror('Trying to use database ' . $this->database . ' failed, exiting');
}
}
mysql_query("SET NAMES utf8", $this->link_id);
mysql_query("SET CHARACTER SET utf8", $this->link_id);
}
/**
* Closes connection to Databaseserver
*/
function close()
{
return @mysql_close($this->link_id);
}
/**
* Escapes user input to be used in mysql queries
*
* @param string $input
* @return string escaped string
*/
function escape($input)
{
if(is_int($input))
{
return (int)$input;
}
elseif(is_float($input))
{
return (float)$input;
}
else
{
return mysql_real_escape_string($input, $this->link_id);
}
}
/**
* Query the Database
*
* @param string Querystring
* @param bool Unbuffered query?
* @return string RessourceId
*/
function query($query_str, $unbuffered = false)
{
global $numbqueries;
if(!$unbuffered)
{
$this->query_id = mysql_query($query_str, $this->link_id);
}
else
{
$this->query_id = mysql_unbuffered_query($query_str, $this->link_id);
}
if(!$this->query_id)
{
$this->showerror('Invalid SQL: ' . $query_str);
}
$numbqueries++;
//echo $query_str.' '.$numbqueries.'<br />';
return $this->query_id;
}
/**
* Fetches Row from Query and returns it as array
*
* @param string RessourceId
* @param string Datatype, num or assoc
* @return array The row
*/
function fetch_array($query_id = - 1, $datatype = 'assoc')
{
if($query_id != - 1)
{
$this->query_id = $query_id;
}
if($datatype == 'num')
{
$datatype = MYSQL_NUM;
}
else
{
$datatype = MYSQL_ASSOC;
}
$this->record = mysql_fetch_array($this->query_id, $datatype);
return $this->record;
}
/**
* Query Database and fetche the first row from Query and returns it as array
*
* @param string Querystring
* @param string Datatype, num or assoc
* @return array The first row
*/
function query_first($query_string, $datatype = 'assoc')
{
$this->query($query_string);
return $this->fetch_array($this->query_id, $datatype);
}
/**
* Returns how many rows have been selected
*
* @param string RessourceId
* @return int Number of rows
*/
function num_rows($query_id = - 1)
{
if($query_id != - 1)
{
$this->query_id = $query_id;
}
return mysql_num_rows($this->query_id);
}
/**
* Returns the auto_incremental-Value of the inserted row
*
* @return int auto_incremental-Value
*/
function insert_id()
{
return mysql_insert_id($this->link_id);
}
/**
* Returns the number of rows affected by last query
*
* @return int affected rows
*/
function affected_rows()
{
return mysql_affected_rows($this->link_id);
}
/**
* Returns errordescription and errornumber if an error occured.
*
* @return int Errornumber
*/
function geterrdescno()
{
if($this->link_id != 0)
{
$this->errdesc = mysql_error($this->link_id);
$this->errno = mysql_errno($this->link_id);
}
else
{
// Maybe we don't have any linkid so let's try to catch at least anything
$this->errdesc = mysql_error();
$this->errno = mysql_errno();
}
return $this->errno;
}
/**
* Dies with an errormessage
*
* @param string Errormessage
*/
function showerror($errormsg, $mysqlActive = true)
{
global $filename;
if($mysqlActive)
{
$this->geterrdescno();
$errormsg.= "\n";
$errormsg.= 'mysql error number: ' . $this->errno . "\n";
$errormsg.= 'mysql error desc: ' . $this->errdesc . "\n";
}
$errormsg.= 'Time/date: ' . date('d/m/Y h:i A') . "\n";
if($filename != 'cronscript.php')
{
$errormsg.= 'Script: ' . htmlspecialchars(getenv('REQUEST_URI')) . "\n";
$errormsg.= 'Referer: ' . htmlspecialchars(getenv('HTTP_REFERER')) . "\n";
die(nl2br($errormsg));
}
else
{
$errormsg.= 'Script: -- Cronscript --' . "\n";
die($errormsg);
}
}
}
?>

File diff suppressed because it is too large Load Diff

View File

@@ -1,145 +1,145 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Duergner <michael@duergner.com> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Classes
* @version $Id$
*/
/**
* Class for wrapping a specific idna conversion class and offering a standard interface
* @package Functions
*/
class idna_convert_wrapper
{
/**
* idna converter we use
* @var object
*/
var $idna_converter;
/**
* Class constructor. Creates a new idna converter
*/
function idna_convert_wrapper()
{
$this->idna_converter = new idna_convert();
}
/**
* Encode a domain name, a email address or a list of one of both.
*
* @param string May be either a single domain name, e single email address or a list of one
* seperated either by ',', ';' or ' '.
*
* @return string Returns either a single domain name, a single email address or a list of one of
* both seperated by the same string as the input.
*/
function encode($to_encode)
{
return $this->_do_action('encode', $to_encode);
}
/**
* Decode a domain name, a email address or a list of one of both.
*
* @param string May be either a single domain name, e single email address or a list of one
* seperated either by ',', ';' or ' '.
*
* @return string Returns either a single domain name, a single email address or a list of one of
* both seperated by the same string as the input.
*/
function decode($to_decode)
{
return $this->_do_action('decode', $to_decode);
}
/**
* Do the real de- or encoding. First checks if a list is submitted and seperates it. Afterwards sends
* each entry to the idna converter to do the converting.
*
* @param string May be either 'decode' or 'encode'.
* @param string The string to de- or endcode.
*
* @return string The input string after being processed.
*/
function _do_action($action, $string)
{
$string = trim($string);
if(strpos($string, ',') !== false)
{
$strings = explode(',', $string);
$sepchar = ',';
}
elseif(strpos($string, ';') !== false)
{
$strings = explode(';', $string);
$sepchar = ';';
}
elseif(strpos($string, ' ') !== false)
{
$strings = explode(' ', $string);
$sepchar = ' ';
}
else
{
$strings = array(
$string
);
$sepchar = '';
}
for ($i = 0;$i < count($strings);$i++)
{
if(strpos($strings[$i], '@') !== false)
{
$split = explode('@', $strings[$i]);
$localpart = $split[0];
$domain = $split[1];
$email = true;
}
else
{
$domain = $strings[$i];
$email = false;
}
if(strlen($domain) !== 0)
{
$domain = utf8_decode($this->idna_converter->$action(utf8_encode($domain . '.none')));
$domain = substr($domain, 0, strlen($domain) - 5);
}
if($email)
{
$strings[$i] = $localpart . '@' . $domain;
}
else
{
$strings[$i] = $domain;
}
}
return implode($sepchar, $strings);
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Duergner <michael@duergner.com> (2003-2009)
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Classes
* @version $Id$
*/
/**
* Class for wrapping a specific idna conversion class and offering a standard interface
* @package Functions
*/
class idna_convert_wrapper
{
/**
* idna converter we use
* @var object
*/
var $idna_converter;
/**
* Class constructor. Creates a new idna converter
*/
function idna_convert_wrapper()
{
$this->idna_converter = new idna_convert();
}
/**
* Encode a domain name, a email address or a list of one of both.
*
* @param string May be either a single domain name, e single email address or a list of one
* seperated either by ',', ';' or ' '.
*
* @return string Returns either a single domain name, a single email address or a list of one of
* both seperated by the same string as the input.
*/
function encode($to_encode)
{
return $this->_do_action('encode', $to_encode);
}
/**
* Decode a domain name, a email address or a list of one of both.
*
* @param string May be either a single domain name, e single email address or a list of one
* seperated either by ',', ';' or ' '.
*
* @return string Returns either a single domain name, a single email address or a list of one of
* both seperated by the same string as the input.
*/
function decode($to_decode)
{
return $this->_do_action('decode', $to_decode);
}
/**
* Do the real de- or encoding. First checks if a list is submitted and seperates it. Afterwards sends
* each entry to the idna converter to do the converting.
*
* @param string May be either 'decode' or 'encode'.
* @param string The string to de- or endcode.
*
* @return string The input string after being processed.
*/
function _do_action($action, $string)
{
$string = trim($string);
if(strpos($string, ',') !== false)
{
$strings = explode(',', $string);
$sepchar = ',';
}
elseif(strpos($string, ';') !== false)
{
$strings = explode(';', $string);
$sepchar = ';';
}
elseif(strpos($string, ' ') !== false)
{
$strings = explode(' ', $string);
$sepchar = ' ';
}
else
{
$strings = array(
$string
);
$sepchar = '';
}
for ($i = 0;$i < count($strings);$i++)
{
if(strpos($strings[$i], '@') !== false)
{
$split = explode('@', $strings[$i]);
$localpart = $split[0];
$domain = $split[1];
$email = true;
}
else
{
$domain = $strings[$i];
$email = false;
}
if(strlen($domain) !== 0)
{
$domain = utf8_decode($this->idna_converter->$action(utf8_encode($domain . '.none')));
$domain = substr($domain, 0, strlen($domain) - 5);
}
if($email)
{
$strings[$i] = $localpart . '@' . $domain;
}
else
{
$strings[$i] = $domain;
}
}
return implode($sepchar, $strings);
}
}
?>

View File

@@ -1,100 +1,100 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - Abstract-Logger-Class
*/
/* We're using the syslog constants for all the loggers (partly implemented)
LOG_EMERG system is unusable
LOG_ALERT action must be taken immediately
LOG_CRIT critical conditions
LOG_ERR error conditions
LOG_WARNING warning conditions
LOG_NOTICE normal, but significant, condition
LOG_INFO informational message
LOG_DEBUG debug-level message
*/
abstract class AbstractLogger
{
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* Enable/Disable Logging
* @var logenabled
*/
private $logenabled = false;
/**
* Enable/Disable Cronjob-Logging
* @var logcronjob
*/
private $logcronjob = false;
/**
* Loggin-Severity
* @var severity
*/
private $severity = 1;
// normal
/**
* setup the main logger
*
* @param array settings
*/
protected function setupLogger($settings)
{
$this->settings = $settings;
$this->logenabled = $this->settings['logger']['enabled'];
$this->logcronjob = $this->settings['logger']['log_cron'];
$this->severity = $this->settings['logger']['severity'];
}
protected function isEnabled()
{
return $this->logenabled;
}
protected function getSeverity()
{
return $this->severity;
}
protected function logCron()
{
return $this->logcronjob;
}
abstract public function logAction();
}
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - Abstract-Logger-Class
*/
/* We're using the syslog constants for all the loggers (partly implemented)
LOG_EMERG system is unusable
LOG_ALERT action must be taken immediately
LOG_CRIT critical conditions
LOG_ERR error conditions
LOG_WARNING warning conditions
LOG_NOTICE normal, but significant, condition
LOG_INFO informational message
LOG_DEBUG debug-level message
*/
abstract class AbstractLogger
{
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* Enable/Disable Logging
* @var logenabled
*/
private $logenabled = false;
/**
* Enable/Disable Cronjob-Logging
* @var logcronjob
*/
private $logcronjob = false;
/**
* Loggin-Severity
* @var severity
*/
private $severity = 1;
// normal
/**
* setup the main logger
*
* @param array settings
*/
protected function setupLogger($settings)
{
$this->settings = $settings;
$this->logenabled = $this->settings['logger']['enabled'];
$this->logcronjob = $this->settings['logger']['log_cron'];
$this->severity = $this->settings['logger']['severity'];
}
protected function isEnabled()
{
return $this->logenabled;
}
protected function getSeverity()
{
return $this->severity;
}
protected function logCron()
{
return $this->logcronjob;
}
abstract public function logAction();
}
?>

View File

@@ -1,188 +1,188 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - File-Logger-Class
*/
class FileLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Logfile
* @var logfile
*/
private $logfile = null;
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
$this->setLogFile($settings['logger']['logfile']);
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new FileLogger($_usernfo, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
$_action = 'unknown';
switch($action)
{
case USR_ACTION:
$_action = 'customer';
break;
case RES_ACTION:
$_action = 'reseller';
break;
case ADM_ACTION:
$_action = 'administrator';
break;
case CRON_ACTION:
$_action = 'cronjob';
break;
case LOG_ERROR:
$_action = 'internal';
break;
default:
$_action = 'unknown';
break;
}
$_type = 'unknown';
switch($type)
{
case LOG_INFO:
$_type = 'information';
break;
case LOG_NOTICE:
$_type = 'notice';
break;
case LOG_WARNING:
$_type = 'warning';
break;
case LOG_ERR:
$_type = 'error';
break;
case LOG_CRIT:
$_type = 'critical';
break;
default:
$_type = 'unknown';
break;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
$fp = @fopen($this->logfile, 'a');
if($fp !== false)
{
$now = time();
if($text != null
&& $text != '')
{
fwrite($fp, date("d.m.Y H:i:s", $now) . " [" . $_type . "] [" . $_action . "-action" . $name . "] " . $text . "\n");
}
else
{
fwrite($fp, date("d.m.Y H:i:s", $now) . " [" . $_type . "] [" . $_action . "-action" . $name . "] No text given!!! Check scripts!\n");
}
fclose($fp);
}
else
{
if($this->logfile != null
|| $this->logfile != '')
{
throw new Exception("Cannot open logfile '" . $this->logfile . "' for writing!");
}
}
}
}
private function setLogFile($filename = null)
{
if($filename != null
&& $filename != ''
&& $filename != "."
&& $filename != ".."
&& !is_dir($filename))
{
$this->logfile = $filename;
return true;
}
return false;
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - File-Logger-Class
*/
class FileLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Logfile
* @var logfile
*/
private $logfile = null;
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
$this->setLogFile($settings['logger']['logfile']);
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new FileLogger($_usernfo, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
$_action = 'unknown';
switch($action)
{
case USR_ACTION:
$_action = 'customer';
break;
case RES_ACTION:
$_action = 'reseller';
break;
case ADM_ACTION:
$_action = 'administrator';
break;
case CRON_ACTION:
$_action = 'cronjob';
break;
case LOG_ERROR:
$_action = 'internal';
break;
default:
$_action = 'unknown';
break;
}
$_type = 'unknown';
switch($type)
{
case LOG_INFO:
$_type = 'information';
break;
case LOG_NOTICE:
$_type = 'notice';
break;
case LOG_WARNING:
$_type = 'warning';
break;
case LOG_ERR:
$_type = 'error';
break;
case LOG_CRIT:
$_type = 'critical';
break;
default:
$_type = 'unknown';
break;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
$fp = @fopen($this->logfile, 'a');
if($fp !== false)
{
$now = time();
if($text != null
&& $text != '')
{
fwrite($fp, date("d.m.Y H:i:s", $now) . " [" . $_type . "] [" . $_action . "-action" . $name . "] " . $text . "\n");
}
else
{
fwrite($fp, date("d.m.Y H:i:s", $now) . " [" . $_type . "] [" . $_action . "-action" . $name . "] No text given!!! Check scripts!\n");
}
fclose($fp);
}
else
{
if($this->logfile != null
|| $this->logfile != '')
{
throw new Exception("Cannot open logfile '" . $this->logfile . "' for writing!");
}
}
}
}
private function setLogFile($filename = null)
{
if($filename != null
&& $filename != ''
&& $filename != "."
&& $filename != ".."
&& !is_dir($filename))
{
$this->logfile = $filename;
return true;
}
return false;
}
}
?>

View File

@@ -1,205 +1,205 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - Froxlor-Base-Logger-Class
*/
class FroxlorLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Database handler
* @var db
*/
private $db = false;
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* LogTypes Array
* @var logtypes
*/
static private $logtypes = null;
/**
* Logger-Object-Array
* @var loggers
*/
static private $loggers = null;
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $db, $settings)
{
$this->userinfo = $userinfo;
$this->db = $db;
$this->settings = $settings;
self::$logtypes = array();
if(!isset($this->settings['logger']['logtypes'])
&& (!isset($this->settings['logger']['logtypes']) || $this->settings['logger']['logtypes'] == '')
&& isset($this->settings['logger']['enabled'])
&& $this->settings['logger']['enabled'])
{
self::$logtypes[0] = 'syslog';
self::$logtypes[1] = 'mysql';
}
else
{
if(isset($this->settings['logger']['logtypes'])
&& $this->settings['logger']['logtypes'] != '')
{
self::$logtypes = explode(',', $this->settings['logger']['logtypes']);
}
else
{
self::$logtypes = null;
}
}
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_db, $_settings)
{
if(!isset($_usernfo)
|| $_usernfo == null)
{
$_usernfo = array();
$_usernfo['loginname'] = 'unknown';
}
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new FroxlorLogger($_usernfo, $_db, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(self::$logtypes == null)
{
return;
}
if($this->settings['logger']['log_cron'] == '0'
&& $action == CRON_ACTION)
{
return;
}
foreach(self::$logtypes as $logger)
{
switch($logger)
{
case 'syslog':
$_log = SysLogger::getInstanceOf($this->userinfo, $this->settings);
break;
case 'file':
try
{
$_log = FileLogger::getInstanceOf($this->userinfo, $this->settings);
}
catch(Exception $e)
{
if($action != CRON_ACTION)
{
standard_error('logerror', $e->getMessage());
}
else
{
echo "Log-Error: " . $e->getMessage();
}
}
break;
case 'mysql':
$_log = MysqlLogger::getInstanceOf($this->userinfo, $this->settings, $this->db);
break;
default:
$_log = null;
break;
}
if($_log != null)
{
try
{
$_log->logAction($action, $type, $text);
}
catch(Exception $e)
{
if($action != CRON_ACTION)
{
standard_error('logerror', $e->getMessage());
}
else
{
echo "Log-Error: " . $e->getMessage();
}
}
}
}
}
public function setCronLog($_cronlog = 0)
{
$_cronlog = (int)$_cronlog;
if($_cronlog != 0
&& $_cronlog != 1)
{
$_cronlog = 0;
}
$this->db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "`
SET `value`='" . $this->db->escape($_cronlog) . "'
WHERE `settinggroup`='logger'
AND `varname`='log_cron'");
return true;
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - Froxlor-Base-Logger-Class
*/
class FroxlorLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Database handler
* @var db
*/
private $db = false;
/**
* Settings array
* @var settings
*/
private $settings = array();
/**
* LogTypes Array
* @var logtypes
*/
static private $logtypes = null;
/**
* Logger-Object-Array
* @var loggers
*/
static private $loggers = null;
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $db, $settings)
{
$this->userinfo = $userinfo;
$this->db = $db;
$this->settings = $settings;
self::$logtypes = array();
if(!isset($this->settings['logger']['logtypes'])
&& (!isset($this->settings['logger']['logtypes']) || $this->settings['logger']['logtypes'] == '')
&& isset($this->settings['logger']['enabled'])
&& $this->settings['logger']['enabled'])
{
self::$logtypes[0] = 'syslog';
self::$logtypes[1] = 'mysql';
}
else
{
if(isset($this->settings['logger']['logtypes'])
&& $this->settings['logger']['logtypes'] != '')
{
self::$logtypes = explode(',', $this->settings['logger']['logtypes']);
}
else
{
self::$logtypes = null;
}
}
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_db, $_settings)
{
if(!isset($_usernfo)
|| $_usernfo == null)
{
$_usernfo = array();
$_usernfo['loginname'] = 'unknown';
}
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new FroxlorLogger($_usernfo, $_db, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(self::$logtypes == null)
{
return;
}
if($this->settings['logger']['log_cron'] == '0'
&& $action == CRON_ACTION)
{
return;
}
foreach(self::$logtypes as $logger)
{
switch($logger)
{
case 'syslog':
$_log = SysLogger::getInstanceOf($this->userinfo, $this->settings);
break;
case 'file':
try
{
$_log = FileLogger::getInstanceOf($this->userinfo, $this->settings);
}
catch(Exception $e)
{
if($action != CRON_ACTION)
{
standard_error('logerror', $e->getMessage());
}
else
{
echo "Log-Error: " . $e->getMessage();
}
}
break;
case 'mysql':
$_log = MysqlLogger::getInstanceOf($this->userinfo, $this->settings, $this->db);
break;
default:
$_log = null;
break;
}
if($_log != null)
{
try
{
$_log->logAction($action, $type, $text);
}
catch(Exception $e)
{
if($action != CRON_ACTION)
{
standard_error('logerror', $e->getMessage());
}
else
{
echo "Log-Error: " . $e->getMessage();
}
}
}
}
}
public function setCronLog($_cronlog = 0)
{
$_cronlog = (int)$_cronlog;
if($_cronlog != 0
&& $_cronlog != 1)
{
$_cronlog = 0;
}
$this->db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "`
SET `value`='" . $this->db->escape($_cronlog) . "'
WHERE `settinggroup`='logger'
AND `varname`='log_cron'");
return true;
}
}
?>

View File

@@ -1,113 +1,113 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - MySQL-Logger-Class
*/
class MysqlLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Database handler
* @var db
*/
private $db = false;
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
* @param resource database
*/
protected function __construct($userinfo, $settings, $db)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
$this->db = $db;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings, $_db)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new MysqlLogger($_usernfo, $_settings, $_db);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
$now = time();
if($text != null
&& $text != '')
{
$this->db->query("INSERT INTO `panel_syslog` (`type`, `date`, `action`, `user`, `text`)
VALUES ('" . (int)$type . "', '" . $now . "', '" . (int)$action . "', '" . $this->db->escape($name) . "', '" . $this->db->escape($text) . "')");
}
else
{
$this->db->query("INSERT INTO `panel_syslog` (`type`, `date`, `action`, `userid`, `text`)
VALUES ('" . (int)$type . "', '" . $now . "', '" . (int)$action . "', '" . $this->db->escape($name) . "', 'No text given!!! Check scripts!')");
}
}
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - MySQL-Logger-Class
*/
class MysqlLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Database handler
* @var db
*/
private $db = false;
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
* @param resource database
*/
protected function __construct($userinfo, $settings, $db)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
$this->db = $db;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings, $_db)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new MysqlLogger($_usernfo, $_settings, $_db);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
$now = time();
if($text != null
&& $text != '')
{
$this->db->query("INSERT INTO `panel_syslog` (`type`, `date`, `action`, `user`, `text`)
VALUES ('" . (int)$type . "', '" . $now . "', '" . (int)$action . "', '" . $this->db->escape($name) . "', '" . $this->db->escape($text) . "')");
}
else
{
$this->db->query("INSERT INTO `panel_syslog` (`type`, `date`, `action`, `userid`, `text`)
VALUES ('" . (int)$type . "', '" . $now . "', '" . (int)$action . "', '" . $this->db->escape($name) . "', 'No text given!!! Check scripts!')");
}
}
}
}
?>

View File

@@ -1,128 +1,128 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - SysLog-Logger-Class
*/
class SysLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new SysLogger($_usernfo, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
$_action = 'unknown';
switch($action)
{
case USR_ACTION:
$_action = 'customer';
break;
case RES_ACTION:
$_action = 'reseller';
break;
case ADM_ACTION:
$_action = 'administrator';
break;
case CRON_ACTION:
$_action = 'cronjob';
break;
case LOG_ERROR:
$_action = 'internal';
break;
default:
$_action = 'unknown';
break;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
openlog("Froxlor", LOG_NDELAY, LOG_USER);
if($text != null
&& $text != '')
{
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] " . $text);
}
else
{
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] No text given!!! Check scripts!");
}
closelog();
}
}
}
?>
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2003-2009 the SysCP Team (see authors).
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Michael Kaufmann <mkaufmann@nutime.de>
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Logger
* @version $Id$
* @link http://www.nutime.de/
*
* Logger - SysLog-Logger-Class
*/
class SysLogger extends AbstractLogger
{
/**
* Userinfo
* @var array
*/
private $userinfo = array();
/**
* Syslogger Objects Array
* @var loggers
*/
static private $loggers = array();
/**
* Class constructor.
*
* @param array userinfo
* @param array settings
*/
protected function __construct($userinfo, $settings)
{
parent::setupLogger($settings);
$this->userinfo = $userinfo;
}
/**
* Singleton ftw ;-)
*
*/
static public function getInstanceOf($_usernfo, $_settings)
{
if(!isset(self::$loggers[$_usernfo['loginname']]))
{
self::$loggers[$_usernfo['loginname']] = new SysLogger($_usernfo, $_settings);
}
return self::$loggers[$_usernfo['loginname']];
}
public function logAction($action = USR_ACTION, $type = LOG_NOTICE, $text = null)
{
if(parent::isEnabled())
{
if(parent::getSeverity() <= 1
&& $type == LOG_NOTICE)
{
return;
}
$_action = 'unknown';
switch($action)
{
case USR_ACTION:
$_action = 'customer';
break;
case RES_ACTION:
$_action = 'reseller';
break;
case ADM_ACTION:
$_action = 'administrator';
break;
case CRON_ACTION:
$_action = 'cronjob';
break;
case LOG_ERROR:
$_action = 'internal';
break;
default:
$_action = 'unknown';
break;
}
if(!isset($this->userinfo['loginname'])
|| $this->userinfo['loginname'] == '')
{
$name = 'unknown';
}
else
{
$name = " (" . $this->userinfo['loginname'] . ")";
}
openlog("Froxlor", LOG_NDELAY, LOG_USER);
if($text != null
&& $text != '')
{
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] " . $text);
}
else
{
syslog((int)$type, "[" . ucfirst($_action) . " Action" . $name . "] No text given!!! Check scripts!");
}
closelog();
}
}
}
?>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +1,37 @@
<?php
/*~ class.smtp.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 2.0.0 rc1 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers) |
'---------------------------------------------------------------------------'
/**
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
* commands except TURN which will always return a not implemented
* error. SMTP also provides some utility methods for sending mail
* to an SMTP server.
* @package PHPMailer
* @author Chris Ryan
/*~ class.smtp.php
.---------------------------------------------------------------------------.
| Software: PHPMailer - PHP email class |
| Version: 2.0.0 rc1 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers) |
'---------------------------------------------------------------------------'
/**
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
* commands except TURN which will always return a not implemented
* error. SMTP also provides some utility methods for sending mail
* to an SMTP server.
* @package PHPMailer
* @author Chris Ryan
*/
class SMTP
@@ -66,8 +66,8 @@ class SMTP
public $do_verp = false;
/**#@+
* @access private
/**#@+
* @access private
*/
private $smtp_conn;
@@ -97,8 +97,8 @@ class SMTP
$this->do_debug = 0;
}
/*************************************************************
* CONNECTION FUNCTIONS *
/*************************************************************
* CONNECTION FUNCTIONS *
***********************************************************/
/**
@@ -125,9 +125,9 @@ class SMTP
if($this->connected())
{
/* ok we are connected! what should we do?
* for now we will just give an error saying we
* are already connected
/* ok we are connected! what should we do?
* for now we will just give an error saying we
* are already connected
*/
$this->error = array(
@@ -180,9 +180,9 @@ class SMTP
return false;
}
/* sometimes the SMTP server takes a little longer to respond
* so we will give it a longer timeout for the first read
* - Windows still does not have support for this timeout function
/* sometimes the SMTP server takes a little longer to respond
* so we will give it a longer timeout for the first read
* - Windows still does not have support for this timeout function
*/
if(substr(PHP_OS, 0, 3) != "WIN")socket_set_timeout($this->smtp_conn, $tval, 0);
@@ -340,8 +340,8 @@ class SMTP
}
}
/***************************************************************
* SMTP COMMANDS *
/***************************************************************
* SMTP COMMANDS *
*************************************************************/
/**
@@ -403,15 +403,15 @@ class SMTP
return false;
}
/* the server is ready to accept data!
* according to rfc 821 we should not send more than 1000
* including the CRLF
* characters on a single line so we will break the data up
* into lines by \r and/or \n then if needed we will break
* each of those into smaller lines to fit within the limit.
* in addition we will be looking for lines that start with
* a period '.' and append and additional period '.' to that
* line. NOTE: this does not count towards are limit.
/* the server is ready to accept data!
* according to rfc 821 we should not send more than 1000
* including the CRLF
* characters on a single line so we will break the data up
* into lines by \r and/or \n then if needed we will break
* each of those into smaller lines to fit within the limit.
* in addition we will be looking for lines that start with
* a period '.' and append and additional period '.' to that
* line. NOTE: this does not count towards are limit.
*/
// normalize the line breaks so we know the explode works
@@ -419,13 +419,13 @@ class SMTP
$msg_data = str_replace("\r", "\n", $msg_data);
$lines = explode("\n", $msg_data);
/* we need to find a good way to determine is headers are
* in the msg_data or if it is a straight msg body
* currently I am assuming rfc 822 definitions of msg headers
* and if the first field of the first line (':' sperated)
* does not contain a space then it _should_ be a header
* and we can process all lines before a blank "" line as
* headers.
/* we need to find a good way to determine is headers are
* in the msg_data or if it is a straight msg body
* currently I am assuming rfc 822 definitions of msg headers
* and if the first field of the first line (':' sperated)
* does not contain a space then it _should_ be a header
* and we can process all lines before a blank "" line as
* headers.
*/
$field = substr($lines[0], 0, strpos($lines[0], ":"));
@@ -467,9 +467,9 @@ class SMTP
$lines_out[] = substr($line, 0, $pos);
$line = substr($line, $pos + 1);
/* if we are processing headers we need to
* add a LWSP-char to the front of the new line
* rfc 822 on long msg headers
/* if we are processing headers we need to
* add a LWSP-char to the front of the new line
* rfc 822 on long msg headers
*/
if($in_headers)
@@ -1299,8 +1299,8 @@ class SMTP
return $rply;
}
/*******************************************************************
* INTERNAL FUNCTIONS *
/*******************************************************************
* INTERNAL FUNCTIONS *
******************************************************************/
/**
@@ -1345,4 +1345,4 @@ class SMTP
}
}
?>
?>

File diff suppressed because it is too large Load Diff