naming conventions

This commit is contained in:
Ulrich Block 2013-10-16 20:59:18 +02:00
parent 641e2b67eb
commit 3144d03643
12 changed files with 110 additions and 66 deletions

View File

@ -58,4 +58,5 @@ if ($ui->smallletters('w', 255, 'get') and isset($what_to_be_included_array[$ui-
include(IncludeTemplate($template_to_use, 'admin_header.tpl'));
include(IncludeTemplate($template_to_use, (isset($template_file) and preg_match('/^(.*)\.[\w]{1,}$/',$template_file)) ? $template_file : 'general.tpl'));
include(IncludeTemplate($template_to_use, 'admin_footer.tpl'));
$sql = null;

View File

@ -1,4 +1,5 @@
<?php
/**
* File: ajax.php.
* Author: Ulrich Block

View File

@ -1,4 +1,5 @@
<?php
/**
* File: api.php.
* Author: Ulrich Block
@ -39,12 +40,18 @@
define('EASYWIDIR', dirname(__FILE__));
if (is_dir(EASYWIDIR . '/install')) die('Please remove the "install" folder');
if (is_dir(EASYWIDIR . '/install')) {
die('Please remove the "install" folder');
}
$logininclude = true;
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/settings.php');
if ($ui->ip4('REMOTE_ADDR', 'server') and $ui->names('user',255, 'post')) {
$query = $sql->prepare("SELECT `ip`,`active`,`pwd`,`salt`,`user`,i.`resellerID` FROM `api_ips` i LEFT JOIN `api_settings` s ON i.`resellerID`=s.`resellerID` WHERE `ip`=?");
$query->execute(array($ui->ip4('REMOTE_ADDR', 'server')));

View File

@ -71,11 +71,12 @@ if (!isset($ip) or $_SERVER['SERVER_ADDR'] == $ip) {
$query = $sql->prepare("SELECT * FROM `api_import` WHERE `active`='Y'");
$query2 = $sql->prepare("UPDATE `userdata` SET `salutation`=?,`mail`=?,`cname`=?,`name`=?,`vname`=?,`birthday`=?,`country`=?,`phone`=?,`fax`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=? WHERE `sourceSystemID`=? AND `externalID`=? AND `resellerid`=? LIMIT 1");
$query3 = $sql->prepare("INSERT INTO `userdata` (`salutation`,`mail`,`cname`,`name`,`vname`,`birthday`,`country`,`phone`,`fax`,`handy`,`city`,`cityn`,`street`,`streetn`,`usergroup`,`sourceSystemID`,`externalID`,`security`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$query3 = $sql->prepare("INSERT INTO `userdata` (`accounttype`,`salutation`,`mail`,`cname`,`vname`,`name`,`birthday`,`country`,`phone`,`fax`,`handy`,`city`,`cityn`,`street`,`streetn`,`sourceSystemID`,`externalID`,`security`,`resellerid`) VALUES ('u',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
$query4 = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE `sourceSystemID`=? AND `externalID`=? LIMIT 1");
$query5 = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE LOWER(`mail`)=? AND LOWER(`cname`)=? LIMIT 1");
$query6 = $sql->prepare("UPDATE `userdata` SET `salutation`=?,`mail`=?,`cname`=?,`name`=?,`vname`=?,`birthday`=?,`country`=?,`phone`=?,`fax`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=?,`security`=? WHERE LOWER(`mail`)=? AND LOWER(`cname`)=? AND `resellerid`=? LIMIT 1");
$query6 = $sql->prepare("UPDATE `userdata` SET `salutation`=?,`mail`=?,`cname`=?,`vname`=?,`name`=?,`birthday`=?,`country`=?,`phone`=?,`fax`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=? WHERE LOWER(`mail`)=? AND LOWER(`cname`)=? AND `resellerid`=? LIMIT 1");
$query7 = $sql->prepare("UPDATE `api_import` SET `lastCheck`=?,`lastID`=? WHERE `importID`=? LIMIT 1");
$query8 = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `userID`=`userID`");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
@ -122,7 +123,7 @@ if (!isset($ip) or $_SERVER['SERVER_ADDR'] == $ip) {
$start += $row['chunkSize'];
unset($lastID);
foreach ($decoded->users as $value) {
foreach ($decoded->entries as $value) {
if (isset($value->externalID)) {
$query4->execute(array(json_encode(array('I' => $row['importID'])), $value->externalID));
@ -140,7 +141,7 @@ if (!isset($ip) or $_SERVER['SERVER_ADDR'] == $ip) {
$query5->execute(array(strtolower($value->email), strtolower($value->loginName)));
if ($query5->fetchColumn()>0 and $row['fetchUpdates'] == 'Y') {
$query6->execute(array(getParam('salutation'), strtolower(getParam('email')), getParam('loginName'), getParam('firstName'), getParam('lastName'), getParam('birthday'), getParam('country'), getParam('phone'), getParam('fax'), getParam('handy'), getParam('city'), getParam('cityn'), getParam('street'), getParam('streetn'), getParam('password'), strtolower($value->email), strtolower($value->loginName), $row['resellerID']));
$query6->execute(array(getParam('salutation'), strtolower(getParam('email')), getParam('loginName'), getParam('firstName'), getParam('lastName'), getParam('birthday'), getParam('country'), getParam('phone'), getParam('fax'), getParam('handy'), getParam('city'), getParam('cityn'), getParam('street'), getParam('streetn'), strtolower($value->email), strtolower($value->loginName), $row['resellerID']));
printText('User updated. Loginname: ' . $value->loginName.' e-mail: ' . strtolower($value->email));
} else if ($checkAmount > 0) {
@ -148,7 +149,8 @@ if (!isset($ip) or $_SERVER['SERVER_ADDR'] == $ip) {
} else {
printText('Import user. Loginname: ' . $value->loginName.' e-mail: ' . strtolower($value->email));
$query3->execute(array(getParam('salutation'), strtolower(getParam('email')), getParam('loginName'), getParam('firstName'), getParam('lastName'), getParam('birthday'), getParam('country'), getParam('phone'), getParam('fax'), getParam('handy'), getParam('city'), getParam('cityn'), getParam('street'), getParam('streetn'), $row['groupID'],json_encode(array('I' => $row['importID'])), getParam('externalID'), getParam('password'), $row['resellerID']));
$query3->execute(array(getParam('salutation'), strtolower(getParam('email')), getParam('loginName'), getParam('firstName'), getParam('lastName'), getParam('birthday'), getParam('country'), getParam('phone'), getParam('fax'), getParam('handy'), getParam('city'), getParam('cityn'), getParam('street'), getParam('streetn'), json_encode(array('I' => $row['importID'])), getParam('externalID'), getParam('password'), $row['resellerID']));
$query8->execute(array($sql->lastInsertId(), $row['groupID'], $row['resellerID']));
}
}

View File

@ -1,4 +1,5 @@
<?php
/**
* File: get_password.php.
* Author: Ulrich Block
@ -39,13 +40,16 @@
define('EASYWIDIR', dirname(__FILE__));
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/config.php');
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/settings.php');
include(EASYWIDIR . '/stuff/keyphrasefile.php');
$ip = $_SERVER['REMOTE_ADDR'];
if ($ui->st('w', 'get') == 'ms' and $ui->username('shorten','50', 'get')) {
$query = $sql->prepare("SELECT r.`id`,r.`resellerid`,r.`installing`,r.`updating`,d.`resellerid` AS `userid`,s.`steamVersion`,r.`localVersion` FROM `rservermasterg` r INNER JOIN `rserverdata` d ON r.`serverid`=d.`id` INNER JOIN `servertypes` s ON r.`servertypeid`=s.`id` WHERE s.`shorten`=? AND (d.`ip`=? OR d.`altips` LIKE ?) LIMIT 1");
$query->execute(array($ui->username('shorten','50', 'get'),$ip,'%'.$ip.'%'));

View File

@ -38,12 +38,13 @@
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
define('EASYWIDIR', dirname(__FILE__));
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/settings.php');
if (isset($admin_id) and $ui->st('img', 'get')) {
$pa = User_Permissions($admin_id);
$multiplier = 1;

View File

@ -1,4 +1,5 @@
<?php
/**
* File: index.php.
* Author: Ulrich Block
@ -37,13 +38,17 @@
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
define('EASYWIDIR', dirname(__FILE__));
$main = 1;
$page_include = 1;
define('EASYWIDIR', dirname(__FILE__));
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/settings.php');
if (isset ($page_active) and $page_active == 'Y') {
include(EASYWIDIR . '/stuff/init_page.php');
if (isset($throw404)) {

View File

@ -1,4 +1,5 @@
<?php
/**
* File: jobs.php.
* Author: Ulrich Block
@ -37,13 +38,13 @@
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
*/
if (isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
$timelimit=ini_get('max_execution_time')-10;
} else {
$timelimit=600;
}
if (isset($argv)) {
$args = array();
foreach ($argv as $a) {

View File

@ -46,7 +46,7 @@ $pa = User_Permissions($admin_id);
if (!isanyadmin($admin_id) and count($pa) == 0) {
redirect('login.php');
}
$licenceDetails=serverAmount($reseller_id);
$licenceDetails = serverAmount($reseller_id);
$gserver_module = (is_numeric($licenceDetails['mG']) and $licenceDetails['mG'] == 0) ? false : true;
$vserver_module = (is_numeric($licenceDetails['mVs']) and $licenceDetails['mVs'] == 0) ? false : true;
$voserver_module = (is_numeric($licenceDetails['mVo']) and $licenceDetails['mVo'] == 0) ? false : true;

View File

@ -280,19 +280,6 @@ if ($ui->st('d', 'get') == 'ud' and $reseller_id == 0 and $pa['updateEW'] and ($
if ($reseller_id == 0){
$rowspan = 8;
$contract = $licenceDetails['c'];
$contract = $sprache->$contract;
$contractTime = $licenceDetails['validUntil'];
$updates = $licenceDetails['updatesUntil'];
if ($licenceDetails['validUntil'] == '0000-00-00') {
$contractTime = $sprache->unlimited;
}
if ($licenceDetails['c'] == 'R') {
$updates = $contractTime;
} else if ($licenceDetails['updatesUntil'] == '0000-00-00') {
$updates = $sprache->unlimited;
}
} else {
$rowspan = 4;

View File

@ -1,4 +1,5 @@
<?php
/**
* File: trafficdata.php.
* Author: Ulrich Block
@ -37,32 +38,32 @@
ini_set('display_errors',1);
error_reporting(E_ALL|E_STRICT);
if (isset($_SERVER['REMOTE_ADDR'])) {
$remoteip = $_SERVER['REMOTE_ADDR'];
} else {
if (isset($argv[1])) {
$maxTime = $argv[1];
} else {
$maxTime=60;
}
if (isset($argv[2])) {
$memoryLimit = $argv[2];
} else {
$memoryLimit='64M';
}
ini_set('max_execution_time',$maxTime);
ini_set('memory_limit',$memoryLimit);
$maxTime = (isset($argv[1])) ? $argv[1]: 60;
$memoryLimit = (isset($argv[2])) ? $argv[2] : '64M';
ini_set('max_execution_time', $maxTime);
ini_set('memory_limit', $memoryLimit);
set_time_limit($maxTime);
print "The time is now: ".ini_get('max_execution_time')."\r\n";
print "The memory limit is now: ".ini_get('memory_limit')."\r\n";
print 'The time is now: ' . ini_get('max_execution_time') . "\r\n";
print 'The memory limit is now: ' . ini_get('memory_limit') . "\r\n";
}
if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
define('EASYWIDIR', dirname(__FILE__));
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/settings.php');
include(EASYWIDIR . '/stuff/keyphrasefile.php');
$query = $sql->prepare("SELECT `type`,`statip`,AES_DECRYPT(`dbname`,:aeskey) AS `decpteddbname`,AES_DECRYPT(`dbuser`,:aeskey) AS `decpteddbuser`,AES_DECRYPT(`dbpassword`,:aeskey) AS `decpteddbpassword`,`table_name`,`column_sourceip`,`column_destip`,`column_byte`,`column_date` FROM `traffic_settings` LIMIT 1");
$query->execute(array(':aeskey' => $aeskey));
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
@ -77,29 +78,32 @@ if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
$column_byte = $row['column_byte'];
$column_date = $row['column_date'];
}
try {
$sql2=new PDO("$stats_databanktype:host=$stats_host;dbname=$stats_db", $stats_user, $stats_pwd);
}
catch(PDOException $error) {
print $error->getMessage();
die("Could not connect to external server\r\n");
}
}
function searchinnerarray($value,$array) {
foreach ($array as $key => $ips) {
if (in_array($value,$ips)) {
$serverid = $key;
}
}
if (isset($serverid)) {
return $serverid;
}
return (isset($serverid)) ? $serverid : false;
}
$query = $sql->prepare("SELECT `ips`,`resellerid`,`resellersid` FROM `resellerdata`");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
$ids = $row['resellerid'] . '-' . $row['resellersid'];
$userips[$ids]=ipstoarray($row['ips']);
}
$query = $sql->prepare("SELECT `id`,`ip`,`ips` FROM `virtualcontainer`");
$query->execute();
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
@ -111,6 +115,7 @@ if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
}
$vserverips[$vserverid] = $vserverip;
}
$query = $sql2->prepare("SHOW PROCESSLIST");
$query->execute();
print "Killing active locks and threads regarding database $stats_db\r\n";
@ -121,29 +126,41 @@ if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
$query2->execute(array($row['Id']));
}
}
$pass = 1;
$Count = $sql2->prepare("SELECT COUNT(`id`) AS `amount` FROM `$table_name`");
$Count->execute();
$pass = 1;
$theCount = $Count->fetchColumn();
while ($theCount>100) {
while ($theCount > 100) {
$pass++;
$serverIDs = array();
$query = $sql2->prepare("SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
$query->execute();
$query = $sql2->prepare("SELECT `id`,`$column_sourceip`,`$column_destip`,`$column_byte`,`$column_date` FROM `$table_name` ORDER BY `id` LIMIT 300");
$query->execute();
$trafficData = $query->fetchAll(PDO::FETCH_ASSOC);
$query = $sql2->prepare("SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ");
$query->execute();
$query = $sql2->prepare("DELETE FROM `$table_name` ORDER BY `id` LIMIT 300");
$query->execute();
$currentCount = $theCount;
$Count->execute();
$theCount = $Count->fetchColumn();
print "Run: $pass; Found $currentCount traffic entries; Entries left after Run: $theCount\r\n";
$pass++;
$serverIDs = array();
foreach ($trafficData as $id => $row) {
unset($trafficData[$id]);
unset($serverid);
$data_id = $row['id'];
$ip_src = $row[$column_sourceip];
$ip_dst = $row[$column_destip];
@ -151,18 +168,22 @@ if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
$stamp_updated = $row[$column_date];
$date=explode(' ', $row[$column_date]);
$hour=explode(':',$date[1]);
$day = $date[0] . ' ' . $hour[0].":00:00";
$day = $date[0] . ' ' . $hour[0] . ':00:00';
if (searchinnerarray($ip_src,$vserverips) or searchinnerarray($ip_dst,$vserverips)) {
if (searchinnerarray($ip_src,$vserverips)) {
$direction="out";
$serverid=searchinnerarray($ip_src,$vserverips);
} else if (searchinnerarray($ip_dst,$vserverips)) {
$direction="in";
$serverid=searchinnerarray($ip_dst,$vserverips);
$direction = 'out';
$serverid = searchinnerarray($ip_src, $vserverips);
} else if (searchinnerarray($ip_dst, $vserverips)) {
$direction = 'in';
$serverid = searchinnerarray($ip_dst, $vserverips);
}
if (isset($serverid) and isset($serverIDs[$serverid])) {
$userid = $serverIDs[$serverid]['userid'];
$resellerid = $serverIDs[$serverid]['resellerid'];
} else if (isset($serverid)) {
$query2 = $sql->prepare("SELECT `userid`,`resellerid` FROM `virtualcontainer` WHERE `id`=? LIMIT 1");
$query2->execute(array($serverid));
@ -173,49 +194,58 @@ if (!isset($remoteip) or $_SERVER['SERVER_ADDR'] == $remoteip) {
$serverIDs[$serverid]['resellerid'] = $resellerid;
}
}
} else if (searchinnerarray($ip_src,$userips)) {
$direction="out";
} else if (searchinnerarray($ip_src, $userips)) {
$direction = 'out';
$serverid = 0;
$userids=searchinnerarray($ip_src,$userips);
$uids=explode("-",$userids);
$userids = searchinnerarray($ip_src, $userips);
$uids = explode('-', $userids);
$userid = $uids[0];
$resellerid = $uids[1];
} else if (searchinnerarray($ip_dst,$userips)) {
$direction="in";
} else if (searchinnerarray($ip_dst, $userips)) {
$direction = 'in';
$serverid = 0;
$userids=searchinnerarray($ip_dst,$userips);
$uids=explode("-",$userids);
$userids = searchinnerarray($ip_dst, $userips);
$uids = explode('-', $userids);
$userid = $uids[0];
$resellerid = $uids[1];
}
if (isset($serverid)) {
if ($direction=="in") {
if ($direction == 'in') {
$ip = $ip_dst;
$ipcase="ip_dst";
$ipcase = 'ip_dst';
} else {
$ip = $ip_src;
$ipcase="ip_src";
$ipcase = 'ip_src';
}
$query2 = $sql->prepare("SELECT `id` FROM `traffic_data` WHERE `ip`=? AND `day`=? AND `userid`=? AND `resellerid`=? LIMIT 1");
$query2->execute(array($ip,$day,$userid,$resellerid));
$query2->execute(array($ip, $day, $userid, $resellerid));
foreach ($query2->fetchAll(PDO::FETCH_ASSOC) as $row) {
$id = $row['id'];
}
if ($query2->rowcount()==1) {
if ($query2->rowCount()==1) {
$query2 = $sql->prepare("UPDATE `traffic_data` SET `$direction`=`$direction`+?,`serverid`=? WHERE `id`=? LIMIT 1");
$query2->execute(array($bytes,$id,$serverid));
$query2->execute(array($bytes, $id, $serverid));
} else {
$query2 = $sql->prepare("INSERT INTO `traffic_data` (`serverid`,`$direction`,`ip`,`day`,`userid`,`resellerid`) VALUES (?,?,?,?,?,?)");
$query2->execute(array($serverid,$bytes,$ip,$day,$userid,$resellerid));
$query2->execute(array($serverid, $bytes, $ip, $day, $userid, $resellerid));
}
}
}
}
print "Truncating $table_name\r\n";
$query = $sql2->prepare("TRUNCATE TABLE `$table_name`");
$query->execute();
$query = $sql2->prepare("OPTIMIZE TABLE `$table_name`");
$query->execute();
$sql = null;
$sql2 = null;
}

View File

@ -38,15 +38,18 @@
$main = 1;
define('EASYWIDIR', dirname(__FILE__));
if (is_dir(EASYWIDIR . '/install')) {
die('Please remove the "install" folder');
}
include(EASYWIDIR . '/stuff/functions.php');
include(EASYWIDIR . '/stuff/class_validator.php');
include(EASYWIDIR . '/stuff/vorlage.php');
include(EASYWIDIR . '/stuff/settings.php');
include(EASYWIDIR . '/stuff/init_user.php');
include(EASYWIDIR . '/stuff/userpanel_home.php');
if (isset($what_to_be_included_array[$w])) {
include(EASYWIDIR . '/stuff/' . $what_to_be_included_array[$w]);
unset($dbConnect);
@ -54,6 +57,7 @@ if (isset($what_to_be_included_array[$w])) {
unset($dbConnect);
$template_file = 'userpanel_home.tpl';
}
include(IncludeTemplate($template_to_use, 'userpanel_header.tpl'));
if (isset($template_file) and preg_match('/^(.*)\.tpl$/', $template_file)) {
include(IncludeTemplate($template_to_use, $template_file));
@ -61,4 +65,5 @@ if (isset($template_file) and preg_match('/^(.*)\.tpl$/', $template_file)) {
include(IncludeTemplate($template_to_use, 'general.tpl'));
}
include(IncludeTemplate($template_to_use, 'userpanel_footer.tpl'));
$sql = null;