예제 #1
0
function geturl($pstring, $urlmode = 0)
{
    global $_SGLOBAL, $_SCONFIG, $spaceself;
    //Éú³ÉHTML
    if (defined('CREATEHTML')) {
        $theurl = gethtmlurl($pstring);
        if (!empty($theurl)) {
            return $theurl;
        }
    }
    //URL»º´æ
    $cachekey = $pstring . $urlmode;
    if (empty($_SGLOBAL['url_cache'])) {
        $_SGLOBAL['url_cache'] = array();
    }
    if (!empty($_SGLOBAL['url_cache'][$cachekey])) {
        return $_SGLOBAL['url_cache'][$cachekey];
    }
    //url½á¹û
    $theurl = '';
    //Ç¿ÖÆphpģʽ
    $isphp = !empty($spaceself) ? 1 : strexists($pstring, 'php/1');
    //Ê×Ò³Á´½Ó
    if ($pstring == 'action/index') {
        $pstring = '';
    }
    //ËÑË÷ÓѺÃģʽ
    if (!empty($_SCONFIG['htmlmode']) && $_SCONFIG['htmlmode'] == 2 && !$isphp && $urlmode != 1) {
        $htmlarr = array('uid' => '', 'action' => '', 'catid' => '', 'fid' => '', 'tagid' => '', 'itemid' => '', 'tid' => '', 'type' => '', 'view' => '', 'mode' => '', 'showpro' => '', 'itemtypeid' => '', 'page' => '');
        $sarr = explode('/', $pstring);
        if (empty($sarr)) {
            $sarr = array('action' => 'index');
        }
        $htmlurlcheck = true;
        for ($i = 0; $i < count($sarr); $i = $i + 2) {
            if (!empty($sarr[$i + 1])) {
                if (key_exists($sarr[$i], $htmlarr)) {
                    $htmlarr[$sarr[$i]] = addslashes(str_replace(array('/', '\\'), '', rawurldecode(stripslashes($sarr[$i + 1]))));
                } else {
                    $htmlurlcheck = false;
                    break;
                }
            }
        }
        if ($htmlurlcheck) {
            $htmls = gethtmlfile($htmlarr);
            if (file_exists($htmls['path'])) {
                $theurl = $htmls['url'];
            }
        }
    }
    //ÆÕͨģʽ
    if (empty($theurl)) {
        if (empty($pstring)) {
            if ($urlmode == 1) {
                $theurl = S_URL_ALL;
            } else {
                $theurl = S_URL;
            }
        } else {
            $pre = '';
            $para = str_replace('/', '-', $pstring);
            if ($isphp || defined('S_ISPHP')) {
                $pre = '/index.php?';
            } else {
                if ($_SCONFIG['urltype'] == 5) {
                    $pre = '/index.php/';
                } else {
                    $pre = '/?';
                }
            }
            if (empty($para)) {
                $pre = '/';
            }
            if ($urlmode == 1) {
                //È«²¿Â·¾¶
                $theurl = S_URL_ALL . $pre . $para;
            } elseif ($urlmode == 2) {
                //´¦Àí
                $theurl = S_URL . $pre . $para;
                $theurl = url_remake($theurl);
            } else {
                //³£¹æ
                $theurl = S_URL . $pre . $para;
            }
        }
    }
    //url»º´æ
    $_SGLOBAL['url_cache'][$cachekey] = $theurl;
    return $theurl;
}
예제 #2
0
function createhtml($setphp, $ele)
{
    global $lang, $alang, $_SGET, $_SCONFIG, $_SGLOBAL, $_SBLOCK, $_SHTML, $_DCACHE, $_SC;
    $channels = getchannels();
    obclean();
    @(include $setphp);
    $content = ob_get_contents();
    obclean();
    $dir = gethtmlurl($ele, 1);
    $file = substr($dir, strrpos($dir, '/') + 1);
    $file = empty($file) ? './index.html' : $file;
    $dir = substr($dir, 0, strrpos($dir, '/'));
    //权限验证
    if (file_exists($dir . '/' . $file)) {
        if (!checkfdperm($dir . '/' . $file, 1)) {
            return $file . $alang['iswrite_file_error'];
        }
    } else {
        if (!checkfdperm($dir)) {
            $dirarr = explode("/", $dir);
            $dirstr = '';
            foreach ($dirarr as $key) {
                if (!is_dir($dirstr . $key)) {
                    @mkdir($dirstr . $key, 0777);
                } elseif (!checkfdperm($dirstr . $key)) {
                    return $dirstr . $key . $alang['iswrite_error'];
                }
                $dirstr .= $key . '/';
            }
        }
    }
    writefile($dir . '/' . $file, $content);
    return true;
}