Example #1
0
function wiz_set_LANGPACK()
{
    $lcode = $_GET["language"];
    //TRACE_error("lcode=".$lcode);
    if ($lcode == "auto" || $lcode == "") {
        $count = cut_count($_SERVER["HTTP_ACCEPT_LANGUAGE"], ',');
        $i = 0;
        while ($i < $count) {
            $tag = cut($_SERVER["HTTP_ACCEPT_LANGUAGE"], $i, ',');
            $pri = cut($tag, 0, '-');
            $sub = cut($tag, 1, '-');
            $lcode = convert_lcode($pri, $sub);
            //The accept language for Japan from IE is ja-JP and the language code for our language pack is jp.
            if ($lcode == "ja") {
                $lcode = "jp";
            }
            if (wiz_load_slp($lcode) > 0) {
                return $lcode;
            }
            $i++;
        }
    } else {
        if (wiz_load_slp($lcode) > 0) {
            return $lcode;
        }
    }
    sealpac("/etc/sealpac/wizard/wiz_en.slp");
    // Use system default language, en.
    return "en";
}
Example #2
0
function ftopics()
{
    global $db, $maxftopics, $lftopics, $maxfposts, $allowHover;
    $f = 0;
    $qry = db("SELECT s1.*,s2.id AS subid FROM " . $db['f_threads'] . " s1, " . $db['f_skats'] . " s2, " . $db['f_kats'] . " s3\n               WHERE s1.kid = s2.id AND s2.sid = s3.id ORDER BY s1.lp DESC LIMIT 100");
    while ($get = _fetch($qry)) {
        if ($f == $maxftopics) {
            break;
        }
        if (fintern($get['kid'])) {
            $lp = cnt($db['f_posts'], " WHERE sid = '" . $get['id'] . "'");
            $pagenr = ceil($lp / $maxfposts);
            if ($pagenr == 0) {
                $page = 1;
            } else {
                $page = $pagenr;
            }
            if ($allowHover == 1) {
                $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['topic'])) . '</td></tr><tr><td><b>' . _forum_posts . ':</b></td><td>' . $lp . '</td></tr><tr><td><b>' . _forum_lpost . ':</b></td><td>' . date("d.m.Y H:i", $get['lp']) . _uhr . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
            }
            $ftopics .= show("menu/forum_topics", array("id" => $get['id'], "pagenr" => $page, "p" => $lp + 1, "titel" => cut(re($get['topic']), $lftopics), "info" => $info, "kid" => $get['kid']));
            $f++;
        }
    }
    return empty($ftopics) ? '' : '<table class="navContent" cellspacing="0">' . $ftopics . '</table>';
}
Example #3
0
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);
    }
}
Example #4
0
    public function getContent()
    {
        global $sql;
        //Lang::load('blocks/shoutbox/lang.*.php');
        $err = new Error();
        $note = new Notifier('note-shoutbox');
        $form['author'] = LOGGED ? User::$nickname : '';
        $form['message'] = '';
        if (isset($_POST['reply-shoutbox'])) {
            $form['author'] = LOGGED ? User::$nickname : filter($_POST['author-shoutbox'], 100);
            $form['message'] = filter($_POST['message-shoutbox'], Kio::getConfig('message_max', 'shoutbox'));
            $err->setError('author_empty', t('Author field is required.'))->condition(!$form['author']);
            $err->setError('author_exists', t('Entered nickname is registered.'))->condition(!LOGGED && is_registered($form['author']));
            $err->setError('message_empty', t('Message field is required.'))->condition(!$form['message']);
            // No errors
            if ($err->noErrors()) {
                $sql->exec('
					INSERT INTO ' . DB_PREFIX . 'shoutbox (added, author, message, author_id, author_ip)
					VALUES (
						' . TIMESTAMP . ',
						"' . $form['author'] . '",
						"' . cut($form['message'], Kio::getConfig('message_max', 'shoutbox')) . '",
						' . UID . ',
						"' . IP . '")');
                $sql->clearCache('shoutbox');
                $note->success(t('Entry was added successfully.'));
                redirect(HREF . PATH . '#shoutbox');
            } else {
                $note->error($err->toArray());
            }
        }
        // If cache for shoutbox doesn't exists
        if (!($entries = $sql->getCache('shoutbox'))) {
            $query = $sql->query('
				SELECT u.nickname, u.group_id, s.added, s.author, s.author_id, s.message
				FROM ' . DB_PREFIX . 'shoutbox s
				LEFT JOIN ' . DB_PREFIX . 'users u ON u.id = s.author_id
				ORDER BY s.id DESC
				LIMIT ' . Kio::getConfig('limit', 'shoutbox'));
            while ($row = $query->fetch()) {
                if ($row['author_id']) {
                    $row['author'] = User::format($row['author_id'], $row['nickname'], $row['group_id']);
                    $row['message'] = parse($row['message'], Kio::getConfig('parser', 'shoutbox'));
                }
                $entries[] = $row;
            }
            $sql->putCacheContent('shoutbox', $entries);
        }
        try {
            $tpl = new PHPTAL('blocks/shoutbox/shoutbox.tpl.html');
            $tpl->entries = $entries;
            $tpl->err = $err->toArray();
            $tpl->form = $form;
            $tpl->note = $note;
            return $tpl->execute();
        } catch (Exception $e) {
            return template_error($e->getMessage());
            //echo Note::error($e->getMessage());
        }
    }
Example #5
0
function get_plugin_stuff($plugin, $info)
{
    if (strrpos($plugin, ".rb") or strrpos($plugin, ".js") or strrpos($plugin, ".php")) {
        $arr = file(abspath . "/plugins/" . $plugin);
    } else {
        $arr = file(abspath . "/plugins/" . $plugin . "/info.data");
    }
    foreach ($arr as $line => $linestuff) {
        if ("# " . $info . "\n" == $linestuff) {
            $linenum = $line + 1;
            $output = $arr[$linenum];
        }
    }
    if ($info == "active" and !strrpos($plugin, ".rb") and !strrpos($plugin, ".js") and !strrpos($plugin, ".php")) {
        $output = file_get_contents(abspath . "/plugins/" . $plugin . "/active.data");
    }
    if ($info == "hook") {
        $output = explode(",", trim($output));
    }
    if ($info == "name" and !isset($output)) {
        $output = ucfirst(preg_replace('/\\.\\w+$/', '', $plugin));
    }
    cut($output);
    return $output;
}
Example #6
0
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 top_match()
{
    global $db, $allowHover, $llwars, $picformat, $sql_prefix;
    $qry = db("SELECT s1.datum,s1.cid,s1.id,s1.bericht,s1.xonx,s1.punkte,s1.gpunkte,s1.squad_id,s2.icon,s2.name FROM " . $db['cw'] . " AS s1\n             LEFT JOIN " . $db['squads'] . " AS s2 ON s1.squad_id = s2.id\n             WHERE `top` = '1'\n             ORDER BY RAND()");
    if ($get = _fetch($qry)) {
        //Clans Mod
        $clandetailssql = db("SELECT clantag, gegner FROM " . $sql_prefix . "clans WHERE id LIKE " . $get['cid']);
        $clans = _fetch($clandetailssql);
        $squad = '_defaultlogo.jpg';
        $gegner = '_defaultlogo.jpg';
        foreach ($picformat as $end) {
            if (file_exists(basePath . '/inc/images/clanwars/' . $get['cid'] . '_logo.' . $end)) {
                $gegner = $get['cid'] . '_logo.' . $end;
            }
            if (file_exists(basePath . '/inc/images/squads/' . $get['squad_id'] . '_logo.' . $end)) {
                $squad = $get['squad_id'] . '_logo.' . $end;
            }
        }
        if ($allowHover == 1 || $allowHover == 2) {
            $hover = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['name'])) . '<br/>vs.<br/> ' . jsconvert(re($clans['gegner'])) . '</td></tr><tr><td><b>' . _played_at . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _cw_xonx . ':</b></td><td>' . jsconvert(re($get['xonx'])) . '</td></tr><tr><td><b>' . _result . ':</b></td><td>' . cw_result_nopic_raw($get['punkte'], $get['gpunkte']) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['cw_comments'], "WHERE cw = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
        }
        $topmatch .= show("menu/top_match", array("id" => $get['id'], "clantag" => re(cut($clans['clantag'], $llwars)), "team" => re(cut($get['name'], $llwars)), "game" => substr(strtoupper(str_replace('.' . $icon, '', re($get['icon']))), 0, 5), "id" => $get['id'], "gegner" => $gegner, "squad" => $squad, "hover" => $hover, "info" => $get['datum'] > time() ? date("d.m.Y", $get['datum']) : cw_result_nopic($get['punkte'], $get['gpunkte'])));
    }
    return empty($topmatch) ? '<center style="margin:3px 0">' . _no_top_match . '</center>' : '<table class="navContent" cellspacing="0">' . $topmatch . '</table>';
}
Example #8
0
function check_pin($pin)
{
    /* more checking added for WPS 2.0 
    		We allow pin with : xxxx-xxxx
    							xxxx xxxx
    							xxxxxxxx
    	*/
    $len = strlen($pin);
    $delim = "";
    //we support 4 digits
    if ($len == 4) {
        if (isdigit($pin) != 1) {
            return 0;
        } else {
            return $pin;
        }
    }
    if ($len == 9) {
        if (cut_count($pin, "-") == 2) {
            $delim = "-";
        } else {
            if (cut_count($pin, " ") == 2) {
                $delim = " ";
            } else {
                return 0;
            }
        }
        $val1 = cut($pin, 0, $delim);
        $val2 = cut($pin, 1, $delim);
        if (strlen($val1) != 4 || strlen($val2) != 4) {
            return 0;
        }
        $pin = $val1 . $val2;
    }
    if (isdigit($pin) != 1) {
        return 0;
    }
    if (strlen($pin) != 8) {
        return 0;
    }
    $i = 0;
    $pow = 3;
    $sum = 0;
    while ($i < 8) {
        $sum = $pow * substr($pin, $i, 1) + $sum;
        if ($pow == 3) {
            $pow = 1;
        } else {
            $pow = 3;
        }
        $i++;
    }
    $sum = $sum % 10;
    if ($sum == 0) {
        return $pin;
    } else {
        return 0;
    }
}
Example #9
0
function check_datetime($prefix)
{
    $date = query($prefix . "/date");
    $time = query($prefix . "/time");
    $month = cut($date, 0, "/");
    $day = cut($date, 1, "/");
    $year = cut($date, 2, "/");
    $hour = cut($time, 0, ":");
    $min = cut($time, 1, ":");
    $sec = cut($time, 2, ":");
    TRACE_debug("FATLADY: RUNTIME.TIME: " . $year . "/" . $month . "/" . $day);
    TRACE_debug("FATLADY: RUNTIME.TIME: " . $hour . ":" . $min . ":" . $sec);
    /* The latest time linux can support is: Tue Jan 19 11:14:07 CST 2038. */
    if (isdigit($year) == 0 || $year < 1999 || $year > 2037) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid year") . " - " . $year);
        return;
    }
    if (isdigit($month) == 0 || $month <= 0 || $month > 12) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid month"));
        return;
    }
    if (isdigit($day) == 0 || $day <= 0 || $day > 31) {
        set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
        return;
    }
    if ($month == 2 || $month == 4 || $month == 6 || $month == 9 || $month == 11) {
        if ($day > 30) {
            set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
            return;
        }
        if ($month == 2) {
            if (is29year($year) == 1) {
                if ($day > 29) {
                    set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
                    return;
                }
            } else {
                if ($day > 28) {
                    set_result("FAILED", $prefix . "/date", i18n("Invalid day"));
                    return;
                }
            }
        }
    }
    if (isdigit($hour) == 0 || $hour < 0 || $hour > 23) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid hour"));
        return;
    }
    if (isdigit($min) == 0 || $min < 0 || $min > 59) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid minute"));
        return;
    }
    if (isdigit($sec) == 0 || $sec < 0 || $sec > 59) {
        set_result("FAILED", $prefix . "/time", i18n("Invalid second"));
        return;
    }
    set_result("OK", "", "");
}
Example #10
0
function dhcpc6setup($inf)
{
    $hlp = "/var/servd/" . $inf . "-dhcp6c.sh";
    $pid = "/var/servd/" . $inf . "-dhcp6c.pid";
    $cfg = "/var/servd/" . $inf . "-dhcp6c.cfg";
    /* DHCP over PPP session ? */
    //$previnf = XNODE_get_var($inf."_PREVINF");
    //XNODE_del_var($inf."_PREVINF");
    $infp = XNODE_getpathbytarget("", "inf", "uid", $inf, 0);
    $previnf = query($infp . "/infprevious");
    $phyinf = query($infp . "/phyinf");
    $inet = query($infp . "/inet");
    $inetp = XNODE_getpathbytarget("/inet", "entry", "uid", $inet, 0);
    $devnam = PHYINF_getifname($phyinf);
    /* dslite ? */
    $nextinf = query($infp . "/infnext");
    //if ($mode=="PPPDHCP" && $_GLOBALS["PREVINF"]!="")
    //msg("mode is ".$mode.", previnf is ".$previnf);
    startcmd('# dhcpc6setup(' . $inf . ',' . $inetp . ')');
    startcmd("previnf is " . $previnf . ", nextinf is " . $nextinf);
    //if ($mode=="PPPDHCP" && $previnf!="")
    //{
    //	$pppdev = PHYINF_getruntimeifname($previnf);
    //	if ($pppdev=="") return error("no PPP device.");
    //}
    /* Gererate DHCP-IAID from 32-bit of mac address*/
    $mac = PHYINF_getphymac($inf);
    $mac1 = cut($mac, 3, ":");
    $mac2 = cut($mac, 0, ":");
    $mac3 = cut($mac, 1, ":");
    $mac4 = cut($mac, 2, ":");
    $iaidstr = $mac1 . $mac2 . $mac3 . $mac4;
    $iaid = strtoul($iaidstr, 16);
    /* Generate configuration file. */
    $send = "\tinformation-only;\n";
    $idas = "";
    //if($mode=="PPPDHCP") $dname = $pppdev;
    //else $dname = $devnam;
    $dname = $devnam;
    $nextinfp = XNODE_getpathbytarget("", "inf", "uid", $nextinf, 0);
    $nextinet = query($nextinfp . "/inet");
    $nextinetp = XNODE_getpathbytarget("inet", "entry", "uid", $nextinet, 0);
    $nextmode = query($nextinetp . "/ipv4/ipv4in6/mode");
    if ($nextinf != "" && $nextmode == "dslite") {
        $rqstmsg = "\trequest aftr-server-domain-name;\n";
    } else {
        $rqstmsg = "";
    }
    fwrite(w, $cfg, "interface " . $dname . " {\n" . $send . $rqstmsg . "\tscript \"" . $hlp . "\";\n" . "};\n" . $idas);
    /* generate callback script */
    fwrite(w, $hlp, "#!/bin/sh\n" . "phpsh /etc/services/INET/inet6_dhcpc_helper.php" . " INF=" . $inf . " MODE=INFOONLY" . " DEVNAM=" . $dname . " GATEWAY=" . "" . " DHCPOPT=" . "" . ' "NAMESERVERS=$new_domain_name_servers"' . ' "NEW_ADDR=$new_addr"' . ' "NEW_PD_PREFIX=$new_pd_prefix"' . ' "NEW_PD_PLEN=$new_pd_plen"' . ' "DNS=' . "" . '"' . ' "NEW_AFTR_NAME=$new_aftr_name"' . ' "NTPSERVER=$new_ntp_servers"' . "\n");
    /* Start DHCP client */
    startcmd("chmod +x " . $hlp);
    //if ($pppdev=="")
    startcmd("dhcp6c -c " . $cfg . " -p " . $pid . " -t LL " . $devnam);
    //else startcmd("dhcp6c -c ".$cfg." -p ".$pid." -t LL -o ".$devnam." ".$pppdev);
    stopcmd("/etc/scripts/killpid.sh /var/servd/" . $inf . "-dhcp6c.pid");
}
Example #11
0
function l_reg()
{
    global $db, $llreg, $maxlreg;
    $qry = db("SELECT id,nick,country,regdatum FROM " . $db['users'] . "\n               ORDER BY regdatum DESC\n               LIMIT " . $maxlreg . "");
    while ($get = _fetch($qry)) {
        $lreg .= show("menu/last_reg", array("nick" => re(cut($get['nick'], $llreg)), "country" => flag($get['country']), "reg" => date("d.m.", $get['regdatum']), "id" => $get['id']));
    }
    return empty($lreg) ? '' : '<table class="navContent" cellspacing="0">' . $lreg . '</table>';
}
Example #12
0
 function cut_preg($str, $start, $end, $preg)
 {
     $title_str = cut($str, $start, $end);
     if (!empty($title_str)) {
         $title_arr = preg($title_str, $preg);
         $title = empty($title_arr[1]) ? '' : strip_tags($title_arr[1]);
         return $title;
     } else {
         return false;
     }
 }
