function check_qos_setting($path) { $enable = query($path . "/device/qos/enable"); $auto = query($path . "/device/qos/autobandwidth"); if ($enable == "1") { if ($auto == "0") { if (isdigit(query($path . "/inf/bandwidth/upstream")) == "0" || query($path . "/inf/bandwidth/upstream") > 102400 || query($path . "/inf/bandwidth/upstream") < 1) { set_result("FAILED", $path . "/inf/bandwidth/upstream", i18n("The input uplink speed is invalid.")); return "FAILED"; } else { // Remove the leading zeros. $upstream_dec = strtoul(query($path . "/inf/bandwidth/upstream"), 10); set($path . "/inf/bandwidth/upstream", $upstream_dec); } } else { set($path . "/device/qos/autobandwidth", "1"); } $type = query($path . "/inf/bandwidth/type"); if ($type == "AUTO" || $type == "ADSL" || $type == "CABLE") { } else { set_result("FAILED", $path . "/inf/bandwidth/type", i18n("Unsupported Connection type be assigned.")); return "FAILED"; } } else { set($path . "/device/qos/enable", "0"); } return "OK"; }
function before() { layout('layouts/default.html.php'); /*set('header', ' <a href="'.url_for().'">Home</a> <a href="'.url_for('people').'">Personen</a> <a href="'.url_for('roles').'">Rollen</a> <a href="'.url_for('access').'">Zugriff</a> <a href="'.url_for('servers').'">Server</a> <a href="'.url_for('daemons').'">Daemons</a> ');*/ set('header', ' <img id="header_img" src="img/aclmodel.png" width="850" height="83" usemap="#head_nav" alt="header_navigation"> <map name="head_nav"> <area id="daemons_nav" shape="rect" href="' . url_for('daemons') . '" coords="682,7,781,28" alt="daemons"> <area id="servers_nav" shape="rect" href="' . url_for('servers') . '" coords="516,7,635,28" alt="servers"> <area id="access_nav" shape="rect" href="' . url_for('access') . '" coords="391,7,478,28" alt="access"> <area id="roles_nav" shape="rect" href="' . url_for('roles') . '" coords="239,7,340,28" alt="roles"> <area id="people_nav" shape="rect" href="' . url_for('people') . '" coords="74,7,193,28" alt="people"> <area id="clients_nav" shape="rect" href="' . url_for('clients') . '" coords="2,55,98,76" alt="clients"> <area id="people_roles_nav" shape="rect" href="' . url_for('people_roles') . '" coords="176,54,267,75" alt="people_roles"> <area id="ports_nav" shape="rect" href="' . url_for('ports') . '" coords="748,55,849,76" alt="ports"> </map> '); set('footer', '© 2011 - Florian Staudacher (Frontend), Alexander Philipp Lintenhofer (Backend)'); }
public static function login() { set('service', self::name); set('hint', 'Please enter your twitter handle'); set('prepend', '@'); return render('ask_username.php'); }
public function indexAction() { // Display the send_us_a_file.html page if the "Send us a file" feature is on and the user is not logged in. if (fz_config_get('app', 'send_us_a_file_feature') && false == $this->getUser()) { set('start_from', Zend_Date::now()->get(Zend_Date::DATE_SHORT)); $maxUploadSize = min(Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('upload_max_filesize')), Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('post_max_size'))); set('max_upload_size', $maxUploadSize); return html('send_us_a_file.html'); } $this->secure(); $user = $this->getUser(); $freeSpaceLeft = max(0, Fz_Db::getTable('File')->getRemainingSpaceForUser($user)); $maxUploadSize = min(Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('upload_max_filesize')), Fz_Db::getTable('File')->shorthandSizeToBytes(ini_get('post_max_size')), $freeSpaceLeft); $progressMonitor = fz_config_get('app', 'progress_monitor'); $progressMonitor = new $progressMonitor(); set('upload_id', md5(uniqid(mt_rand(), true))); set('start_from', Zend_Date::now()->get(Zend_Date::DATE_SHORT)); set('refresh_rate', 1200); set('files', Fz_Db::getTable('File')->findByOwnerOrderByUploadDateDesc($user)); set('use_progress_bar', $progressMonitor->isInstalled()); set('upload_id_name', $progressMonitor->getUploadIdName()); set('free_space_left', $freeSpaceLeft); set('max_upload_size', $maxUploadSize); set('sharing_destinations', fz_config_get('app', 'sharing_destinations', array())); set('disk_usage', array('space' => '<b id="disk-usage-value">' . bytesToShorthand(Fz_Db::getTable('File')->getTotalDiskSpaceByUser($user)) . '</b>', 'quota' => fz_config_get('app', 'user_quota'))); return html('main/index.php'); }
function index() { modTitle('Planit | Recheche'); if (!isCO()) { setAlert('Veuillez vous connecter pour faire une recherche', 'warning'); } loadModel('villes'); $k['villes'] = getAllVille(); set($k); if (!empty($_POST)) { $ok = 0; foreach ($_POST as $post) { if (!empty($post)) { $ok = 1; break; } } if ($ok) { loadModel('recherche'); $v['result'] = search_result($_POST); if (empty($v['result'])) { setAlert('Aucun resultat trouve', 'warning'); } set($v); } else { setAlert('Remplir au moins un champs', 'danger'); } } render(); }
public function __construct($_path, $_index, Theme $_theme, Controller $_controller) { # Set Properties $this->path = $_path; $this->index = $_index; $this->theme = $_theme; $this->controller = $_controller; # Load plugin config $this->config(); # API Init $this->api(); # Setup Plugin if (path_contains('ga/')) { # Setup theme $this->theme->use_theme(plugin_dir() . '/' . self::_NAMESPACE . '/ui'); # Setup Controller $this->controller->use_controller(plugin_dir() . '/' . self::_NAMESPACE . '/controller'); # Set Request Variables set('ga.request', $this->request()); } # Create an authorisation link if # the current user is not authorised if ($this->active == false) { set('ga.auth_link', $this->api->auth->buildAuthUrl()); } }
function set_profile($phy) { if ($_GLOBALS["1xenable"] == "1") { //eap=%s\n } else { set($phy . "/authtype", toupper($_GLOBALS["auth"])); set($phy . "/encrtype", toupper($_GLOBALS["encr"])); set($phy . "/wps/configured", "1"); if ($_GLOBALS["auth"] != "open" && $_GLOBALS["auth"] != "shared") { set($phy . "/nwkey/psk/key", $_GLOBALS["key"]); } else { if ($_GLOBALS["encr"] == "WEP") { set($phy . "/nwkey/wep/key", $_GLOBALS["key"]); set($phy . "/nwkey/wep/defkey", $_GLOBALS["keyindex"]); $key_len = strlen($_GLOBALS["key"]); if ($key_len == "5" || $key_len == "13") { set($phy . "/nwkey/wep/ascii", "1"); } else { set($phy . "/nwkey/wep/ascii", "0"); set($phy . "/nwkey/wep/ascii", "0"); } } } } }
function view($id) { //$v['new'] = getOneNew($id); $v['new'] = ['id' => 1, 'title' => 'Ma super new', 'content' => 'Trop cool la vie']; set($v); render('view'); }
public static function login() { set('service', self::name); set('prepend', 'superuser.com/users/'); set('append', '/user-name'); return render('ask_username.php'); }
function PHYINF_setup($uid, $type, $inf) { $path = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $uid, 1); set($path . "/valid", "1"); set($path . "/type", $type); set($path . "/name", $inf); setattr($path . "/mtu", "get", "ip -f link link show dev " . $inf . " | scut -p mtu"); setattr($path . "/macaddr", "get", "ip -f link addr show dev " . $inf . " | scut -p link/ether"); setattr($path . "/ipv6/link/ipaddr", "get", devipv6addr($inf, "link", 1)); setattr($path . "/ipv6/link/prefix", "get", devipv6addr($inf, "link", 2)); setattr($path . "/ipv6/global/ipaddr", "get", devipv6addr($inf, "global", 1)); setattr($path . "/ipv6/global/prefix", "get", devipv6addr($inf, "global", 2)); setattr($path . "/stats/rx/bytes", "get", "cat /sys/class/net/" . $inf . "/statistics/rx_bytes"); setattr($path . "/stats/rx/packets", "get", "cat /sys/class/net/" . $inf . "/statistics/rx_packets"); setattr($path . "/stats/rx/multicast", "get", "cat /sys/class/net/" . $inf . "/statistics/multicast"); setattr($path . "/stats/rx/error", "get", "cat /sys/class/net/" . $inf . "/statistics/rx_errors"); setattr($path . "/stats/rx/drop", "get", "cat /sys/class/net/" . $inf . "/statistics/rx_dropped"); setattr($path . "/stats/tx/bytes", "get", "cat /sys/class/net/" . $inf . "/statistics/tx_bytes"); setattr($path . "/stats/tx/packets", "get", "cat /sys/class/net/" . $inf . "/statistics/tx_packets"); setattr($path . "/stats/tx/collision", "get", "cat /sys/class/net/" . $inf . "/statistics/collisions"); setattr($path . "/stats/tx/error", "get", "cat /sys/class/net/" . $inf . "/statistics/tx_errors"); setattr($path . "/stats/tx/drop", "get", "cat /sys/class/net/" . $inf . "/statistics/tx_dropped"); setattr($path . "/stats/reset", "set", "/etc/scripts/resetstats.sh " . $inf); return $path; }
function daemons_servers_delete() { $cfg = $GLOBALS['cfg']; $db = $GLOBALS['db']; $server_id = intval(params('server_id')); $daemon_id = intval(params('daemon_id')); $arrService = $db->select("SELECT id\n FROM {$cfg['tblService']}\n WHERE server_id='{$server_id}'\n AND daemon_id='{$daemon_id}'"); if (!$arrService) { halt(SERVER_ERROR); return; } $id = $arrService[0]['id']; $result = $db->delete("DELETE FROM {$cfg['tblService']}\n WHERE id='{$id}'\n LIMIT 1"); $resultForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE dienst_id='{$id}'"); if (!$result || !$resultForeign) { halt(SERVER_ERROR); return; } set('server', array('id' => $server_id)); set('daemon', array('id' => $daemon_id)); if (isAjaxRequest()) { return js('daemons_servers/delete.js.php', null); } else { halt(HTTP_NOT_IMPLEMENTED); } }
function setup_mdns($uid, $port, $srvname, $srvcfg) { $dirty = 0; $stsp = XNODE_getpathbytarget("/runtime/services/mdnsresponder", "server", "uid", $uid, 0); if ($stsp == "") { if ($port != "0") { $dirty++; $stsp = XNODE_getpathbytarget("/runtime/services/mdnsresponder", "server", "uid", $uid, 1); set($stsp . "/srvname", $srvname); set($stsp . "/port", $port); set($stsp . "/srvcfg", $srvcfg); } } else { if ($port == "0") { $dirty++; del($stsp); } else { if (query($stsp . "/srvname") != $srvname) { $dirty++; set($stsp . "/srvname", $srvname); } if (query($stsp . "/port") != $port) { $dirty++; set($stsp . "/port", $port); } if (query($stsp . "/srvcfg") != $srvcfg) { $dirty++; set($stsp . "/srvcfg", $srvcfg); } } } return $dirty; }
function fatlady_phyinf($prefix, $inf) { /* Check the interface setting */ if (query($prefix . "/inf/uid") != $inf) { /* internet error, no i18n(). */ set_result("FAILED", $prefix . "/inf/uid", "INF UID mismatch"); return; } /* Check PHYINF */ $phy = query($prefix . "/inf/phyinf"); $phyp = XNODE_getpathbytarget($prefix, "phyinf", "uid", $phy, 0); if ($phy == "" || $phyp == "") { /* internet error, no i18n(). */ set_result("FAILED", $prefix . "/inf/phyinf", "Invalid phyinf"); return; } /* Check MACADDR */ $macaddr = query($phyp . "/macaddr"); if ($macaddr != "" && PHYINF_validmacaddr($macaddr) != "1") { set_result("FAILED", $phyp . "/macaddr", i18n("Invalid MAC address")); return; } $type = query($phyp . "/type"); if ($type == "eth") { $media = query($phyp . "/media/linktype"); if ($media != "" && $media != "AUTO" && $media != "1000F" && $media != "1000H" && $media != "100F" && $media != "100H" && $media != "10F" && $media != "10H") { set_result("FAILED", $phyp . "/media/linktype", i18n("Invalid media type")); return; } } /* We only validate the 'macaddr' & 'media' here, * so be sure to save 'macaddr' & 'media' only at 'setcfg' */ set($prefix . "/valid", 1); set_result("OK", "", ""); }
static function count_with($number) { $counter = new Counter(); $count = $counter->count_with($number); set('count', $count); return html('index.html.php'); }
function page_add_bookmark() { $form = new Zebra_Form('form'); $form->clientside_validation(array('close_tips' => true, 'on_ready' => false, 'disable_upload_validation' => true, 'scroll_to_error' => false, 'tips_position' => 'right', 'validate_on_the_fly' => true, 'validate_all' => true)); $form->add('label', 'label_url', 'url', 'URL'); $url = $form->add('text', 'url', 'http://'); $url->set_rule(array('required' => array('url_error', 'URL musí být vyplněno.'), 'url' => array(true, 'url_error', 'Pole musí obsahovat platné URL (včetně protokolu).'))); $form->add('label', 'label_title', 'title', 'Název stránky'); $title = $form->add('text', 'title', ''); $title->set_rule(array('required' => array('title_error', 'Název musí být vyplněn.'))); $form->add('submit', 'submitbtn', 'Přidat'); if ($form->validate()) { $ok = model_add($_POST['url'], $_POST['title'], array()); if ($ok) { flash('info', 'Záložka byla vytvořena'); } else { flash('error', 'Záložku se nepodařilo vytvořit.'); } redirect_to('/'); } // set('form', $form->render('views/add_form.php', true)); set('form', $form->render('', true)); set('title', 'Nová záložka'); return html('add.html.php'); }
function fatlady_dhcps($prefix, $svc) { $service = cut($svc, 0, "."); $version = scut($service, 0, "DHCPS"); XNODE_set_var("FATLADY_DHCPS_PATH", $prefix); XNODE_set_var("SERVICE_NAME", $svc); $b = "/htdocs/phplib/fatlady/DHCPS"; if ($version == 4) { dophp("load", $b . "/dhcps4.php"); } else { if ($version == 6) { dophp("load", $b . "/dhcps6.php"); } else { $_GLOBALS["FATLADY_result"] = "FAILED"; $_GLOBALS["FATLADY_node"] = ""; $_GLOBALS["FATLADY_message"] = "Unsupported DHCP service : " . $svc; /* internal error, no i18n(). */ } } XNODE_del_var("FATLADY_DHCPS_PATH"); XNODE_del_var("SERVICE_NAME"); if ($_GLOBALS["FATLADY_result"] == "OK") { set($prefix . "/valid", 1); } }
function PHYINF_setup($uid, $type, $inf) { $path = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $uid, 1); set($path . "/valid", "1"); set($path . "/type", $type); set($path . "/name", $inf); setattr($path . "/mtu", "get", "ip -f link link show dev " . $inf . " | scut -p mtu"); setattr($path . "/macaddr", "get", "ip -f link addr show dev " . $inf . " | scut -p link/ether"); setattr($path . "/ipv6/link/ipaddr", "get", devipv6addr($inf, "link", 1)); setattr($path . "/ipv6/link/prefix", "get", devipv6addr($inf, "link", 2)); setattr($path . "/ipv6/global/ipaddr", "get", devipv6addr($inf, "global", 1)); setattr($path . "/ipv6/global/prefix", "get", devipv6addr($inf, "global", 2)); setattr($path . "/stats/rx/bytes", "get", "scut -p " . $inf . ": -f 1 /proc/net/dev"); setattr($path . "/stats/rx/packets", "get", "scut -p " . $inf . ": -f 2 /proc/net/dev"); setattr($path . "/stats/rx/multicast", "get", "scut -p " . $inf . ": -f 8 /proc/net/dev"); setattr($path . "/stats/rx/error", "get", "scut -p " . $inf . ": -f 3 /proc/net/dev"); setattr($path . "/stats/rx/drop", "get", "scut -p " . $inf . ": -f 4 /proc/net/dev"); setattr($path . "/stats/tx/bytes", "get", "scut -p " . $inf . ": -f 9 /proc/net/dev"); setattr($path . "/stats/tx/packets", "get", "scut -p " . $inf . ": -f 10 /proc/net/dev"); setattr($path . "/stats/tx/error", "get", "scut -p " . $inf . ": -f 11 /proc/net/dev"); setattr($path . "/stats/reset", "set", "/etc/scripts/resetstats.sh " . $inf); setattr($path . "/stats/tx/drop", "get", "scut -p " . $inf . ": -f 12 /proc/net/dev"); setattr($path . "/stats/tx/collision", "get", "scut -p " . $inf . ": -f 14 /proc/net/dev"); setattr($path . "/stats/tx/collision", "get", "scut -p " . $inf . ": -f 14 /proc/net/dev"); setattr($path . "/stats/connected_mac_2p4G", "get", "wl -i wifig0 bssid"); setattr($path . "/stats/connected_mac_5G", "get", "wl -i wifia0 bssid"); return $path; }
function before($route) { $lang_mapping = array('fr' => 'fr_FR'); if (!isset($_SESSION['locale'])) { $locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2)); } $lang = $_SESSION['locale']; // Convert simple language code into full language code if (array_key_exists($lang, $lang_mapping)) { $lang = $lang_mapping[$lang]; } $lang = "{$lang}.utf8"; $textdomain = "localization"; putenv("LANGUAGE={$lang}"); putenv("LANG={$lang}"); putenv("LC_ALL={$lang}"); putenv("LC_MESSAGES={$lang}"); setlocale(LC_ALL, $lang); setlocale(LC_CTYPE, $lang); $locales_dir = dirname(__FILE__) . '/i18n'; bindtextdomain($textdomain, $locales_dir); bind_textdomain_codeset($textdomain, 'UTF-8'); textdomain($textdomain); set('locale', $lang); }
function books_new() { $book_data = book_data_from_form(); set('book', make_book_obj($book_data)); set('authors', find_authors()); return html('books/new.html.php'); }
/** * Add an element to an array using "dot" notation if it doesn't exist. * * @param array $array * @param string $key * @param mixed $value * @return array */ function array_add($array, $key, $value) { if (is_null(get($array, $key))) { set($array, $key, $value); } return $array; }
public function getRecordWhere($data) { $result = null; $adapter = GlobalAdapterFeature::getStaticAdapter(); $connection = $adapter->getDriver()->getConnection($data); $connection->beginTransaction(); try { function add($datas) { global $data; $data = $datas; } add($data); function set(Select $select) { global $data; foreach ($data as $key => $value) { $select->where->like($key, "%{$value}%"); } } $result = $this->area->select(function (Select $select) { set($select); }); $connection->commit(); } catch (\Exception $e) { $connection->rollback(); } return $result; }
public function testWriteable() { set('writable_dirs', ['app/cache', 'app/logs']); $this->exec('deploy:writable'); $this->assertTrue(is_writable($this->getEnv('release_path') . '/app/cache')); $this->assertTrue(is_writable($this->getEnv('release_path') . '/app/logs')); }
/** * Check if the current user is authenticated and forward * to a login action if not. * * @param string $credential */ protected function secure($credential = null) { $this->getAuthHandler()->secure(); // TODO check credentials // setting user template var set('user', $this->getUser()); }
function dhcps_setcfg($prefix, $svc) { /* set dhcpX of inf */ $inf = cut($svc, 1, "."); $svc = tolower(cut($svc, 0, ".")); $base = XNODE_getpathbytarget("", "inf", "uid", $inf, 0); $dhcps_uid = query($prefix . "/inf/" . $svc); set($base . "/" . $svc, $dhcps_uid); /* copy the dhcp profile. */ $uid = INF_getinfinfo($inf, $svc); $spath = XNODE_getpathbytarget($prefix . "/" . $svc, "entry", "uid", $dhcps_uid, 0); $dhcps = XNODE_getpathbytarget("/" . $svc, "entry", "uid", $uid, 0); if ($dhcps != "") { if ($svc == "dhcps4") { copy_dhcps4($spath, $dhcps); } else { if ($svc == "dhcps6") { $_GLOBALS["SETCFG_DHCPS6_SRC_PATH"] = $spath; $_GLOBALS["SETCFG_DHCPS6_DST_PATH"] = $dhcps; $b = "/htdocs/phplib/setcfg/libs"; dophp("load", $b . "/dhcps6.php"); } } } else { TRACE_error("SETCFG/DHCPS: no dhcps entry for [" . $uid . "] found!"); } }
function check_dmz_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { anchor($path); $hostid = query("hostid"); if ($hostid == "") { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } if ($addrtype == "ipv4") { $dmzip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($dmzip, $mask) == 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
function document() { set("title", "Documents"); set("data", Document::getAll()); set("promos", Promo::getAll()); return html("list.html.php", "layout.html.php"); }
public static function view_all() { global $db; $query = $db->query('SELECT * FROM scores ORDER BY userid,service'); set('scores', $query->fetchAll(PDO::FETCH_OBJ)); return render('home.php'); }
/** * Change Rank controller. * * @author paul.michaud * @author loic.bothorel */ function changeRank() { $promoParam = params('promo'); $tabPromo = getDistinctPromo(); set('tabPromo', $tabPromo); set('promoParam', $promoParam); return render('changeRank.html.php', 'layout/layout.html.php'); }
function index() { modTitle('Planit | Gérer les vols'); loadModel('ajouter_vol'); $v['vols'] = getAllVol(); set($v); render(); }
/** * Action called to manage the config * List the config settings. */ public function configAction() { $this->secure('admin'); set('config', option('fz_config')); # same as: set ('config', fz_config_get()); return html('admin/config.php'); //TODO: edit and save settings }