Example #1
0
 public function getThumbnailUrl()
 {
     if ($this->getThumbnail()) {
         return get_sub_root() . "/files/avatars/" . $this->getThumbnail();
     }
     $settings = Vars::getSettings();
     return get_sub_root() . "/files/avatars/" . $settings['profile']['avatar_default'];
 }
Example #2
0
 static function redirectToI18nUrl()
 {
     $uri = get_request_uri();
     $pos = strpos($uri, "/" . get_sub_root() . get_language());
     if ($pos === false || $pos !== false && $pos != 0) {
         $uri = get_request_uri(false);
         $uri = preg_replace('/\\/' . str_replace('/', '\\/', get_sub_root()) . '/', get_language() . '/', $uri, 1);
         HTML::forward($uri);
     }
 }
Example #3
0
    /**
     * print js to gerenate spam token
     * 
     * @param type $jquery_selector
     */
    public static function loadSpamToken($jquery_selector, $unique_id)
    {
        echo '
<script type="text/javascript">
jQuery(function($){
  $("' . $jquery_selector . ' input[type=submit]").addClass("disabled");
  $.get("/' . get_sub_root() . 'form/spam/token/fetch?unique_id=' . $unique_id . '", function(data) {
    var input = $("<input type=\'hidden\' name=\'"+data["key"]+"\' value=\'"+data["value"]+"\' />");
    $("' . $jquery_selector . '").append(input);
    $("' . $jquery_selector . ' input[type=submit]").removeClass("disabled");
  }, "json");
});
</script>
';
    }
Example #4
0
<?php

require_once 'bootstrap.php';
$settings = Vars::getSettings();
/** rounting **/
$relative_uri;
if ($settings['i18n']) {
    $relative_uri = get_request_uri_relative();
} else {
    $relative_uri = str_replace(get_sub_root(), '', get_request_uri());
}
//_debug($settings['routing']);
// try to match a route
foreach ($settings['routing'] as $route) {
    $path = $route['path'];
    $isSecure = $route['isSecure'];
    $controller = $route['controller'];
    $i18n = $route['i18n'];
    //  _debug($relative_uri);
    $vars = array();
    $user = User::getInstance();
    if (preg_match('/' . $path . '/', $relative_uri, $vars)) {
        // redirect to lang url if lang code is not here
        if ($i18n && $settings['i18n']) {
            HTML::redirectToI18nUrl();
        }
        if ($isSecure && !$user->isLogin()) {
            dispatch('core/login');
        } else {
            dispatch($controller, $vars);
        }
Example #5
0
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title><?php 
echo isset($title) ? $title : '';
?>
</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<script type="text/javascript">
  var site = jQuery();
  site.settings = <?php 
echo HTML::renderSettingsInJson();
?>
;
  site.settings.subroot = '<?php 
echo get_sub_root();
?>
';
</script>

<?php 
HTML::renderOutHeaderUpperRegistry();
?>
  
<?php 
Asset::printTopAssets('frontend');
HTML::renderOutHeaderLowerRegistry();
?>

  
<?php 
Example #6
0
/**
 * print out an uri
 */
function uri($uri, $i18n = true)
{
    $settings = Vars::getSettings();
    $rtn = "/" . get_sub_root();
    if (isset($settings['i18n']) && $settings['i18n'] && $i18n) {
        $rtn .= get_language() . '/';
    }
    $rtn .= $uri;
    return $rtn;
}
Example #7
0
 public function logout()
 {
     global $siteuser;
     unset($siteuser);
     unset($_SESSION['siteuser_id']);
     unset($_SESSION['siteuser_password']);
     unset($_SESSION['siteuser_permissions']);
     unset($_SESSION['siteuser_roles']);
     setcookie('siteuser_id', null, time() - 3600, '/' . get_sub_root());
     setcookie('siteuser_password', null, time() - 3600, '/' . get_sub_root());
 }
<?php

require_once __DIR__ . '/../../../../bootstrap.php';
if (!User::getInstance()->isLogin()) {
    $rtn->error = i18n(array('en' => 'Authorisation required.', 'zh' => '抱歉,您没有权限进行此操作'));
    echo json_encode($rtn);
    exit;
}
$file_path = WEBROOT . DS . get_sub_root() . $_GET['path'];
$rtn = new stdClass();
if (is_file($file_path)) {
    if (unlink($file_path)) {
        $rtn->success = 1;
    } else {
        $rtn->error = i18n(array('en' => 'Image file exists but failed to be removed.', 'zh' => '图片文件存在,但删除失败'));
    }
} else {
    $rtn->error = i18n(array('en' => 'Image file does not exist', 'zh' => '图片文件不存在'));
}
echo json_encode($rtn);
exit;
Example #9
0
 static function printBottomAssets($which_end)
 {
     foreach (self::getBottomAssets('css', $which_end) as $asset) {
         $url = preg_match('/^(\\/\\/|http)/', $asset->source) ? $asset->source : '/' . get_sub_root() . 'modules/' . $asset->source;
         echo "  <link rel='stylesheet' href='{$url}'>\n";
     }
     foreach (self::getBottomAssets('js', $which_end) as $asset) {
         $url = preg_match('/^(\\/\\/|http)/', $asset->source) ? $asset->source : '/' . get_sub_root() . 'modules/' . $asset->source;
         echo "  <script type='text/javascript' src='{$url}'></script>\n";
     }
 }