diff --git a/lib/classes/database/class.Database.php b/lib/classes/database/class.Database.php index 7adc2094..fef3002f 100644 --- a/lib/classes/database/class.Database.php +++ b/lib/classes/database/class.Database.php @@ -53,6 +53,12 @@ class Database { */ private static $_dbname = null; + /** + * sql-access data + */ + private static $_needsqldata = false; + private static $_sqldata = null; + /** * Wrapper for PDOStatement::execute so we can catch the PDOException * and display the error nicely on the panel @@ -119,6 +125,40 @@ class Database { self::$_needroot = $needroot; } + /** + * enable the temporary access to sql-access data + * note: if you want root-sqldata you need to + * call needRoot(true) first. Also, this will + * only give you the data ONCE as it disable itself + * after the first access to the data + * + * @param bool $needsql + */ + public static function needSqlData($needsql = false) { + self::$_needsqldata = $needsql; + self::$_sqldata = array(); + self::$_link = null; + } + + /** + * returns the sql-access data as array using indeces + * 'user', 'passwd' and 'host'. Returns false if not enabled + * + * @return array|bool + */ + public static function getSqlData() { + if (self::$_sqldata !== null + && is_array(self::$_sqldata) + && isset(self::$_sqldata['user']) + ) { + return self::$_sqldata; + // automatically disable sql-data + self::$_sqldata = null; + self::$_needsqldata = false; + } + return false; + } + /** * let's us interact with the PDO-Object by using static * call like "Database::function()" @@ -194,6 +234,15 @@ class Database { $host = $sql["host"]; } + // save sql-access-data if needed + if (self::$_needsqldata) { + self::$_sqldata = array( + 'user' => $user, + 'passwd' => $password, + 'host' => $host + ); + } + // build up connection string $driver = 'mysql'; $dsn = $driver.":"; diff --git a/lib/classes/output/class.paging.php b/lib/classes/output/class.paging.php index 505d378c..5bdf4d8b 100644 --- a/lib/classes/output/class.paging.php +++ b/lib/classes/output/class.paging.php @@ -316,7 +316,12 @@ class paging { || ($natSorting === null && $this->natSorting == true) ) { // Acts similar to php's natsort(), found in one comment at http://my.opera.com/cpr/blog/show.dml/160556 - $sortcode = 'ORDER BY CONCAT( IF( ASCII( LEFT( ' . $sortfield . ', 5 ) ) > 57, LEFT( ' . $sortfield . ', 1 ), \'0\' ), IF( ASCII( RIGHT( ' . $sortfield . ', 1 ) ) > 57, LPAD( ' . $sortfield . ', 255, \'0\' ), LPAD( CONCAT( ' . $sortfield . ', \'-\' ), 255, \'0\' ) ) ) ' . $sortorder; + $sortcode = "ORDER BY CONCAT( IF( ASCII( LEFT( " . $sortfield . ", 5 ) ) > 57, + LEFT( " . $sortfield . ", 1 ), 0 ), + IF( ASCII( RIGHT( " . $sortfield . ", 1 ) ) > 57, + LPAD( " . $sortfield . ", 255, '0' ), + LPAD( CONCAT( " . $sortfield . ", '-' ), 255, '0' ) + )) " . $sortorder; } else { $sortcode = 'ORDER BY ' . $sortfield . ' ' . $sortorder; } diff --git a/scripts/jobs/cron_autoresponder.php b/scripts/jobs/cron_autoresponder.php index ab648791..49914f3c 100644 --- a/scripts/jobs/cron_autoresponder.php +++ b/scripts/jobs/cron_autoresponder.php @@ -24,39 +24,39 @@ $mail = new PHPMailer(true); //dont do anything when module is disabled -if((int)$settings['autoresponder']['autoresponder_active'] == 0) -{ +if ((int)$settings['autoresponder']['autoresponder_active'] == 0) { return; } //only send autoresponder to mails which were delivered since last run -if((int)$settings['autoresponder']['last_autoresponder_run'] == 0) -{ +if ((int)$settings['autoresponder']['last_autoresponder_run'] == 0) { //mails from last 5 minutes, otherwise all mails will be parsed -> mailbomb prevention $cycle = 300; -} -else -{ +} else { // calculate seconds since last check $cycle = time() - (int)$settings['autoresponder']['last_autoresponder_run']; - //prevent mailbombs when cycle is bigger than two days if($cycle > (2 * 60 * 60 * 24))$cycle = (60 * 60 * 24); } // set last_autoresponder_run -$db->query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = '" . (int)time() . "' WHERE `settinggroup` = 'autoresponder' AND `varname` = 'last_autoresponder_run'"); +$upd_stmt = Database::prepare(" + UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = :timeval + WHERE `settinggroup` = 'autoresponder' AND `varname` = 'last_autoresponder_run' +"); +Database::pexecute($upd_stmt, array('timeval' => time())); // get all customer set ip autoresponders -$result = $db->query("SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` INNER JOIN `" . TABLE_MAIL_USERS . "` ON `" . TABLE_MAIL_AUTORESPONDER . "`.`email` = `" . TABLE_MAIL_USERS . "`.`email` WHERE `enabled` = 1"); +$result_stmt = Database::query(" + SELECT * FROM `" . TABLE_MAIL_AUTORESPONDER . "` INNER JOIN `" . TABLE_MAIL_USERS . "` + ON `" . TABLE_MAIL_AUTORESPONDER . "`.`email` = `" . TABLE_MAIL_USERS . "`.`email` + WHERE `enabled` = 1 +"); -if($db->num_rows($result) > 0) -{ - while($row = $db->fetch_array($result)) - { - /* - * check if specific autoresponder should be used - */ +if (Database::num_rows() > 0) { + + while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { + //check if specific autoresponder should be used $ts_now = time(); $ts_start = (int)$row['date_from']; $ts_end = (int)$row['date_until']; @@ -69,11 +69,10 @@ if($db->num_rows($result) > 0) if($ts_end != -1 && $ts_end < $ts_now) continue; // setup mail-path (e.g. /var/customers/mail/[loginname]/[user@domain.tld]/new - $path = $row['homedir'] . $row['maildir'] . "new/"; + $path = makeCorrectDir($row['homedir'] . $row['maildir'] . "new/"); // if the directory does not exist, inform syslog - if(!is_dir($path)) - { + if (!is_dir($path)) { $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Error accessing maildir: " . $path); continue; } @@ -84,10 +83,8 @@ if($db->num_rows($result) > 0) ); $responded_counter = 0; - foreach ($its as $fullFilename => $it ) - { - if($it->getFilename() == '.' || $it->getFilename() == '..') - { + foreach ($its as $fullFilename => $it ) { + if ($it->getFilename() == '.' || $it->getFilename() == '..') { continue; } @@ -97,8 +94,7 @@ if($db->num_rows($result) > 0) * than our cycle-seconds? */ $filemtime = $it->getMTime(); - if(time() - $filemtime <= $cycle) - { + if (time() - $filemtime <= $cycle) { // why not read up to k lines? // I've been patching this forever, to avoid FATAL ERROR / memory exhausted // (fgets() is now binary safe, too) @@ -113,8 +109,7 @@ if($db->num_rows($result) > 0) } // error reading mail contents or just empty - if(count($content) == 0) - { + if (count($content) == 0) { $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Unable to read mail from maildir: " . dirname($fullFilename)); continue; } @@ -124,33 +119,31 @@ if($db->num_rows($result) > 0) $to = ''; $sender = ''; $spam = false; - foreach($content as $line) - { + foreach ($content as $line) { // header ends on first empty line, skip rest of mail - if(strlen(rtrim($line)) == 0) - { + if (strlen(rtrim($line)) == 0) { break; } //fetching from field - if(!strlen($from) - && preg_match("/^From:(.+)<(.*)>$/", $line, $match) + if (!strlen($from) + && preg_match("/^From:(.+)<(.*)>$/", $line, $match) ) { $from = strtolower($match[2]); } - elseif(!strlen($from) - && preg_match("/^From:\s+(.*@.*)$/", $line, $match) + elseif (!strlen($from) + && preg_match("/^From:\s+(.*@.*)$/", $line, $match) ) { $from = strtolower($match[1]); } //fetching to field - if((!strlen($to) || $to != $row['email']) + if ((!strlen($to) || $to != $row['email']) && preg_match("/^To:(.+)<(.*)>$/", $line, $match) ) { $to = strtolower($match[2]); } - elseif((!strlen($to) || $to != $row['email']) + elseif ((!strlen($to) || $to != $row['email']) && preg_match("/^To:\s+(.*@.*)$/", $line, $match) ) { $to = strtolower($match[1]); @@ -161,39 +154,38 @@ if($db->num_rows($result) > 0) * of the customer which autoresponder this is * we have to check for CC too, #476 */ - elseif((!strlen($to) || $to != $row['email']) + elseif ((!strlen($to) || $to != $row['email']) && preg_match("/^Cc:(.+)<(.*)>$/", $line, $match) ) { $to = strtolower($match[2]); } - elseif((!strlen($to) || $to != $row['email']) + elseif ((!strlen($to) || $to != $row['email']) && preg_match("/^Cc:\s+(.*@.*)$/", $line, $match) ) { $to = strtolower($match[1]); } - //fetching sender field - if(!strlen($sender) - && preg_match("/^Sender:(.+)<(.*)>$/", $line, $match) + // fetching sender field + if (!strlen($sender) + && preg_match("/^Sender:(.+)<(.*)>$/", $line, $match) ) { $sender = strtolower($match[2]); } - elseif(!strlen($sender) - && preg_match("/Sender:\s+(.*@.*)$/", $line, $match) + elseif (!strlen($sender) + && preg_match("/Sender:\s+(.*@.*)$/", $line, $match) ) { $sender = strtolower($match[1]); } //check for amavis/spamassassin spam headers - if(preg_match("/^X-Spam-Status: (Yes|No)(.*)$/", $line, $match)) - { - if($match[1] == 'Yes') + if (preg_match("/^X-Spam-Status: (Yes|No)(.*)$/", $line, $match)) { + if(strtolower($match[1]) == 'yes') { $spam = true; + } } - + //check for precedence header - if(preg_match("/^Precedence: (bulk|list|junk)(.*)$/", $line, $match)) - { + if (preg_match("/^Precedence: (bulk|list|junk)(.*)$/", $line, $match)) { // use the spam flag to skip reply $spam = true; } @@ -201,20 +193,17 @@ if($db->num_rows($result) > 0) // check if the receiver is really the one // with the autoresponder - if(!strlen($to) || $to != $row['email']) - { + if (!strlen($to) || $to != $row['email']) { $to = ''; } //skip mail when marked as spam - if($spam == true) - { + if ($spam == true) { continue; } //error while parsing mail - if($to == '' || $from == '') - { + if ($to == '' || $from == '') { $cronlog->logAction(CRON_ACTION, LOG_WARNING, "No valid headers found in mail to parse"); continue; } @@ -222,8 +211,7 @@ if($db->num_rows($result) > 0) //important! prevent mailbombs when mail comes from a maildaemon/mailrobot //robot/daemon mails must go to Sender: field in envelope header //refers to "Das Postfix-Buch" / RFC 2822 - if($sender != '') - { + if ($sender != '') { $from = $sender; } @@ -233,8 +221,7 @@ if($db->num_rows($result) > 0) //check if mail is already an answer $fullcontent = implode("", $content); - if(strstr($fullcontent, $message) || $from == $to) - { + if (strstr($fullcontent, $message) || $from == $to) { continue; } diff --git a/scripts/jobs/cron_backup.php b/scripts/jobs/cron_backup.php index fa58db07..76ebee09 100644 --- a/scripts/jobs/cron_backup.php +++ b/scripts/jobs/cron_backup.php @@ -15,115 +15,144 @@ * */ -if(@php_sapi_name() != 'cli'){ - die('This script will only work in the shell'); -} - -openRootDB($debugHandler, $lockfile); - /** * Backup - */ +*/ +if ($settings['system']['backup_enabled'] == '1') { -if($settings['system']['backup_enabled'] == '1'){ + fwrite($debugHandler, 'backup customers started...' . "\n"); - fwrite($debugHandler, 'backup customers started...' . "\n"); + // get sql-root access data for mysqldump + Database::needRoot(true); + Database::needSqlData(true); + $sql_root = Database::getSqlData(); + Database::needRoot(false); - $result = $db->query("SELECT customerid, loginname, guid, documentroot, backup_allowed, backup_enabled FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC;"); - while($row = $db->fetch_array($result)){ - fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' started...' . "\n"); + $result_stmt = Database::query(" + SELECT customerid, loginname, guid, documentroot, backup_allowed, backup_enabled + FROM `" . TABLE_PANEL_CUSTOMERS . "` ORDER BY `customerid` ASC; + "); - // backup - if($row['backup_allowed'] == '1' && $row['backup_enabled'] == '1'){ - // get uid & gid from ftp table - $ftp_result = $db->query("SELECT uid, gid FROM `" . TABLE_FTP_USERS . "` WHERE `username` = '" . $db->escape($row['loginname']) . "';"); - $ftp_row = mysql_fetch_array($ftp_result); + while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { - // create backup dir an set rights - if(!file_exists($settings['system']['backup_dir'] . $row['loginname'])) { - safe_exec('install -d ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . ' -o ' . escapeshellarg($ftp_row['uid']) . ' -g ' . escapeshellarg($ftp_row['gid']) . ' -m ' . '0500'); - } + fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' started...' . "\n"); - // create customers html backup - safe_exec('tar -C ' . escapeshellarg($row['documentroot']) . ' -c -z -f ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($row['loginname']) . 'html.tar.gz .'); + // backup + if ($row['backup_allowed'] == '1' + && $row['backup_enabled'] == '1' + ) { + // get uid & gid from ftp table + $ftp_result_stmt = Database::prepare(" + SELECT uid, gid FROM `" . TABLE_FTP_USERS . "` + WHERE `username` = :loginname + "); + $ftp_row = Database::pexecute_first($ftp_result_stmt, array('loginname' => $row['loginname'])); - // get customer dbs - $dbs_result = $db->query("SELECT databasename FROM `" . TABLE_PANEL_DATABASES . "` WHERE `customerid` = '" . $db->escape($row['customerid']) . "';"); - while($dbs_row = $db->fetch_array($dbs_result)){ - // create customers sql backup - safe_exec(escapeshellcmd($settings['system']['backup_mysqldump_path']) . ' --opt --force --allow-keywords -u ' . escapeshellarg($sql_root[0]['user']) . ' -p' . escapeshellarg($sql_root[0]['password']) . ' -h ' . $sql_root[0]['host'] . ' -B ' . escapeshellarg($dbs_row['databasename']) . ' -r ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql' ); - // compress sql backup - safe_exec('tar -C ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . ' -c -z -f ' . escapeshellarg($settings['system']['backup_dir']) . $row['loginname'] . '/' . escapeshellarg($dbs_row['databasename']) . '.tar.gz ' . escapeshellarg($dbs_row['databasename']) . '.sql'); - // remove uncompresed sql files - safe_exec('rm ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql'); - } - - // create 1 big file with html & db - if($settings['system']['backup_bigfile'] == 1){ - safe_exec('tar -C ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . ' --exclude=' . escapeshellarg($row['loginname']) . '.tar.gz -c -z -f ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($row['loginname']) . '.tar.gz .'); - // remove separated files - $tmp_files = scandir($settings['system']['backup_dir'] . $row['loginname']); - foreach ($tmp_files as $tmp_file){ - if(preg_match('/.*(html|sql|aps).*\.tar\.gz$/', $tmp_file) && !preg_match('/^' . $row['loginname'] . '\.tar\.gz$/', $tmp_file)){ - safe_exec('rm ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($tmp_file) . ''); - } - } - } - else { - //remove big file if separated backups are used - if (file_exists($settings['system']['backup_dir'] . $row['loginname'] . '/' . $row['loginname'] . '.tar.gz')) { - safe_exec('rm ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($row['loginname']) . '.tar.gz'); - } - } - - // chown & chmod files to prevent manipulation - safe_exec('chown ' . escapeshellarg($row['guid']) . ':' . escapeshellarg($row['guid']) . ' ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/*'); - safe_exec('chmod 0400 ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/*'); - - // create ftp backup user - $user_result = $db->query("SELECT username, password FROM `" . TABLE_FTP_USERS . "` WHERE `customerid` = '" . $db->escape($row['customerid']) . "' AND `username` = '" . $db->escape($row['loginname']) . "';"); - $user_row = mysql_fetch_array($user_result); - $db->query("REPLACE INTO `" . TABLE_FTP_USERS . "` (`customerid`, `username`, `password`, `homedir`, `login_enabled`, `uid`, `gid`) VALUES ('" . $db->escape($row['customerid']) . "', '" . $db->escape($row['loginname']) . "_backup', '" . $db->escape($user_row['password']) . "', '" . $db->escape($settings['system']['backup_dir']) . $db->escape($row['loginname']) . "/', 'y', '" . $db->escape($row['guid']) . "', '" . $db->escape($row['guid']) . "')"); - - if($settings['system']['backup_ftp_enabled'] == '1'){ - // upload backup to customers ftp server - $ftp_files = scandir($settings['system']['backup_dir'] . $row['loginname']); - foreach ($ftp_files as $ftp_file){ - if(preg_match('/.*\.tar\.gz$/', $ftp_file)){ - $ftp_con = ftp_connect($settings['system']['backup_ftp_server']); - $ftp_login = ftp_login($ftp_con, $settings['system']['backup_ftp_user'], $settings['system']['backup_ftp_pass']); - - /* Check whether to use passive mode or not */ - if($settings['system']['backup_ftp_passive'] == 1) - { - ftp_pasv($ftp_con, true); + // create backup dir an set rights + $_backupdir = makeCorrectDir($settings['system']['backup_dir'] . $row['loginname']); + if (!file_exists($_backupdir)) { + safe_exec('install -d ' . escapeshellarg($_backupdir) . ' -o ' . escapeshellarg($ftp_row['uid']) . ' -g ' . escapeshellarg($ftp_row['gid']) . ' -m ' . '0500'); } - else - { - ftp_pasv($ftp_con, false); - } - - $ftp_upload = ftp_put($ftp_con, $ftp_file, $settings['system']['backup_dir'] . $row['loginname'] . "/" . $ftp_file, FTP_BINARY); - } - } - } - fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' finished...' . "\n"); - } - - // delete old backup data (deletes backup if customer or admin disables backup) - elseif($row['backup_allowed'] == '0' || $row['backup_enabled'] == '0'){ - if (file_exists($settings['system']['backup_dir'] . $row['loginname'] . '/')){ - $files = scandir($settings['system']['backup_dir'] . $row['loginname'] . '/'); - foreach ($files as $file){ - if(preg_match('/.*\.tar\.gz$/', $file)){ - safe_exec('rm ' . escapeshellarg($settings['system']['backup_dir']) . escapeshellarg($row['loginname']) . '/' . escapeshellarg($file) . ''); - } + // create customers html backup + safe_exec('tar -C ' . escapeshellarg($row['documentroot']) . ' -c -z -f ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($row['loginname']) . 'html.tar.gz .'); + + // get customer dbs + $dbs_result_stmt = Database::prepare(" + SELECT `databasename` FROM `" . TABLE_PANEL_DATABASES . "` + WHERE `customerid` = :customerid + "); + Database::pexecute($dbs_result_stmt, array('customerid' => $row['customerid'])); + + while ($dbs_row = $dbs_result_stmt->fetch(PDO::FETCH_ASSOC)){ + // create customers sql backup + safe_exec(escapeshellcmd($settings['system']['backup_mysqldump_path']) . ' --opt --force --allow-keywords -u ' . escapeshellarg($sql_root['user']) . ' -p' . escapeshellarg($sql_root['passwd']) . ' -h ' . $sql_root['host'] . ' -B ' . escapeshellarg($dbs_row['databasename']) . ' -r ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql' ); + // compress sql backup + safe_exec('tar -C ' . escapeshellarg($_backupdir) . ' -c -z -f ' . escapeshellarg($settings['system']['backup_dir']) . $row['loginname'] . '/' . escapeshellarg($dbs_row['databasename']) . '.tar.gz ' . escapeshellarg($dbs_row['databasename']) . '.sql'); + // remove uncompresed sql files + safe_exec('rm ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($dbs_row['databasename']) . '.sql'); + } + + // create 1 big file with html & db + if ($settings['system']['backup_bigfile'] == 1) { + safe_exec('tar -C ' . escapeshellarg($_backupdir) . '/' . ' --exclude=' . escapeshellarg($row['loginname']) . '.tar.gz -c -z -f ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($row['loginname']) . '.tar.gz .'); + // remove separated files + $tmp_files = scandir($_backupdir); + foreach ($tmp_files as $tmp_file) { + if (preg_match('/.*(html|sql|aps).*\.tar\.gz$/', $tmp_file) && !preg_match('/^' . $row['loginname'] . '\.tar\.gz$/', $tmp_file)) { + safe_exec('rm ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($tmp_file)); + } + } + } else { + //remove big file if separated backups are used + if (file_exists(makeCorrectFile($_backupdir . '/' . $row['loginname'] . '.tar.gz'))) { + safe_exec('rm ' . escapeshellarg($_backupdir) . '/' . escapeshellarg($row['loginname']) . '.tar.gz'); + } + } + + // chown & chmod files to prevent manipulation + safe_exec('chown ' . escapeshellarg($row['guid']) . ':' . escapeshellarg($row['guid']) . ' ' . escapeshellarg($_backupdir) . '/*'); + safe_exec('chmod 0400 ' . escapeshellarg($_backupdir) . '/*'); + + // create ftp backup user + $user_result_stmt = Database::prepare(" + SELECT username, password FROM `" . TABLE_FTP_USERS . "` + WHERE `customerid` = :customerid AND `username` = :username; + "); + $user_row = Database::pexecute_first($user_result_stmt, array('customerid' => $row['customerid'], 'username' => $row['loginname'])); + + $ins_stmt = Database::prepare(" + REPLACE INTO `" . TABLE_FTP_USERS . "` + (`customerid`, `username`, `password`, `homedir`, `login_enabled`, `uid`, `gid`) + VALUES + (:customerid, :username, :password, :homedir, 'y', :guid, :guid) + "); + $ins_data = array( + 'customerid' => $row['customerid'], + 'username' => $row['loginname']."_backup", + 'password' => $user_row['password'], + 'homedir' => makeCorrectDir($settings['system']['backup_dir'].'/'.$row['loginname'].'/'), + 'guid' => $row['guid'] + ); + Database::pexecute($ins_stmt, $ins_data); + + if ($settings['system']['backup_ftp_enabled'] == '1') { + // upload backup to customers ftp server + $_ftpdir = makeCorrectDir($settings['system']['backup_dir'].'/'.$row['loginname'].'/'); + $ftp_files = scandir($_ftpdir); + + foreach ($ftp_files as $ftp_file) { + if (preg_match('/.*\.tar\.gz$/', $ftp_file)) { + + $ftp_con = ftp_connect($settings['system']['backup_ftp_server']); + $ftp_login = ftp_login($ftp_con, $settings['system']['backup_ftp_user'], $settings['system']['backup_ftp_pass']); + + // Check whether to use passive mode or not + if ($settings['system']['backup_ftp_passive'] == 1) { + ftp_pasv($ftp_con, true); + } else { + ftp_pasv($ftp_con, false); + } + $_file = makeCorrectFile($_ftpdir.'/'.$ftp_file); + $ftp_upload = ftp_put($ftp_con, $ftp_file, $_file, FTP_BINARY); + } + } + } + fwrite($debugHandler, 'backup for ' . $row['loginname'] . ' finished...' . "\n"); + } + // delete old backup data (deletes backup if customer or admin disables backup) + elseif ($row['backup_allowed'] == '0' || $row['backup_enabled'] == '0') { + $_ftpdir = makeCorrectDir($settings['system']['backup_dir'].'/'.$row['loginname'].'/'); + if (file_exists($_ftpdir)){ + $files = scandir($_ftpdir); + foreach ($files as $file) { + if (preg_match('/.*\.tar\.gz$/', $file)){ + $_file = makeCorrectFile($_ftpdir.'/'.$file); + safe_exec('rm -f ' . escapeshellarg($_file)); + } + } + } } - } } - } - fwrite($debugHandler, 'backup customers finished...' . "\n"); + fwrite($debugHandler, 'backup customers finished...' . "\n"); } - -?> diff --git a/scripts/jobs/cron_lighttp.htaccess.php b/scripts/jobs/cron_lighttp.htaccess.php deleted file mode 100644 index eecfcc19..00000000 --- a/scripts/jobs/cron_lighttp.htaccess.php +++ /dev/null @@ -1,161 +0,0 @@ - (2003-2009) - * @author Froxlor team (2010-) - * @license GPLv2 http://files.froxlor.org/misc/COPYING.txt - * @package Cron - * - */ - -/** - * LOOK INTO EVERY CUSTOMER DIR TO SEE IF THERE ARE ANY .HTACCESS FILE TO "TRANSLATE" - */ - -if($settings['system']['webserver'] == 'lighttpd') -{ - fwrite($debugHandler, ' cron_lighttp.htaccess: Searching for .htaccess files to translate' . "\n"); - $lpath = makeCorrectDir(strrchr($settings['system']['apacheconf_vhost'], '/')); - $htaccessfh = @fopen($lpath . 'syscp-htaccess.conf', 'w'); - - if($htaccessfh !== false) - { - read_directory($settings['system']['documentroot_prefix'], 25, $htaccessfh); - } - else - { - fwrite($debugHandler, ' ERROR: Cannot open file ' . $lpath . 'syscp-htaccess.conf' . "\n"); - } -} -else -{ - fwrite($debugHandler, ' cron_lighttp.htaccess: You don\'t use Lighttpd, you do not have to run this cronscript!' . "\n"); -} - -/** - * FUNCTIONS - */ - -function read_directory($dir1 = null, $min_depth = 25, $htaccessfh = null) -{ - global $htaccessfh, $theme; - - if(!is_string($dir1)) - { - return false; - } - - $depth = explode("/", $dir1); - $current_depth = sizeof($depth); - - if($current_depth < $min_depth) - { - $min_depth = $current_depth; - } - - $dir = $dir1; - $dh = opendir($dir); - - while($file = readdir($dh)) - { - if(($file != ".") - && ($file != "..")) - { - $file = $dir . "/" . $file; - for ($i = 0;$i <= ($current_depth - $min_depth);$i++) - - // $file is sub-directory - - if($ddh = @opendir($file)) - { - read_directory($file); - } - else - { - if(strtolower($file) == '.htaccess') - { - parseHtaccess($file); - } - } - } - } - - closedir($dh); - return true; -} - -function parseHtaccess($file = null) -{ - global $debugHandler, $htaccessfh, $theme; - $htacc = @file_get_contents($file); - - if($htacc != "") - { - $htlines = array(); - $htlines = explode("\n", $htacc); - $userhasrewrites = false; - $userrewrites = array(); - $rule = array(); - foreach($htlines as $htl) - { - if(preg_match('/^RewriteEngine\ on$/si', $htl) !== null) - { - $userhasrewrites = true; - } - elseif(preg_match('/^RewriteRule\ +\^(.*)\$\(.*)$/si', $htl, $rule) !== null) - { - $regex = isset($rule[0]) ? $rule[0] : ''; - $relativeuri = isset($rule[1]) ? $rule[1] : ''; - - if($regex != '' - && $relativeuri != '') - { - $userrewrites[]['regex'] = $regex; - $userrewrites[]['relativeuri'] = $relativeuri; - } - } - } - - if($userhasrewrites) - { - fwrite($htaccessfh, '$PHYSICAL["path"] == "' . dirname($file) . '" {' . "\n"); - fwrite($htaccessfh, ' url.rewrite-once = (' . "\n"); - $count = 1; - $max = count($userrewrites); - foreach($userrewrites as $usrrw) - { - fwrite($htaccessfh, ' "^' . $usrrw['regex'] . '$" => "' . $usrrw['relativeuri'] . '"'); - - if($count < $max) - { - fwrite($htaccessfh, ',' . "\n"); - } - else - { - fwrite($htaccessfh, "\n"); - } - - $count++; - } - - fwrite($htaccessfh, ' )' . "\n"); - fwrite($htaccessfh, '}' . "\n"); - } - } - else - { - fwrite($debugHandler, ' WARNING: file ' . $file . ' seems to be empty or there was an error' . "\n"); - return; - } -} - -?> diff --git a/scripts/jobs/cron_tasks.php b/scripts/jobs/cron_tasks.php index b9589ad1..542601e3 100644 --- a/scripts/jobs/cron_tasks.php +++ b/scripts/jobs/cron_tasks.php @@ -17,9 +17,7 @@ * */ -/* - * necessary includes - */ +// necessary includes require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.dns.10.bind.php'); require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.10.apache.php'); require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.15.apache_fcgid.php'); @@ -31,13 +29,15 @@ require_once makeCorrectFile(dirname(__FILE__) . '/cron_tasks.inc.http.35.nginx_ /** * LOOK INTO TASKS TABLE TO SEE IF THERE ARE ANY UNDONE JOBS */ - fwrite($debugHandler, ' cron_tasks: Searching for tasks to do' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, "Searching for tasks to do"); -$result_tasks = $db->query("SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `id` ASC"); +$result_tasks_stmt = Database::query(" + SELECT `id`, `type`, `data` FROM `" . TABLE_PANEL_TASKS . "` ORDER BY `id` ASC +"); +$num_results = Database::num_rows(); $resultIDs = array(); -while ($row = $db->fetch_array($result_tasks)) { +while ($row = $result_tasks_stmt->fetch(PDO::FETCH_ASSOC)) { $resultIDs[] = $row['id']; @@ -48,7 +48,6 @@ while ($row = $db->fetch_array($result_tasks)) { /** * TYPE=1 MEANS TO REBUILD APACHE VHOSTS.CONF */ - if ($row['type'] == '1') { // get configuration-I/O object @@ -89,6 +88,7 @@ while ($row = $db->fetch_array($result_tasks)) { } /** + * FIXME * as we might have a change from mod_php to fcgid/fpm or the other way around * we need to check customer directory permissions * -> 0.9.31 @@ -104,20 +104,28 @@ while ($row = $db->fetch_array($result_tasks)) { fwrite($debugHandler, ' cron_tasks: Task2 started - create new home' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task2 started - create new home'); - if(is_array($row['data'])) - { + if (is_array($row['data'])) { // define paths $userhomedir = makeCorrectDir($settings['system']['documentroot_prefix'] . '/' . $row['data']['loginname'] . '/'); $usermaildir = makeCorrectDir($settings['system']['vmail_homedir'] . '/' . $row['data']['loginname'] . '/'); // stats directory - if($settings['system']['awstats_enabled'] == '1') - { + if ($settings['system']['awstats_enabled'] == '1') { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($userhomedir . 'awstats')); safe_exec('mkdir -p ' . escapeshellarg($userhomedir . 'awstats')); + // in case we changed from the other stats -> remove old + // (yes i know, the stats are lost - that's why you should not change all the time!) + if (file_exists($userhomedir . 'webalizer')) { + safe_exec('rm -rf ' . escapeshellarg($userhomedir . 'webalizer')); + } } else { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: mkdir -p ' . escapeshellarg($userhomedir . 'webalizer')); safe_exec('mkdir -p ' . escapeshellarg($userhomedir . 'webalizer')); + // in case we changed from the other stats -> remove old + // (yes i know, the stats are lost - that's why you should not change all the time!) + if (file_exists($userhomedir . 'awstats')) { + safe_exec('rm -rf ' . escapeshellarg($userhomedir . 'awstats')); + } } // maildir @@ -125,8 +133,7 @@ while ($row = $db->fetch_array($result_tasks)) { safe_exec('mkdir -p ' . escapeshellarg($usermaildir)); //check if admin of customer has added template for new customer directories - if((int)$row['data']['store_defaultindex'] == 1) - { + if ((int)$row['data']['store_defaultindex'] == 1) { storeDefaultIndex($row['data']['loginname'], $userhomedir, $cronlog, true); } @@ -141,25 +148,15 @@ while ($row = $db->fetch_array($result_tasks)) { } } - /** - * TYPE=3 MEANS TO DO NOTHING - */ - elseif ($row['type'] == '3') - { - } - /** * TYPE=4 MEANS THAT SOMETHING IN THE BIND CONFIG HAS CHANGED. REBUILD froxlor_bind.conf IF BIND IS ENABLED */ - elseif ($row['type'] == '4' && (int)$settings['system']['bind_enable'] != 0) - { - if(!isset($nameserver)) - { + elseif ($row['type'] == '4' && (int)$settings['system']['bind_enable'] != 0) { + if (!isset($nameserver)) { $nameserver = new bind($db, $cronlog, $debugHandler, $settings); } - if($settings['dkim']['use_dkim'] == '1') - { + if ($settings['dkim']['use_dkim'] == '1') { $nameserver->writeDKIMconfigs(); } @@ -169,13 +166,16 @@ while ($row = $db->fetch_array($result_tasks)) { /** * TYPE=5 MEANS THAT A NEW FTP-ACCOUNT HAS BEEN CREATED, CREATE THE DIRECTORY */ - elseif ($row['type'] == '5') - { + elseif ($row['type'] == '5') { $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Creating new FTP-home'); - $result_directories = $db->query('SELECT `f`.`homedir`, `f`.`uid`, `f`.`gid`, `c`.`documentroot` AS `customerroot` FROM `' . TABLE_FTP_USERS . '` `f` LEFT JOIN `' . TABLE_PANEL_CUSTOMERS . '` `c` USING (`customerid`) WHERE `f`.`username` NOT LIKE \'%_backup\''); + // FIXME %_backup clause not necessary after backup-feature is being removed + $result_directories_stmt = Database::query(" + SELECT `f`.`homedir`, `f`.`uid`, `f`.`gid`, `c`.`documentroot` AS `customerroot` + FROM `" . TABLE_FTP_USERS . "` `f` LEFT JOIN `" . TABLE_PANEL_CUSTOMERS . "` `c` USING (`customerid`) + WHERE `f`.`username` NOT LIKE '%_backup' + "); - while($directory = $db->fetch_array($result_directories)) - { + while ($directory = $db->fetch_array($result_directories)) { mkDirWithCorrectOwnership($directory['customerroot'], $directory['homedir'], $directory['uid'], $directory['gid']); } } @@ -183,90 +183,77 @@ while ($row = $db->fetch_array($result_tasks)) { /** * TYPE=6 MEANS THAT A CUSTOMER HAS BEEN DELETED AND THAT WE HAVE TO REMOVE ITS FILES */ - elseif ($row['type'] == '6') - { + elseif ($row['type'] == '6') { fwrite($debugHandler, ' cron_tasks: Task6 started - deleting customer data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task6 started - deleting customer data'); - if(is_array($row['data'])) - { - if(isset($row['data']['loginname'])) - { - /* - * remove homedir - */ + if (is_array($row['data'])) { + if (isset($row['data']['loginname'])) { + // remove homedir $homedir = makeCorrectDir($settings['system']['documentroot_prefix'] . '/' . $row['data']['loginname']); - if($homedir != '/' - && $homedir != $settings['system']['documentroot_prefix'] - && substr($homedir, 0, strlen($settings['system']['documentroot_prefix'])) == $settings['system']['documentroot_prefix']) - { + if (file_exists($homedir) + && $homedir != '/' + && $homedir != $settings['system']['documentroot_prefix'] + && substr($homedir, 0, strlen($settings['system']['documentroot_prefix'])) == $settings['system']['documentroot_prefix'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($homedir)); safe_exec('rm -rf '.escapeshellarg($homedir)); } - /* - * remove backup dir - */ + // remove backup dir + // FIXME remove when backup-feature has been removed $backupdir = makeCorrectDir($settings['system']['backup_dir'] . $row['data']['loginname']); - if($backupdir != '/' - && $backupdir != $settings['system']['backup_dir'] - && substr($backupdir, 0, strlen($settings['system']['backup_dir'])) == $settings['system']['backup_dir']) - { + if (file_exists($backupdir) + && $backupdir != '/' + && $backupdir != $settings['system']['backup_dir'] + && substr($backupdir, 0, strlen($settings['system']['backup_dir'])) == $settings['system']['backup_dir'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($backupdir)); safe_exec('rm -rf '.escapeshellarg($backupdir)); } - /* - * remove maildir - */ + // remove maildir $maildir = makeCorrectDir($settings['system']['vmail_homedir'] . '/' . $row['data']['loginname']); - if($maildir != '/' - && $maildir != $settings['system']['vmail_homedir'] - && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] - && is_dir($maildir) - && fileowner($maildir) == $settings['system']['vmail_uid'] - && filegroup($maildir) == $settings['system']['vmail_gid']) - { + if (file_exists($maildir) + && $maildir != '/' + && $maildir != $settings['system']['vmail_homedir'] + && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] + && is_dir($maildir) + && fileowner($maildir) == $settings['system']['vmail_uid'] + && filegroup($maildir) == $settings['system']['vmail_gid'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir)); safe_exec('rm -rf '.escapeshellarg($maildir)); } - /* - * remove tmpdir if it exists - */ + // remove tmpdir if it exists $tmpdir = makeCorrectDir($settings['system']['mod_fcgid_tmpdir'] . '/' . $row['data']['loginname'] . '/'); - if (is_dir($tmpdir) - && $tmpdir != "/" - && $tmpdir != $settings['system']['mod_fcgid_tmpdir'] - && substr($tmpdir, 0, strlen($settings['system']['mod_fcgid_tmpdir'])) == $settings['system']['mod_fcgid_tmpdir']) - { + if (file_exists($tmpdir) + && is_dir($tmpdir) + && $tmpdir != "/" + && $tmpdir != $settings['system']['mod_fcgid_tmpdir'] + && substr($tmpdir, 0, strlen($settings['system']['mod_fcgid_tmpdir'])) == $settings['system']['mod_fcgid_tmpdir'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($tmpdir)); safe_exec('rm -rf '.escapeshellarg($tmpdir)); } - /* - * see if we have some php-fcgid leftovers if used - * and remove them, #200 - * UPDATE: this is being done in ConfigIO::cleanUp() - */ - - /** - * webserver logs - */ + // webserver logs $logsdir = makeCorrectFile($settings['system']['logfiles_directory'].'/'.$row['data']['loginname']); - if ($logsdir != '/' + + if (file_exists($logsdir) + && $logsdir != '/' && $logsdir != makeCorrectDir($settings['system']['logfiles_directory']) && substr($logsdir, 0, strlen($settings['system']['logfiles_directory'])) == $settings['system']['logfiles_directory'] ) { // build up wildcard for webX-{access,error}.log{*} - $logfiles = $logsdir.'-*'; + $logfiles .= '-*'; safe_exec('rm -f '.escapeshellarg($logfiles)); } - } } } @@ -274,53 +261,56 @@ while ($row = $db->fetch_array($result_tasks)) { /** * TYPE=7 Customer deleted an email account and wants the data to be deleted on the filesystem */ - elseif ($row['type'] == '7') - { + elseif ($row['type'] == '7') { fwrite($debugHandler, ' cron_tasks: Task7 started - deleting customer e-mail data' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task7 started - deleting customer e-mail data'); - if(is_array($row['data'])) - { - if(isset($row['data']['loginname']) + if (is_array($row['data'])) { + + if (isset($row['data']['loginname']) && isset($row['data']['email']) ) { - /* - * remove specific maildir - */ + // remove specific maildir $email_full = $row['data']['email']; if (empty($email_full)) { $cronlog->logAction(CRON_ACTION, LOG_ERROR, 'FATAL: Task7 asks to delete a email account but email field is empty!'); } - $email_user=substr($email_full,0,strrpos($email_full,"@")); - $email_domain=substr($email_full,strrpos($email_full,"@")+1); - $maildirname=trim($settings['system']['vmail_maildirname']); + $email_user = substr($email_full,0,strrpos($email_full,"@")); + $email_domain = substr($email_full,strrpos($email_full,"@")+1); + $maildirname = trim($settings['system']['vmail_maildirname']); // Add trailing slash to Maildir if needed - $maildirpath=$maildirname; - if (!empty($maildirname) and substr($maildirname,-1) != "/") $maildirpath.="/"; + $maildirpath = $maildirname; + if (!empty($maildirname) and substr($maildirname,-1) != "/") { + $maildirpath .= "/"; + } + $maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $email_domain .'/'. $email_user); - if($maildir != '/' && !empty($maildir) && !empty($email_full) - && $maildir != $settings['system']['vmail_homedir'] - && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] - && is_dir($maildir) - && is_dir(makeCorrectDir($maildir.'/'.$maildirpath)) - && fileowner($maildir) == $settings['system']['vmail_uid'] - && filegroup($maildir) == $settings['system']['vmail_gid']) - { + if ($maildir != '/' + && !empty($maildir) + && !empty($email_full) + && $maildir != $settings['system']['vmail_homedir'] + && substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] + && is_dir($maildir) + && is_dir(makeCorrectDir($maildir.'/'.$maildirpath)) + && fileowner($maildir) == $settings['system']['vmail_uid'] + && filegroup($maildir) == $settings['system']['vmail_gid'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir)); safe_exec('rm -rf '.escapeshellarg($maildir)); - } - else { + + } else { // backward-compatibility for old folder-structure $maildir_old = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $row['data']['email']); - if ($maildir_old != '/' && !empty($maildir_old) + if ($maildir_old != '/' + && !empty($maildir_old) && $maildir_old != $settings['system']['vmail_homedir'] && substr($maildir_old, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'] && is_dir($maildir_old) && fileowner($maildir_old) == $settings['system']['vmail_uid'] - && filegroup($maildir_old) == $settings['system']['vmail_gid']) - { + && filegroup($maildir_old) == $settings['system']['vmail_gid'] + ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir_old)); safe_exec('rm -rf '.escapeshellarg($maildir_old)); } @@ -333,25 +323,23 @@ while ($row = $db->fetch_array($result_tasks)) { * TYPE=8 Customer deleted a ftp account and wants the homedir to be deleted on the filesystem * refs #293 */ - elseif ($row['type'] == '8') - { + elseif ($row['type'] == '8') { fwrite($debugHandler, ' cron_tasks: Task8 started - deleting customer ftp homedir' . "\n"); $cronlog->logAction(CRON_ACTION, LOG_INFO, 'Task8 started - deleting customer ftp homedir'); - if(is_array($row['data'])) - { - if(isset($row['data']['loginname']) + if (is_array($row['data'])) { + + if (isset($row['data']['loginname']) && isset($row['data']['homedir']) ) { - /* - * remove specific homedir - */ + // remove specific homedir $ftphomedir = makeCorrectDir($row['data']['homedir']); $customerdocroot = makeCorrectDir($settings['system']['documentroot_prefix'].'/'.$row['data']['loginname'].'/'); - if($ftphomedir != '/' - && $ftphomedir != $settings['system']['documentroot_prefix'] - && $ftphomedir != $customerdocroot + if(file_exists($ftphomedir) + && $ftphomedir != '/' + && $ftphomedir != $settings['system']['documentroot_prefix'] + && $ftphomedir != $customerdocroot ) { $cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($ftphomedir)); safe_exec('rm -rf '.escapeshellarg($ftphomedir)); @@ -371,8 +359,8 @@ while ($row = $db->fetch_array($result_tasks)) { $usedquota = getFilesystemQuota(); // Select all customers Froxlor knows about - $result = $db->query("SELECT `guid`, `loginname`, `diskspace` FROM `" . TABLE_PANEL_CUSTOMERS . "`;"); - while ($row = $db->fetch_array($result)) { + $result_stmt = Database::query("SELECT `guid`, `loginname`, `diskspace` FROM `" . TABLE_PANEL_CUSTOMERS . "`;"); + while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { // We do not want to set a quota for root by accident if ($row['guid'] != 0) { // The user has no quota in Froxlor, but on the filesystem @@ -394,15 +382,18 @@ while ($row = $db->fetch_array($result_tasks)) { } } -if ($db->num_rows($result_tasks) != 0) { +if ($num_results != 0) { $where = array(); + $where_data = array(); foreach ($resultIDs as $id) { - $where[] = '`id`=\'' . (int)$id . '\''; + $where[] = "`id` = :id_" . (int)$id; + $where_data['id_'.$id] = $id; } $where = implode($where, ' OR '); - $db->query('DELETE FROM `' . TABLE_PANEL_TASKS . '` WHERE ' . $where); + $del_stmt = Database::prepare("DELETE FROM `" . TABLE_PANEL_TASKS . "` WHERE " . $where); + Database::pexecute($del_stmt, $where_data); unset($resultIDs); unset($where); } -$db->query('UPDATE `' . TABLE_PANEL_SETTINGS . '` SET `value` = UNIX_TIMESTAMP() WHERE `settinggroup` = \'system\' AND `varname` = \'last_tasks_run\' '); +Database::query("UPDATE `" . TABLE_PANEL_SETTINGS . "` SET `value` = UNIX_TIMESTAMP() WHERE `settinggroup` = 'system' AND `varname` = 'last_tasks_run';"); diff --git a/scripts/jobs/cron_traffic.php b/scripts/jobs/cron_traffic.php index 95aaa588..2c2d9d91 100644 --- a/scripts/jobs/cron_traffic.php +++ b/scripts/jobs/cron_traffic.php @@ -378,7 +378,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { 'mail' => $current_diskspace['mail'], 'mysql' => $current_diskspace['mysql'] ); - $ins_stmt = Database::preapre(" + $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_PANEL_DISKSPACE . "` SET `customerid` = :customerid, `year` = :year, @@ -535,7 +535,7 @@ while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) { 'mail' => $admin_diskspace[$row['adminid']]['mail'], 'mysql' => $admin_diskspace[$row['adminid']]['mysql'] ); - $ins_stmt = Database::preapre(" + $ins_stmt = Database::prepare(" INSERT INTO `" . TABLE_PANEL_DISKSPACE_ADMINS . "` SET `adminid` = :adminid, `year` = :year,