diff --git a/web/ajax.php b/web/ajax.php index ad38c10f..5b8a6a21 100644 --- a/web/ajax.php +++ b/web/ajax.php @@ -132,6 +132,11 @@ if ($ui->smallletters('w', 9, 'get') == 'datatable') { require_once(EASYWIDIR . '/stuff/ajax/datatable_appserver.php'); + // App server + } else if ($ui->smallletters('d', 4, 'get') == 'user' and isset($admin_id) and isset($reseller_id) and isset($resellerLockupID) and ($pa['user'] or $pa['user_users'] or $pa['userPassword'])) { + + require_once(EASYWIDIR . '/stuff/ajax/datatable_user.php'); + // Code wise it seems odd, but this way we can get plausible userIDs for following queries up front without having to repeat ourselves } else { diff --git a/web/languages/default/de/general.xml b/web/languages/default/de/general.xml index a269616e..00c610a2 100644 --- a/web/languages/default/de/general.xml +++ b/web/languages/default/de/general.xml @@ -53,6 +53,7 @@ Die Status Informationen werden alle %n% Minuten aktualisiert. Hostsystem Hotline + Inaktiv Importieren Impressum Jobs diff --git a/web/languages/default/dk/general.xml b/web/languages/default/dk/general.xml index b3167a01..870cb7e8 100644 --- a/web/languages/default/dk/general.xml +++ b/web/languages/default/dk/general.xml @@ -36,6 +36,7 @@ Grupper Værtssystem Hotline + Impressum Job Job afventer diff --git a/web/languages/default/uk/general.xml b/web/languages/default/uk/general.xml index 0e0092d1..97ad4020 100644 --- a/web/languages/default/uk/general.xml +++ b/web/languages/default/uk/general.xml @@ -57,6 +57,7 @@ The status information are gathered every %n% minutes. Hostsystem Hotline + Inactive Import Imprint Jobs diff --git a/web/stuff/admin/user.php b/web/stuff/admin/user.php index 78f67f02..fe24fa74 100644 --- a/web/stuff/admin/user.php +++ b/web/stuff/admin/user.php @@ -35,878 +35,638 @@ * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem * Programm erhalten haben. Wenn nicht, siehe . */ - -include(EASYWIDIR . '/stuff/keyphrasefile.php'); -include(EASYWIDIR . '/third_party/password_compat/password.php'); -if ((!isset($admin_id) or $main != 1) or (isset($admin_id) and !$pa['user'] and !$pa['user_users'])) { - header('Location: admin.php'); +if ((!isset($admin_id) or $main != 1) or (isset($admin_id) and !$pa['user'] and !$pa['user_users'] and !$pa['userPassword'])) { + header('Location: admin.php'); die(); } -$sprache = getlanguagefile('user',$user_language,$reseller_id); -$rsprache = getlanguagefile('reseller',$user_language,$reseller_id); +include(EASYWIDIR . '/stuff/keyphrasefile.php'); +include(EASYWIDIR . '/third_party/password_compat/password.php'); + +$sprache = getlanguagefile('user', $user_language, $reseller_id); +$rsprache = getlanguagefile('reseller', $user_language, $reseller_id); $loguserid = $admin_id; $logusername = getusername($admin_id); $logusertype = 'admin'; if ($reseller_id == 0) { - $logreseller = 0; - $logsubuser = 0; + $logreseller = 0; + $logsubuser = 0; } else { $logsubuser = (isset($_SESSION['oldid'])) ? $_SESSION['oldid'] : 0; - $logreseller = 0; + $logreseller = 0; } -if ($ui->w('action', 4, 'post') and !token(true)) { - $template_file = $spracheResponse->token; +// Define the ID variable which will be used at the form and SQLs +$id = $ui->id('id', 10, 'get'); -} else if ($ui->st('d', 'get') == 'ad') { - if ($ui->smallletters('action',2, 'post') == 'ad') { +// Default variables. Mostly needed for the add operation +$externalID = $ui->escaped('externalID', 'post'); +$passwordRepeat = $ui->password('pass2', 255, 'post'); +$salutation = $ui->isinteger('salutation', 'post'); +$name = $ui->names('name', 255, 'post'); +$vname = $ui->names('vname', 255, 'post'); +$mail = $ui->ismail('mail', 'post'); +$phone = $ui->phone('phone', 'post'); +$handy = $ui->phone('handy', 'post'); +$city = $ui->names('city', 50, 'post'); +$cityn = $ui->id('cityn', 6, 'post'); +$street = $ui->names('street', 50, 'post'); +$streetn = $ui->streetNumber('streetn', 'post'); +$country = $ui->st('country', 'post'); +$fax = $ui->phone('fax', 'post'); +$fdlpath = $ui->url('fdlpath', 'post'); - $error = array(); +$active = ($ui->active('active', 'post')) ? $ui->active('active', 'post') : 'Y'; +$useractive = ($ui->active('useractive', 'post')) ? $ui->active('useractive', 'post') : 'Y'; +$accountType = ($ui->smallletters('accounttype', 1, 'post')) ? $ui->smallletters('accounttype', 1, 'post') : ''; +$password = ($ui->password('password', 255, 'post')) ? $ui->password('password', 255, 'post') : passwordgenerate(10); +$birthday = date('Y-m-d', strtotime($ui->isDate('birthday', 'post'))); +$maxuser = ($ui->id('maxuser', 10, 'post')) ? $ui->id('maxuser', 10, 'post') : 0; +$maxgserver = ($ui->id('maxgserver', 10, 'post')) ? $ui->id('maxgserver', 10, 'post') : 0; +$maxvoserver = ($ui->id('maxvoserver', 10, 'post')) ? $ui->id('maxvoserver', 10, 'post') : 0; +$maxvserver = ($ui->id('maxvserver', 10, 'post') and $easywiModules['ro']) ? $ui->id('maxvserver', 10, 'post') : 0; +$maxdedis = ($ui->id('maxdedis', 10, 'post') and $easywiModules['ro']) ? $ui->id('maxdedis', 10, 'post') : 0; +$maxuserram = ($ui->id('maxuserram', 255, 'post') and $easywiModules['ro']) ? $ui->id('maxuserram', 255, 'post') : 0; +$maxusermhz = ($ui->id('maxusermhz', 255, 'post') and $easywiModules['ro']) ? $ui->id('maxusermhz', 255, 'post') : 0; + +$mail_backup = ($ui->active('mail_backup', 'post')) ? $ui->active('mail_backup', 'post') : 'N'; +$mail_serverdown = ($ui->active('mail_serverdown', 'post')) ? $ui->active('mail_serverdown', 'post') : 'N'; +$mail_ticket = ($ui->active('mail_ticket', 'post')) ? $ui->active('mail_ticket', 'post') : 'N'; +$mail_gsupdate = ($ui->active('mail_gsupdate', 'post')) ? $ui->active('mail_gsupdate', 'post') : 'N'; +$mail_securitybreach = ($ui->active('mail_securitybreach', 'post')) ? $ui->active('mail_securitybreach', 'post') : 'N'; +$mail_vserver = ($ui->active('mail_vserver', 'post')) ? $ui->active('mail_vserver', 'post') : 'N'; + +if ($accountType == 'a' and $ui->username('acname', 255, 'post')) { + $cname = $ui->username('acname', 255, 'post'); +} else if ($accountType == 'r' and $ui->username('rcname', 255, 'post')) { + $cname = $ui->username('rcname', 255, 'post'); +} else if ($accountType == 'u' and $ui->username('cname', 255, 'post')) { + $cname = $ui->username('cname', 255, 'post'); +} else { + $cname = $rSA['prefix2']; +} + +$bogus = $cname . $mail; + +if ($accountType == 'r') { + + $userGroups = (array) $ui->id('groups_r', 10, 'post'); + + $mail_gsupdate = ($ui->active('rmail_gsupdate', 'post')) ? $ui->active('rmail_gsupdate', 'post') : 'N'; + $mail_securitybreach = ($ui->active('rmail_securitybreach', 'post')) ? $ui->active('rmail_securitybreach', 'post') : 'N'; + $mail_vserver = ($ui->active('rmail_vserver', 'post')) ? $ui->active('rmail_vserver', 'post') : 'N'; + +} else if ($accountType == 'a') { + $userGroups = (array) $ui->id('groups_a', 10, 'post'); +} else if ($accountType == 'u') { + $userGroups = (array) $ui->id('groups_u', 10, 'post'); +} else if ($ui->id('groups', 10, 'post')) { + $userGroups = (array) $ui->id('groups', 10, 'post'); +} else { + $userGroups = array(); +} + +$query = $sql->prepare("SELECT `accounttype` FROM `userdata` WHERE `id`=? LIMIT 1"); +$query->execute(array($admin_id)); +$userAccounttype = $query->fetchColumn(); + +// CSFR protection with hidden tokens. If token(true) returns false, we likely have an attack +if ($ui->w('action',4, 'post') and !token(true)) { + + unset($header, $text); + + $errors = array($spracheResponse->token); + + $template_file = ($ui->st('d', 'get') == 'ad') ? 'admin_user_add.tpl' : 'admin_user_md.tpl'; + +// Add and modify entries. Same validation can be used. +} else if (($ui->st('d', 'get') == 'ad' or ($ui->st('d', 'get') == 'md') and ($id != $admin_id or $reseller_id == 0)) and ($pa['user'] or $pa['user_users']) and (($accountType == 'a' and $pa['user']) or $accountType != 'a' and ($pa['user'] or $pa['user_users']))) { + + // Error handling. Check if required attributes are set and can be validated + $errors = array(); + + $selectlanguages = getlanguages($template_to_use); + + $groups = array('a' => array(), 'r' => array(), 'u' => array()); + $defaultGroups = array(); + + $query = $sql->prepare("SELECT `id`,`grouptype`,`name`,`defaultgroup` FROM `usergroups` WHERE `active`='Y' AND `resellerid`=?"); + $query->execute(array($resellerLockupID)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + if ($row['defaultgroup'] == 'Y') { + $defaultGroups[$row['grouptype']][$row['id']] = $row['name']; + } + + $groups[$row['grouptype']][$row['id']] = $row['name']; + } + + // Add or mod is opened + if (!$ui->smallletters('action', 2, 'post')) { + + // Gather data for adding if needed and define add template + if ($ui->st('d', 'get') == 'ad') { + + $template_file = 'admin_user_add.tpl'; + + // Gather data for modding in case we have an ID and define mod template + } else if ($ui->st('d', 'get') == 'md' and $id) { + + $query = ($reseller_id == 0) ? $sql->prepare("SELECT * FROM `userdata` WHERE id=? AND (`resellerid`=? OR `id`=resellerid) LIMIT 1") : $sql->prepare("SELECT * FROM `userdata` WHERE id=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($id, $resellerLockupID)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + $jobPending = $gsprache->no; + $active = $row['active']; + + if ($row['jobPending'] == 'Y') { + $query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='us' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1"); + $query2->execute(array($row['id'], $row['resellerid'])); + while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { + + if ($row2['action'] == 'ad') { + $jobPending = $gsprache->add; + } else if ($row2['action'] == 'dl') { + $jobPending = $gsprache->del; + } else { + $jobPending = $gsprache->mod; + } + + $json = @json_decode($row2['extraData']); + $active = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N'; + } + } + + $cname = $row['cname']; + $name = $row['name']; + $vname = $row['vname']; + $mail = $row['mail']; + $phone = $row['phone']; + $handy = $row['handy']; + $city = $row['city']; + $cityn = $row['cityn']; + $street = $row['street']; + $streetn = $row['streetn']; + $fdlpath = $row['fdlpath']; + $accountType = $row['accounttype']; + $salutation = $row['salutation']; + $birthday = $row['birthday']; + $country = $row['country']; + $fax = $row['fax']; + $mail_backup = $row['mail_backup']; + $mail_gsupdate = $row['mail_gsupdate']; + $mail_securitybreach = $row['mail_securitybreach']; + $mail_serverdown = $row['mail_serverdown']; + $mail_ticket = $row['mail_ticket']; + $mail_vserver = $row['mail_vserver']; + $creationTime = $row['creationTime']; + $updateTime = $row['updateTime']; + $externalID = $row['externalID']; + + if ($user_language == 'de') { + $creationTime = date('d-m-Y H:i:s', strtotime($row['creationTime'])); + $updateTime = date('d-m-Y H:i:s', strtotime($row['updateTime'])); + } + } + + if ($query->rowCount() > 0) { + + $groupsAssigned = array(); + + $query = $sql->prepare("SELECT `groupID` FROM `userdata_groups` WHERE `userID`=?"); + $query->execute(array($id)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + $groupsAssigned[] = $row['groupID']; + } + + if ($accountType == 'r') { + + $query = $sql->prepare("SELECT * FROM `resellerdata` WHERE `resellerid`=?"); + $query->execute(array($id)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + $useractive = $row['useractive']; + $maxuser = $row['maxuser']; + $maxgserver = $row['maxgserver']; + $maxvoserver = $row['maxvoserver']; + $maxdedis = $row['maxdedis']; + $maxvserver = $row['maxvserver']; + $maxuserram = $row['maxuserram']; + $maxusermhz = $row['maxusermhz']; + } + } + + $template_file = 'admin_user_md.tpl'; + + } else { + $template_file = 'admin_404.tpl'; + } + + // Show 404 if GET parameters did not add up or no ID was given with mod + } else { + $template_file = 'admin_404.tpl'; + } + + // Form is submitted + } else if ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad') { + + if (!$active) { + $errors['active'] = $sprache->active; + } + + if (!$mail){ + $errors['mail'] = $sprache->error_mail; + } else { + + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userdata` WHERE `mail`=? AND `id`!=? LIMIT 1"); + $query->execute(array($mail, $id)); - if (!$ui->ismail('mail', 'post')){ - $error[] = $sprache->error_mail; - } else { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE `mail`=? LIMIT 1"); - $query->execute(array($ui->ismail('mail', 'post'))); if ($query->fetchColumn() > 0) { - $error[] = $sprache->error_mail_exists; + $errors['mail'] = $sprache->error_mail_exists; } } - if (!$ui->password('security', 20, 'post')) { - $error[] = $sprache->error_pass; - } + if ($ui->st('action', 'post') == 'ad') { - if (!$ui->smallletters('accounttype',1, 'post')){ - $error[] = ''; - } else { - $accounttype = $ui->smallletters('accounttype',1, 'post'); - $query = $sql->prepare("SELECT `accounttype` FROM `userdata` WHERE `id`=? LIMIT 1"); - $query->execute(array($admin_id)); - $user_accounttype = $query->fetchColumn(); - $fdlpath = $ui->url('fdlpath', 'post'); - } + if (!$password) { + $errors['password'] = $sprache->error_pass; + } - if (count($error)>0) { - $template_file = 'Error: '.implode('
',$error); - } else { + if (!in_array($accountType, array('a', 'r', 'u'))) { + $errors['accounttype'] = $sprache->accounttype; + } - $query = $sql->prepare("SELECT `prefix1`,`prefix2` FROM `settings` WHERE `resellerid`=? LIMIT 1"); - $query->execute(array($resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $prefix1 = $row['prefix1']; - $prefix2 = $row['prefix2']; - } + if ($rSA['prefix1'] == 'Y' and $accountType != 'a') { - if ($prefix1== 'Y' and $accounttype != 'a') { - $cname = $prefix2; - $bogus = $cname.$ui->ismail('mail', 'post'); - } else { + $cname = $prefix2; - if ($accounttype == 'a' and $ui->username('acname',255, 'post')) { - $cname = $ui->username('acname',255, 'post'); - } else if ($accounttype == 'r' and $ui->username('rcname',255, 'post')) { - $cname = $ui->username('rcname',255, 'post'); - } else if ($accounttype == 'u' and $ui->username('cname',255, 'post')) { - $cname = $ui->username('cname',255, 'post'); + } else { + + if ($rSA['prefix2'] == $cname) { + $errors['cname'] = $sprache->nickname; } else { - $error[] = 'Entered Username not valid!'; - } - if ($cname != '' and $cname != null and $cname != false) { $bogus = $cname; $query = $sql->prepare("SELECT `id` FROM `userdata` WHERE `cname`=? LIMIT 1"); $query->execute(array($cname)); + if ($query->rowCount() > 0) { - unset($cname,$bogus); - } - else { + $errors['cname'] = $sprache->nickname; + } else { + # https://github.com/easy-wi/developer/issues/2 "Substitutes" $query = $sql->prepare("SELECT 1 FROM `userdata_substitutes` WHERE `loginName`=? LIMIT 1"); $query->execute(array($cname)); + if ($query->rowCount() > 0) { - unset($cname,$bogus); + $errors['cname'] = $sprache->nickname; } } - } else { - $error[] = 'Username transmitted empty!'; } - } + } + } - if (isset($cname) and isset($bogus)) { + // Submitted values are OK + if (count($errors) == 0) { - $active = $ui->active('active', 'post'); - $security="bogus"; - $name = $ui->names('name',255, 'post'); - $vname = $ui->names('vname',255, 'post'); - $mail = $ui->ismail('mail', 'post'); - $phone = $ui->phone('phone',50, 'post'); - $handy = $ui->phone('handy',50, 'post'); - $city = $ui->names('city',50, 'post'); - $cityn = $ui->id('cityn',6, 'post'); - $street = $ui->names('street',50, 'post'); - $streetn = $ui->streetNumber('streetn', 'post'); - $password = $ui->password('security',255, 'post'); - $salutation = $ui->id('salutation',1, 'post'); - $birthday = date('Y-m-d',strtotime($ui->isDate('birthday', 'post'))); - $country = $ui->st('country', 'post'); - $fax = $ui->phone('fax',50, 'post'); - $externalID = $ui->externalID('externalID', 'post'); - $mail_backup = yesNo('mail_backup'); - $mail_gsupdate = yesNo('mail_gsupdate'); - $mail_securitybreach = yesNo('mail_securitybreach'); - $mail_serverdown = yesNo('mail_serverdown'); - $mail_ticket = yesNo('mail_ticket'); - $mail_vserver = yesNo('mail_vserver'); - - - if ($accounttype == 'r') { - $usergroup = $ui->id('groups_r',19, 'post'); - $mail_backup=yesNo('mail_backup'); - $mail_gsupdate=yesNo('rmail_gsupdate'); - $mail_securitybreach=yesNo('rmail_securitybreach'); - $mail_vserver=yesNo('rmail_vserver'); - $useractive=yesNo('useractive'); - } else if ($accounttype == 'a') { - $usergroup = $ui->id('groups_a',19, 'post'); - } else { - $usergroup = $ui->id('groups_u',19, 'post'); - } + // Make the inserts or updates define the log entry and get the affected rows from insert + if ($ui->st('action', 'post') == 'ad') { $query = $sql->prepare("INSERT INTO `userdata` (`creationTime`,`updateTime`,`active`,`salutation`,`birthday`,`country`,`fax`,`cname`,`security`,`name`,`vname`,`mail`,`phone`,`handy`,`city`,`cityn`,`street`,`streetn`,`fdlpath`,`accounttype`,`mail_backup`,`mail_gsupdate`,`mail_securitybreach`,`mail_serverdown`,`mail_ticket`,`mail_vserver`,`externalID`) VALUES (NOW(),NOW(),?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); - $query->execute(array($active,$salutation,$birthday,$country,$fax,$bogus,$security,$name,$vname,$mail,$phone,$handy,$city,$cityn,$street,$streetn,$fdlpath,$accounttype,$mail_backup,$mail_gsupdate,$mail_securitybreach,$mail_serverdown,$mail_ticket,$mail_vserver,$externalID)); + $query->execute(array($active, $salutation, $birthday, $country, $fax, $bogus, $password, $name, $vname, $mail, $phone, $handy, $city, $cityn, $street, $streetn, $fdlpath, $accountType, $mail_backup, $mail_gsupdate, $mail_securitybreach, $mail_serverdown, $mail_ticket, $mail_vserver, $externalID)); $id = $sql->lastInsertId(); - $query = ($accounttype == 'r' and $reseller_id == 0) ? $sql->prepare("SELECT `id` FROM `usergroups` WHERE `id`=? AND `grouptype`=? AND `resellerid`=0 LIMIT 1") : $sql->prepare("SELECT `id` FROM `usergroups` WHERE `id`=? AND `grouptype`=? AND `resellerid`=? LIMIT 1"); - $query2 = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `groupID`=VALUES(`groupID`)"); - foreach ($usergroup as $gid) { - if ($accounttype == 'r' and $reseller_id == 0) { - $query->execute(array($gid, $accounttype)); - } else { - $query->execute(array($gid, $accounttype, $resellerLockupID)); - } + $rowCount = $query->rowCount(); - if (isid($query->fetchColumn(), 10)) { - if ($accounttype == 'r' and $reseller_id == 0) { - $query2->execute(array($id, $gid, $id)); - } else { - $query2->execute(array($id, $gid, $resellerLockupID)); - } - } + if ($rSA['prefix1'] == 'Y' and $accountType != 'a') { + $cname = $cname . $id; } - customColumns('U',$id,'save'); - - $query = $sql->prepare("INSERT INTO `easywi_statistics_current` (`userID`) VALUES (?) ON DUPLICATE KEY UPDATE `userID`=VALUES(`userID`)"); - $query->execute(array(($accounttype == 'a') ? 0 : $id)); - - $cnamenew = $ui->username('cname',255, 'post'); - - if ($prefix1== 'Y' and $accounttype != 'a') { - $cnamenew = $cname.$id; - } else if ($accounttype != 'a') { - $cnamenew = $cname; - } else if ($accounttype == 'a' and $ui->username('acname',255, 'post')) { - $cnamenew = $ui->username('acname',255, 'post'); - } else { - die('Fatal Error 2: Username transmitted empty!'); - } - - if ($accounttype == 'a') { - $resellerid = $reseller_id; - } else if ($accounttype == 'u') { - $resellerid = $reseller_id; - } else if ($accounttype == 'r') { - $resellerid = $id; - if (!$ui->id('maxuser',10, 'post')) { - $maxuser = 0; - } else { - $maxuser = $ui->id('maxuser',10, 'post'); - } - if (!$ui->id('maxgserver',10, 'post')) { - $maxgserver = 0; - } else { - $maxgserver = $ui->id('maxgserver',10, 'post'); - } - if (!$ui->id('maxvoiceserver',10, 'post')) { - $maxvoserver = 0; - } else { - $maxvoserver = $ui->id('maxvoiceserver',10, 'post'); - } - - if ($easywiModules['ro']) { - if (!$ui->id('maxgserver',10, 'post')) { - $maxvserver = 0; - } else { - $maxvserver = $ui->id('maxgserver',10, 'post'); - } - if (!$ui->id('maxdedis',10, 'post')) { - $maxdedis = 0; - } else { - $maxdedis = $ui->id('maxdedis',10, 'post'); - } - $maxuserram = $ui->id('maxuserram',255, 'post'); - $maxusermhz = $ui->id('maxusermhz',255, 'post'); - - } else { - $maxvdedis = 0; - $maxvserver = 0; - $maxuserram = 0; - $maxusermhz = 0; - } - - function CopyAdminTable ($tablename, $id, $reseller_id, $limit, $where='') { - - global $sql; - - $query = $sql->prepare("SELECT * FROM `$tablename` WHERE `resellerid`=? " . $where . " " .$limit); - $query->execute(array($reseller_id)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $keys = array(); - $questionmarks = array(); - $intos = array(); - foreach ($row as $key=>$value) { - if ($key != 'id' and $key != 'resellerid'){ - $keys[]="`".$key."`"; - $questionmarks[] = '?'; - $intos[] = $value; - } - } - $keys[]="`resellerid`"; - $intos[] = $id; - $questionmarks[] = '?'; - $into='INSERT INTO `'.$tablename.'` ('.implode(',',$keys).') VALUES ('.implode(',',$questionmarks).')'; - $query = $sql->prepare("$into"); - $query->execute($intos); - } - } - CopyAdminTable('servertypes',$id,$resellerLockupID,''); - CopyAdminTable('settings',$id,$resellerLockupID,'LIMIT 1'); - CopyAdminTable('voice_stats_settings',$id,$resellerLockupID,'LIMIT 1'); - - if ($reseller_id > 0 and $reseller_id != $admin_id) { - CopyAdminTable('usergroups',$id,$resellerLockupID,'', "AND `active`='Y' AND `name` IS NOT NULL AND `grouptype`='u'"); - } else { - CopyAdminTable('usergroups',$id,$resellerLockupID,'', "AND `active`='Y' AND `name` IS NOT NULL AND `grouptype` IN ('u','r')"); - } - - $query = $sql->prepare("SELECT * FROM `addons` WHERE `resellerid`=?"); - $query2 = $sql->prepare("INSERT INTO `addons` (`active`,`addon`,`type`,`folder`,`menudescription`,`configs`,`cmd`,`paddon`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?)"); - $query3 = $sql->prepare("SELECT `lang`,`text` FROM `translations` WHERE `type`='ad' AND `transID`=? AND `resellerID`=? LIMIT 1"); - $query4 = $sql->prepare("INSERT INTO `translations` (`type`,`lang`,`text`,`transID`,`resellerID`) VALUES ('ad',?,?,?,?)"); - $query5 = $sql->prepare("SELECT t2.`id` FROM `addons_allowed` AS a INNER JOIN `servertypes` AS t1 ON a.`servertype_id`=t1.`id` INNER JOIN `servertypes` AS t2 ON t1.`shorten`=t2.`shorten` AND t2.`resellerid`=? WHERE a.`addon_id`=? AND a.`reseller_id`=?"); - $query6 = $sql->prepare("INSERT INTO `addons_allowed` (`addon_id`,`servertype_id`,`reseller_id`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `addon_id`=`addon_id`"); - $query->execute(array($resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $query2->execute(array($row['active'], $row['addon'], $row['type'], $row['folder'], $row['menudescription'], $row['configs'], $row['cmd'], $row['paddon'],$id)); - $newID = $sql->lastInsertId(); - $query3->execute(array($row['id'], $resellerLockupID)); - while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) { - $query4->execute(array($row3['lang'], $row3['text'], $newID, $id)); - } - $query5->execute(array($id, $row['id'], $resellerLockupID)); - foreach ($query5->fetchAll(PDO::FETCH_ASSOC) as $row3) { - $query6->execute(array($newID, $row3['id'], $id)); - } - } - $query = $sql->prepare("SELECT * FROM `lendsettings` WHERE `resellerid`=? LIMIT 1"); - $query2 = $sql->prepare("INSERT INTO `lendsettings` (`mintime`,`maxtime`,`timesteps`,`minplayer`,`maxplayer`,`playersteps`,`vomintime`,`vomaxtime`,`votimesteps`,`vominplayer`,`vomaxplayer`,`voplayersteps`,`shutdownempty`,`shutdownemptytime`,`ftpupload`,`ftpuploadpath`,`lendaccess`,`lastcheck`,`oldcheck`,`resellerid`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'0xe4bca9cd69b8488c9c5ee5b7d32c12f3a3cdae349a54edbe6659fc2817ccc86489b12864ebbb43eff607be85611da6c4','3',?,?,?)"); - $query->execute(array($resellerLockupID)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) $query2->execute(array($row['mintime'], $row['maxtime'], $row['timesteps'], $row['minplayer'], $row['maxplayer'], $row['playersteps'], $row['vomintime'], $row['vomaxtime'], $row['votimesteps'], $row['vominplayer'], $row['vomaxplayer'], $row['voplayersteps'], $row['shutdownempty'], $row['shutdownemptytime'], $row['ftpupload'], $row['lastcheck'], $row['oldcheck'],$id)); - $query = $sql->prepare("SELECT * FROM `translations` WHERE `type`='em' AND `resellerID`=?"); - $query2 = $sql->prepare("INSERT INTO `translations` (`type`,`transID`,`lang`,`text`,`resellerID`) VALUES ('em',?,?,?,?) ON DUPLICATE KEY UPDATE `text`=VALUES(`text`)"); - $query->execute(array($resellerLockupID)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) $query2->execute(array($row['transID'], $row['lang'], $row['text'],$id)); - $resellersid=($reseller_id == 0) ? $resellerid : $reseller_id; - $query = $sql->prepare("INSERT INTO `resellerdata` (`useractive`,`maxuser`,`maxgserver`,`maxvoserver`,`maxdedis`,`maxvserver`,`maxuserram`,`maxusermhz`,`resellerid`,`resellersid`) VALUES (?,?,?,?,?,?,?,?,?,?)"); - $query->execute(array($useractive,$maxuser,$maxgserver,$maxvoserver,$maxdedis,$maxvserver,$maxuserram,$maxusermhz,$resellerid,$resellersid)); - $query = $sql->prepare("INSERT INTO `eac` (`resellerid`) VALUES (?)"); - $query->execute(array($resellerid)); - } - - if (!isset($resellersid)) { - $resellersid = $reseller_id; - } - - - - $newHash = passwordCreate($cnamenew, $password); + $newHash = passwordCreate($cname, $password); if (is_array($newHash)) { $query = $sql->prepare("UPDATE `userdata` SET `cname`=?,`security`=?,`salt`=?,`resellerid`=? WHERE `id`=? LIMIT 1"); - if ($user_accounttype == 'a' and $accounttype == 'r') { - $query->execute(array($cnamenew, $newHash['hash'], $newHash['salt'], $id, $id)); - } else if ($user_accounttype == 'r' and $accounttype == 'r') { - $query->execute(array($cnamenew, $newHash['hash'], $newHash['salt'], $admin_id, $id)); + + if ($userAccounttype == 'a' and $accountType == 'r') { + $query->execute(array($cname, $newHash['hash'], $newHash['salt'], $id, $id)); + } else if ($userAccounttype == 'r' and $accountType == 'r') { + $query->execute(array($cname, $newHash['hash'], $newHash['salt'], $admin_id, $id)); } else { - $query->execute(array($cnamenew, $newHash['hash'], $newHash['salt'], $resellerLockupID, $id)); + $query->execute(array($cname, $newHash['hash'], $newHash['salt'], $resellerLockupID, $id)); } } else { $query = $sql->prepare("UPDATE `userdata` SET `cname`=?,`security`=?,`resellerid`=? WHERE `id`=? LIMIT 1"); - if ($user_accounttype == 'a' and $accounttype == 'r') { - $query->execute(array($cnamenew, $newHash, $id, $id)); - } else if ($user_accounttype == 'r' and $accounttype == 'r') { - $query->execute(array($cnamenew, $newHash, $admin_id, $id)); + + if ($userAccounttype == 'a' and $accountType == 'r') { + $query->execute(array($cname, $newHash, $id, $id)); + } else if ($userAccounttype == 'r' and $accountType == 'r') { + $query->execute(array($cname, $newHash, $admin_id, $id)); } else { - $query->execute(array($cnamenew, $newHash, $resellerLockupID, $id)); + $query->execute(array($cname, $newHash, $resellerLockupID, $id)); } } - sendmail('emailuseradd',$id,$cnamenew,$password); + $rowCount += $query->rowCount(); - $template_file = $sprache->user_create .": $cnamenew."; - $loguseraction="%add% %user% $cnamenew"; - $insertlog->execute(); + if ($accountType == 'r') { - } else { - $template_file = $sprache->error_cname; - } - } + CopyAdminTable('servertypes', $id, $resellerLockupID, ''); + CopyAdminTable('settings', $id, $resellerLockupID, 'LIMIT 1'); - } else { - $randompass = passwordgenerate(10); - $randompass2 = passwordgenerate(10); - $query = $sql->prepare("SELECT `prefix1` FROM `settings` WHERE `resellerid`=? LIMIT 1"); - $query->execute(array($resellerLockupID)); - $prefix1 = $query->fetchColumn(); - $groups = array(); - $groups=array('a' => array(),'r' => array(),'u' => array()); - $defaultGroups = array(); - $query = $sql->prepare("SELECT `id`,`grouptype`,`name`,`defaultgroup` FROM `usergroups` WHERE `active`='Y' AND `resellerid`=?"); - $query->execute(array($resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - if ($row['defaultgroup'] == 'Y') { - $defaultGroups[$row['grouptype']][$row['id']] = $row['name']; - } - $groups[$row['grouptype']][$row['id']] = $row['name']; - } - $selectlanguages=getlanguages($template_to_use); - $template_file = 'admin_user_add.tpl'; - } -} else if ($ui->st('d', 'get') == 'dl' and ($pa['user'] or $pa['user_users']) and $ui->id('id', 10, 'get') != $admin_id) { - - $id = $ui->id('id', 10, 'get'); - - if (!$ui->smallletters('action',2, 'post')) { - - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT `cname`,`name`,`accounttype` FROM `userdata` WHERE `id`=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1"); - } else { - $query = $sql->prepare("SELECT `cname`,`name`,`accounttype` FROM `userdata` WHERE `id`=? AND `resellerid`=? AND `resellerid`!=`id` LIMIT 1"); - } - - $query->execute(array($id,$resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - if (($row['accounttype'] == 'a' and $pa['user']) or ($row['accounttype'] != 'a') and ($pa['user'] or $pa['user_users'])) { - $cname = $row['cname']; - $name = $row['name']; - } - } - if (isset($cname)) { - $template_file = 'admin_user_dl.tpl'; - } else { - $template_file = 'admin_404.tpl'; - } - - } else if ($ui->smallletters('action',2, 'post') == 'dl') { - - $template_file = ''; - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT `cname`,`resellerid`,`accounttype` FROM `userdata` WHERE `id`=? AND (`resellerid`=? OR `id`=resellerid) LIMIT 1"); - } else { - $query = $sql->prepare("SELECT `cname`,`resellerid`,`accounttype` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1"); - } - $query->execute(array($id,$resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - if (($row['accounttype'] == 'a' and $pa['user']) or ($row['accounttype'] != 'a') and ($pa['user'] or $pa['user_users'])) { - $deleted = true; - $cname = $row['cname']; - $resellerid = $row['resellerid']; - $update = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); - $update->execute(array($id,$resellerid)); - $insert = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'dl',?)"); - $insert->execute(array($admin_id,$id,$id, $row['cname'],$resellerid)); - updateJobs($id,$resellerLockupID); - } - } - if ($query->rowCount() > 0 and isset($deleted)) { - $update = $sql->prepare("UPDATE `userdata` SET `jobPending`='Y' WHERE `id`=? AND `resellerid`=?"); - $update->execute(array($id,$resellerid)); - $template_file .= $spracheResponse->table_del ."
"; - $loguseraction="%del% %user% $cname"; - $insertlog->execute(); - } else { - $template_file = 'admin_404.tpl'; - } - } else { - $template_file = 'admin_404.tpl'; - } -} else if ($ui->st('d', 'get') == 'md' and $ui->id('id', 10, 'get') and ($ui->id('id', 10, 'get') != $admin_id or $reseller_id == 0)) { - - $id = $ui->id('id', 10, 'get'); - - if (!$ui->smallletters('action',2, 'post')) { - - $query = ($reseller_id == 0) ? $sql->prepare("SELECT * FROM `userdata` WHERE id=? AND (`resellerid`=? OR `id`=resellerid) LIMIT 1") : $sql->prepare("SELECT * FROM `userdata` WHERE id=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($id, $resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - - $active = 'N'; - - if ($row['jobPending'] == 'Y') { - $query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='us' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1"); - $query2->execute(array($row['id'], $row['resellerid'])); - while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { - if ($row2['action'] == 'ad') { - $jobPending = $gsprache->add; - } else if ($row2['action'] == 'dl') { - $jobPending = $gsprache->del; + if ($reseller_id > 0 and $reseller_id != $admin_id) { + CopyAdminTable('usergroups', $id, $resellerLockupID, '', "AND `active`='Y' AND `name` IS NOT NULL AND `grouptype`='u'"); } else { - $jobPending = $gsprache->mod; + CopyAdminTable('usergroups', $id, $resellerLockupID, '', "AND `active`='Y' AND `name` IS NOT NULL AND `grouptype` IN ('u','r')"); + } + + $query = $sql->prepare("INSERT INTO `lendsettings` (`resellerid`) VALUES (?)"); + $query->execute(array($id)); + $query = $sql->prepare("INSERT INTO `eac` (`resellerid`) VALUES (?)"); + $query->execute(array($id)); + $query = $sql->prepare("INSERT INTO `resellerdata` (`useractive`,`maxuser`,`maxgserver`,`maxvoserver`,`maxdedis`,`maxvserver`,`maxuserram`,`maxusermhz`,`resellerid`,`resellersid`) VALUES (?,?,?,?,?,?,?,?,?,?)"); + $query->execute(array($useractive, $maxuser, $maxgserver, $maxvoserver, $maxdedis, $maxvserver, $maxuserram, $maxusermhz, $id, ($reseller_id == 0) ? $id : $reseller_id)); + + $query = $sql->prepare("SELECT * FROM `translations` WHERE `type`='em' AND `resellerID`=?"); + $query2 = $sql->prepare("INSERT INTO `translations` (`type`,`transID`,`lang`,`text`,`resellerID`) VALUES ('em',?,?,?,?) ON DUPLICATE KEY UPDATE `text`=VALUES(`text`)"); + $query->execute(array($resellerLockupID)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + $query2->execute(array($row['transID'], $row['lang'], $row['text'], $id)); } - $json = @json_decode($row2['extraData']); - $active = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N'; } - } else { - $jobPending = $gsprache->no; - $active = $row['active']; - } - $cname = $row['cname']; - $name = $row['name']; - $vname = $row['vname']; - $mail = $row['mail']; - $phone = $row['phone']; - $handy = $row['handy']; - $city = $row['city']; - $cityn = $row['cityn']; - $street = $row['street']; - $streetn = $row['streetn']; - $fdlpath = $row['fdlpath']; - $accounttype = $row['accounttype']; - $salutation = $row['salutation']; - $birthday = $row['birthday']; - $country = $row['country']; - $fax = $row['fax']; - $mail_backup = $row['mail_backup']; - $mail_gsupdate = $row['mail_gsupdate']; - $mail_securitybreach = $row['mail_securitybreach']; - $mail_serverdown = $row['mail_serverdown']; - $mail_ticket = $row['mail_ticket']; - $mail_vserver = $row['mail_vserver']; - $creationTime = $row['creationTime']; - $updateTime = $row['updateTime']; - $externalID = $row['externalID']; + sendmail('emailuseradd', $id, $cname, $password); - if ($user_language == 'de') { - $creationTime = date('d-m-Y H:i:s', strtotime($row['creationTime'])); - $updateTime = date('d-m-Y H:i:s', strtotime($row['updateTime'])); - } + $loguseraction = '%add% %user% ' . $cname; - } + } else if ($ui->st('action', 'post') == 'md' and $id) { - if (isset($accounttype) and (($accounttype == 'a' and $pa['user']) or $accounttype != 'a' and ($pa['user'] or $pa['user_users']))) { + $jobPending = 'N'; + $rowCount = 0; - $groups = array(); - $groupsAssigned = array(); - - $query = $sql->prepare("SELECT `id`,`name` FROM `usergroups` WHERE `active`='Y' AND `grouptype`=? AND `resellerid`=?"); - $query->execute(array($accounttype, $resellerLockupID)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $groups[$row['id']] = $row['name']; - } - - $query = $sql->prepare("SELECT `groupID` FROM `userdata_groups` WHERE `userID`=?"); - $query->execute(array($id)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $groupsAssigned[] = $row['groupID']; - } - - if ($accounttype == 'r') { - - $query = $sql->prepare("SELECT * FROM `resellerdata` WHERE `resellerid`=?"); - $query->execute(array($id)); + if ($reseller_id == 0){ + $query = $sql->prepare("SELECT `accounttype`,`active`,`cname`,`resellerid` FROM `userdata` WHERE `id`=? LIMIT 1"); + $query->execute(array($id)); + } else { + $query = $sql->prepare("SELECT `accounttype`,`active`,`cname`,`resellerid` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($id, $resellerLockupID)); + } while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $useractive = $row['useractive']; - $maxuser = $row['maxuser']; - $maxgserver = $row['maxgserver']; - $maxvoiceserver = $row['maxvoserver']; - $maxdedis = $row['maxdedis']; - $maxvserver = $row['maxvserver']; - $maxuserram = $row['maxuserram']; - $maxusermhz = $row['maxusermhz']; + $accountType = $row['accounttype']; + $cname = $row['cname']; + $resellerUpdateId = $row['resellerid']; + $oldActive = $row['active']; } - } - $selectlanguages = getlanguages($template_to_use); + if (isset($oldActive)) { - $template_file = 'admin_user_md.tpl'; + if ($oldActive != $active) { - } else { - $template_file = 'admin_404.tpl'; - } + $jobPending = 'Y'; - } else if ($ui->smallletters('action',2, 'post') == 'md') { + $query = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); + $query->execute(array($id, $resellerLockupID)); - $errors = array(); + $rowCount += $query->rowCount(); - if (!$ui->ismail('mail', 'post')){ - $errors[] = $sprache->error_mail; - } else { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE `mail`=? AND `id`!=? LIMIT 1"); - $query->execute(array($ui->ismail('mail', 'post'),$id)); + $query = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'md',?,?)"); + $query->execute(array($admin_id, $id, $id, $cname, json_encode(array('newActive' => $active)), $resellerLockupID)); - if ($query->fetchColumn() > 0) { - $error[] = $sprache->error_mail; - } - } - if (!$ui->id('groups',30, 'post') and $id != $admin_id){ - $errors[] = 'Error: Group'; - } - if (count($errors)>0) { - $template_file = implode('
',$errors); - } else { - $jobPending = ''; + $rowCount += $query->rowCount(); - if ($reseller_id == 0){ - $query = $sql->prepare("SELECT `accounttype`,`active`,`cname`,`resellerid` FROM `userdata` WHERE `id`=? LIMIT 1"); - $query->execute(array($id)); - } else { - $query = $sql->prepare("SELECT `accounttype`,`active`,`cname`,`resellerid` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($id,$resellerLockupID)); - } - - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $accounttype = $row['accounttype']; - $oldactive = $row['active']; - $cname = $row['cname']; - $resellerlockupid = $row['resellerid']; - } - - if (isset($oldactive)) { - $fdlpath = $ui->url('fdlpath', 'post'); - $active = (in_array($ui->escaped('active', 'post'), array('N','Y','R'))) ? $ui->escaped('active', 'post') : 'N'; - $mail_backup=yesNo('mail_backup'); - $mail_gsupdate=yesNo('mail_gsupdate'); - $mail_securitybreach=yesNo('mail_securitybreach'); - $mail_serverdown=yesNo('mail_serverdown'); - $mail_ticket=yesNo('mail_ticket'); - $mail_vserver=yesNo('mail_vserver'); - $template_file = ''; - $name = $ui->names('name',255, 'post'); - $vname = $ui->names('vname',255, 'post'); - $mail = $ui->ismail('mail', 'post'); - $phone = $ui->phone('phone',50, 'post'); - $handy = $ui->phone('handy',50, 'post'); - $city = $ui->names('city',50, 'post'); - $cityn = $ui->id('cityn',6, 'post'); - $street = $ui->names('street',50, 'post'); - $streetn = $ui->streetNumber('streetn', 'post'); - $salutation = $ui->id('salutation',1, 'post'); - $birthday=date('Y-m-d',strtotime($ui->isDate('birthday', 'post'))); - $country = $ui->st('country', 'post'); - $fax = $ui->phone('fax',50, 'post'); - $externalID = $ui->externalID('externalID', 'post'); - $useractive = ($ui->active('useractive', 'post')) ? $ui->active('useractive', 'post') : 'N'; - - if ($ui->id('maxuser',10, 'post') and $accounttype == 'r') { - - if ($resellerlockupid==0) { - $resellerlockupid = $id; + updateJobs($id, $resellerLockupID); + } + + $query = $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`salutation`=?,`birthday`=?,`country`=?,`fax`=?,`name`=?,`vname`=?,`mail`=?,`phone`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=?,`fdlpath`=?,`mail_backup`=?,`mail_gsupdate`=?,`mail_securitybreach`=?,`mail_serverdown`=?,`mail_ticket`=?,`mail_vserver`=?,`externalID`=?,`jobPending`=? WHERE `id`=? and `resellerid`=? LIMIT 1"); + $query->execute(array($salutation, $birthday, $country, $fax, $name, $vname, $mail, $phone, $handy, $city, $cityn, $street, $streetn, $fdlpath, $mail_backup, $mail_gsupdate, $mail_securitybreach, $mail_serverdown, $mail_ticket, $mail_vserver, $externalID, $jobPending, $id, $resellerUpdateId)); + + $rowCount += $query->rowCount(); + } + + if ($accountType == 'r' and isset($resellerUpdateId)) { + + if ($resellerUpdateId == 0) { + $resellerUpdateId = $id; } - $maxuser = $ui->id('maxuser',10, 'post'); - $maxgserver = $ui->id('maxgserver',10, 'post'); - $maxvoserver = $ui->id('maxvoiceserver',10, 'post'); - $maxdedis = $ui->id('maxdedis',10, 'post'); - $maxvserver = $ui->id('maxgserver',10, 'post'); - $maxuserram = $ui->id('maxuserram',255, 'post'); - $maxusermhz = $ui->id('maxusermhz',255, 'post'); $query = $sql->prepare("SELECT `useractive` FROM `resellerdata` WHERE `resellerid`=? LIMIT 1"); $query->execute(array($id)); + if ($query->fetchColumn() != $useractive) { + $query = $sql->prepare("SELECT `id`,`cname` FROM `userdata` WHERE `resellerid`=?"); + $query2 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); + $query3 = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'md',?,?)"); + $query->execute(array($id)); - foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row){ - $update = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); - $update->execute(array($id,$resellerLockupID)); - $insert = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'md',?,?)"); - $insert->execute(array($admin_id, $row['id'], $row['id'], $row['cname'],json_encode(array('newActive' => $useractive)),$id)); - updateJobs($row['id'],$resellerLockupID); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + $query2->execute(array($id, $resellerUpdateId)); + + $query3->execute(array($admin_id, $row['id'], $row['id'], $row['cname'], json_encode(array('newActive' => $useractive)), $id)); + + updateJobs($row['id'], $resellerUpdateId); } } + $query = $sql->prepare("UPDATE `resellerdata` SET `useractive`=?,`maxuser`=?,`maxgserver`=?,`maxvoserver`=?,`maxdedis`=?,`maxvserver`=?,`maxuserram`=?,`maxusermhz`=? WHERE `resellerid`=? LIMIT 1"); - $query->execute(array($useractive,$maxuser,$maxgserver,$maxvoserver,$maxdedis,$maxvserver,$maxuserram,$maxusermhz,$id)); - + $query->execute(array($useractive, $maxuser, $maxgserver, $maxvoserver, $maxdedis, $maxvserver, $maxuserram, $maxusermhz, $id)); } - if ($oldactive != $active) { - $jobPending=",`jobPending`='Y'"; - $update = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); - $update->execute(array($id,$resellerLockupID)); - $insert = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`extraData`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'md',?,?)"); - $insert->execute(array($admin_id,$id,$id,$cname,json_encode(array('newActive' => $active)),$resellerLockupID)); - updateJobs($id,$resellerLockupID); - } + $loguseraction = '%mod% %user% ' . $cname; + } - $query = $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`salutation`=?,`birthday`=?,`country`=?,`fax`=?,`name`=?,`vname`=?,`mail`=?,`phone`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=?,`fdlpath`=?,`mail_backup`=?,`mail_gsupdate`=?,`mail_securitybreach`=?,`mail_serverdown`=?,`mail_ticket`=?,`mail_vserver`=?,`externalID`=?" . $jobPending ." WHERE `id`=? and `resellerid`=? LIMIT 1"); - $query->execute(array($salutation,$birthday,$country,$fax,$name,$vname,$mail,$phone,$handy,$city,$cityn,$street,$streetn,$fdlpath,$mail_backup,$mail_gsupdate,$mail_securitybreach,$mail_serverdown,$mail_ticket,$mail_vserver,$externalID,$id,$resellerlockupid)); + $query = $sql->prepare("INSERT INTO `easywi_statistics_current` (`userID`) VALUES (?) ON DUPLICATE KEY UPDATE `userID`=VALUES(`userID`)"); + $query->execute(array(($accountType == 'a') ? 0 : $id)); - customColumns('U', $id, 'save'); + $rowCount += $query->rowCount(); - if ($id != $admin_id) { - $tempArray = array(); - $query = ($accounttype == 'r' and $reseller_id == 0) ? $sql->prepare("SELECT `id` FROM `usergroups` WHERE `id`=? AND `grouptype`=? AND `resellerid`=0 LIMIT 1") : $sql->prepare("SELECT `id` FROM `usergroups` WHERE `id`=? AND `grouptype`=? AND `resellerid`=? LIMIT 1"); - $query2 = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `groupID`=VALUES(`groupID`)"); - foreach ($ui->id('groups',10, 'post') as $gid) { + customColumns('U', $id, 'save'); - $tempArray[] = $gid; + $notIn = (is_array ($userGroups) and count($userGroups) > 0) ? 'AND `groupID` NOT IN ('. implode(',', $userGroups) .')' : ''; - if ($accounttype == 'r' and $reseller_id == 0) { - $query->execute(array($gid, $accounttype)); - } else { - $query->execute(array($gid, $accounttype, $resellerlockupid)); - } + $query = $sql->prepare("DELETE FROM `userdata_groups` WHERE `userID`=? AND `resellerID`=? " . $notIn); + $query->execute(array($id, $resellerLockupID)); - if (isid($query->fetchColumn(),10)) { - $query2->execute(array($id, $gid, $resellerlockupid)); - } - } - $query = $sql->prepare("SELECT `groupID` FROM `userdata_groups` WHERE `userID`=? AND `resellerID`=?"); - $query2 = $sql->prepare("DELETE FROM `userdata_groups` WHERE `groupID`=? AND `userID`=? AND `resellerID`=? LIMIT 1"); - $query->execute(array($id,$resellerlockupid)); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - if (!in_array($row['groupID'],$tempArray)) $query2->execute(array($row['groupID'],$id,$resellerlockupid)); + $rowCount += $query->rowCount(); + + $query = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,?) ON DUPLICATE KEY UPDATE `groupID`=VALUES(`groupID`)"); + + foreach ($userGroups as $gid) { + + if (isset($groups[$accountType][$gid])) { + + if ($accountType == 'r' and $reseller_id == 0) { + $query->execute(array($id, $gid, $id)); + } else { + $query->execute(array($id, $gid, $resellerLockupID)); } + + $rowCount += $query->rowCount(); } - $query = $sql->prepare("DELETE FROM `userpermissions` WHERE `userid`=? LIMIT 1"); - $query->execute(array($id)); - if (isset($template_file)) $template_file .= $spracheResponse->table_add ."
"; - else $template_file = $spracheResponse->table_add ."
"; - $loguseraction="%mod% %user% $cname"; + } + + // Check if a row was affected during insert or update + if (isset($rowCount) and $rowCount > 0) { + $insertlog->execute(); + $template_file = $spracheResponse->table_add; + + // No update or insert failed } else { - $template_file = 'userpanel_404.tpl'; + $template_file = $spracheResponse->error_table; + } + + // An error occurred during validation unset the redirect information and display the form again + } else { + unset($header, $text); + $template_file = ($ui->st('d', 'get') == 'ad') ? 'admin_user_add.tpl' : 'admin_user_md.tpl'; + } + } + +// Remove entries in case we have an ID given with the GET request +} else if ($ui->st('d', 'get') == 'dl' and $id and $id != $admin_id and ($pa['user'] or $pa['user_users'])) { + + unset($cname); + + $whereCase = ($pa['user'] and $reseller_id == 0) ? '' : 'AND `accounttype`!=\'a\''; + + $query = ($reseller_id == 0) ? $sql->prepare("SELECT CONCAT(`vname`,' ',`name`) AS `full_name`,`cname`,`accounttype`,`resellerid` FROM `userdata` WHERE `id`=? {$whereCase} AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("SELECT CONCAT(`vname`,' ',`name`) AS `full_name`,`cname`,`accounttype`,`resellerid` FROM `userdata` WHERE `id`=? AND `resellerid`=? {$whereCase} LIMIT 1"); + $query->execute(array($id, $resellerLockupID)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + $cname = $row['cname']; + $fullName = $row['full_name']; + $accountType = $row['accounttype']; + $resellerId = $row['resellerid']; + } + + if (isset($cname)) { + + // Nothing submitted yet, display the delete form + if (!$ui->st('action', 'post')) { + + $template_file = 'admin_user_dl.tpl'; + + // User submitted remove the entry + } else if ($ui->st('action', 'post') == 'dl') { + + // Deactivate all old jobs belonging to this user + $query = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `type`='us' AND (`status` IS NULL OR `status`='1') AND `userID`=? and `resellerID`=?"); + $query->execute(array($id, $resellerId)); + + // Add the removal job + $query = $sql->prepare("INSERT INTO `jobs` (`api`,`type`,`invoicedByID`,`affectedID`,`userID`,`name`,`status`,`date`,`action`,`resellerid`) VALUES ('U','us',?,?,?,?,NULL,NOW(),'dl',?)"); + $query->execute(array($admin_id, $id, $id, $cname, $resellerId)); + + updateJobs($id, $resellerLockupID); + + // Check if a row was affected meaning an entry could be deleted. If yes add log entry and display success message + if ($query->rowCount() > 0) { + + $query = $sql->prepare("UPDATE `userdata` SET `jobPending`='Y' WHERE `id`=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($id, $resellerId)); + + $template_file = $spracheResponse->table_del; + $loguseraction = '%del% %user% ' . $cname; + $insertlog->execute(); + + // Nothing was deleted, display an error + } else { + $template_file = $spracheResponse->error_table; } } + + // GET Request did not add up. Display 404 error. } else { $template_file = 'admin_404.tpl'; } -} else if ($ui->st('d', 'get') == 'pw' and $ui->id('id', 10, 'get') and $pa['userPassword'] and ($ui->id('id', 10, 'get') != $admin_id or $reseller_id == 0)) { +// Password changes ID given with the GET request +} else if ($ui->st('d', 'get') == 'pw' and $id) { - $id = $ui->id('id', 10, 'get'); + unset($cname); - $query = ($reseller_id == 0) ? $sql->prepare("SELECT `cname`,`accounttype` FROM `userdata` WHERE `id`=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("SELECT `cname`,`accounttype` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($id,$resellerLockupID)); + $whereCase = ($pa['user'] and $reseller_id == 0) ? '' : 'AND `accounttype`!=\'a\''; + + $query = ($reseller_id == 0) ? $sql->prepare("SELECT CONCAT(`vname`,' ',`name`) AS `full_name`,`cname`,`accounttype` FROM `userdata` WHERE `id`=? {$whereCase} AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("SELECT CONCAT(`vname`,' ',`name`) AS `full_name`,`cname`,`accounttype` FROM `userdata` WHERE `id`=? AND `resellerid`=? {$whereCase} LIMIT 1"); + $query->execute(array($id, $resellerLockupID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - if (($row['accounttype'] == 'a' and $pa['user']) or ($row['accounttype'] != 'a') and ($pa['user'] or $pa['user_users'])) { - $cname = $row['cname']; - } + $cname = $row['cname']; + $fullName = $row['full_name']; } - if (!$ui->smallletters('action',2, 'post') and isset($cname)) { - - $template_file = 'admin_user_pass.tpl'; - - } else if ($ui->smallletters('action',2, 'post') == 'pw' and isset($cname)) { + if (isset($cname)) { $errors = array(); - if (!$ui->password('password', 20, 'post')) { - $errors[] = $sprache->error_pass; - } - if (!$ui->password('pass2', 20, 'post')) { - $errors[] = $sprache->error_pass; - } - if ($ui->password('password', 20, 'post') != $ui->password('pass2', 20, 'post')) { - $errors[] = $sprache->error_passw_succ; - } + // Nothing submitted yet, display the delete form + if (!$ui->st('action', 'post')) { - if (count($errors)>0) { - $template_file = implode('
',$errors); - } else { + $template_file = 'admin_user_pass.tpl'; - $password = $ui->password('password', 20, 'post'); + // User submitted remove the entry + } else if ($ui->st('action', 'post') == 'pw') { - $newHash = passwordCreate($cname, $ui->password('password', 255, 'post')); - - if (is_array($newHash)) { - $query = ($reseller_id == 0) ? $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=?,`salt`=? WHERE id=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=?,`salt`=? WHERE id=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($newHash['hash'], $newHash['salt'], $id, $resellerLockupID)); - - } else { - $query = ($reseller_id == 0) ? $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=? WHERE id=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=? WHERE id=? AND `resellerid`=? LIMIT 1"); - $query->execute(array($newHash, $id, $resellerLockupID)); + if (!$password) { + $errors[] = $sprache->error_pass; } + if (!$passwordRepeat) { + $errors[] = $sprache->error_pass; + } - $template_file = $spracheResponse->table_add ."
"; - $loguseraction="%psw% %user% $cname"; - $insertlog->execute(); + if ($password != $passwordRepeat) { + $errors[] = $sprache->error_passw_succ; + } + + if (count($errors) > 0) { + + unset($header, $text); + + $template_file = 'admin_user_pass.tpl'; + + } else { + + $password = $ui->password('password', 255, 'post'); + + $newHash = passwordCreate($cname, $ui->password('password', 255, 'post')); + + if (is_array($newHash)) { + $query = ($reseller_id == 0) ? $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=?,`salt`=? WHERE id=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=?,`salt`=? WHERE id=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($newHash['hash'], $newHash['salt'], $id, $resellerLockupID)); + + } else { + $query = ($reseller_id == 0) ? $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=? WHERE id=? AND (`resellerid`=? OR `id`=`resellerid`) LIMIT 1") : $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`security`=? WHERE id=? AND `resellerid`=? LIMIT 1"); + $query->execute(array($newHash, $id, $resellerLockupID)); + } + + // Check if a row was affected meaning an entry could be deleted. If yes add log entry and display success message + if ($query->rowCount() > 0) { + + $template_file = $spracheResponse->table_add; + $loguseraction = '%psw% %user% ' . $cname; + $insertlog->execute(); + + // Nothing was deleted, display an error + } else { + $template_file = $spracheResponse->error_table; + } + } } + + // GET Request did not add up. Display 404 error. } else { $template_file = 'admin_404.tpl'; } + +// List the available entries } else { - $ticketLinks['Y'] = 'admin.php?w=us&a='.$ui->id('a',3, 'get'); - $ticketLinks['N'] = 'admin.php?w=us&a='.$ui->id('a',3, 'get'); - $ticketLinks['R'] = 'admin.php?w=us&a='.$ui->id('a',3, 'get'); + configureDateTables('-1, -2', '1, "asc"', 'ajax.php?w=datatable&d=user'); - $o = $ui->st('o', 'get'); - - if ($ui->st('o', 'get') == 'da') { - $orderby = '`active` DESC'; - } else if ($ui->st('o', 'get') == 'aa') { - $orderby = '`active` ASC'; - } else if ($ui->st('o', 'get') == 'dn') { - $orderby = '`name` DESC'; - } else if ($ui->st('o', 'get') == 'an') { - $orderby = '`name` ASC'; - } else if ($ui->st('o', 'get') == 'du') { - $orderby = '`cname` DESC'; - } else if ($ui->st('o', 'get') == 'au') { - $orderby = '`cname` ASC'; - } else if ($ui->st('o', 'get') == 'dt') { - $orderby = '`accounttype` DESC'; - } else if ($ui->st('o', 'get') == 'at') { - $orderby = '`accounttype` ASC'; - } else if ($ui->st('o', 'get') == 'di') { - $orderby = '`id` DESC'; - } else { - $orderby = '`id` ASC'; - $o = 'ai'; - } - - $table = array(); - $selected = array(); - $and = ''; - - if (!$pa['user']) { - $and = " AND `accounttype` IN ('u','r')"; - } - - if (isset($ui->get['state'])) { - foreach ($ui->get['state'] as $get) { - if (preg_match('/[YNR]/',$get)) $selected[] = $get; - } - } else { - $selected=array('Y','N','R'); - } - foreach ($ticketLinks as $k => $v) { - foreach (array('Y','N','R') as $s) { - if ((in_array($s,$selected) and $k != $s) or (!in_array($s,$selected) and $k==$s)) $ticketLinks[$k] .= '&state[]='.$s; - } - } - - if (count($selected) == 1) { - $and .= " AND `active`='${selected[0]}'"; - } else if (count($selected) == 2) { - $and .= " AND (`active`='${selected[0]}' OR `active`='${selected[1]}')"; - } - - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT `id`,`active`,`cname`,`name`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`) ${and} ORDER BY $orderby LIMIT $start,$amount"); - $query->execute(); - } else { - $query = $sql->prepare("SELECT `id`,`active`,`cname`,`name`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE `id`!=:id AND `resellerid`=:id ${and} ORDER BY $orderby LIMIT $start,$amount"); - $query->execute(array(':id' => $resellerLockupID)); - } - - $query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='us' AND (`status` IS NULL OR `status`=1 OR `status`=4) ORDER BY `jobID` DESC LIMIT 1"); - while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $adminaccount = false; - - if ($row['accounttype'] == 'a') { - $adminaccount = true; - $accounttype = $sprache->accounttype_admin; - } else if ($row['accounttype'] == 'r') { - $accounttype = $sprache->accounttype_reseller; - } else { - $accounttype = $sprache->accounttype_user; - } - - if ($row['jobPending'] == 'Y') { - $query2->execute(array($row['id'], $row['resellerid'])); - while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { - if ($row2['action'] == 'ad') { - $jobPending = $gsprache->add; - } else if ($row2['action'] == 'dl') { - $jobPending = $gsprache->del; - } else { - $jobPending = $gsprache->mod; - } - - $json = @json_decode($row2['extraData']); - $tobeActive = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N'; - } - - } else { - $jobPending = $gsprache->no; - } - - if (($row['active'] == 'Y' and $row['jobPending'] == 'N') or ($row['jobPending'] == 'Y') and isset($tobeActive) and $tobeActive == 'Y') { - $imgName = '16_ok'; - $imgAlt = 'Active'; - } else { - $imgName = '16_bad'; - $imgAlt = 'Inactive'; - } - $table[] = array('id' => $row['id'], 'img' => $imgName,'alt' => $imgAlt,'adminaccount' => $adminaccount,'accounttype' => $accounttype,'cname' => $row['cname'], 'name' => $row['name'], 'jobPending' => $jobPending,'active' => $row['active']); - } - - $next = $start+$amount; - - if ($reseller_id == 0) { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`) ${and}"); - $query->execute(); - } else { - $query = $sql->prepare("SELECT COUNT(`id`) AS `amount` FROM `userdata` WHERE `id`=:id AND `resellerid`=:id ${and}"); - $query->execute(array(':id' => $resellerLockupID)); - } - - $colcount = $query->fetchColumn(); - if ($colcount > $next) { - $vor = $start+$amount; - } else { - $vor = $start; - } - $back = $start - $amount; - if ($back >= 0){ - $zur = $start - $amount; - } else { - $zur = $start; - } - $pageamount = ceil($colcount / $amount); - $link='1'; - } else { - $link .= '&p=0">1'; - } - $pages[] = $link; - $i = 1; - while ($i<$pageamount) { - $selectpage = ($i - 1) * $amount; - if ($start==$selectpage) { - $pages[] = '' . $i . ''; - } else { - $pages[] = '' . $i . ''; - } - $i++; - } - $pages=implode(', ',$pages); $template_file = 'admin_user_list.tpl'; } \ No newline at end of file diff --git a/web/stuff/ajax/datatable_gameserver.php b/web/stuff/ajax/datatable_gameserver.php index 8974e455..1b54c64d 100644 --- a/web/stuff/ajax/datatable_gameserver.php +++ b/web/stuff/ajax/datatable_gameserver.php @@ -37,7 +37,6 @@ * Programm erhalten haben. Wenn nicht, siehe . */ - if (!defined('AJAXINCLUDED')) { die('Do not access directly!'); } @@ -97,14 +96,14 @@ if ($sSearch) { } $query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='gs' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1"); +$query3 = $sql->prepare("UPDATE `gsswitch` SET `jobPending`='N' WHERE `id`=? AND `resellerid`=? LIMIT 1"); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { - $tobeActive = false; $jobPending = $gsprache->no; $statusMessage = $gsprache->status_ok; - if (isset($row['jobPending']) and $row['jobPending'] == 'Y') { + if ($row['jobPending'] == 'Y') { $query2->execute(array($row['id'], $resellerLockupID)); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { @@ -118,7 +117,11 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { } $json = @json_decode($row2['extraData']); - $tobeActive = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N'; + $row['status'] = ((is_object($json) and isset($json->newActive) and $json->newActive == 'N')) ? 2 : 0; + } + + if ($query2->rowCount() == 0) { + $query3->execute(array($row['id'], $resellerLockupID)); } } diff --git a/web/stuff/ajax/datatable_user.php b/web/stuff/ajax/datatable_user.php new file mode 100644 index 00000000..08e8e7a9 --- /dev/null +++ b/web/stuff/ajax/datatable_user.php @@ -0,0 +1,188 @@ + + * + * This file is part of Easy-WI. + * + * Easy-WI is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Easy-WI is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Easy-WI. If not, see . + * + * Diese Datei ist Teil von Easy-WI. + * + * Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen + * der GNU General Public License, wie von der Free Software Foundation, + * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren + * veroeffentlichten Version, weiterverbreiten und/oder modifizieren. + * + * Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber + * OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite + * Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK. + * Siehe die GNU General Public License fuer weitere Details. + * + * Sie sollten eine Kopie der GNU General Public License zusammen mit diesem + * Programm erhalten haben. Wenn nicht, siehe . + */ + + +if (!defined('AJAXINCLUDED')) { + die('Do not access directly!'); +} + +$sprache = getlanguagefile('user', $user_language, $reseller_id); + +if ($reseller_id == 0) { + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`)"); + $query->execute(); +} else { + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userdata` WHERE `id`=:id AND `resellerid`=:id"); + $query->execute(array(':id' => $resellerLockupID)); +} + +$array['iTotalRecords'] = $query->fetchColumn(); + +if ($sSearch) { + + $toLower = strtolower($sSearch); + + $accountTypeQuery = array(); + + if (strpos(strtolower($sprache->accounttype_admin), $toLower) !== false) { + $accountTypeQuery[] = 'OR `accounttype`=\'a\''; + } + + if (strpos(strtolower($sprache->accounttype_reseller), $toLower) !== false) { + $accountTypeQuery[] = 'OR `accounttype`=\'r\''; + } + + if (strpos(strtolower($sprache->accounttype_user), $toLower) !== false) { + $accountTypeQuery[] = 'OR `accounttype`=\'u\''; + } + + $accountTypeQuery = (count($accountTypeQuery) > 0) ? implode(' ', $accountTypeQuery) : ''; + + $activeQuery = array(); + + if (strpos(strtolower($gsprache->status_inactive), $toLower) !== false) { + $activeQuery[] = 'OR `active`=\'N\''; + } + + if (strpos(strtolower($gsprache->status_ok), $toLower) !== false) { + $activeQuery[] = 'OR `active`=\'Y\''; + } + + $activeQuery = (count($activeQuery) > 0) ? implode(' ', $activeQuery) : ''; + + if ($reseller_id == 0) { + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`) AND (`cname` LIKE :search OR `id` LIKE :search OR CONCAT(`vname`,' ',`name`) LIKE :search {$accountTypeQuery} {$activeQuery})"); + $query->execute(array(':search' => '%' . $sSearch . '%')); + } else { + $query = $sql->prepare("SELECT COUNT(1) AS `amount` FROM `userdata` WHERE `id`=:id AND `resellerid`=:id AND (`cname` LIKE :search OR `id` LIKE :search OR CONCAT(`vname`,' ',`name`) LIKE :search {$accountTypeQuery} {$activeQuery})"); + $query->execute(array(':search' => '%' . $sSearch . '%', ':id' => $resellerLockupID)); + } + + $array['iTotalDisplayRecords'] = $query->fetchColumn(); + +} else { + $array['iTotalDisplayRecords'] = $array['iTotalRecords']; +} + +$orderFields = array(0 => '`cname`', 1 => '`id`', 2 => '`full_name`', 3 => '`active`', 4 => '`accounttype`'); + +if (isset($orderFields[$iSortCol]) and is_array($orderFields[$iSortCol])) { + $orderBy = implode(' ' . $sSortDir . ', ', $orderFields[$iSortCol]) . ' ' . $sSortDir; +} else if (isset($orderFields[$iSortCol]) and !is_array($orderFields[$iSortCol])) { + $orderBy = $orderFields[$iSortCol] . ' ' . $sSortDir; +} else { + $orderBy = '`id` DESC'; +} + +if ($sSearch) { + + if ($reseller_id == 0) { + $query = $sql->prepare("SELECT `cname`,`id`,CONCAT(`vname`,' ',`name`) AS `full_name`,`active`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`) AND (`cname` LIKE :search OR `id` LIKE :search OR CONCAT(`vname`,' ',`name`) LIKE :search {$accountTypeQuery} {$activeQuery}) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array(':search' => '%' . $sSearch . '%')); + } else { + $query = $sql->prepare("SELECT `cname`,`id`,CONCAT(`vname`,' ',`name`) AS `full_name`,`active`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE `id`!=:id AND `resellerid`=:id AND (`cname` LIKE :search OR `id` LIKE :search OR CONCAT(`vname`,' ',`name`) LIKE :search {$accountTypeQuery} {$activeQuery}) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array(':search' => '%' . $sSearch . '%', ':id' => $resellerLockupID)); + } + +} else { + + if ($reseller_id == 0) { + $query = $sql->prepare("SELECT `cname`,`id`,CONCAT(`vname`,' ',`name`) AS `full_name`,`active`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE (`resellerid`=0 OR `id`=`resellerid`) ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(); + } else { + $query = $sql->prepare("SELECT `cname`,`id`,CONCAT(`vname`,' ',`name`) AS `full_name`,`active`,`accounttype`,`jobPending`,`resellerid` FROM `userdata` WHERE `id`!=:id AND `resellerid`=:id ORDER BY $orderBy LIMIT {$iDisplayStart},{$iDisplayLength}"); + $query->execute(array(':id' => $resellerLockupID)); + } +} + +$query2 = $sql->prepare("SELECT `action`,`extraData` FROM `jobs` WHERE `affectedID`=? AND `resellerID`=? AND `type`='us' AND (`status` IS NULL OR `status`=1) ORDER BY `jobID` DESC LIMIT 1"); +$query3 = $sql->prepare("UPDATE `userdata` SET `jobPending`='N' WHERE `id`=? AND `resellerid`=? LIMIT 1"); + +while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + $jobPending = $gsprache->no; + $statusMessage = $gsprache->status_ok; + + if ($row['jobPending'] == 'Y') { + + $query2->execute(array($row['id'], $row['resellerid'])); + while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { + + if ($row2['action'] == 'ad') { + $jobPending = $gsprache->add; + } else if ($row2['action'] == 'dl') { + $jobPending = $gsprache->del; + } else { + $jobPending = $gsprache->mod; + } + + $json = @json_decode($row2['extraData']); + $row['active'] = (is_object($json) and isset($json->newActive)) ? $json->newActive : 'N'; + } + + if ($query2->rowCount() == 0) { + $query3->execute(array($row['id'], $row['resellerid'])); + } + } + + $statusMessage = ($row['active'] == 'N') ? $gsprache->status_inactive : $gsprache->status_ok; + + if ($row['accounttype'] == 'a') { + $accounttype = $sprache->accounttype_admin; + } else if ($row['accounttype'] == 'r') { + $accounttype = $sprache->accounttype_reseller; + } else { + $accounttype = $sprache->accounttype_user; + } + + $actionString = ''; + + if ($pa['userPassword'] and (($row['accounttype'] == 'a' and $pa['user']) or $row['accounttype'] != 'a')) { + $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_pw.tpl', 'us', 'pw', $row['id'], $gsprache->password); + } + + if ($row['id'] != $admin_id and (($row['accounttype'] == 'a' and $pa['user']) or ($row['accounttype'] != 'a' and ($pa['user_users'] or $pa['user'])))) { + $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_dl.tpl', 'us', 'dl', $row['id'], $gsprache->del); + } + if (($row['accounttype'] == 'a' and $pa['user']) or ($row['accounttype'] != 'a' and ($pa['user_users'] or $pa['user']))) { + $actionString .= ' ' . returnButton($template_to_use, 'ajax_admin_buttons_md.tpl', 'us', 'md', $row['id'], $gsprache->mod); + } + + $array['aaData'][] = array(returnButton($template_to_use, 'ajax_admin_user_switch.tpl', $row['cname'], '', $row['id'], ''), $row['id'], $row['full_name'], returnButton($template_to_use, 'ajax_admin_show_status.tpl', '', '', ($row['active'] == 'N') ? 3 : 4, (string) $statusMessage), (string) $accounttype, (string) $jobPending, $actionString); +} \ No newline at end of file diff --git a/web/stuff/global_userdata.php b/web/stuff/global_userdata.php index c699ed49..7f912497 100644 --- a/web/stuff/global_userdata.php +++ b/web/stuff/global_userdata.php @@ -88,7 +88,8 @@ if ($ui->st('d', 'get') == 'pw') { if (!$ui->smallletters('action',2, 'post')) { $template_file = ($logusertype == 'user') ? 'userpanel_pass.tpl' : 'admin_user_own_pass.tpl'; - } else if ($ui->smallletters('action',2, 'post') == 'md'){ + } else if ($ui->smallletters('action',2, 'post') == 'md') { + $errors = array(); if (!$ui->password('password', 255, 'post')) { diff --git a/web/stuff/jobs/jobs_mysql.php b/web/stuff/jobs/jobs_mysql.php index 2bb58dfb..ae1db763 100644 --- a/web/stuff/jobs/jobs_mysql.php +++ b/web/stuff/jobs/jobs_mysql.php @@ -45,6 +45,7 @@ $query4 = $sql->prepare("SELECT e.`active`,e.`dbname`,AES_DECRYPT(e.`password`,? $query5 = $sql->prepare("DELETE FROM `mysql_external_dbs` WHERE `id`=? LIMIT 1"); $query6 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? LIMIT 1"); $query7 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE (`status` IS NULL OR `status`='1') AND `type`='my' AND `hostID`=?"); +$query8 = $sql->prepare("UPDATE `jobs` SET `action`='dl' WHERE `hostID`=? AND `type`='my'"); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { @@ -56,8 +57,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $remotesql = new ExternalSQL ($row2['ip'], $row2['port'], $row2['user'], $row2['decryptedpassword']); } - - if (isset($remotesql) and $remotesql->error == 'ok') { + if (isset($remotesql) or $remotesql->error == 'ok') { $query3->execute(array($row['hostID'])); while ($row2 = $query3->fetch(PDO::FETCH_ASSOC)) { @@ -111,7 +111,22 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $query6->execute(array($row2['jobID'])); } - } else { + } else if (isset($remotesql)) { + $query7->execute(array($row['hostID'])); + + } else { + + $query8->execute(array($row['hostID'])); + + $query3->execute(array($row['hostID'])); + while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) { + if ($row2['action'] == 'dl') { + + $query5->execute(array($row2['affectedID'])); + + customColumns('M', $row2['affectedID'], 'del'); + } + } } } \ No newline at end of file diff --git a/web/stuff/jobs/jobs_user.php b/web/stuff/jobs/jobs_user.php index aca7e16e..0dac492d 100644 --- a/web/stuff/jobs/jobs_user.php +++ b/web/stuff/jobs/jobs_user.php @@ -87,7 +87,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $query2 = $sql->prepare("UPDATE `jobs` SET `status`='4' WHERE `jobID`=? LIMIT 1"); $query2->execute(array($row['jobID'])); - updateJobs($row['affectedID'], $row['resellerID'],$jobPending='Y'); + updateJobs($row['affectedID'], $row['resellerID'], 'Y'); $theOutput->printGraph($command); } \ No newline at end of file diff --git a/web/stuff/jobs/jobs_user_rm.php b/web/stuff/jobs/jobs_user_rm.php index d6a2c2c2..c8ecfe5e 100644 --- a/web/stuff/jobs/jobs_user_rm.php +++ b/web/stuff/jobs/jobs_user_rm.php @@ -55,13 +55,14 @@ if (!function_exists('removeUser')) { } } -$query = $sql->prepare("SELECT * FROM `jobs` j WHERE `status`='4' AND `type`='us' AND `action` IN ('dl','md') AND NOT EXISTS (SELECT 1 FROM `jobs` WHERE `userID`=j.`userID` AND (`status`=1 OR `status` IS NULL) AND `type`!='us' LIMIT 1)"); +$query = $sql->prepare("SELECT j.* FROM `jobs` AS j WHERE `status`='4' AND `type`='us' AND `action` IN ('dl','md') AND NOT EXISTS (SELECT 1 FROM `jobs` WHERE `userID`=j.`userID` AND (`status`=1 OR `status` IS NULL) AND `type`!='us' LIMIT 1)"); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $ok = true; if ($row['action'] == 'dl') { + $query2 = $sql->prepare("SELECT `accounttype`,`resellerid` FROM `userdata` WHERE `id`=? LIMIT 1"); $query2->execute(array($row['affectedID'])); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { @@ -108,7 +109,6 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { 'voice_masterserver' => 'resellerid', 'translations' => 'resellerID', 'voice_server_stats' => 'resellerid', - 'voice_stats_settings' => 'resellerid', 'mysql_external_servers' => 'resellerid', 'mysql_external_dbs' => 'resellerid', 'usergroups' => 'resellerid', @@ -117,6 +117,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { 'voice_tsdns' => 'resellerid', 'voice_dns' => 'resellerID' ); + removeUser($row['affectedID'],$tables); if ($row2['resellerid'] == $row['affectedID']) { @@ -140,7 +141,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $query2 = $sql->prepare("DELETE FROM `userdata` WHERE `id`=? LIMIT 1"); $query2->execute(array($row['affectedID'])); - $command = $gsprache->del.' userID: ' . $row['affectedID'] . ' name:' . $row['name']; + $command = $gsprache->del . ' userID: ' . $row['affectedID'] . ' name:' . $row['name']; } else { @@ -177,7 +178,7 @@ $sql->exec("DELETE o.* FROM `userdata_substitutes_servers` o LEFT JOIN `userdata $sql->exec("DELETE s.* FROM `userdata_social_identities` s LEFT JOIN `userdata` u ON s.`userID`=u.`id` WHERE u.`id` IS NULL"); $sql->exec("DELETE s.* FROM `userdata_social_identities_substitutes` s LEFT JOIN `userdata_substitutes` u ON s.`userID`=u.`sID` WHERE u.`sID` IS NULL"); $sql->exec("DELETE g.* FROM `gsswitch` g LEFT JOIN `userdata` u ON g.`userid`=u.`id` WHERE u.`id` IS NULL"); -$sql->exec("DELETE FROM `gsswitch` WHERE NOT EXISTS (SELECT 1 FROM `serverlist` WHERE `switchID`=`gsswitch`.`id`)"); +#$sql->exec("DELETE FROM `gsswitch` WHERE NOT EXISTS (SELECT 1 FROM `serverlist` WHERE `switchID`=`gsswitch`.`id`)"); $sql->exec("DELETE s.* FROM `serverlist` s LEFT JOIN `gsswitch` g ON s.`switchID`=g.`id` WHERE g.`id` IS NULL"); $sql->exec("DELETE a.* FROM `addons_installed` a LEFT JOIN `serverlist` s ON a.`serverid`=s.`id` WHERE s.`id` IS NULL"); $sql->exec("DELETE a.* FROM `addons_installed` a LEFT JOIN `userdata` u ON a.`userid`=u.`id` WHERE u.`id` IS NULL"); diff --git a/web/stuff/jobs/jobs_voice.php b/web/stuff/jobs/jobs_voice.php index 41c30a00..995fb0ce 100644 --- a/web/stuff/jobs/jobs_voice.php +++ b/web/stuff/jobs/jobs_voice.php @@ -44,6 +44,8 @@ $query2 = $sql->prepare("SELECT `active`,`usedns`,`defaultdns`,`bitversion`,`def $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + unset($queryport); + $query2->execute(array(':aeskey' => $aeskey,':id' => $row['hostID'], ':reseller_id' => $row['resellerID'])); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { @@ -82,15 +84,196 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { } } - if (isset($queryport)) { + if (isset($queryip, $queryport)) { + $connection = new TS3($queryip, $queryport, 'serveradmin', $querypassword); $errorcode = $connection->errorcode; - } - if (!isset($errorcode) or strpos($errorcode, 'error id=0') === false) { + if (!isset($errorcode) or strpos($errorcode, 'error id=0') === false) { - $query2 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE `status` IS NULL AND `type`='vo' AND `hostID`=?"); - $query2->execute(array($row['hostID'])); + $query2 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE `status` IS NULL AND `type`='vo' AND `hostID`=?"); + $query2->execute(array($row['hostID'])); + + } else { + + $query2 = $sql->prepare("SELECT * FROM `jobs` WHERE (`status` IS NULL OR `status`='1') AND `type`='vo' AND `hostID`=?"); + $query2->execute(array($row['hostID'])); + while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { + + $extraData = @json_decode($row2['extraData']); + + $query3 = $sql->prepare("SELECT * FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1"); + $query3->execute(array($row2['affectedID'], $row2['resellerID'])); + while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) { + + $active = $row3['active']; + $localserverid = $row3['localserverid']; + $backup = $row3['backup']; + $lendserver = $row3['lendserver']; + $ip = $row3['ip']; + $port = $row3['port']; + $slots = $row3['slots']; + $initialpassword = $row3['initialpassword']; + $password = $row3['password']; + $forcebanner = $row3['forcebanner']; + $forcebutton = $row3['forcebutton']; + $forceservertag = $row3['forceservertag']; + $forcewelcome = $row3['forcewelcome']; + $maxtraffic = $row3['maxtraffic']; + $filetraffic = $row3['filetraffic']; + $max_download_total_bandwidth = $row3['max_download_total_bandwidth']; + $max_upload_total_bandwidth = $row3['max_upload_total_bandwidth']; + $dns = $row3['dns']; + $masterserver = $row3['masterserver']; + } + + if ($row2['action'] == 'dl' and isset($localserverid) and isid($localserverid, 30)) { + + $command = $gsprache->del . ' voiceserverID: ' . $row2['affectedID'] . ' name:'.$row2['name']; + $connection->DelServer($localserverid); + + $query3 = $sql->prepare("DELETE FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1"); + $query3->execute(array($row2['affectedID'], $row['resellerID'])); + + customColumns('T', $row2['affectedID'], 'del'); + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); + + if ($usedns == 'Y') { + tsdns('dl', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip), array($port), array($dns), $row['resellerID']); + } + + tsbackup('delete', $ssh2user, $serverdir, $masterserver, $localserverid, '*'); + + $query3 = $sql->prepare("DELETE v.* FROM `voice_server_backup` v LEFT JOIN `userdata` u ON v.`uid`=u.`id` WHERE u.`id` IS NULL"); + $query3->execute(); + + } else if ($row2['action'] == 'ad' and isset($active)) { + + if (isid($localserverid, 30)) { + + $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Skipping, virtual ID already exists in Easy-WI DB: '.$localserverid; + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); + + } else { + + $virtualserver_id = $connection->AddServer($slots, $ip, $port, $initialpassword, $name, array('Y', $welcome), $max_download_total_bandwidth, $max_upload_total_bandwidth, array('Y', $hostbanner_url), $hostbanner_gfx_url, array('Y', $hostbutton_url), $hostbutton_gfx_url, $hostbutton_tooltip); + + if (isid($virtualserver_id, 19)) { + + $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Name:'.$row2['name']; + + if ($active == 'N') { + $connection->StopServer($virtualserver_id); + } + + $query3 = $sql->prepare("UPDATE `voice_server` SET `localserverid`=?,`jobPending`='N' WHERE `id`=? LIMIT 1"); + $query3->execute(array($virtualserver_id, $row2['affectedID'])); + + if ($usedns == 'Y') { + $template_file = tsdns('md', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip), array($port), array($dns), $row['resellerID']); + } + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `affectedID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['affectedID'])); + + } else { + + $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Error: '.$virtualserver_id; + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); + } + } + + } else if ($row2['action'] == 'md' and isset($localserverid) and isid($localserverid, 30)) { + + $command = $gsprache->mod . ' voiceserverID: ' . $row2['affectedID'] . ' name:' . $row2['name']; + + $query3 = $sql->prepare("SELECT `active`,`slots`,`ip`,`port`,`dns` FROM `voice_server` WHERE `id`=? LIMIT 1"); + $query3->execute(array($row2['affectedID'])); + foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row3) { + + $oldip = $row3['ip']; + $oldport = $row3['port']; + $olddns = $row3['dns']; + $connection->StartServer($localserverid); + $serverdetails = $connection->ServerDetails($localserverid); + $name = $serverdetails['virtualserver_name']; + $welcome = $serverdetails['virtualserver_welcomemessage']; + $hostbanner_url = $serverdetails['virtualserver_hostbanner_url']; + $hostbanner_gfx_url = $serverdetails['virtualserver_hostbanner_gfx_url']; + $hostbutton_tooltip = $serverdetails['virtualserver_hostbutton_tooltip']; + $hostbutton_url = $serverdetails['virtualserver_hostbutton_url']; + $hostbutton_gfx_url = $serverdetails['virtualserver_hostbutton_gfx_url']; + + $connection->ModServer($localserverid, $slots, $ip, $port, $initialpassword, $name, $welcome, $max_download_total_bandwidth, $max_upload_total_bandwidth, $hostbanner_url, $hostbanner_gfx_url, $hostbutton_url, $hostbutton_gfx_url, $hostbutton_tooltip); + + if ($forcebanner== 'Y') { + $removelist[] = 'b_virtualserver_modify_hostbanner'; + $removelist[] = 'i_needed_modify_power_virtualserver_modify_hostbanner'; + } else if ($forcebanner== 'N') { + $addlist[] = 'b_virtualserver_modify_hostbanner'; + $addlist[] = 'i_needed_modify_power_virtualserver_modify_hostbanner'; + } + + if ($forcebutton == 'Y') { + $removelist[] = 'b_virtualserver_modify_hostbutton'; + $removelist[] = 'i_needed_modify_power_virtualserver_modify_hostbutton'; + } else if ($forcebutton == 'N') { + $addlist[] = 'b_virtualserver_modify_hostbutton'; + $addlist[] = 'i_needed_modify_power_virtualserver_modify_hostbutton'; + } + + if ($forcewelcome == 'Y') { + $removelist[] = 'b_virtualserver_modify_welcomemessage'; + $removelist[] = 'i_needed_modify_power_virtualserver_modify_welcomemessage'; + } else if ($forcewelcome == 'N') { + $addlist[] = 'b_virtualserver_modify_welcomemessage'; + $addlist[] = 'i_needed_modify_power_virtualserver_modify_welcomemessage'; + } + + if (isset($addlist)) { + $connection->AdminPermissions($localserverid,'add', $addlist); + } + + if (isset($removelist)) { + $connection->AdminPermissions($localserverid,'del', $removelist); + } + + if ($usedns == 'Y') { + $template_file = tsdns('md', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip, $oldip), array($port, $oldport), array($dns, $olddns), $row2['resellerID']); + } + + if ($row3['active'] == 'N' or $extraData->newActive == 'N') { + $connection->StopServer($localserverid); + } + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); + + $query3 = $sql->prepare("UPDATE `voice_server` SET `jobPending`='N' WHERE `id`=? LIMIT 1"); + $query3->execute(array($row2['affectedID'])); + } + } else if (!isset($localserverid) or !isid($localserverid, 30)) { + + $command = 'Error: can not find voiceserver'; + + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); + + } else { + $command='Error: unknown command'; + } + + $theOutput->printGraph($command); + } + + $connection->CloseConnection(); + } } else { @@ -98,178 +281,14 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $query2->execute(array($row['hostID'])); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { - $extraData = @json_decode($row2['extraData']); + $query3 = $sql->prepare("DELETE FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1"); + $query3->execute(array($row2['affectedID'], $row['resellerID'])); - $query3 = $sql->prepare("SELECT * FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1"); - $query3->execute(array($row2['affectedID'], $row2['resellerID'])); - while ($row3 = $query3->fetch(PDO::FETCH_ASSOC)) { + $query3 = $sql->prepare("DELETE v.* FROM `voice_server_backup` v LEFT JOIN `userdata` u ON v.`uid`=u.`id` WHERE u.`id` IS NULL"); + $query3->execute(); - $active = $row3['active']; - $localserverid = $row3['localserverid']; - $backup = $row3['backup']; - $lendserver = $row3['lendserver']; - $ip = $row3['ip']; - $port = $row3['port']; - $slots = $row3['slots']; - $initialpassword = $row3['initialpassword']; - $password = $row3['password']; - $forcebanner = $row3['forcebanner']; - $forcebutton = $row3['forcebutton']; - $forceservertag = $row3['forceservertag']; - $forcewelcome = $row3['forcewelcome']; - $maxtraffic = $row3['maxtraffic']; - $filetraffic = $row3['filetraffic']; - $max_download_total_bandwidth = $row3['max_download_total_bandwidth']; - $max_upload_total_bandwidth = $row3['max_upload_total_bandwidth']; - $dns = $row3['dns']; - $masterserver = $row3['masterserver']; - } - - if ($row2['action'] == 'dl' and isset($localserverid) and isid($localserverid, 30)) { - - $command = $gsprache->del . ' voiceserverID: ' . $row2['affectedID'] . ' name:'.$row2['name']; - $connection->DelServer($localserverid); - - $query3 = $sql->prepare("DELETE FROM `voice_server` WHERE `id`=? AND `resellerid`=? LIMIT 1"); - $query3->execute(array($row2['affectedID'], $row['resellerID'])); - - customColumns('T', $row2['affectedID'], 'del'); - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['jobID'])); - - if ($usedns == 'Y') { - tsdns('dl', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip), array($port), array($dns), $row['resellerID']); - } - - tsbackup('delete', $ssh2user, $serverdir, $masterserver, $localserverid, '*'); - - $query3 = $sql->prepare("DELETE v.* FROM `voice_server_backup` v LEFT JOIN `userdata` u ON v.`uid`=u.`id` WHERE u.`id` IS NULL"); - $query3->execute(); - - } else if ($row2['action'] == 'ad' and isset($active)) { - - if (isid($localserverid, 30)) { - - $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Skipping, virtual ID already exists in Easy-WI DB: '.$localserverid; - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['jobID'])); - - } else { - - $virtualserver_id = $connection->AddServer($slots, $ip, $port, $initialpassword, $name, array('Y', $welcome), $max_download_total_bandwidth, $max_upload_total_bandwidth, array('Y', $hostbanner_url), $hostbanner_gfx_url, array('Y', $hostbutton_url), $hostbutton_gfx_url, $hostbutton_tooltip); - - if (isid($virtualserver_id, 19)) { - - $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Name:'.$row2['name']; - - if ($active == 'N') { - $connection->StopServer($virtualserver_id); - } - - $query3 = $sql->prepare("UPDATE `voice_server` SET `localserverid`=?,`jobPending`='N' WHERE `id`=? LIMIT 1"); - $query3->execute(array($virtualserver_id, $row2['affectedID'])); - - if ($usedns == 'Y') { - $template_file = tsdns('md', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip), array($port), array($dns), $row['resellerID']); - } - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `affectedID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['affectedID'])); - - } else { - - $command = $gsprache->add.' voiceserverID: '.$row2['affectedID'].'; Error: '.$virtualserver_id; - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['jobID'])); - } - } - - } else if ($row2['action'] == 'md' and isset($localserverid) and isid($localserverid, 30)) { - - $command = $gsprache->mod . ' voiceserverID: ' . $row2['affectedID'] . ' name:' . $row2['name']; - - $query3 = $sql->prepare("SELECT `active`,`slots`,`ip`,`port`,`dns` FROM `voice_server` WHERE `id`=? LIMIT 1"); - $query3->execute(array($row2['affectedID'])); - foreach ($query3->fetchAll(PDO::FETCH_ASSOC) as $row3) { - - $oldip = $row3['ip']; - $oldport = $row3['port']; - $olddns = $row3['dns']; - $connection->StartServer($localserverid); - $serverdetails = $connection->ServerDetails($localserverid); - $name = $serverdetails['virtualserver_name']; - $welcome = $serverdetails['virtualserver_welcomemessage']; - $hostbanner_url = $serverdetails['virtualserver_hostbanner_url']; - $hostbanner_gfx_url = $serverdetails['virtualserver_hostbanner_gfx_url']; - $hostbutton_tooltip = $serverdetails['virtualserver_hostbutton_tooltip']; - $hostbutton_url = $serverdetails['virtualserver_hostbutton_url']; - $hostbutton_gfx_url = $serverdetails['virtualserver_hostbutton_gfx_url']; - - $connection->ModServer($localserverid, $slots, $ip, $port, $initialpassword, $name, $welcome, $max_download_total_bandwidth, $max_upload_total_bandwidth, $hostbanner_url, $hostbanner_gfx_url, $hostbutton_url, $hostbutton_gfx_url, $hostbutton_tooltip); - - if ($forcebanner== 'Y') { - $removelist[] = 'b_virtualserver_modify_hostbanner'; - $removelist[] = 'i_needed_modify_power_virtualserver_modify_hostbanner'; - } else if ($forcebanner== 'N') { - $addlist[] = 'b_virtualserver_modify_hostbanner'; - $addlist[] = 'i_needed_modify_power_virtualserver_modify_hostbanner'; - } - - if ($forcebutton == 'Y') { - $removelist[] = 'b_virtualserver_modify_hostbutton'; - $removelist[] = 'i_needed_modify_power_virtualserver_modify_hostbutton'; - } else if ($forcebutton == 'N') { - $addlist[] = 'b_virtualserver_modify_hostbutton'; - $addlist[] = 'i_needed_modify_power_virtualserver_modify_hostbutton'; - } - - if ($forcewelcome == 'Y') { - $removelist[] = 'b_virtualserver_modify_welcomemessage'; - $removelist[] = 'i_needed_modify_power_virtualserver_modify_welcomemessage'; - } else if ($forcewelcome == 'N') { - $addlist[] = 'b_virtualserver_modify_welcomemessage'; - $addlist[] = 'i_needed_modify_power_virtualserver_modify_welcomemessage'; - } - - if (isset($addlist)) { - $connection->AdminPermissions($localserverid,'add', $addlist); - } - - if (isset($removelist)) { - $connection->AdminPermissions($localserverid,'del', $removelist); - } - - if ($usedns == 'Y') { - $template_file = tsdns('md', $queryip, $ssh2port, $ssh2user, $publickey, $keyname, $ssh2password, $mnotified, $serverdir, $bitversion, array($ip, $oldip), array($port, $oldport), array($dns, $olddns), $row2['resellerID']); - } - - if ($row3['active'] == 'N' or $extraData->newActive == 'N') { - $connection->StopServer($localserverid); - } - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['jobID'])); - - $query3 = $sql->prepare("UPDATE `voice_server` SET `jobPending`='N' WHERE `id`=? LIMIT 1"); - $query3->execute(array($row2['affectedID'])); - } - } else if (!isset($localserverid) or !isid($localserverid, 30)) { - - $command = 'Error: can not find voiceserver'; - - $query3 = $sql->prepare("UPDATE `jobs` SET `status`='2' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); - $query3->execute(array($row2['jobID'])); - - } else { - $command='Error: unknown command'; - } - - $theOutput->printGraph($command); + $query3 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? AND `type`='vo' LIMIT 1"); + $query3->execute(array($row2['jobID'])); } - - $connection->CloseConnection(); } } \ No newline at end of file diff --git a/web/stuff/jobs/jobs_webspace.php b/web/stuff/jobs/jobs_webspace.php index b65f49bf..4afd1c11 100644 --- a/web/stuff/jobs/jobs_webspace.php +++ b/web/stuff/jobs/jobs_webspace.php @@ -43,14 +43,19 @@ $query3 = $sql->prepare("DELETE FROM `webVhost` WHERE `webVhostID`=? LIMIT 1"); $query4 = $sql->prepare("SELECT `active` FROM `webVhost` WHERE `webVhostID`=? LIMIT 1"); $query5 = $sql->prepare("UPDATE `jobs` SET `status`='3' WHERE `jobID`=? LIMIT 1"); $query6 = $sql->prepare("UPDATE `webVhost` SET `jobPending`='N' WHERE `webVhostID`=? LIMIT 1"); -$query7 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE (`status` IS NULL OR `status`='1') IS NULL AND `type`='wv' AND `hostID`=?"); +$query7 = $sql->prepare("UPDATE `jobs` SET `status`='1' WHERE (`status` IS NULL OR `status`='1') AND `type`='wv' AND `hostID`=?"); +$query8 = $sql->prepare("UPDATE `jobs` SET `action`='dl' WHERE `hostID`=? AND `type`='wv'"); $query->execute(); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $vhostObject = new HttpdManagement($row['hostID'], $row['resellerID']); - if ($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) { + if (($vhostObject != false and $vhostObject->ssh2Connect() and $vhostObject->sftpConnect()) or $vhostObject->masterNotfound) { + + if ($vhostObject->masterNotfound) { + $query8->execute(array($row['hostID'])); + } $query2->execute(array($row['hostID'])); while ($row2 = $query2->fetch(PDO::FETCH_ASSOC)) { @@ -59,7 +64,9 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { if ($row2['action'] == 'dl') { - $vhostObject->vhostDelete($row2['affectedID']); + if (!$vhostObject->masterNotfound) { + $vhostObject->vhostDelete($row2['affectedID']); + } $query3->execute(array($row2['affectedID'])); @@ -91,6 +98,7 @@ while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $vhostObject->restartHttpdServer(); } else { + $theOutput->printGraph('cannot connect to web host with ID: ' . $row['hostID']); $query7->execute(array($row['hostID'])); } } \ No newline at end of file diff --git a/web/stuff/methods/class_httpd.php b/web/stuff/methods/class_httpd.php index 4bf4cd74..42b73970 100644 --- a/web/stuff/methods/class_httpd.php +++ b/web/stuff/methods/class_httpd.php @@ -53,7 +53,7 @@ class HttpdManagement { // Data private $sql, $aeskey, $resellerID, $hostID, $ssh2Pass, $hostData = array(), $vhostData = false, $dataPrepared = false; - public $ssh2Object = false, $sftpObject = false; + public $ssh2Object = false, $sftpObject = false, $masterNotfound = false; public function __destruct() { unset($this->sql, $this->aeskey, $this->hostID, $this->ssh2Object, $this->sftpObject); @@ -129,8 +129,9 @@ class HttpdManagement { return true; } - return false; + $this->masterNotfound = true; + return false; } private function removeNotNeededSlashes ($value) { diff --git a/web/stuff/methods/class_masterserver.php b/web/stuff/methods/class_masterserver.php index 60c64cb5..fb52e880 100644 --- a/web/stuff/methods/class_masterserver.php +++ b/web/stuff/methods/class_masterserver.php @@ -55,6 +55,7 @@ class masterServer { private $updateIDs = array(); private $removeLogs = array(); + private $winCmds = array(); private $imageserver, $resellerID, $webhost, $rootOK, $rootID, $rootNotifiedCount, $steamAccount, $steamPassword, $updates, $os, $aeskey, $shellScript, $uniqueHex, $masterserverDir; public $sship, $sshport, $sshuser, $sshpass, $publickey, $keyname; public $updateAmount = 0; @@ -117,66 +118,117 @@ class masterServer { $this->webhost = $query->fetchColumn(); } + private function checkIfImageServerIsInSameSubnet ($type, $imageString) { + + // Get the imageserver if possible and use Easy-WI server as fallback + $mainIp = explode('.', $this->sship); + $mainSubnet = $mainIp[0] . '.' . $mainIp[1] . '.' . $mainIp[2]; + + if ($type == 'rsync') { + $splitPaths = @preg_split('/\//', $imageString, -1, PREG_SPLIT_NO_EMPTY); + $splitCredentialsAndServer = (isset($split1[1])) ? preg_split('/\:/', $splitPaths[1], -1, PREG_SPLIT_NO_EMPTY) : preg_split('/\:/', $splitPaths[0], -1, PREG_SPLIT_NO_EMPTY); + } else { + $splitPaths = @preg_split('/\//', $imageString, -1, PREG_SPLIT_NO_EMPTY); + $splitCredentialsAndServer = (isset($split1[1])) ? preg_split('/\@/', $splitPaths[1], -1, PREG_SPLIT_NO_EMPTY) : preg_split('/\@/', $splitPaths[0], -1, PREG_SPLIT_NO_EMPTY); + } + + foreach ($splitCredentialsAndServer as $splitIp) { + + if ($splitIp != $this->sship && isip($splitIp, 'all')) { + + $ipParts = explode('.', $splitIp); + $subnet = $ipParts[0] . '.' . $ipParts[1] . '.' . $ipParts[2]; + + if ($mainSubnet == $subnet) { + return $imageString; + } + } + } + + return false; + } + + private function getPreferdImageServer ($preferedServer, $allServer) { + + if (count($preferedServer) > 0) { + $allServer = $preferedServer; + } + + if (count($allServer) > 0) { + $imageserverCount = count($allServer) - 1; + $arrayEntry = rand(0, $imageserverCount); + return $imageserverCount[$arrayEntry]; + } + + return false; + } + private function getImageServer () { global $sql; - // Get the imageserver if possible and use Easy-WI server as fallback - $mainip = explode('.', $this->sship); - $mainsubnet = $mainip[0] . '.' . $mainip[1] . '.' . $mainip[2]; - $query = $sql->prepare("SELECT `imageserver` FROM `settings` WHERE `resellerid`=? LIMIT 1"); $query->execute(array($this->resellerID)); $splitImageservers = preg_split('/\r\n/', $query->fetchColumn(), -1, PREG_SPLIT_NO_EMPTY); - $imageservers = array(); + $rsyncServers = array(); + $ftpServers = array(); foreach ($splitImageservers as $server) { - - $split2 = array(); - if (isurl($server)) { - $imageservers[] = $server; - $split1 = preg_split('/\//', $server, -1, PREG_SPLIT_NO_EMPTY); - $split2 = (isset($split1[1])) ? preg_split('/\@/', $split1[1], -1, PREG_SPLIT_NO_EMPTY) : preg_split('/\@/', $split1[0], -1, PREG_SPLIT_NO_EMPTY); - + $ftpServers[] = $server; } else if (isRsync($server)) { - $imageservers[] = $server; - $split1 = preg_split('/\//', $server, -1, PREG_SPLIT_NO_EMPTY); - $split2 = (isset($split1[1])) ? preg_split('/\:/', $split1[1], -1, PREG_SPLIT_NO_EMPTY) : preg_split('/\:/', $split1[0], -1, PREG_SPLIT_NO_EMPTY); + $rsyncServers[] = $server; } + } - foreach ($split2 as $splitip) { + $preferedServer = array(); - if ($splitip == $this->sship) { - $noSync = true; + if ($this->os == 'L' and count($rsyncServers) > 0) { - } else if (isip($splitip,'all')) { - $ipparts = explode('.', $splitip); - $subnet = $ipparts[0] . '.' . $ipparts[1] . '.' . $ipparts[2]; + foreach ($rsyncServers as $server) { - if ($mainsubnet == $subnet) { - $imageserver = $server; - } + $imageServer = $this->checkIfImageServerIsInSameSubnet('rsync', $server); + + if ($imageServer) { + $preferedServer[] = $imageServer; } } + + $imageServer = $this->getPreferdImageServer($preferedServer, $rsyncServers); } - if (!isset($imageserver) and count($imageservers) > 0) { - $imageserver_count = count($imageservers) - 1; - $arrayentry = rand(0, $imageserver_count); - $imageserver = $imageservers[$arrayentry]; + if (!isset($imageServer) and count($ftpServers) > 0) { + foreach ($ftpServers as $server) { + + $imageServer = $this->checkIfImageServerIsInSameSubnet('ftp', $server); + + if ($imageServer) { + $preferedServer[] = $imageServer; + } + } + + $imageServer = $this->getPreferdImageServer($preferedServer, $ftpServers); } - if (!isset($imageserver)) { - $imageserver = 'easywi'; + if (!isset($imageServer) or !$imageServer) { + $imageServer = 'easywi'; } - if (isset($noSync) or $this->updates == 2) { - $imageserver = 'none'; + if ($this->updates == 2) { + $imageServer = 'none'; } - $this->imageserver = $imageserver; + $this->imageserver = $imageServer; + } + + private function imageStringtoWinDeamon () { + + if (isurl($this->imageserver)) { + return ftpStringToData($this->imageserver); + } + + return false; } public function getCommands () { @@ -185,7 +237,7 @@ class masterServer { return $this->shellScript; } - return false; + return implode('
', $this->winCmds); } private function startShellScript () { @@ -245,6 +297,13 @@ class masterServer { $this->shellScript .= '$SYNCCMD/masterserver/' . $shorten . ' > ' . $updateLog . "\n"; $this->shellScript .= '${IONICE}nice -n +19 find ' . $this->masterserverDir . $shorten . '/ -type f -name "*.listing" -delete' . "\n"; $this->shellScript .= 'fi' . "\n"; + } else { + + $imageServer = $this->imageStringtoWinDeamon(); + + if (is_array($imageServer)) { + $this->winCmds[] = 'master ' . $shorten . ' ftp:' . $imageServer['server'] . ':' . $imageServer['port'] . ':' . $imageServer['user'] . ':' . $imageServer['pwd'] . ':/Masterserver ' . $this->webhost . '/get_password.php?w=ms&shorten=' . $shorten; + } } } @@ -408,6 +467,38 @@ class masterServer { } } + private function windowsCollectData ($row) { + + if ($row['supdates'] != 3 and $row['updates'] != 3) { + + if (strlen($this->steamAccount) > 0) { + + $connectData = $this->steamAccount; + + if (strlen($this->steamPassword) > 0) { + $connectData .= ':' . $this->steamPassword; + } + + } else if (strlen($row['steamAcc']) > 0) { + + $connectData = $row['steamAcc']; + + if (strlen($this->steamPassword) > 0) { + $connectData .= ':' . $row['steamPwd']; + } + + } else { + $connectData = 'anonymous'; + } + + $callBackUrl = (strlen($this->webhost) > 0) ? $this->webhost . '/get_password.php?w=ms&shorten=' . $row['shorten'] : ''; + + $this->winCmds[] = 'master ' . $row['shorten'] . ' steam:' . $connectData . ':' . workAroundForValveChaos($row['appID'], $row['shorten'], false) . ' ' . $callBackUrl; + } + + $this->updateAmount++; + } + private function addonSync ($serverTypeIDs) { if (count($serverTypeIDs) > 0) { @@ -432,6 +523,22 @@ class masterServer { $this->shellScript .= 'fi' . "\n"; $this->shellScript .= 'find ' . $absoluteAddonPath . ' -type d -exec chmod 750 {} \;' . "\n"; $this->shellScript .= 'find ' . $absoluteAddonPath . ' -type f -exec chmod 640 {} \;' . "\n"; + + } else { + + $imageServer = $this->imageStringtoWinDeamon(); + + if ($row['type'] == 'tool') { + $addonMasterFolder = 'MasterAddons'; + $addonCmd = 'masteraddon'; + } else { + $addonMasterFolder = 'MasterMaps'; + $addonCmd = 'mastermaps'; + } + + if (is_array($imageServer)) { + $this->winCmds[] = $addonCmd . ' install ' . $imageServer['server'] . ' ' . $imageServer['port'] . ' ' . $imageServer['user'] . ' ' . $imageServer['pwd'] . ' /' . $addonMasterFolder . ' ' . $row['addon']; + } } } } @@ -474,6 +581,8 @@ class masterServer { if ($this->os == 'L') { $this->linuxCollectData($row, $force, $returnSuccessInAnyCase); + } else { + $this->windowsCollectData($row, $force, $returnSuccessInAnyCase); } // Set masterserver to updating @@ -557,56 +666,95 @@ class masterServer { return $ssh2Pass; } + private function linuxSshConnectAndExecute ($updating, $getReturn, $ssh2Pass) { + + $sftpObject = new Net_SFTP($this->sship, $this->sshport); + + $loginReturn = $sftpObject->login($this->sshuser, $ssh2Pass); + + if ($loginReturn) { + + $sftpObject->put('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh', $this->shellScript); + $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh'); + + // File has been created, now login with SSH2 and execute the script + $sshObject = new Net_SSH2($this->sship, $this->sshport); + + if ($sshObject->login($this->sshuser, $ssh2Pass)) { + + if ($updating === true) { + + $this->setUpdating(); + + $removeLogs = $this->removeUpdateLogs(); + + if ($removeLogs !== false) { + $sftpObject->put('/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh', $removeLogs); + $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh'); + } + } + + if ($getReturn === false) { + + $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh & '); + + return true; + } + + return $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh'); + } + } + + return false; + } + + private function windowsSshConnectAndExecute ($updating, $getReturn, $ssh2Pass) { + + $sshObject = new Net_SSH2($this->sship, $this->sshport); + + if ($sshObject->login($this->sshuser, $ssh2Pass)) { + + if ($updating === true) { + $this->setUpdating(); + } + + if ($getReturn === false) { + + foreach ($this->winCmds as $command) { + $sshObject->exec($command . "\r\n"); + } + + return true; + } + + $return = ''; + + foreach ($this->winCmds as $command) { + + $temp = $sshObject->exec($command . "\r\n"); + + if ($temp) { + $return .= $temp; + } + } + + return $return; + } + + return false; + } + public function sshConnectAndExecute ($updating = true, $getReturn = false) { $ssh2Pass = $this->getKeyAndOrPassword(); - if ($this->os == 'L') { - - $sftpObject = new Net_SFTP($this->sship, $this->sshport); - - $loginReturn = $sftpObject->login($this->sshuser, $ssh2Pass); - - if ($loginReturn) { - - $sftpObject->put('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh', $this->shellScript); - $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh'); - - // File has been created, now login with SSH2 and execute the script - $sshObject = new Net_SSH2($this->sship, $this->sshport); - - if ($sshObject->login($this->sshuser, $ssh2Pass)) { - - if ($updating === true) { - - $this->setUpdating(); - - $removeLogs = $this->removeUpdateLogs(); - - if ($removeLogs !== false) { - $sftpObject->put('/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh', $removeLogs); - $sftpObject->chmod(0700, '/home/' . $this->sshuser . '/temp/remove-update-logs-' . $this->uniqueHex . '.sh'); - } - } - - if ($getReturn === false) { - - $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh & '); - - return true; - } - - return $sshObject->exec('/home/' . $this->sshuser . '/temp/master-' . $this->uniqueHex . '.sh'); - } - } - - } else { + $return = ($this->os == 'L') ? $this->linuxSshConnectAndExecute($updating, $getReturn, $ssh2Pass) : $this->windowsSshConnectAndExecute($updating, $getReturn, $ssh2Pass); + if (!$return) { + $this->handleFailedConnectAttemps(); } - $this->handleFailedConnectAttemps(); - - return false; + return $return; } private function linuxCheckForUpdate ($shorten) { @@ -651,12 +799,16 @@ class masterServer { $this->shellScript .= 'if [ -d "' . $this->masterserverDir . $shorten . '" ]; then rm -rf "' . $this->masterserverDir . $shorten . '"; fi' . "\n"; } + private function WindowsMasterRemove ($shorten) { + $this->winCmds[] = 'delmaster ' . $shorten; + } + public function masterRemove ($shorten) { if ($this->os == 'L') { $this->linuxMasterRemove($shorten); } else { - + $this->WindowsMasterRemove($shorten); } } diff --git a/web/stuff/methods/functions.php b/web/stuff/methods/functions.php index c9e78291..9d6a64f4 100644 --- a/web/stuff/methods/functions.php +++ b/web/stuff/methods/functions.php @@ -899,7 +899,7 @@ if (!function_exists('passwordgenerate')) { return (array_key_exists($key, $array) and $array[$key] == $value) ? true : false; } - function updateJobs($localID, $resellerID, $jobPending='Y') { + function updateJobs($localID, $resellerID, $jobPending = 'Y') { global $sql; @@ -945,6 +945,35 @@ if (!function_exists('passwordgenerate')) { } } + function CopyAdminTable ($tablename, $id, $reseller_id, $limit, $where='') { + + global $sql; + + $query = $sql->prepare("SELECT * FROM `$tablename` WHERE `resellerid`=? " . $where . " " .$limit); + $query->execute(array($reseller_id)); + while ($row = $query->fetch(PDO::FETCH_ASSOC)) { + + $keys = array(); + $questionmarks = array(); + $intos = array(); + + foreach ($row as $key=>$value) { + if ($key != 'id' and $key != 'resellerid'){ + $keys[]="`".$key."`"; + $questionmarks[] = '?'; + $intos[] = $value; + } + } + + $keys[] = "`resellerid`"; + $intos[] = $id; + $questionmarks[] = '?'; + $into = 'INSERT INTO `' . $tablename . '` (' . implode(',', $keys) . ') VALUES (' . implode(',', $questionmarks) . ')'; + $query2 = $sql->prepare("$into"); + $query2->execute($intos); + } + } + function dataExist ($value, $array) { return (isset($array[$value]) and isset($array[$array[$value]]) and !in_array($array[$array[$value]], array(false, null,''))) ? true : false; } diff --git a/web/template/adminlte/admin/admin_gserver_md.tpl b/web/template/adminlte/admin/admin_gserver_md.tpl index b840484a..2241c232 100644 --- a/web/template/adminlte/admin/admin_gserver_md.tpl +++ b/web/template/adminlte/admin/admin_gserver_md.tpl @@ -166,7 +166,7 @@
-
+
diff --git a/web/template/adminlte/admin/admin_header.tpl b/web/template/adminlte/admin/admin_header.tpl index 981166f4..71f9a163 100644 --- a/web/template/adminlte/admin/admin_header.tpl +++ b/web/template/adminlte/admin/admin_header.tpl @@ -306,7 +306,7 @@
    -
  • smallletters('w',255,'get')=='us') echo 'class="active"';?>> user.' '.$gsprache->overview;?>
  • +
  • smallletters('w',255,'get')=='us') echo 'class="active"';?>> user.' '.$gsprache->overview;?>
  • smallletters('w',255,'get')=='ug') echo 'class="active"';?>> groups;?>
  • diff --git a/web/template/adminlte/admin/admin_social_provider_add.tpl b/web/template/adminlte/admin/admin_social_provider_add.tpl index 2a107e83..df1700a7 100644 --- a/web/template/adminlte/admin/admin_social_provider_add.tpl +++ b/web/template/adminlte/admin/admin_social_provider_add.tpl @@ -2,6 +2,7 @@

    Social Auth Provider

    diff --git a/web/template/adminlte/admin/admin_social_provider_dl.tpl b/web/template/adminlte/admin/admin_social_provider_dl.tpl index dde6b0e5..21ea56d4 100644 --- a/web/template/adminlte/admin/admin_social_provider_dl.tpl +++ b/web/template/adminlte/admin/admin_social_provider_dl.tpl @@ -2,6 +2,7 @@

    Social Auth Provider

    diff --git a/web/template/adminlte/admin/admin_social_provider_list.tpl b/web/template/adminlte/admin/admin_social_provider_list.tpl index b6124895..14548d3c 100644 --- a/web/template/adminlte/admin/admin_social_provider_list.tpl +++ b/web/template/adminlte/admin/admin_social_provider_list.tpl @@ -2,6 +2,7 @@

    Social Auth Provider

    @@ -24,7 +25,7 @@ Service Provider - status;?> + active;?> action;?> @@ -32,7 +33,7 @@ - + yes : $gsprache->no;?> del;?> mod;?> @@ -43,7 +44,7 @@ Service Provider - status;?> + active;?> action;?> diff --git a/web/template/adminlte/admin/admin_social_provider_md.tpl b/web/template/adminlte/admin/admin_social_provider_md.tpl index c1a6e9f6..5c2c9184 100644 --- a/web/template/adminlte/admin/admin_social_provider_md.tpl +++ b/web/template/adminlte/admin/admin_social_provider_md.tpl @@ -2,6 +2,7 @@

    Social Auth Provider

    diff --git a/web/template/adminlte/admin/admin_user_add.tpl b/web/template/adminlte/admin/admin_user_add.tpl new file mode 100644 index 00000000..a7ce3e19 --- /dev/null +++ b/web/template/adminlte/admin/admin_user_add.tpl @@ -0,0 +1,392 @@ +
    +

    user;?>

    + +
    + +
    + + 0){ ?> +
    +
    +
    + +

    errors;?>

    + +
    +
    +
    + + +
    +
    +
    + +
    + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +
    +
    + + \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_dl.tpl b/web/template/adminlte/admin/admin_user_dl.tpl new file mode 100644 index 00000000..ec5f56ba --- /dev/null +++ b/web/template/adminlte/admin/admin_user_dl.tpl @@ -0,0 +1,45 @@ +
    +

    user;?>

    + +
    + +
    +
    +
    +
    + +
    + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_groups_list.tpl b/web/template/adminlte/admin/admin_user_groups_list.tpl index e384087b..39cdcb74 100644 --- a/web/template/adminlte/admin/admin_user_groups_list.tpl +++ b/web/template/adminlte/admin/admin_user_groups_list.tpl @@ -2,8 +2,8 @@

    groups;?>

    @@ -38,7 +38,7 @@ - + yes : $gsprache->no;?> diff --git a/web/template/adminlte/admin/admin_user_list.tpl b/web/template/adminlte/admin/admin_user_list.tpl new file mode 100644 index 00000000..ab59ec4e --- /dev/null +++ b/web/template/adminlte/admin/admin_user_list.tpl @@ -0,0 +1,51 @@ +
    +

    user;?>

    + +
    + +
    + +
    +
    + user;?> add;?> +
    +
    +
    + +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    nickname;?>IDuser;?>active;?>accounttype;?>jobPending;?>action;?>
    nickname;?>IDuser;?>active;?>accounttype;?>jobPending;?>action;?>
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_md.tpl b/web/template/adminlte/admin/admin_user_md.tpl new file mode 100644 index 00000000..6d63e4cc --- /dev/null +++ b/web/template/adminlte/admin/admin_user_md.tpl @@ -0,0 +1,265 @@ +
    +

    user;?>

    + +
    + +
    + + 0){ ?> +
    +
    +
    + +

    errors;?>

    + +
    +
    +
    + + +
    +
    +
    + +
    + + + + +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    +
    + +
    +
    + +
    + +
    + +
    +
    + +
    +
    + +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + + + +
    + +
    + +
    +
    + +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_own_md.tpl b/web/template/adminlte/admin/admin_user_own_md.tpl new file mode 100644 index 00000000..d47c5d61 --- /dev/null +++ b/web/template/adminlte/admin/admin_user_own_md.tpl @@ -0,0 +1,164 @@ +
    +

    settings;?>

    + +
    + +
    + +
    +
    +
    + +
    + + + + +
    + + 0 ) echo '

    Social Auth

    ';?> + + + + + + 0 ) echo '
    ';?> + +

    Mails

    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +

    user;?>

    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_own_pass.tpl b/web/template/adminlte/admin/admin_user_own_pass.tpl new file mode 100644 index 00000000..a9e14c35 --- /dev/null +++ b/web/template/adminlte/admin/admin_user_own_pass.tpl @@ -0,0 +1,43 @@ +
    +

    passw;?>

    + +
    + + +
    + +
    +
    +
    + +
    + + + + +
    +
    + +
    + +
    +
    +
    + +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/admin/admin_user_pass.tpl b/web/template/adminlte/admin/admin_user_pass.tpl new file mode 100644 index 00000000..ee859f74 --- /dev/null +++ b/web/template/adminlte/admin/admin_user_pass.tpl @@ -0,0 +1,72 @@ +
    +

    user;?>

    + +
    + +
    + + 0){ ?> +
    +
    +
    + +

    errors;?>

    + +
    +
    +
    + + +
    +
    +
    + +
    + + + + +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    +
    + + +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/web/template/adminlte/ajax/ajax_admin_buttons_pw.tpl b/web/template/adminlte/ajax/ajax_admin_buttons_pw.tpl new file mode 100644 index 00000000..78742625 --- /dev/null +++ b/web/template/adminlte/ajax/ajax_admin_buttons_pw.tpl @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/web/template/default/admin/admin_header.tpl b/web/template/default/admin/admin_header.tpl index 92597ccb..7b37eb24 100644 --- a/web/template/default/admin/admin_header.tpl +++ b/web/template/default/admin/admin_header.tpl @@ -256,7 +256,7 @@