Example #13
0
function perform($jsonObject)
{
    $action = $jsonObject->action;
    switch ($action) {
        case "load":
            return loadCompany($jsonObject);
        case "save":
            return saveName($jsonObject);
        case "cut":
            return cut($jsonObject);
    }
}
Example #14
0
function l_wars()
{
    global $db, $maxlwars, $llwars, $allowHover;
    $qry = db("SELECT s1.datum,s1.gegner,s1.id,s1.bericht,s1.xonx,s1.clantag,s1.punkte,s1.gpunkte,s1.squad_id,s2.icon,s2.name FROM " . $db['cw'] . " AS s1\n             LEFT JOIN " . $db['squads'] . " AS s2 ON s1.squad_id = s2.id\n             WHERE datum < " . time() . "\n             ORDER BY datum DESC\n             LIMIT " . $maxlwars . "");
    while ($get = _fetch($qry)) {
        if ($allowHover == 1 || $allowHover == 2) {
            $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['name'])) . '<br/>vs.<br/> ' . jsconvert(re($get['gegner'])) . '</td></tr><tr><td><b>' . _played_at . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _cw_xonx . ':</b></td><td>' . jsconvert(re($get['xonx'])) . '</td></tr><tr><td><b>' . _result . ':</b></td><td>' . cw_result_nopic_raw($get['punkte'], $get['gpunkte']) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['cw_comments'], "WHERE cw = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
        }
        $lwars .= show("menu/last_wars", array("id" => $get['id'], "clantag" => re(cut($get['clantag'], $llwars)), "icon" => re($get['icon']), "info" => $info, "result" => cw_result_pic($get['punkte'], $get['gpunkte'])));
    }
    return empty($lwars) ? '' : '<table class="navContent" cellspacing="0">' . $lwars . '</table>';
}
Example #15
0
function perform($jsonObject)
{
    $action = $jsonObject->action;
    switch ($action) {
        case "load":
            return loadEmployee($jsonObject);
        case "save":
            return saveEmployee($jsonObject);
        case "cut":
            return cut($jsonObject);
    }
}
Example #16
0
function changes_default_wifi($phyinfuid, $ssid, $password, $mac, $country)
{
    $authtype = "WPA+2PSK";
    $encrtype = "TKIP+AES";
    $p = XNODE_getpathbytarget("", "phyinf", "uid", $phyinfuid, 0);
    $wifi = XNODE_getpathbytarget("/wifi", "entry", "uid", query($p . "/wifi"), 0);
    if ($p == "" || $wifi == "") {
        return;
    }
    anchor($wifi);
    if ($ssid == "") {
        $n5 = cut($mac, 4, ":");
        $n6 = cut($mac, 5, ":");
        $ssidsuffix = $n5 . $n6;
        $ssid = query("ssid");
        if ($ssidsuffix != "") {
            //For dlink product, make the default SSID "dlink-mac" for 2.4GHz and "dlink-5GHz-mac" for 5GHz.
            if (substr($ssid, 0, 5) == "dlink") {
                $ssid1 = "dlink";
                $ssid2 = scut($ssid, 0, "dlink");
                $ssid = $ssid1 . $ssid2 . "-" . toupper($ssidsuffix);
            }
        }
    }
    //set default value for CN
    if ($country == "CN") {
        //$ssid = "D-Link_DIR-802";
        $authtype = "OPEN";
        $encrtype = "NONE";
        set("authtype", $authtype);
        set("encrtype", $encrtype);
        set("ssid", $ssid);
        set("nwkey/psk/passphrase", "");
        //20130812 jack add for hostapd error
        set("nwkey/psk/key", "");
        return;
    }
    //TRACE_error("ssid=".$ssid."=password="******"");
    if ($password != "" && $ssid != "") {
        //chanhe the mode to wpa-auto psk
        set("authtype", "WPA+2PSK");
        set("encrtype", "TKIP+AES");
        set("wps/configured", "1");
        set("ssid", $ssid);
        set("nwkey/psk/passphrase", "1");
        set("nwkey/psk/key", $password);
        set("nwkey/wpa/groupintv", "3600");
        set("nwkey/rekey/gtk", "1800");
    } else {
        TRACE_error("the mfc do not init wifi password,using default");
    }
}
Example #17
0
function top_dl()
{
    global $db, $maxtopdl, $ltopdl, $allowHover;
    $qry = db("SELECT * FROM " . $db['downloads'] . " ORDER BY hits DESC\n             LIMIT " . $maxtopdl . "");
    while ($get = _fetch($qry)) {
        if ($allowHover == 1) {
            $getkat = _fetch(db("SELECT name FROM " . $db['dl_kat'] . " WHERE id = '" . $get['kat'] . "'"));
            $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['download'])) . '</td></tr><tr><td><b>' . _datum . ':</b></td><td>' . date("d.m.Y H:i", $get['date']) . _uhr . '</td></tr><tr><td><b>' . _dl_dlkat . ':</b></td><td>' . jsconvert(re($getkat['name'])) . '</td></tr><tr><td><b>' . _hits . ':</b></td><td>' . $get['hits'] . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
        }
        $top_dl .= show("menu/top_dl", array("id" => $get['id'], "titel" => cut(re($get['download']), $ltopdl), "info" => $info, "hits" => $get['hits']));
    }
    return empty($top_dl) ? '' : '<table class="navContent" cellspacing="0">' . $top_dl . '</table>';
}
Example #18
0
function dmz_setcfg($prefix, $svc)
{
    $nat = cut($svc, 1, ".");
    $base = XNODE_getpathbytarget("/nat", "entry", "uid", $nat);
    $dmzenable = query($prefix . "/nat/entry/dmz/enable");
    $dmzinf = query($prefix . "/nat/entry/dmz/inf");
    $dmzhostid = query($prefix . "/nat/entry/dmz/hostid");
    $dmzsch = query($prefix . "/nat/entry/dmz/schedule");
    set($base . "/dmz/enable", $dmzenable);
    set($base . "/dmz/hostid", $dmzhostid);
    set($base . "/dmz/inf", $dmzinf);
    set($base . "/dmz/schedule", $dmzsch);
}
Example #19
0
function strip_char($original, $char)
{
    $cnt = cut_count($original, $char);
    if ($cnt == 0) {
        return $original;
    }
    $i = 0;
    $strip = "";
    while ($i < $cnt) {
        $strip = $strip . cut($original, $i, $char);
        $i++;
    }
    return $strip;
}
Example #20
0
function n_wars()
{
    global $db, $maxnwars, $lnwars, $allowHover;
    $qry = db("SELECT s1.id,s1.datum,s1.clantag,s1.maps,s1.gegner,s1.squad_id,s2.icon,s1.xonx,s2.name FROM " . $db['cw'] . " AS s1\n               LEFT JOIN " . $db['squads'] . " AS s2 ON s1.squad_id = s2.id\n               WHERE s1.datum > " . time() . "\n               ORDER BY s1.datum\n               LIMIT " . $maxnwars . "");
    if (_rows($qry)) {
        while ($get = _fetch($qry)) {
            if ($allowHover == 1 || $allowHover == 2) {
                $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['name'])) . '<br/>vs.<br /> ' . jsconvert(re($get['gegner'])) . '</td></tr><tr><td><b>' . _datum . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _cw_xonx . ':</b></td><td>' . jsconvert(re($get['xonx'])) . '</td></tr><tr><td><b>' . _cw_maps . ':</b></td><td>' . jsconvert(re($get['maps'])) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['cw_comments'], "WHERE cw = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
            }
            $nwars .= show("menu/next_wars", array("id" => $get['id'], "clantag" => re(cut($get['clantag'], $lnwars)), "icon" => re($get['icon']), "info" => $info, "datum" => date("d.m.:", $get['datum'])));
        }
    }
    return empty($nwars) ? '' : '<table class="navContent" cellspacing="0">' . $nwars . '</table>';
}
Example #21
0
 function show_random()
 {
     global $book_list_model;
     echo "<div class='sidebar-products clearfix'>\n\t\t<h2>Có thể bạn muốn xem</h2>";
     $result = $book_list_model->get_data_random();
     foreach ($result as $data) {
         echo "<div class='item' style='width: 100%;'><table><tr>\n\t\t\t<td width='20%'><a href='../../" . sf($data['title'], 0) . "." . $data['id'] . ".html'><img src='../../135x180/" . $data['img1'] . "' alt='" . $data['title'] . "' title='" . $data['title'] . "'></a></td>\n\t\t\t<td><h3 style='margin-left:10px;'><a href='../../" . sf($data['title'], 0) . "." . $data['id'] . ".html' alt='" . $data['title'] . "' title='" . $data['title'] . "'>" . cut($data['title'], 30) . "</a><br/><span class='author2'>" . $data['author'] . "</span>";
         if ($data['rating'] != 0) {
             echo "<br/><div class='rateit' data-rateit-value='" . $data['rating'] . "' data-rateit-ispreset='true' data-rateit-readonly='true'></div>";
         }
         echo "</div></h3>\n\t\t\t</td></tr></table></div>";
     }
     echo "</div>";
 }
