public function testCreateReservationFromWeekdaytoWeekend(){ $this->setSessionUserAdmin(); $startDate = '2011-11-18'; # A Friday $length = 1; $endDate = '2011-11-21'; # The Next Monday $actualLength = 3; $equipId = 1; $userComment = "test user comment"; $adminComment = "test admin comment"; $modStatus = RES_STATUS_PENDING; createReservation(getSessionVariable('user_id'), $equipId, $startDate, $length, $userComment, $adminComment, $modStatus); $actualReservation = mysql_fetch_assoc(doQuery("select * from ".getConfigVar('db_prefix')."_reservations ORDER BY res_id DESC LIMIT 1")); $this->assertEquals(getSessionVariable('user_id'), $actualReservation['user_id'], "User IDs not equal"); $this->assertEquals($equipId, $actualReservation['equip_id'], "Equip IDs not equal"); $this->assertEquals($startDate, $actualReservation['start_date'], "Start dates not equal"); $this->assertEquals($actualLength, $actualReservation['length'], "Lengths not equal"); $this->assertEquals($endDate, $actualReservation['end_date'], "End dates not equal"); $this->assertEquals($userComment, $actualReservation['user_comment'], "User comments not equal"); $this->assertEquals($adminComment, $actualReservation['admin_comment'], "Admin comments not equal"); $this->assertEquals($modStatus, $actualReservation['mod_status'], "Statuses not equal"); }
function getModulePath($module) { static $arrModulePath = array(); if (!isFrameworkInstalled()) { return AUIEO_FRAMEWORK_PATH . "modules/"; } if (!isApplicationInstalled()) { if (file_exists("modules/{$module}")) { return "modules/"; } else { return AUIEO_FRAMEWORK_PATH . "modules/"; } } if (isset($arrModulePath[$module])) { return $arrModulePath[$module]; } $modulePath = getConfigVar("MODULE_PATH"); if (!is_null($modulePath)) { if (file_exists("{$modulePath}{$module}")) { $arrModulePath[$module] = "{$modulePath}"; return $arrModulePath[$module]; } } if (file_exists("modules/{$module}")) { $arrModulePath[$module] = "modules/"; return $arrModulePath[$module]; } if (file_exists(AUIEO_FRAMEWORK_PATH . "modules/{$module}")) { $arrModulePath[$module] = AUIEO_FRAMEWORK_PATH . "modules/"; return $arrModulePath[$module]; } return null; }
function db_error_logger($errno, $errstr, $errfile = "", $errline = "", $errorcontext = array()){ $errno = makeStringSafe($errno); $errstr = makeStringSafe($errstr); $errfile = makeStringSafe($errfile); $errline = makeStringSafe($errline); if($errno < E_STRICT){ doQuery("INSERT INTO ".getDBPrefix()."_error_log set user_id = '".getSessionVariable("user_id")."', error_number = '".$errno."', message = '".$errstr."', file = '".$errfile."', line_number = '".$errline."', context = '".serialize($errorcontext)."', time = '".getCurrentMySQLDateTime()."'"); $errorrow = mysql_fetch_assoc(doQuery("SELECT error_id FROM ".getDBPrefix()."_error_log ORDER BY error_id DESC LIMIT 1")); if(getConfigVar('error_output') == ERROR_OUTPUT_DBID || getConfigVar('error_output') == ERROR_OUTPUT_BOTH){ echo "<h4 style=\"color: #FF0000;\">An error occured! If you would like to report this error, please report that your 'ERROR_ID' is '".$errorrow['error_id']."'.</h4>"; } } return !(getConfigVar("error_output") == ERROR_OUTPUT_PHP || getConfigVar("error_output") == ERROR_OUTPUT_BOTH); }
public static function setUpBeforeClass() { // make sure DETECT_URLS is set to yes self::$detect_urls_var = getConfigVar('DETECT_URLS'); if (self::$detect_urls_var != 'yes') { setConfigVar('DETECT_URLS', 'yes'); } }
function sendWarningNotice($userid, $reason, $type) { $subject = "Reservation System Warning"; $message = "You have been given a(n) " . getWarningType($type) . ". The reason given was: " . $reason; $headers = 'From: ' . getConfigVar('smtp_email') . "\r\n" . 'Reply-To: ' . getConfigVar('smtp_email') . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $user = mysql_fetch_assoc(getUserByID($userid)); //sendMail(getConfigVar('smtp_email'), $user['email'], $subject, $message); mail($row['email'], $subject, $message); }
function initMySQL() { global $link; $link = mysql_connect(getConfigVar('mysql_server'), getConfigVar('mysql_user'), getConfigVar('mysql_password')); if (!$link) { die('<script language="Javascript"> alert("Q' . $numqs . ': Could not connect: ' . mysql_error($link) . '")</script>'); } $db_selected = mysql_select_db(getConfigVar('mysql_database'), $link); if (!$db_selected) { die('<script language="Javascript"> alert("Q' . $numqs . ': Couldn\'t use ' . getConfigVar('mysql_database') . ': ' . mysql_error($link) . '")</script>'); } }
public function testSetSessionVariableShouldSetValue() { $variableName = "varTestSet"; $expectedValue = "TestValue"; setSessionVariable($variableName, $expectedValue); $this->assertTrue(isset($_SESSION[getConfigVar('location').'-'.$variableName]), "setSessionVariable(variable_name, value) did not set session variable."); $this->assertEquals($expectedValue, $_SESSION[getConfigVar('location').'-'.$variableName], "setSessionVariable(variable_name, value) improperly set value."); }
function getEquipmentTypesDropDownSelected($name, $size, $selectedvalue) { $types = getConfigVar("equipment_types"); $options = ""; foreach ($types as $type) { if ($selectedvalue == $type) { $options = $options . "<option value=\"" . $type . "\" selected=\"selected\">" . $type . "</option>"; } else { $options = $options . "<option value=\"" . $type . "\">" . $type . "</option>"; } } $dropdown = "<select name=\"" . $name . "\" size=\"" . $size . "\">" . $options . "</select>"; return $dropdown; }
public function dispatch() { $msgheader = array(self::NOT_AUTHENTICATED => 'Not authenticated', self::MISCONFIGURED => 'Configuration error', self::INTERNAL => 'Internal error', self::DB_WRITE_FAILED => 'Database write failed'); $msgbody = array(self::NOT_AUTHENTICATED => '<h2>This system requires authentication. You should use a username and a password.</h2>', self::MISCONFIGURED => '<h2>Configuration error</h2><br>' . $this->message, self::INTERNAL => '<h2>Internal error</h2><br>' . $this->message, self::DB_WRITE_FAILED => '<h2>Database write failed</h2><br>' . $this->message); switch ($this->code) { case self::NOT_AUTHENTICATED: header('WWW-Authenticate: Basic realm="' . getConfigVar('enterprise') . ' RackTables access"'); header("HTTP/1.1 401 Unauthorized"); case self::MISCONFIGURED: case self::INTERNAL: case self::DB_WRITE_FAILED: $this->genHTMLPage($msgheader[$this->code], $msgbody[$this->code]); break; default: throw new RackTablesError('Dispatching error, unknown code ' . $this->code, RackTablesError::INTERNAL); } }
public static function setUpBeforeClass() { // make sure AUTOPORTS_CONFIG is empty self::$autoports_config_var = getConfigVar('AUTOPORTS_CONFIG'); if (self::$autoports_config_var != '') { setConfigVar('AUTOPORTS_CONFIG', ''); } // find a port type that is incompatible with 1000Base-T $result = usePreparedSelectBlade('SELECT type1 FROM PortCompat WHERE type1 != 24 AND type2 != 24 LIMIT 1'); self::$portc_type = $result->fetchColumn(); // add sample data // - set port a & b's type to 1000Base-T // - set port c's type to the incompatible one self::$object_id = commitAddObject('unit test object', NULL, 4, NULL); self::$porta = commitAddPort(self::$object_id, 'test porta', '1-24', NULL, NULL); self::$portb = commitAddPort(self::$object_id, 'test portb', '1-24', NULL, NULL); self::$portc = commitAddPort(self::$object_id, 'test portc', self::$portc_type, NULL, NULL); }
function snmpgeneric_snmpconfig($object_id) { $object = spotEntity('object', $object_id); //$object['attr'] = getAttrValues($object_id); $endpoints = findAllEndpoints($object_id, $object['name']); addJS('function showsnmpv3(element) { var style; if(element.value != \'v3\') { style = \'none\'; document.getElementById(\'snmp_community_label\').style.display=\'\'; } else { style = \'\'; document.getElementById(\'snmp_community_label\').style.display=\'none\'; } var elements = document.getElementsByName(\'snmpv3\'); for(var i=0;i<elements.length;i++) { elements[i].style.display=style; } };', TRUE); addJS('function shownewobject(element) { var style; if(element.checked) { style = \'\'; } else { style = \'none\'; } var elements = document.getElementsByName(\'newobject\'); for(var i=0;i<elements.length;i++) { elements[i].style.display=style; } };', TRUE); addJS('function checkInput() { var host = document.getElementById(\'host\'); if(host.value == "-1") { var newvalue = prompt("Enter Hostname or IP Address",""); if(newvalue != "") { host.options[host.options.length] = new Option(newvalue, newvalue); host.value = newvalue; } } if(host.value != "-1" && host.value != "") return true; else return false; };', TRUE); echo '<body onload="document.getElementById(\'submitbutton\').focus(); showsnmpv3(document.getElementById(\'snmpversion\')); shownewobject(document.getElementById(\'asnewobject\'));">'; foreach ($endpoints as $key => $value) { $endpoints[$value] = $value; unset($endpoints[$key]); } unset($key); unset($value); foreach (getObjectIPv4Allocations($object_id) as $ip => $value) { $ip = ip_format($ip); if (!in_array($ip, $endpoints)) { $endpoints[$ip] = $ip; } } unset($ip); unset($value); foreach (getObjectIPv6Allocations($object_id) as $value) { $ip = ip_format(ip_parse($value['addrinfo']['ip'])); if (!in_array($ip, $endpoints)) { $endpoints[$ip] = $ip; } } unset($value); /* ask for ip/host name on submit see js checkInput() */ $endpoints['-1'] = 'ask me'; // saved snmp settings $snmpstr = strtok($object['comment'], "\n\r"); $snmpstrarray = explode(':', $snmpstr); if ($snmpstrarray[0] == "SNMP") { /* keep it compatible with older version */ switch ($snmpstrarray[2]) { case "1": $snmpstrarray[2] = 'v1'; break; case "2": case "v2C": $snmpstrarray[2] = 'v2c'; break; case "3": $snmpstrarray[2] = 'v3'; break; } $snmpnames = array('SNMP', 'host', 'version', 'community'); if ($snmpstrarray[2] == "v3") { $snmpnames = array_merge($snmpnames, array('sec_level', 'auth_protocol', 'auth_passphrase', 'priv_protocol', 'priv_passphrase')); } $snmpvalues = array(); foreach ($snmpnames as $key => $value) { if (isset($snmpstrarray[$key])) { switch ($key) { case 6: case 8: $snmpvalues[$value] = base64_decode($snmpstrarray[$key]); break; default: $snmpvalues[$value] = $snmpstrarray[$key]; } } } unset($snmpvalues['SNMP']); $snmpconfig = $snmpvalues; } else { $snmpconfig = array(); } $snmpconfig += $_POST; if (!isset($snmpconfig['host'])) { $snmpconfig['host'] = -1; /* try to find first FQDN or IP */ foreach ($endpoints as $value) { if (preg_match('/^[^ .]+(\\.[^ .]+)+\\.?/', $value)) { $snmpconfig['host'] = $value; break; } } unset($value); } // sg_var_dump_html($endpoints); if (!isset($snmpconfig['version'])) { $snmpconfig['version'] = mySNMP::SNMP_VERSION; } if (!isset($snmpconfig['community'])) { $snmpconfig['community'] = getConfigVar('DEFAULT_SNMP_COMMUNITY'); } if (empty($snmpconfig['community'])) { $snmpconfig['community'] = mySNMP::SNMP_COMMUNITY; } if (!isset($snmpconfig['sec_level'])) { $snmpconfig['sec_level'] = NULL; } if (!isset($snmpconfig['auth_protocol'])) { $snmpconfig['auth_protocol'] = NULL; } if (!isset($snmpconfig['auth_passphrase'])) { $snmpconfig['auth_passphrase'] = NULL; } if (!isset($snmpconfig['priv_protocol'])) { $snmpconfig['priv_protocol'] = NULL; } if (!isset($snmpconfig['priv_passphrase'])) { $snmpconfig['priv_passphrase'] = NULL; } if (!isset($snmpconfig['asnewobject'])) { $snmpconfig['asnewobject'] = NULL; } if (!isset($snmpconfig['object_type_id'])) { $snmpconfig['object_type_id'] = '8'; } if (!isset($snmpconfig['object_name'])) { $snmpconfig['object_name'] = NULL; } if (!isset($snmpconfig['object_label'])) { $snmpconfig['object_label'] = NULL; } if (!isset($snmpconfig['object_asset_no'])) { $snmpconfig['object_asset_no'] = NULL; } if (!isset($snmpconfig['save'])) { $snmpconfig['save'] = true; } // sg_var_dump_html($snmpconfig); // $snmpv3displaystyle = ($snmpconfig['version'] == "3" ? "style=\"\"" : "style=\"display:none;\""); echo '<h1 align=center>SNMP Config</h1>'; echo '<form method=post name="snmpconfig" onsubmit="return checkInput()" action=' . $_SERVER['REQUEST_URI'] . ' />'; echo '<table cellspacing=0 cellpadding=5 align=center class=widetable> <tr><th class=tdright>Host:</th><td>'; //if($snmpconfig['asnewobject'] == '1' ) if ($snmpconfig['host'] != '-1' and !isset($endpoints[$snmpconfig['host']])) { $endpoints[$snmpconfig['host']] = $snmpconfig['host']; } echo getSelect($endpoints, array('id' => 'host', 'name' => 'host'), $snmpconfig['host'], FALSE); echo '</td></tr> <tr> <th class=tdright><label for=snmpversion>Version:</label></th> <td class=tdleft>'; echo getSelect(array("v1" => 'v1', "v2c" => 'v2c', "v3" => 'v3'), array('name' => 'version', 'id' => 'snmpversion', 'onchange' => 'showsnmpv3(this)'), $snmpconfig['version'], FALSE); echo '</td> </tr> <tr> <th id="snmp_community_label" class=tdright><label for=community>Community:</label></th> <th name="snmpv3" style="display:none;" class=tdright><label for=community>Security Name:</label></th> <td class=tdleft><input type=text name=community value=' . $snmpconfig['community'] . ' ></td> </tr> <tr name="snmpv3" style="display:none;"> <th></th> </tr> <tr name="snmpv3" style="display:none;"> <th class=tdright><label">Security Level:</label></th> <td class=tdleft>'; echo getSelect(array('noAuthNoPriv' => 'no Auth and no Priv', 'authNoPriv' => 'auth without Priv', 'authPriv' => 'auth with Priv'), array('name' => 'sec_level'), $snmpconfig['sec_level'], FALSE); echo '</td></tr> <tr name="snmpv3" style="display:none;"> <th class=tdright><label>Auth Type:</label></th> <td class=tdleft> <input name=auth_protocol type=radio value=MD5 ' . ($snmpconfig['auth_protocol'] == 'MD5' ? ' checked="checked"' : '') . '/><label>MD5</label> <input name=auth_protocol type=radio value=SHA ' . ($snmpconfig['auth_protocol'] == 'SHA' ? ' checked="checked"' : '') . '/><label>SHA</label> </td> </tr> <tr name="snmpv3" style="display:none;"> <th class=tdright><label>Auth Key:</label></th> <td class=tdleft><input type=password id=auth_passphrase name=auth_passphrase value="' . $snmpconfig['auth_passphrase'] . '"></td> </tr> <tr name="snmpv3" style="display:none;"> <th class=tdright><label>Priv Type:</label></th> <td class=tdleft> <input name=priv_protocol type=radio value=DES ' . ($snmpconfig['priv_protocol'] == 'DES' ? ' checked="checked"' : '') . '/><label>DES</label> <input name=priv_protocol type=radio value=AES ' . ($snmpconfig['priv_protocol'] == 'AES' ? ' checked="checked"' : '') . '/><label>AES</label> </td> </tr> <tr name="snmpv3" style="display:none;"> <th class=tdright><label>Priv Key</label></th> <td class=tdleft><input type=password name=priv_passphrase value="' . $snmpconfig['priv_passphrase'] . '"></td> </tr> </tr> <tr> <th></th> <td class=tdleft> <input name=asnewobject id=asnewobject type=checkbox value=1 onchange="shownewobject(this)"' . ($snmpconfig['asnewobject'] == '1' ? ' checked="checked"' : '') . '> <label>Create as new object</label></td> </tr>'; // $newobjectdisplaystyle = ($snmpconfig['asnewobject'] == '1' ? "" : "style=\"display:none;\""); echo '<tr name="newobject" style="display:none;"> <th class=tdright>Type:</th><td class=tdleft>'; $typelist = withoutLocationTypes(readChapter(CHAP_OBJTYPE, 'o')); $typelist = cookOptgroups($typelist); printNiftySelect($typelist, array('name' => "object_type_id"), $snmpconfig['object_type_id']); echo '</td></tr> <tr name="newobject" style="display:none;"> <th class=tdright>Common name:</th><td class=tdleft><input type=text name=object_name value=' . $snmpconfig['object_name'] . '></td></tr> <tr name="newobject" style="display:none;"> <th class=tdright>Visible label:</th><td class=tdleft><input type=text name=object_label value=' . $snmpconfig['object_label'] . '></td></tr> <tr name="newobject" style="display:none;"> <th class=tdright>Asset tag:</th><td class=tdleft><input type=text name=object_asset_no value=' . $snmpconfig['object_asset_no'] . '></td></tr> <tr> <th></th> <td class=tdleft> <input name=save id=save type=checkbox value=1' . ($snmpconfig['save'] == '1' ? ' checked="checked"' : '') . '> <label>Save SNMP settings for object</label></td> </tr> <td colspan=2> <input type=hidden name=snmpconfig value=1> <input type=submit id="submitbutton" tabindex="1" value="Show List"></td></tr> </table></form>'; }
/** * Determine the site is in maintenance mode or not. * */ function is_closedMode() { $disabledAction = array('PostController/actionCreate', 'SiteController/actionIndex', 'UserController/actionCreate'); if (getConfigVar('site_close') == 1 && !isset($_SESSION['admin']) && in_array((isset($_GET['controller']) ? $_GET['controller'] : 'SiteController') . '/' . (isset($_GET['action']) ? $_GET['action'] : 'actionIndex'), $disabledAction)) { show_message(getConfigVar('close_reason')); } }
function getConfiguredQuickLinks() { $ret = array(); foreach (explode(',', getConfigVar('QUICK_LINK_PAGES')) as $page_code) { if (!empty($page_code)) { $title = getPageName($page_code); if (!empty($title)) { $ret[] = array('href' => makeHref(array('page' => $page_code)), 'title' => $title); } } } return $ret; }
function renderNewVSForm() { startPortlet('Add new virtual service'); printOpFormIntro('add'); $default_port = getConfigVar('DEFAULT_SLB_VS_PORT'); global $vs_proto; if ($default_port == 0) { $default_port = ''; } echo "<table border=0 cellpadding=5 cellspacing=0 align=center>\n"; echo "<tr><th class=tdright>VIP:</th><td class=tdleft><input type=text name=vip></td>"; echo "<tr><th class=tdright>Port:</th><td class=tdleft>"; echo "<input type=text name=vport size=5 value='{$default_port}'></td></tr>"; echo "<tr><th class=tdright>Proto:</th><td class=tdleft>"; printSelect($vs_proto, array('name' => 'proto'), array_shift(array_keys($vs_proto))); echo "</td></tr>"; echo "<tr><th class=tdright>Name:</th><td class=tdleft><input type=text name=name></td><td>"; echo "<tr><th class=tdright>Tags:</th><td class=tdleft>"; printTagsPicker(); echo "</td></tr>"; echo "<tr><th class=tdrigh>VS configuration:</th><td class=tdleft><textarea name=vsconfig rows=10 cols=80></textarea></td></tr>"; echo "<tr><th class=tdrigh>RS configuration:</th><td class=tdleft><textarea name=rsconfig rows=10 cols=80></textarea></td></tr>"; echo "<tr><td colspan=2>"; printImageHREF('CREATE', 'create virtual service', TRUE); echo "</td></tr>"; echo '</table></form>'; finishPortlet(); }
function sendMail($sender, $rec, $subj, $bod){ if(getConfigVar("send_mail")){ require_once "Mail.php"; $from = "<$sender>"; $to = "<$rec>"; $subject = $subj; $body = $bod; $host = getConfigVar('smtp_server'); $port = getConfigVar('smtp_port'); $username = getConfigVar('smtp_user'); $password = getConfigVar('smtp_password'); $headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject); $smtp = Mail::factory('smtp', array ('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $headers, $body); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { #echo("<p>Message successfully sent!</p>"); } } }
function printTagTRs($cell, $baseurl = '') { if (getConfigVar('SHOW_EXPLICIT_TAGS') == 'yes' and count($cell['etags'])) { echo "<tr><th width='50%' class=tagchain>Explicit tags:</th><td class=tagchain>"; echo serializeTags($cell['etags'], $baseurl) . "</td></tr>\n"; } if (getConfigVar('SHOW_IMPLICIT_TAGS') == 'yes' and count($cell['itags'])) { echo "<tr><th width='50%' class=tagchain>Implicit tags:</th><td class=tagchain>"; echo serializeTags($cell['itags'], $baseurl) . "</td></tr>\n"; } if (getConfigVar('SHOW_AUTOMATIC_TAGS') == 'yes' and count($cell['atags'])) { echo "<tr><th width='50%' class=tagchain>Automatic tags:</th><td class=tagchain>"; echo serializeTags($cell['atags']) . "</td></tr>\n"; } }
/** * getConfigVar 的代理函数 * @param $name * @return mixed */ public function __get($name) { return getConfigVar($name); }
assertUIntArg('object_id'); // default value for bond_name if (!isset($_REQUEST['bond_name'])) { $_REQUEST['bond_name'] = ''; } // default value for bond_type // note on meanings of on 'bond_type' values: // 'regular': Connected // 'virtual': Loopback // 'shared': Shared // 'router': Router if (!isset($_REQUEST['bond_type'])) { $_REQUEST['bond_type'] = 'regular'; } // confirm that a network exists that matches the IP address if (getConfigVar('IPV4_JAYWALK') != 'yes' and NULL === getIPAddressNetworkId($ip_bin)) { throw new InvalidRequestArgException('ip', $_REQUEST['ip'], 'no network covering the requested IP address'); } bindIPToObject($ip_bin, $_REQUEST['object_id'], $_REQUEST['bond_name'], $_REQUEST['bond_type']); redirectUser($_SERVER['SCRIPT_NAME'] . '?method=get_object&object_id=' . $_REQUEST['object_id']); break; // delete an IP address allocation for an object // UI equivalent: /index.php? // UI handler: delIPAllocation() // delete an IP address allocation for an object // UI equivalent: /index.php? // UI handler: delIPAllocation() case 'delete_object_ip_allocation': require_once 'inc/init.php'; $ip_bin = assertIPArg('ip'); assertUIntArg('object_id');
<?php if ($pageid == "warnuser") { $user = mysql_fetch_assoc(getUserByID($_GET['user_id'])); echo "\r\n\r\n\t\t<center><h3>Warn " . $user['name'] . "</h3></center>\r\n\r\n\t\t<form action=\"./index.php?pageid=submitwarning\" method=\"POST\">\r\n\t\t<input type=\"hidden\" name=\"user_id\" value=\"" . $_GET['user_id'] . "\">\r\n\t\t\t<table class=\"warning\">\r\n\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\r\n\t\t\t\t\t<td colspan=2 class=\"centeredcellbold\">Warn Reason</td>\r\n\t\t\t\t\t\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\r\n\t\t\t\t\t<td colspan=2 class=\"centeredcellbold\"><textarea cols=\"55\" rows=\"7\" name=\"reason\"></textarea></td>\r\n\t\t\t\t\r\n\t\t\t\t</tr>\r\n\t\t\t\t\r\n\t\t\t\t<tr>\r\n\t\t\t\t\r\n\t\t\t\t\t<td class=\"centeredcell\"><select name=\"type\"><option value=\"1\">Active</option><option value=\"2\">Notification</option><option value=\"3\">Inactive</option></select></td>\r\n\t\t\t\t\t<td class=\"centeredcell\"><input type=\"submit\" value=\"Warn\"></textarea></td>\r\n\t\t\t\t\r\n\t\t\t\t</tr>\r\n\t\t\t\r\n\t\t\t</table>\r\n\t\t\r\n\t\t</form>\r\n\r\n\t"; } else { if ($pageid == "submitwarning") { warnUser($_POST['user_id'], $_POST['reason'], $_POST['type']); $user = mysql_fetch_assoc(getUserByID($_POST['user_id'])); echo "<center><h3>" . $user['name'] . " Warned</h3><a href=\"./index.php?pageid=edituser&user="******"\">View User</a></center>"; } else { if ($pageid == "viewwarnings") { if (getSessionVariable('user_level') < getConfigVar("admin_rank") && getSessionVariable('user_id') != $_GET['user_id']) { echo "<center><h3><font color=\"#FF0000\">Error: You are not authorized to view other user's warnings.</font></h3></center>"; } else { $warnings = getWarningsForUser($_GET['user_id']); $user = mysql_fetch_assoc(getUserByID($_GET['user_id'])); $options = ""; while ($row = mysql_fetch_assoc($warnings)) { $options = $options . "<option value=\"" . $row['warn_id'] . "\">" . $row['time'] . " - " . getWarningType($row['type']) . "</option>"; } echo "<center><h3>View Warnings For " . $user['name'] . "</h3>"; if ($options != "") { echo "<form action=\"index.php\" method=\"GET\">\r\n\t\t\t<input type=\"hidden\" name=\"pageid\" value=\"editwarning\">\r\n\t\t\t<select name=\"warn_id\">" . $options . "</select><input type=\"submit\" value=\"View\"></form></center>"; } else { echo "<h4>User has no warnings.</h4>"; } } } else { if ($pageid == "editwarning" || $pageid == "savewarning") { $message = "";
function renderSimpleTableWithOriginEditor($rows, $column) { function printNewitemTR($column) { printOpFormIntro('add'); echo '<tr>'; echo '<td> </td>'; echo '<td class=tdleft>' . getImageHREF('create', 'create new', TRUE, 200) . '</td>'; echo "<td><input type=text size={$column['width']} name={$column['value']} tabindex=100></td>"; echo '<td class=tdleft>' . getImageHREF('create', 'create new', TRUE, 200) . '</td>'; echo '</tr></form>'; } echo '<table class=widetable border=0 cellpadding=5 cellspacing=0 align=center>'; echo "<tr><th>Origin</th><th> </th><th>{$column['header']}</th><th> </th></tr>"; if (getConfigVar('ADDNEW_AT_TOP') == 'yes') { printNewitemTR($column); } foreach ($rows as $row) { echo '<tr>'; if ($row['origin'] == 'default') { echo '<td>' . getImageHREF('computer', 'default') . '</td>'; echo '<td> </td>'; echo '<td>' . niftyString($row[$column['value']], $column['width']) . '</td>'; echo '<td> </td>'; } else { printOpFormIntro('upd', array($column['key'] => $row[$column['key']])); echo '<td>' . getImageHREF('favorite', 'custom') . '</td>'; echo '<td>' . getOpLink(array('op' => 'del', $column['key'] => $row[$column['key']]), '', 'destroy', 'remove') . '</td>'; echo "<td><input type=text size={$column['width']} name={$column['value']} value='" . niftyString($row[$column['value']], $column['width']) . "'></td>"; echo '<td>' . getImageHREF('save', 'Save changes', TRUE) . '</td>'; echo '</form>'; } echo '</tr>'; } if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { printNewitemTR($column); } echo '</table>'; }
public static function teardown(){ doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_users"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_equipment"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_blackouts"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_error_log"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_log"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_messages"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_reservations"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_users"); doQuery("TRUNCATE TABLE ".getConfigVar('db_prefix')."_warnings"); }
session_start(); //error_reporting(E_ALL); //ini_set('display_errors', '2'); require './lib/constants.php'; require 'functions.php'; $resid = 0; $page = ""; $errormessage = ""; $message = ""; if (isset($_POST['page']) && $_POST['page'] == "login") { $id = $_POST['id']; $password = $_POST['pass']; $resid = $_POST['resid']; $userq = processLogin($id, $password); $error = 0; if (getConfigVar("use_ldap")) { if (mysql_num_rows($userq) == 0) { $error = RES_ERROR_LOGIN_USER_PASS; $errormessage = "Incorrect user name or password<br><br>"; } } else { if (mysql_num_rows($userq) == 0) { $error = RES_ERROR_LOGIN_NO_USER; $errormessage = "No such user id<br><br>"; } else { $row = mysql_fetch_assoc($userq); if ($row['password'] != encrypt($password)) { $error = RES_ERROR_LOGIN_USER_PASS; $errormessage = "Incorrect user name or password<br><br>"; } }
function renderSLBTriplets2($cell, $editable = FALSE, $hl_ip = NULL) { list($realm1, $realm2) = array_values(array_diff(array('object', 'ipvs', 'ipv4rspool'), array($cell['realm']))); if ($editable && getConfigVar('ADDNEW_AT_TOP') == 'yes') { callHook('renderNewTripletForm', $realm1, $realm2); } $fields = array('ipvs' => 'vs_id', 'object' => 'object_id', 'ipv4rspool' => 'rspool_id'); $headers = array('ipvs' => 'VS', 'object' => 'LB', 'ipv4rspool' => 'RS pool'); $triplets = groupTriplets(getTriplets($cell)); // sort $headers by number of grouped cells $new_headers = array(); $grouped_by = array('ipvs' => 0, 'object' => 0, 'ipv4rspool' => 0); foreach ($triplets as $slb) { if (isset($slb['span'])) { foreach (array_keys($slb['span']) as $realm) { $grouped_by[$realm]++; } } } arsort($grouped_by, SORT_NUMERIC); foreach (array_keys($grouped_by) as $realm) { $new_headers[$realm] = $headers[$realm]; } $headers = $new_headers; // render table header if (count($triplets)) { startPortlet('VS group instances (' . count($triplets) . ')'); echo "<table cellspacing=0 cellpadding=5 align=center class=widetable><tr><th></th>"; foreach ($headers as $realm => $header) { if ($realm != $cell['realm']) { echo "<th>{$header}</th>"; } } echo '<th>Ports</th>'; echo '<th>VIPs</th>'; echo "</tr>"; } addJS('js/slb_editor.js'); addJS('js/jquery.thumbhover.js'); $class = 'slb-checks'; if ($editable) { $class .= ' editable'; } // render table rows global $nextorder; $order = 'odd'; $span = array(); foreach ($triplets as $slb) { $vs_cell = spotEntity('ipvs', $slb['vs_id']); amplifyCell($vs_cell); echo makeHtmlTag('tr', array('valign' => 'top', 'class' => "row_{$order} triplet-row", 'data-object_id' => $slb['object_id'], 'data-vs_id' => $slb['vs_id'], 'data-rspool_id' => $slb['rspool_id'])); echo '<td><a href="#" onclick="' . "slb_config_preview(event, {$slb['object_id']}, {$slb['vs_id']}, {$slb['rspool_id']}); return false" . '">' . getImageHREF('Zoom', 'config preview') . '</a></td>'; foreach (array_keys($headers) as $realm) { if ($realm == $cell['realm']) { continue; } if (isset($span[$realm])) { if (--$span[$realm] <= 0) { unset($span[$realm]); } } else { $span_html = ''; if (isset($slb['span'][$realm])) { $span[$realm] = $slb['span'][$realm] - 1; $span_html = sprintf("rowspan=%d", $slb['span'][$realm]); } echo "<td {$span_html} class=tdleft>"; $slb_cell = spotEntity($realm, $slb[$fields[$realm]]); renderSLBEntityCell($slb_cell); echo "</td>"; } } // render ports echo "<td class=tdleft><ul class='{$class}'>"; foreach ($vs_cell['ports'] as $port) { echo '<li class="' . (($row = isPortEnabled($port, $slb['ports'])) ? 'enabled' : 'disabled') . '">'; echo formatVSPort($port) . getPopupSLBConfig($row); if ($editable) { renderPopupTripletForm($slb, $port, NULL, $row); } echo '</li>'; } echo '</ul></td>'; // render VIPs echo "<td class=tdleft><ul class='{$class}'>"; foreach ($vs_cell['vips'] as $vip) { $row = isVIPEnabled($vip, $slb['vips']); $li_class = $row ? 'enabled' : 'disabled'; if ($vip['vip'] === $hl_ip && $li_class == 'enabled') { $li_class .= ' highlight'; } echo "<li class='{$li_class}'>"; echo formatVSIP($vip); if (is_array($row) && !empty($row['prio'])) { $prio_class = 'slb-prio slb-prio-' . preg_replace('/\\s.*/', '', $row['prio']); echo '<span class="' . htmlspecialchars($prio_class, ENT_QUOTES) . '">' . htmlspecialchars($row['prio']) . '</span>'; } echo getPopupSLBConfig($row); if ($editable) { renderPopupTripletForm($slb, NULL, $vip, $row); } echo '</li>'; } echo '<ul></td>'; if ($editable) { echo '<td valign=middle>'; printOpFormIntro('del', array('object_id' => $slb['object_id'], 'vs_id' => $slb['vs_id'], 'rspool_id' => $slb['rspool_id'])); printImageHREF('DELETE', 'Remove triplet', TRUE); echo '</form></td>'; } echo "</tr>\n"; $order = $nextorder[$order]; } if (count($triplets)) { echo "</table>\n"; finishPortlet(); } if ($editable && getConfigVar('ADDNEW_AT_TOP') != 'yes') { callHook('renderNewTripletForm', $realm1, $realm2); } }
/** * * Fing tab handler * */ function FingTab($id) { $can_import = permitted(NULL, NULL, 'importFingData'); // // allocation settings // // address allocation code, IPv4 networks view $aac_left = array('regular' => '', 'virtual' => '<span class="aac-left" title="Loopback">L:</span>', 'shared' => '<span class="aac-left" title="Shared">S:</span>', 'router' => '<span class="aac-left" title="Router">R:</span>', 'point2point' => '<span class="aac-left" title="Point-to-point">P:</span>'); // // header // global $pageno, $tabno; $maxperpage = getConfigVar('IPV4_ADDRS_PER_PAGE'); $range = spotEntity('ipv4net', $id); loadIPAddrList($range); echo "<center><h1>{$range['ip']}/{$range['mask']}</h1><h2>{$range['name']}</h2></center>\n"; // // execute fing // try { $known_ips = get_fing_scan($range['ip'], $range['mask']); $fing_cfg = get_fing_settings($range['ip'], $range['mask']); $fing_gw = $fing_cfg["gateway"]; } catch (FingException $e) { render_fing_error("Could not get network scan via fing:", $e->getMessage()); return FALSE; } echo "<table class=objview border=0 width='100%'><tr><td class=pcleft>"; startPortlet('overlook fing (via: ' . $fing_gw . ')'); // // pagination // if (isset($_REQUEST['pg'])) { $page = $_REQUEST['pg']; } else { $page = 0; } $startip = ip4_bin2int($range['ip_bin']); $endip = ip4_bin2int(ip_last($range)); $numpages = 0; if ($endip - $startip > $maxperpage) { $numpages = ($endip - $startip) / $maxperpage; $startip = $startip + $page * $maxperpage; $endip = $startip + $maxperpage - 1; } echo "<center>"; if ($numpages) { echo '<h3>' . ip4_format(ip4_int2bin($startip)) . ' ~ ' . ip4_format(ip4_int2bin($endip)) . '</h3>'; } for ($i = 0; $i < $numpages; $i++) { if ($i == $page) { echo "<b>{$i}</b> "; } else { echo "<a href='" . makeHref(array('page' => $pageno, 'tab' => $tabno, 'id' => $id, 'pg' => $i)) . "'>{$i}</a> "; } } echo "</center>"; if ($can_import) { printOpFormIntro('importFingData', array('addrcount' => $endip - $startip + 1)); $box_counter = 1; } echo "<table class='widetable' border=0 cellspacing=0 cellpadding=5 align='center'>\n"; echo "<tr><th class='tdleft'>address</th><th class='tdleft'>state</th><th class='tdleft'>current name</th><th class='tdleft'>DNS name</th><th class='tdleft'>MAC</th><th class='tdleft'>Allocation</th>"; if ($can_import) { echo '<th>import</th>'; } echo "</tr>\n"; // // Loop through all IPs // $cnt_match = $cnt_missing = $cnt_mismatch = $cnt_total = 0; for ($ip = $startip; $ip <= $endip; $ip++) { $cnt_total++; $print_cbox = FALSE; $ip_bin = ip4_int2bin($ip); $addr = isset($range['addrlist'][$ip_bin]) ? $range['addrlist'][$ip_bin] : array('name' => '', 'reserved' => 'no'); $straddr = ip4_format($ip_bin); list($fing_hostname, $fing_state, $fing_mac_vendor) = get_fing_info($straddr, $known_ips); $ip_is_up = strtoupper($fing_state) == "UP" ? TRUE : FALSE; if ($can_import) { echo "<input type=hidden name=addr_{$cnt_total} value={$straddr}>\n"; echo "<input type=hidden name=descr_{$cnt_total} value={$fing_hostname}>\n"; echo "<input type=hidden name=rsvd_{$cnt_total} value={$addr['reserved']}>\n"; } $skip_dns_check = FALSE; echo "<tr"; // Ignore network and broadcast addresses if ($ip == $startip && $addr['name'] == 'network' || $ip == $endip && $addr['name'] == 'broadcast') { echo " class='trbusy'"; $skip_dns_check = TRUE; } elseif (!$ip_is_up) { echo " class='trnull'"; } // set line color depending if we have the name already in the DB if (!$skip_dns_check) { if ($addr['name'] == $fing_hostname) { if (strlen($fing_hostname)) { echo ' class=trok'; $cnt_match++; } } elseif (!strlen($addr['name']) or !strlen($fing_hostname)) { echo ' class=trwarning'; $print_cbox = TRUE; $cnt_missing++; } else { echo ' class=trerror'; $print_cbox = TRUE; $cnt_mismatch++; } } //IP echo "><td class='tdleft"; if (isset($range['addrlist'][$ip_bin]['class']) and strlen($range['addrlist'][$ip_bin]['class'])) { echo ' ' . $range['addrlist'][$ip_bin]['class']; } echo "'><a href='" . makeHref(array('page' => 'ipaddress', 'ip' => $straddr)) . "'>{$straddr}</a></td>"; //other columns if ($skip_dns_check) { echo "<td class='tdleft'> </td>"; } else { if (!$ip_is_up) { echo "<td class='tdleft'>" . $fing_state . "</td>"; } else { echo "<td class='tdleft'><div class='strong'>" . $fing_state . "</div></td>"; } } echo "<td class=tdleft>{$addr['name']}</td>"; echo "<td class='tdleft'>" . $fing_hostname . "</td>"; echo "<td class='tdleft'>" . $fing_mac_vendor . "</td>"; //allocation echo "<td>"; $delim = ''; if ($addr['reserved'] == 'yes') { echo "<strong>RESERVED</strong> "; $delim = '; '; } foreach ($addr['allocs'] as $ref) { echo $delim . $aac_left[$ref['type']]; echo makeIPAllocLink($ip_bin, $ref, TRUE); $delim = '; '; } if ($delim != '') { $delim = '<br>'; } foreach ($addr['vslist'] as $vs_id) { $vs = spotEntity('ipv4vs', $vs_id); echo $delim . mkA("{$vs['name']}:{$vs['vport']}/{$vs['proto']}", 'ipv4vs', $vs['id']) . '→'; $delim = '<br>'; } foreach ($addr['vsglist'] as $vs_id) { $vs = spotEntity('ipvs', $vs_id); echo $delim . mkA($vs['name'], 'ipvs', $vs['id']) . '→'; $delim = '<br>'; } foreach ($addr['rsplist'] as $rsp_id) { $rsp = spotEntity('ipv4rspool', $rsp_id); echo "{$delim}→" . mkA($rsp['name'], 'ipv4rspool', $rsp['id']); $delim = '<br>'; } echo "</td>"; // import column if ($can_import) { echo '<td>'; if ($print_cbox) { echo "<input type=checkbox name=import_{$cnt_total} id=atom_1_" . $box_counter++ . "_1>"; } else { echo ' '; } echo '</td>'; } echo "</tr>"; } if ($can_import && $box_counter > 1) { echo '<tr><td colspan=4 align=center><input type=submit value="Import selected records"></td><td colspan=2 align=right>'; addJS('js/racktables.js'); echo --$box_counter ? "<a href='javascript:;' onclick=\"toggleColumnOfAtoms(1, 1, {$box_counter})\">(toggle selection)</a>" : ' '; echo '</td></tr>'; } echo "</table>"; if ($can_import) { echo '</form>'; } finishPortlet(); echo "</td><td class=pcright>"; // // PING Statistics // startPortlet('ping stats'); $cnt_ping_up = get_fing_up_count($known_ips); echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>"; echo "<tr class=trok><th class=tdright>Replied to Ping</th><td class=tdleft>{$cnt_ping_up}</td></tr>\n"; echo "<tr class=trwarning><th class=tdright>No Response</th><td class=tdleft>" . ($cnt_total - $cnt_ping_up) . "</td></tr>\n"; echo "</table>\n"; finishPortlet(); // // DNS Statistics // startPortlet('dns stats'); echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>"; echo "<tr class=trok><th class=tdright>Exact matches:</th><td class=tdleft>{$cnt_match}</td></tr>\n"; echo "<tr class=trwarning><th class=tdright>Missing from DB/DNS:</th><td class=tdleft>{$cnt_missing}</td></tr>\n"; if ($cnt_mismatch) { echo "<tr class=trerror><th class=tdright>Mismatches:</th><td class=tdleft>{$cnt_mismatch}</td></tr>\n"; } echo "</table>\n"; finishPortlet(); }
// Note that we don't perform autorization here, so each 1st level page // has to do it in its way, e.g. by calling authorize() after fixContext(). } elseif (!isset($remote_username)) { // Some functions require remote_username to be set to something to act correctly, // even though they don't use the value itself. $admin_account = spotEntity('user', 1); if (isCLIMode() && FALSE !== ($env_user = getenv('USER'))) { // use USER env var if we are in CLI mode $remote_username = $env_user; } else { $remote_username = $admin_account['user_name']; } unset($env_user); unset($admin_account); } $virtual_obj_types = explode(',', getConfigVar('VIRTUAL_OBJ_LISTSRC')); alterConfigWithUserPreferences(); $op = ''; // load additional plugins ob_start(); foreach (glob("{$racktables_plugins_dir}/*.php") as $filename) { require_once $filename; } // display plugins output if it contains something but newlines $tmp = ob_get_clean(); if ($tmp != '' and !preg_match("/^\n+\$/D", $tmp)) { echo $tmp; } unset($tmp); // These will be filled in by fixContext() $expl_tags = array();
} // fetch all the needed data from DB (preparing for DB connection loss) $switch_queue = array(); foreach ($switch_list as $object_id) { $cell = spotEntity('object', $object_id); $new_disabled = !considerConfiguredConstraint($cell, 'SYNC_802Q_LISTSRC'); $queue = detectVLANSwitchQueue(getVLANSwitchInfo($object_id)); if ($queue == 'disabled' xor $new_disabled) { usePreparedExecuteBlade('UPDATE VLANSwitch SET out_of_sync="yes", last_error_ts=NOW(), last_errno=? WHERE object_id=?', array($new_disabled ? E_8021Q_SYNC_DISABLED : E_8021Q_NOERROR, $object_id)); } elseif (in_array($queue, $todo[$options['mode']])) { $switch_queue[] = $cell; } } // YOU SHOULD NOT USE DB FUNCTIONS BELOW IN THE PARENT PROCESS // THE PARENT'S DB CONNECTION IS LOST DUE TO RECONNECTING IN THE CHILD $fork_slots = getConfigVar('SYNCDOMAIN_MAX_PROCESSES'); $do_fork = $fork_slots > 1 and extension_loaded('pcntl'); if ($fork_slots > 1 and !$do_fork) { throw new RackTablesError('PHP extension \'pcntl\' not found, can not use childs', RackTablesError::MISCONFIGURED); } $switches_working = 0; $switchesdone = 0; foreach ($switch_queue as $object) { if ($do_fork) { // wait for the next free slot while ($fork_slots <= $switches_working) { pcntl_waitpid(-1, $wait_status); --$switches_working; } $i_am_child = 0 === ($fork_res = pcntl_fork()); }
function addRealServers() { global $sic; assertStringArg('format'); assertStringArg('rawtext'); $ngood = 0; // Keep in mind, that the text will have HTML entities (namely '>') escaped. foreach (explode("\n", dos2unix($sic['rawtext'])) as $line) { if (!strlen($line)) { continue; } $match = array(); switch ($_REQUEST['format']) { case 'ipvs_2': // address and port only if (!preg_match('/^ -> ([0-9\\.]+):([0-9]+) /', $line, $match)) { if (!preg_match('/^ -> \\[([0-9a-fA-F:]+)\\]:([0-9]+) /', $line, $match)) { continue; } } addRStoRSPool(getBypassValue(), ip_parse($match[1]), $match[2], getConfigVar('DEFAULT_IPV4_RS_INSERVICE'), ''); break; case 'ipvs_3': // address, port and weight if (!preg_match('/^ -> ([0-9\\.]+):([0-9]+) +[a-zA-Z]+ +([0-9]+) /', $line, $match)) { if (!preg_match('/^ -> \\[([0-9a-fA-F:]+)\\]:([0-9]+) +[a-zA-Z]+ +([0-9]+) /', $line, $match)) { continue; } } addRStoRSPool(getBypassValue(), ip_parse($match[1]), $match[2], getConfigVar('DEFAULT_IPV4_RS_INSERVICE'), 'weight ' . $match[3]); break; case 'ssv_2': // IP address and port if (!preg_match('/^([0-9\\.a-fA-F:]+) ([0-9]+)$/', $line, $match)) { continue; } addRStoRSPool(getBypassValue(), ip_parse($match[1]), $match[2], getConfigVar('DEFAULT_IPV4_RS_INSERVICE'), ''); break; case 'ssv_1': // IP address if (!($ip_bin = ip_checkparse($line))) { continue; } addRStoRSPool(getBypassValue(), $ip_bin, 0, getConfigVar('DEFAULT_IPV4_RS_INSERVICE'), ''); break; default: showFuncMessage(__FUNCTION__, 'ERR1'); return; } $ngood++; } showFuncMessage(__FUNCTION__, 'OK', array($ngood)); }
public function setSessionUserMod(){ $this->setSessionUser(2, getConfigVar('moderator_rank')); }
function __construct($controlpanel, $encryptURL = false, $ipFilterControlpanel = null, $homepage = false) { $autoSession = getConfigVar("AUTO_SESSION"); if (isset($_REQUEST["webservice"])) { if ($_REQUEST["webservice"] == "getchallenge") { session_start(); } else { if (isset($_REQUEST["accessKey"])) { $sql = "select * from webservice where accessKey='{$_REQUEST["accessKey"]}'"; $pdo = connectPDO(getAppConfig("DATABASE_HOST"), getAppConfig("DATABASE_USER"), getAppConfig("DATABASE_PASSWORD"), getAppConfig("DATABASE_NAME"), getAppConfig("DATABASE_SERVER")); //ClsNaanalPDO::getNamedInstance(); try { $statement = $pdo->query($sql); $arr = $statement->fetchAll(PDO::FETCH_ASSOC); $_SESSION = unserialize(base64_decode($arr[0]["session_object"])); if ($arr[0]["logged"]) { $arrData = array(); $arrData["error"] = "You already logged."; die(json_encode($arrData)); } } catch (Exception $e) { die($e); } } else { if (isset($_REQUEST["sessionName"])) { $sql = "select * from webservice where session='{$_REQUEST["sessionName"]}'"; $pdo = connectPDO(getAppConfig("DATABASE_HOST"), getAppConfig("DATABASE_USER"), getAppConfig("DATABASE_PASSWORD"), getAppConfig("DATABASE_NAME"), getAppConfig("DATABASE_SERVER")); //ClsNaanalPDO::getNamedInstance(); try { $statement = $pdo->query($sql); $arr = $statement->fetchAll(PDO::FETCH_ASSOC); $_SESSION = unserialize(base64_decode($arr[0]["session_object"])); } catch (Exception $e) { die($e); } } } } } else { if (!($autoSession === false)) { session_start(); } } if (isset($_REQUEST["webservice"])) { if (isset($_POST["element"])) { $arr = json_decode($_POST["element"]); foreach ($arr as $pk => $pv) { if ($_REQUEST["webservice"] == "getchallenge") { if ($pk == "webservice" || $pk == "loginname") { continue; } } else { if ($_REQUEST["webservice"] == "getchallenge") { if ($pk == "webservice" || $pk == "accessKey" || $pk == "loginname") { continue; } } else { if ($pk == "element" || $pk == "webservice" || $pk == "sessionName" || $pk == "elementType") { continue; } } } $_POST[$pk] = $pv; } } else { if (isset($_GET["element"])) { $arr = json_decode($_POST["element"]); foreach ($arr as $pk => $pv) { if ($_REQUEST["webservice"] == "getchallenge") { if ($pk == "webservice" || $pk == "loginname") { continue; } } else { if ($_REQUEST["webservice"] == "getchallenge") { if ($pk == "webservice" || $pk == "accessKey" || $pk == "loginname") { continue; } } else { if ($pk == "element" || $pk == "webservice" || $pk == "sessionName" || $pk == "elementType") { continue; } } } $_GET[$pk] = $pv; } } } } if ($homepage === false) { $homepage = getIndexPage(); } parent::__construct($controlpanel, $homepage); if (get_magic_quotes_gpc()) { if (isset($_REQUEST)) { $_REQUEST = $this->sanitize($_REQUEST, false); } if (isset($_GET)) { $_GET = $this->sanitize($_GET, false); } if (isset($_POST)) { $_POST = $this->sanitize($_POST, false); } if (isset($_COOKIE)) { $_COOKIE = $this->sanitize($_COOKIE, false); } if (isset(ClsConfig::$AUTO_SESSION) && ClsConfig::$AUTO_SESSION !== false) { if (isset($_SESSION)) { $_SESSION = $this->sanitize($_SESSION, false); } } if (isset($_FILES)) { $_FILES = $this->sanitize($_FILES, false); } if (isset($_SERVER)) { $_SERVER = $this->sanitize($_SERVER, false); } } else { if (isset($_REQUEST)) { $_REQUEST = $this->sanitize($_REQUEST, true); } if (isset($_GET)) { $_GET = $this->sanitize($_GET, true); } if (isset($_POST)) { $_POST = $this->sanitize($_POST, true); } if (isset($_COOKIE)) { $_COOKIE = $this->sanitize($_COOKIE, true); } if (class_exists("ClsConfig") && isset(ClsConfig::$AUTO_SESSION) && ClsConfig::$AUTO_SESSION !== false) { if (isset($_SESSION)) { $_SESSION = $this->sanitize($_SESSION, true); } } if (isset($_FILES)) { $_FILES = $this->sanitize($_FILES, true); } if (isset($_SERVER)) { $_SERVER = $this->sanitize($_SERVER, false); } } if (isset($_SERVER["PATH_INFO"]) && !empty($_SERVER["PATH_INFO"])) { $arrServerPathInfo = pathinfo($_SERVER["PATH_INFO"]); $arrPathInfo = explode("/", $_SERVER["PATH_INFO"]); array_shift($arrPathInfo); if (!empty($arrPathInfo)) { $_REQUEST["page"] = array_shift($arrPathInfo); $_GET["page"] = $_REQUEST["page"]; } if (!empty($arrPathInfo)) { $_REQUEST["action"] = array_shift($arrPathInfo); $_GET["action"] = $_REQUEST["action"]; } if (isset($arrServerPathInfo["extension"])) { $arPth = pathinfo($_SERVER["SCRIPT_NAME"]); //trace($arPth["dirname"]); $pth = implode("/", $arrPathInfo); header("Location:http://{$_SERVER["SERVER_NAME"]}{$arPth["dirname"]}/{$pth}"); exit; } if (!empty($arrPathInfo)) { $_REQUEST["switch"] = array_shift($arrPathInfo); $_GET["switch"] = $_REQUEST["switch"]; } while (!empty($arrPathInfo)) { $_REQUEST["AUIEO_ACTION_PARAM_DATA"][] = array_shift($arrPathInfo); $_GET["AUIEO_ACTION_PARAM_DATA"][] = $_REQUEST["AUIEO_ACTION_PARAM_DATA"]; } } $autoSession = getConfigVar("AUTO_SESSION"); if (!($autoSession === false)) { $this->objNaanalSession = ClsNaanalSession::getInstance(); } $this->objNaanalRequest = ClsNaanalRequest::getInstance(); $this->objNaanalPost = ClsNaanalPost::getInstance(); $this->objNaanalGet = ClsNaanalGet::getInstance(); $this->files = $_FILES; $this->page = $this->objNaanalRequest->getModule(); $this->module = $this->objNaanalRequest->getModule(); $this->action = $this->objNaanalRequest->getAction(); $this->switch = $this->objNaanalRequest->getSwitch(); if (class_exists("ClsConfig")) { $this->fldUserID = isset(ClsConfig::$FLD_USERID) ? ClsConfig::$FLD_USERID : "userid"; $this->fldUser = isset(ClsConfig::$FLD_USER) ? ClsConfig::$FLD_USER : "******"; $this->fldPassword = isset(ClsConfig::$FLD_PASSWORD) ? ClsConfig::$FLD_PASSWORD : "******"; } $this->encryptURL = $encryptURL; if ($this->encryptURL && isset($_REQUEST["@page"])) { $shld = new URLShield(true, true); $shld->expose(); } }
function renderPopupIPv4Selector() { assertPermission('ipv4space', 'default'); echo '<h2>Choose a port:</h2><br><br>'; echo '<form action="javascript:;">'; echo '<input type=hidden id=ip>'; echo '<select size=' . getConfigVar('MAXSELSIZE') . ' id=addresses>'; $addresses = getAllIPv4Allocations(); usort($addresses, 'sortObjectAddressesAndNames'); foreach ($addresses as $address) { echo "<option value='{$address['ip']}' onclick='getElementById(\"ip\").value=\"{$address['ip']}\";'>" . "{$address['object_name']} {$address['name']} {$address['ip']}</option>\n"; } echo '</select><br><br>'; echo "<input type=submit value='Proceed' onclick='" . "if (getElementById(\"ip\")!=\"\") {" . " opener.document.getElementById(\"remoteip\").value=getElementById(\"ip\").value;" . " window.close();}'>"; echo '</form>'; }