示例#1
0
/**
 * array to utf8 & urlencode
 *
 */
function arrayRecursive(&$array, $function, $apply_to_keys_also = false, $cs)
{
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            arrayRecursive($array[$key], $function, $apply_to_keys_also, $cs);
        } else {
            $array[$key] = $function(toutf8($value, $cs));
        }
        if ($apply_to_keys_also && is_string($key)) {
        }
    }
}
示例#2
0
function mobile_msg($msg, $forward = '')
{
    if (!$msg && $forward) {
        dheader($forward);
    }
    extract($GLOBALS, EXTR_SKIP);
    include template('msg', 'mobile');
    if (DT_CHARSET != 'UTF-8') {
        toutf8();
    }
    exit;
}
示例#3
0
}
if (!$memm->MemConnect($type, $curcon)) {
    exit("ConnectFail");
}
$thekey = str_replace("_ _rd", "'", $key[0]['key']);
$thekey = str_replace("_ _rx", "\\", $thekey);
if ($_GET['action'] == 'ser') {
    $list = $memm->MemGet(array($thekey));
    if (is_array($list[0][$thekey])) {
        arrayRecursive($list[0][$thekey], 'htmlspecialchars', true, $cs);
        echo serialize($list[0][$thekey]);
    } else {
        if (gettype($list[0][$thekey]) == 'object') {
            echo serialize(toutf8($list[0][$thekey], $cs));
        } else {
            echo htmlspecialchars(toutf8($list[0][$thekey], $cs));
        }
    }
}
if ($_GET['action'] == 'unser') {
    $list = $memm->MemGet(array($thekey));
    if (is_array($list[0][$thekey]) || gettype($list[0][$thekey]) == 'object') {
        arrayRecursive($list[0][$thekey], 'htmlspecialchars', true, $cs);
        echo "<pre>";
        print_r($list[0][$thekey]);
        echo "</pre>";
    } else {
        $unser = @unserialize($list[0][$thekey]);
        if (is_array($unser)) {
            arrayRecursive($unser, 'htmlspecialchars', true, $cs);
            echo "<pre>";
示例#4
0
$local = get_cookie('mobile_setting');
if ($local) {
    $data = $local;
} else {
    if ($_userid) {
        $data = file_get(DT_ROOT . '/file/user/' . dalloc($_userid) . '/' . $_userid . '/mobile.php');
        if ($data) {
            set_cookie('mobile_setting', $data, $DT_TIME + 30 * 86400);
        }
    }
}
if ($data) {
    $MOB_MOD = array();
    foreach ($MOB_MODULE as $m) {
        $MOB_MOD[$m['moduleid']] = $m;
    }
    foreach (explode(',', $data) as $id) {
        if (isset($MOB_MOD[$id])) {
            $MOD_MY[] = $MOB_MOD[$id];
        }
    }
}
if (count($MOD_MY) < 2) {
    $MOD_MY = $MOB_MODULE;
}
$head_name = $EXT['mobile_sitename'] ? $EXT['mobile_sitename'] : $DT['sitename'];
$foot = 'home';
include template('index', 'mobile');
if (DT_CHARSET != 'UTF-8') {
    toutf8();
}
示例#5
0
/**
 * get the list of all keys and its regex
 * number + alphabet + hangul + others
 */
function get_keys()
{
    global $Config;
    $keys = array();
    for ($i = 0; $i <= 9; $i++) {
        $keys["{$i}"] = "{$i}";
    }
    for ($i = 65; $i <= 90; $i++) {
        $k = chr($i);
        $keys["{$k}"] = "{$k}";
    }
    if (strtolower($Config['charset']) == 'euc-kr') {
        $korean = array("°¡", "±î", "³ª", "´Ù", "µû", "¶ó", "¸¶", "¹Ù", "ºü", "»ç", "½Î", "¾Æ", "ÀÚ", "Â¥", "Â÷", "Ä«", "Ÿ", "ÆÄ", "ÇÏ", "Èÿ");
        for ($i = 0; $i < count($korean) - 1; $i++) {
            $k1 = $korean[$i];
            $k2 = $korean[$i + 1];
            $k2 = $k2[0] . chr(ord($k2[1]) - 1);
            $keys["{$k1}"] = '[' . $k1 . '-' . $k2 . ']';
        }
        $k1 = $korean[0];
        $keys['Others'] = '[^0-9A-Z' . $k1 . '-' . $k2 . ']';
        return $keys;
    }
    for ($i = 0; $i < 19; $i++) {
        $u1 = 0xac00 + (int) ($i * 588 / 588) * 588;
        $u2 = 0xac00 + (int) ($i * 588 / 588) * 588 + 20 * 28 + 27;
        $k1 = toutf8($u1);
        $k2 = toutf8($u2);
        $keys["{$k1}"] = '[' . $k1 . '-' . $k2 . ']';
    }
    $k1 = toutf8(0xac00);
    $keys['Others'] = '[^0-9A-Z' . $k1 . '-' . $k2 . ']';
    return $keys;
}
示例#6
0
function add_bookmark($url, $folder, $type, $bookmark_json, $name = null, $redirect = 0)
{
    global $site_url;
    if ($bookmark = parse_bookmark_json($bookmark_json)) {
        $id = ++$bookmark[1];
    } else {
        $id = 1;
    }
    if ($type == 'url' && !isset($name)) {
        $name = substr($url, 0, 140);
        //$str = @file_get_contents($url);
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        $str = curl_exec($ch);
        curl_close($ch);
        if (strlen($str)) {
            preg_match('/\\<title\\>(.*)\\<\\/title\\>/i', $str, $title);
            $name = isset($title[1]) ? toutf8($title[1]) : '';
        }
    }
    $hash = sha1($url);
    if ($type == 'url' && $redirect) {
        $url = $site_url . 'index.php?action=redirect&u=' . urlencode($url) . '&id=_' . $id;
    }
    $new = array('_' . $id => array('id' => $id, 'type' => $type, 'name' => $type == 'url' ? $name : $url, 'date_added' => isset($time) ? $time : time(), 'hash' => $hash));
    if ($type == 'url') {
        $new['_' . $id]['url'] = $url;
    }
    $data = $new['_' . $id];
    if ($folder) {
        $levels = array_reverse(explode('_', substr($folder, 1)));
        foreach ($levels as $level) {
            if ($level) {
                $new = array('_' . $level => array('entries' => $new));
            }
        }
    }
    if (isset($bookmark[0]['entries']) && is_array($bookmark[0]['entries'])) {
        $bookmark[0]['entries'] = array_merge_recursive($bookmark[0]['entries'], $new);
    } else {
        $bookmark[0]['entries'] = $new;
    }
    file_put_contents($bookmark_json, json_encode($bookmark), LOCK_EX);
    if ($type == 'folder') {
        move_bookmark($data, ($folder !== '_0' ? $folder : '') . '_-1', $bookmark_json);
    }
    return $data;
}