Example #22
0
function calcute_ds_port()
{
    $ds_port = 48820;
    $inffp = XNODE_getpathbytarget("/runtime", "inf", "uid", "LAN-1");
    $phy = query($inffp . "/phyinf");
    $phyfp = XNODE_getpathbytarget("/runtime", "phyinf", "uid", $phy);
    $mac = query($phyfp . "/macaddr");
    //use last two part of mac calcute a 4-digit number
    if ($mac != "") {
        $count = cut_count($mac, ":");
        $mac_cut = cut($mac, $count - 2, ":") . cut($mac, $count - 1, ":");
        $tmp = strtoul($mac_cut, 16) % 10000;
        $ds_port = 40000 + $tmp;
    }
    return $ds_port;
}
Example #23
0
function perform($jsonObject)
{
    $action = $jsonObject->action;
    switch ($action) {
        case "load":
            return loadDepartment($jsonObject);
        case "save":
            return saveName($jsonObject);
        case "cut":
            return cut($jsonObject);
        case "selectDepartment":
            return getDepartmentId($jsonObject);
        case "selectEmployee":
            return getEmployeeId($jsonObject);
    }
}
Example #24
0
function perform($jsonObject)
{
    $action = $jsonObject->action;
    switch ($action) {
        case "load":
            return loadCompany($jsonObject);
        case "save":
            return saveName($jsonObject);
        case "cut":
            return cut($jsonObject);
        case "reset":
            return resetCompany($jsonObject);
        case "selectDepartment":
            return getDepartmentId($jsonObject);
    }
}
Example #25
0
function l_artikel()
{
    global $db, $maxlartikel, $lartikel, $allowHover;
    $qry = db("SELECT id,titel,text,autor,datum,kat,public FROM " . $db['artikel'] . "\n\t\t\t   WHERE public = 1\n               ORDER BY id DESC\n               LIMIT " . $maxlartikel . "");
    if (_rows($qry)) {
        while ($get = _fetch($qry)) {
            $qrykat = db("SELECT kategorie FROM " . $db['newskat'] . "\n                      WHERE id = '" . $get['kat'] . "'");
            $getkat = _fetch($qrykat);
            $text = strip_tags($get['text']);
            if ($allowHover == 1) {
                $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['titel'])) . '</td></tr><tr><td><b>' . _datum . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _autor . ':</b></td><td>' . rawautor($get['autor']) . '</td></tr><tr><td><b>' . _news_admin_kat . ':</b></td><td>' . jsconvert(re($getkat['kategorie'])) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['acomments'], "WHERE artikel = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
            }
            $l_articles .= show("menu/last_artikel", array("id" => $get['id'], "titel" => re(cut($get['titel'], $lartikel)), "text" => cut(bbcode($text), 260), "datum" => date("d.m.Y", $get['datum']), "info" => $info));
        }
    }
    return empty($l_articles) ? '' : '<table class="navContent" cellspacing="0">' . $l_articles . '</table>';
}
Example #26
0
function l_news()
{
    global $db, $maxlnews, $lnews, $allowHover;
    if (!permission("intnews")) {
        $int = "AND intern = 0";
    }
    $qry = db("SELECT id,titel,autor,datum,kat,public,timeshift FROM " . $db['news'] . "\n               WHERE public = 1\n\t\t\t\t\t\t\t AND datum <= " . time() . "\n\t\t\t         " . $int . "\n               ORDER BY id DESC\n               LIMIT " . $maxlnews . "");
    while ($get = _fetch($qry)) {
        $qrykat = db("SELECT kategorie FROM " . $db['newskat'] . "\n                    WHERE id = '" . $get['kat'] . "'");
        $getkat = _fetch($qrykat);
        if ($allowHover == 1) {
            $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . jsconvert(re($get['titel'])) . '</td></tr><tr><td><b>' . _datum . ':</b></td><td>' . date("d.m.Y H:i", $get['datum']) . _uhr . '</td></tr><tr><td><b>' . _autor . ':</b></td><td>' . rawautor($get['autor']) . '</td></tr><tr><td><b>' . _news_admin_kat . ':</b></td><td>' . jsconvert(re($getkat['kategorie'])) . '</td></tr><tr><td><b>' . _comments_head . ':</b></td><td>' . cnt($db['newscomments'], "WHERE news = '" . $get['id'] . "'") . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
        }
        $l_news .= show("menu/last_news", array("id" => $get['id'], "titel" => re(cut($get['titel'], $lnews)), "datum" => date("d.m.Y", $get['datum']), "info" => $info));
    }
    return empty($l_news) ? '' : '<table class="navContent" cellspacing="0">' . $l_news . '</table>';
}
Example #27
0
function perform($jsonObject)
{
    $action = $jsonObject->action;
    switch ($action) {
        case "load":
            return loadEmployee($jsonObject->id);
        case "blank":
            return loadBlank();
        case "save":
            return saveEmployee($jsonObject);
        case "create":
            return create($jsonObject);
        case "cut":
            return cut($jsonObject);
        case "delete":
            return delete($jsonObject);
    }
}
Example #28
0
function replaceTex($pathOfTexFile, $studentId)
{
    // mysql connection info
    $conHost = "127.0.0.1";
    // connect ip
    $conUsername = "******";
    $conPassword = "******";
    $conDatabase = "formatPaper";
    $conView = "VassignmentBook";
    $conQuery = "SELECT * FROM  {$conView}  WHERE studentId = '{$studentId}';";
    // connect mysql
    $con = mysql_connect($conHost, $conUsername, $conPassword);
    if (!$con) {
        die('Could not connect: ' . mysql_error());
    }
    // echo $conQuery; // 检查查询语句
    // query database
    mysql_select_db($conDatabase, $con);
    $result = mysql_query("SET NAMES 'UTF8'");
    $result = mysql_query($conQuery, $con);
    $infoarr = mysql_fetch_array($result);
    mysql_close($con);
    $fstr = file_get_contents($pathOfTexFile);
    foreach ($infoarr as $key => $value) {
        if ($value) {
            $value = str_replace("&nbsp;", " ", $value);
            $value = analysis(html_entity_decode($value));
        }
        $fstr = str_replace("!{$key}-!", html_entity_decode($value), $fstr);
    }
    if ($infoarr['subjectName']) {
        $cuttitle = cut($infoarr['subjectName']);
        $fstr = str_replace($infoarr['subjectName'], $cuttitle, $fstr);
    }
    $fstr = str_replace("\\block{" . $infoarr['topicType'] . "}", "\\blockC{" . $infoarr['topicType'] . "}", $fstr);
    $fstr = preg_replace("/\\!(\\w+)\\-!/", "", $fstr);
    //$newadd = str_replace("template", $studentId, $pathOfTexFile);
    $newadd = str_replace("template", getStuId($studentId), $pathOfTexFile);
    //echo $newadd ."<br/>\n";
    // 这里的路径为执行该函数的 php 所在路径决定
    $fstr = str_replace("\r\n", "\n", $fstr);
    file_put_contents($newadd, $fstr);
}
Example #29
0
function read_result()
{
    $result = "fail";
    $return = fread("", "/var/tmp/mydlink_result");
    if (isempty($return) == 1) {
        return "Result of mydlink registration is not exist or NULL";
    }
    $cnt = cut_count($return, "\r\n");
    $t = $cnt - 1;
    $tmp = cut($return, $t, "\r\n");
    $L1 = strlen($tmp);
    $L2 = strstr($tmp, "\n") + strlen("\n");
    $result_str = substr($tmp, $L2, $L1 - $L2);
    $temp = strstr($result_str, "success");
    if (isempty($temp) == 1) {
        $result = $result_str;
    } else {
        $result = "OK";
    }
    return $result;
}
Example #30
0
function shout($ajax = 0)
{
    global $db, $maxshout, $lshouttext, $lshoutnick, $shout_max_zeichen, $userid, $chkMe;
    $qry = db("SELECT * FROM " . $db['shout'] . "\n               ORDER BY id DESC LIMIT " . $maxshout . "");
    $i = 1;
    while ($get = _fetch($qry)) {
        $class = $color % 2 ? "navShoutContentFirst" : "navShoutContentSecond";
        $color++;
        if (permission("shoutbox")) {
            $delete = '<a href="../shout/?action=admin&amp;do=delete&amp;id=' . $get['id'] . '" onclick="return(DZCP.del(\'' . _confirm_del_shout . '\'))"><img src="../inc/images/delete_small.gif" title="' . _button_title_del . '" alt="' . _button_title_del . '" /></a>';
        } else {
            $delete = "";
        }
        $is_num = preg_match("#\\d#", $get['email']);
        if ($is_num && !check_email($get['email'])) {
            $nick = autor($get['email'], "navShout");
        } else {
            $nick = '<a class="navShout" href="mailto:' . eMailAddr($get['email']) . '" title="' . $get['nick'] . '">' . cut($get['nick'], $lshoutnick) . '</a>';
        }
        $show .= show("menu/shout_part", array("nick" => $nick, "datum" => date("j.m.Y H:i", $get['datum']) . _uhr, "text" => bbcode(wrap(re($get['text']), $lshouttext)), "class" => $class, "del" => $delete));
        $i++;
    }
    if (settings('reg_shout') == 1 && $chkMe == 'unlogged') {
        $dis = ' style="text-align:center;cursor:wait" disabled="disabled"';
        $dis1 = ' style="cursor:wait;color:#888" disabled="disabled"';
        $only4reg = _shout_must_reg;
    } else {
        if ($chkMe == "unlogged") {
            $form = show("menu/shout_form", array("dis" => $dis));
            $sec = show("menu/shout_antispam", array("help" => _login_secure_help, "dis" => $dis));
        } else {
            $form = autor($userid, "navShout");
        }
    }
    $add = show("menu/shout_add", array("form" => $form, "t_zeichen" => _zeichen, "noch" => _noch, "dis1" => $dis1, "dis" => $dis, "only4reg" => $only4reg, "security" => $sec, "zeichen" => $shout_max_zeichen));
    $shout = show("menu/shout", array("shout" => $show, "shoutbox" => _shoutbox_head, "archiv" => _shoutbox_archiv, "add" => $add));
    return empty($ajax) ? '<table class="navContent" cellspacing="0">' . $shout . '</table>' : $show;
}