示例#1
0
 /**
  * Builds the NoPermission UI
  *
  * @access  public
  * @param   string  $user    Username
  * @param   string  $gadget  The Gadget user is requesting
  * @param   string  $action  The 'denied' action
  * @return  string  XHTML content
  */
 function ShowNoPermission($user, $gadget, $action)
 {
     // Load the template
     $tpl = $this->gadget->template->load('NoPermission.html');
     $tpl->SetBlock('NoPermission');
     $tpl->SetVariable('nopermission', _t('USERS_NO_PERMISSION_TITLE'));
     $tpl->SetVariable('description', _t('USERS_NO_PERMISSION_DESC', $gadget, $action));
     $tpl->SetVariable('admin_script', BASE_SCRIPT);
     $tpl->SetVariable('site-name', $this->gadget->registry->fetch('site_name', 'Settings'));
     $tpl->SetVariable('site-slogan', $this->gadget->registry->fetch('site_slogan', 'Settings'));
     $tpl->SetVariable('BASE_URL', $GLOBALS['app']->GetSiteURL('/'));
     $tpl->SetVariable('.dir', _t('GLOBAL_LANG_DIRECTION') == 'rtl' ? '.rtl' : '');
     if ($GLOBALS['app']->Session->Logged()) {
         $tpl->SetBlock('NoPermission/known');
         $logoutLink = $this->gadget->urlMap('Logout');
         $referLink = empty($_SERVER['HTTP_REFERER']) ? $GLOBALS['app']->getSiteURL('/') : Jaws_XSS::filter($_SERVER['HTTP_REFERER']);
         $tpl->SetVariable('known_description', _t('USERS_NO_PERMISSION_KNOWN_DESC', $logoutLink, $referLink));
         $tpl->ParseBlock('NoPermission/known');
     } else {
         $tpl->SetBlock('NoPermission/anon');
         $loginLink = $this->gadget->urlMap('LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(false))));
         $referLink = empty($_SERVER['HTTP_REFERER']) ? $GLOBALS['app']->getSiteURL('/') : Jaws_XSS::filter($_SERVER['HTTP_REFERER']);
         $tpl->SetVariable('anon_description', _t('USERS_NO_PERMISSION_ANON_DESC', $loginLink, $referLink));
         $tpl->ParseBlock('NoPermission/anon');
     }
     $tpl->ParseBlock('NoPermission');
     return $tpl->Get();
 }
示例#2
0
 /**
  * Creates and returns some data
  *
  * @access  public
  * @param   string  $dir
  * @param   int     $offset
  * @param   int     $order
  * @return  array   directory tree array
  */
 function GetDirectory($dir, $offset, $order)
 {
     $model = $this->gadget->model->load('Directory');
     $files = $model->ReadDir($dir, 15, $offset, $order);
     if (Jaws_Error::IsError($files)) {
         return array();
         //Jaws_Error::Fatal($files->getMessage(), __FILE__, __LINE__);
     }
     $tree = array();
     foreach ($files as $file) {
         $item = array();
         //Icon
         $link =& Piwi::CreateWidget('Image', $file['mini_icon']);
         $item['image'] = $link->Get();
         //Title
         $item['title'] = $file['title'];
         $actions = '';
         if ($file['is_dir']) {
             $link =& Piwi::CreateWidget('Link', $file['filename'], "javascript: cwd('{$file['relative']}');");
             $link->setStyle('float: left;');
             $item['name'] = $link->Get();
             if ($this->gadget->GetPermission('ManageDirectories')) {
                 //edit directory properties
                 $link =& Piwi::CreateWidget('Link', _t('GLOBAL_EDIT'), "javascript: editDir(this, '{$file['filename']}');", STOCK_EDIT);
                 $actions .= $link->Get() . ' ';
                 //delete directory
                 $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript: delDir(this, '{$file['filename']}');", STOCK_DELETE);
                 $actions .= $link->Get() . ' ';
             }
         } else {
             if (empty($file['id'])) {
                 $furl = Jaws_XSS::filter($file['url']);
             } else {
                 $fid = empty($file['fast_url']) ? $file['id'] : Jaws_XSS::filter($file['fast_url']);
                 $furl = $this->gadget->urlMap('Download', array('id' => $fid));
             }
             $link =& Piwi::CreateWidget('Link', $file['filename'], $furl);
             $link->setStyle('float: left;');
             $item['name'] = $link->Get();
             if ($this->gadget->GetPermission('ManageFiles')) {
                 //edit file properties
                 $link =& Piwi::CreateWidget('Link', _t('GLOBAL_EDIT'), "javascript: editFile(this, '{$file['filename']}');", STOCK_EDIT);
                 $actions .= $link->Get() . ' ';
                 //delete file
                 $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript: delFile(this, '{$file['filename']}');", STOCK_DELETE);
                 $actions .= $link->Get() . ' ';
             }
         }
         $item['size'] = $file['size'];
         $item['hits'] = $file['hits'];
         $item['actions'] = $actions;
         $tree[] = $item;
     }
     return $tree;
 }
示例#3
0
文件: Agent.php 项目: Dulciane/jaws
 /**
  * Checks the Agent is blocked or not
  *
  * @access  public
  * @param   string  $agent  Agent
  * @return  bool    True if the Agent is blocked
  */
 function IsAgentBlocked($agent)
 {
     $table = Jaws_ORM::getInstance()->table('policy_agentblock');
     $table->select('blocked:boolean');
     $table->where('agent', Jaws_XSS::filter($agent));
     $blocked = $table->fetchOne();
     if (!Jaws_Error::IsError($blocked) && !is_null($blocked)) {
         return $blocked;
     }
     return $this->gadget->registry->fetch('block_undefined_agent') == 'true';
 }
示例#4
0
 /**
  * Fetch WWW-Authentication data
  *
  * @access  public
  * @return  void
  */
 function AssignData()
 {
     if (!empty($_SERVER['PHP_AUTH_USER'])) {
         $this->username = Jaws_XSS::filter($_SERVER['PHP_AUTH_USER']);
     }
     if (!empty($_SERVER['PHP_AUTH_PW'])) {
         $this->password = Jaws_XSS::filter($_SERVER['PHP_AUTH_PW']);
     }
     //Try to get authentication information from IIS
     if (empty($this->username) && empty($this->password) && !empty($_SERVER['HTTP_AUTHORIZATION'])) {
         list($this->username, $this->password) = explode(':', base64_decode(substr($this->server['HTTP_AUTHORIZATION'], 6)));
     }
 }
示例#5
0
 /**
  * Create a new Friend
  *
  * @access  public
  * @param   string  $friend Friend name
  * @param   string  $url    Friend's url
  * @return  mixed   True if query is successful, if not, returns Jaws_Error on any error
  */
 function NewFriend($friend, $url)
 {
     $params['friend'] = Jaws_XSS::filter($friend);
     $params['url'] = Jaws_XSS::filter($url);
     $friendTable = Jaws_ORM::getInstance()->table('friend');
     $result = $friendTable->insert($params)->exec();
     if (Jaws_Error::IsError($result)) {
         $GLOBALS['app']->Session->PushLastResponse(_t('FRIENDS_ERROR_NOT_ADDED'), RESPONSE_ERROR);
         return new Jaws_Error(_t('FRIENDS_ERROR_NOT_ADDED'));
     }
     $GLOBALS['app']->Session->PushLastResponse(_t('FRIENDS_ADDED'), RESPONSE_NOTICE);
     return true;
 }
示例#6
0
文件: Logs.php 项目: Dulciane/jaws
 /**
  * Inserts a Log
  *
  * @access  public
  * @param   string  $gadget     Gadget name
  * @param   string  $action     Action name
  * @param   int     $priority   Priority of log
  * @param   array   $params     Action parameters
  * @param   int     $status     Status code
  * @return  mixed   Log identity or Jaws_Error on failure
  */
 function InsertLog($user, $gadget, $action, $priority = 0, $params = null, $status = 200)
 {
     // ip address
     $ip = 0;
     if (preg_match('/\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b/', $_SERVER['REMOTE_ADDR'])) {
         $ip = ip2long($_SERVER['REMOTE_ADDR']);
         $ip = $ip < 0 ? $ip + 0xffffffff + 1 : $ip;
     }
     // agent
     $agent = substr(Jaws_XSS::filter($_SERVER['HTTP_USER_AGENT']), 0, 252);
     $logsTable = Jaws_ORM::getInstance()->table('logs');
     $logsTable->insert(array('user' => (int) $user, 'gadget' => $gadget, 'action' => $action, 'priority' => $priority, 'params' => $params, 'apptype' => JAWS_APPTYPE, 'backend' => JAWS_SCRIPT == 'admin', 'ip' => $ip, 'agent' => $agent, 'status' => (int) $status, 'insert_time' => time()));
     return $logsTable->exec();
 }
示例#7
0
 /**
  * Creates and prints the template of Friends
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Display()
 {
     $tpl = $this->gadget->template->load('Friends.html');
     $model = $this->gadget->model->load('Friends');
     $friends = $model->GetRandomFriends();
     if (!Jaws_Error::IsError($friends)) {
         $tpl->SetBlock('friends');
         $tpl->SetVariable('title', $this->gadget->title);
         foreach ($friends as $friend) {
             $tpl->SetBlock('friends/friend');
             $tpl->SetVariable('name', Jaws_XSS::filter($friend['friend']));
             $tpl->SetVariable('url', Jaws_XSS::filter($friend['url']));
             $tpl->ParseBlock('friends/friend');
         }
     }
     $tpl->ParseBlock('friends');
     return $tpl->Get();
 }
示例#8
0
 /**
  * Prints all the files with their titles and contents of initial folder
  *
  * @access  public
  * @param   string  $path
  * @return  string  XHTML template content with titles and contents
  */
 function InitialFolder($path = '')
 {
     if (!$this->gadget->GetPermission('OutputAccess')) {
         return false;
     }
     if ($this->gadget->registry->fetch('frontend_avail') != 'true') {
         return false;
     }
     $tpl = $this->gadget->template->load('FileBrowser.html');
     $tpl->SetBlock('initial_folder');
     $tpl->SetVariable('title', $this->gadget->title);
     $model = $this->gadget->model->load('Directory');
     $items = $model->ReadDir($path);
     if (!Jaws_Error::IsError($items)) {
         foreach ($items as $item) {
             $tpl->SetBlock('initial_folder/item');
             $tpl->SetVariable('icon', $item['mini_icon']);
             $tpl->SetVariable('name', Jaws_XSS::filter($item['filename']));
             $tpl->SetVariable('title', Jaws_XSS::filter($item['title']));
             if ($item['is_dir']) {
                 $relative = Jaws_XSS::filter($item['relative']) . '/';
                 $url = $this->gadget->urlMap('Display', array('path' => $relative));
             } else {
                 if (empty($item['id'])) {
                     $url = Jaws_XSS::filter($item['url']);
                 } else {
                     $fid = empty($item['fast_url']) ? $item['id'] : Jaws_XSS::filter($item['fast_url']);
                     $url = $this->gadget->urlMap('Download', array('id' => $fid));
                 }
             }
             $tpl->SetVariable('url', $url);
             $tpl->ParseBlock('initial_folder/item');
         }
     }
     $tpl->ParseBlock('initial_folder');
     return $tpl->Get();
 }
示例#9
0
文件: Plugin.php 项目: juniortux/jaws
 /**
  * The preg_replace call back function
  *
  * @access  private
  * @param   string  $matches    Matched strings from preg_replace_callback
  * @return  string  Gadget action output
  */
 function Prepare($matches)
 {
     $matches[1] = Jaws_XSS::filter($matches[1]);
     $gadget = ucfirst(strtolower($matches[1]));
     if ($gadget == 'Staticpage' || $gadget == 'Page') {
         $gadget = 'StaticPage';
     }
     $link = Jaws_XSS::filter($matches[2]);
     $linkText = isset($matches[3]) ? $matches[3] : $linkText;
     switch ($gadget) {
         case 'Blog':
             $mapURL = $GLOBALS['app']->Map->GetURLFor('Blog', 'SingleView', array('id' => $link));
             break;
         case 'Phoo':
             $mapURL = $GLOBALS['app']->Map->GetURLFor('Phoo', 'ViewAlbum', array('id' => $link));
             break;
         case 'StaticPage':
             $mapURL = $GLOBALS['app']->Map->GetURLFor('StaticPage', 'Page', array('id' => $link));
             break;
     }
     $text = '<a href="' . $mapURL . '">' . $linkText . '</a>';
     return $text;
 }
示例#10
0
文件: XmlRpc.php 项目: juniortux/jaws
/**
 * metaWeblog.getCategories
 *
 * @access  public
 * @param   array   $params     array of params
 * @return  XML_RPC_Response object
 */
function metaWeblog_getCategories($params)
{
    $blog = getScalarValue($params, 0);
    // blog gadget only supports 1 blog, so this parameter is not used.
    $user = getScalarValue($params, 1);
    $password = getScalarValue($params, 2);
    $userInfo = userAuthentication($user, $password);
    if (Jaws_Error::IsError($userInfo)) {
        return new XML_RPC_Response(0, $GLOBALS['XML_RPC_erruser'] + 4, _t('GLOBAL_ERROR_LOGIN_WRONG'));
    }
    if (!GetBlogPermission($user, 'default_admin')) {
        return new XML_RPC_Response(0, $GLOBALS['XML_RPC_erruser'] + 3, $categories->GetMessage());
    }
    $model = Jaws_Gadget::getInstance('Blog')->model->load('Categories');
    if (Jaws_Error::isError($model)) {
        return new XML_RPC_Response(0, $GLOBALS['XML_RPC_erruser'] + 2, $model->GetMessage());
    }
    $categories = $model->GetCategories();
    if (Jaws_Error::IsError($categories)) {
        return new XML_RPC_Response(0, $GLOBALS['XML_RPC_erruser'] + 2, $categories->GetMessage());
    }
    $struct = array();
    foreach ($categories as $category) {
        $cid = empty($category['fast_url']) ? $category['id'] : Jaws_XSS::filter($category['fast_url']);
        $htmlurl = $GLOBALS['app']->Map->GetURLFor('Blog', 'ShowCategory', array('id' => $cid));
        $rssurl = $GLOBALS['app']->Map->GetURLFor('Blog', 'ShowRSSCategory', array('id' => $category['id']));
        $data = array('categoryId' => new XML_RPC_Value($category['id']), 'categoryName' => new XML_RPC_Value($category['name']), 'title' => new XML_RPC_Value($category['name']), 'description' => new XML_RPC_Value($category['description']), 'htmlUrl' => new XML_RPC_Value($htmlurl), 'rssUrl' => new XML_RPC_Value($rssurl));
        $struct[] = new XML_RPC_Value($data, 'struct');
    }
    $val = new XML_RPC_Value($struct, 'array');
    return new XML_RPC_Response($val);
}
示例#11
0
文件: Quotes.php 项目: Dulciane/jaws
 /**
  * Displays quotes by group in standalone mode
  *
  * @access  public
  * @return  XHTML template content
  */
 function QuotesByGroup()
 {
     header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 200 OK");
     $action = $this->gadget->action->load('Groups');
     return $action->ViewGroupQuotes();
 }
示例#12
0
 /**
  * insert new session
  *
  * @access  public
  * @return  mixed   Session ID if success, otherwise Jaws_Error or false
  */
 function insert()
 {
     $max_active_sessions = (int) $GLOBALS['app']->Registry->fetch('max_active_sessions', 'Policy');
     if (!empty($max_active_sessions)) {
         $activeSessions = $this->GetSessionsCount(true);
         if ($activeSessions >= $max_active_sessions) {
             // remove expired session
             $this->DeleteExpiredSessions();
             $GLOBALS['app']->Session->Logout();
             Jaws_Error::Fatal(_t('GLOBAL_HTTP_ERROR_CONTENT_503_OVERLOAD'), 0, 503);
         }
     }
     // agent
     $agent = substr(Jaws_XSS::filter($_SERVER['HTTP_USER_AGENT']), 0, 252);
     // ip
     $ip = 0;
     if (preg_match('/\\b(?:\\d{1,3}\\.){3}\\d{1,3}\\b/', $_SERVER['REMOTE_ADDR'])) {
         $ip = ip2long($_SERVER['REMOTE_ADDR']);
         $ip = $ip < 0 ? $ip + 0xffffffff + 1 : $ip;
     }
     // referrer
     $referrer = Jaws_Utils::getHostReferrer();
     $sessTable = Jaws_ORM::getInstance()->table('session', '', 'sid');
     if (!empty($GLOBALS['app']->Session->_Attributes)) {
         //A new session, we insert it to the DB
         $updatetime = time();
         $user = $GLOBALS['app']->Session->GetAttribute('user');
         $serialized = serialize($GLOBALS['app']->Session->_Attributes);
         $sessTable->insert(array('user' => $user, 'type' => JAWS_APPTYPE, 'longevity' => $GLOBALS['app']->Session->GetAttribute('longevity'), 'data' => $serialized, 'referrer' => md5($referrer), 'checksum' => md5($user . $serialized), 'ip' => $ip, 'agent' => $agent, 'createtime' => $updatetime, 'updatetime' => $updatetime));
         $result = $sessTable->exec();
         if (!Jaws_Error::IsError($result)) {
             return $result;
         }
     }
     return false;
 }
示例#13
0
文件: Feeds.php 项目: juniortux/jaws
 /**
  * Create ATOM struct of a given category
  *
  * @access  public
  * @param   int     $category   Category ID
  * @param   string  $feed_type  OPTIONAL feed type
  * @return  mixed   Can return the Atom Object or Jaws_Error on error
  */
 function GetCategoryAtomStruct($category, $feed_type = 'atom')
 {
     $model = $this->gadget->model->load('Categories');
     $catInfo = $model->GetCategory($category);
     if (Jaws_Error::IsError($catInfo)) {
         return new Jaws_Error(_t('BLOG_ERROR_GETTING_CATEGORIES_ATOMSTRUCT'));
     }
     $now = Jaws_DB::getInstance()->date();
     $blogTable = Jaws_ORM::getInstance()->table('blog');
     $blogTable->select('blog.id:integer', 'user_id:integer', 'blog_entrycat.category_id:integer', 'username', 'email', 'nickname', 'title', 'fast_url', 'summary', 'text', 'blog.publishtime', 'blog.updatetime', 'clicks:integer', 'comments:integer', 'allow_comments:boolean', 'published:boolean')->join('users', 'blog.user_id', 'users.id')->join('blog_entrycat', 'blog.id', 'blog_entrycat.entry_id');
     $blogTable->where('published', true)->and()->where('blog.publishtime', $now, '<=');
     $blogTable->and()->where('blog_entrycat.category_id', $catInfo['id']);
     $result = $blogTable->orderby('blog.publishtime desc')->fetchAll();
     if (Jaws_Error::IsError($result)) {
         return new Jaws_Error(_t('BLOG_ERROR_GETTING_CATEGORIES_ATOMSTRUCT'));
     }
     $cid = empty($catInfo['fast_url']) ? $catInfo['id'] : Jaws_XSS::filter($catInfo['fast_url']);
     $categoryAtom = new Jaws_AtomFeed();
     $siteURL = $GLOBALS['app']->GetSiteURL('/');
     $url = $this->gadget->urlMap($feed_type == 'atom' ? 'ShowAtomCategory' : 'ShowRSSCategory', array('id' => $cid), true);
     $categoryAtom->SetTitle($this->gadget->registry->fetch('site_name', 'Settings'));
     $categoryAtom->SetLink($url);
     $categoryAtom->SetId($siteURL);
     $categoryAtom->SetTagLine($catInfo['name']);
     $categoryAtom->SetAuthor($this->gadget->registry->fetch('site_author', 'Settings'), $siteURL, $this->gadget->registry->fetch('gate_email', 'Settings'));
     $categoryAtom->SetGenerator('JAWS ' . $GLOBALS['app']->Registry->fetch('version'));
     $categoryAtom->SetCopyright($this->gadget->registry->fetch('site_copyright', 'Settings'));
     $objDate = Jaws_Date::getInstance();
     foreach ($result as $r) {
         $entry = new AtomEntry();
         $entry->SetTitle($r['title']);
         $post_id = empty($r['fast_url']) ? $r['id'] : $r['fast_url'];
         $url = $this->gadget->urlMap('SingleView', array('id' => $post_id), true);
         $entry->SetLink($url);
         $entry->SetId($url);
         $summary = $r['summary'];
         $text = $r['text'];
         // for compatibility with old versions
         $more_pos = Jaws_UTF8::strpos($text, '[more]');
         if ($more_pos !== false) {
             $summary = Jaws_UTF8::substr($text, 0, $more_pos);
             $text = Jaws_UTF8::str_replace('[more]', '', $text);
             // Update this entry to split summary and body of post
             $model = $this->gadget->model->load('Posts');
             $model->SplitEntry($r['id'], $summary, $text);
         }
         $summary = empty($summary) ? $text : $summary;
         $summary = $this->gadget->ParseText($summary);
         $text = $this->gadget->ParseText($text);
         $entry->SetSummary($summary, 'html');
         $entry->SetContent($text, 'html');
         $email = $r['email'];
         $entry->SetAuthor($r['nickname'], $categoryAtom->Link->HRef, $email);
         $entry->SetPublished($objDate->ToISO($r['publishtime']));
         $entry->SetUpdated($objDate->ToISO($r['updatetime']));
         $categoryAtom->AddEntry($entry);
         if (!isset($last_modified)) {
             $last_modified = $r['updatetime'];
         }
     }
     if (isset($last_modified)) {
         $categoryAtom->SetUpdated($objDate->ToISO($last_modified));
     } else {
         $categoryAtom->SetUpdated($objDate->ToISO(date('Y-m-d H:i:s')));
     }
     return $categoryAtom;
 }
示例#14
0
文件: Banners.php 项目: Dulciane/jaws
 /**
  * Displays banners(all-time visibles and random ones)
  *
  * @access  public
  * @param   int     $gid    Group ID
  * @return  string  XHTML template content
  */
 function Banners($gid = 0)
 {
     $id = (int) $this->gadget->request->fetch('id', 'get');
     $abs_url = false;
     if (!empty($id)) {
         $gid = $id;
         header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 200 OK");
         $abs_url = true;
     }
     $groupModel = $this->gadget->model->load('Groups');
     $group = $groupModel->GetGroup($gid);
     if (Jaws_Error::IsError($group) || empty($group) || !$group['published']) {
         return false;
     }
     $bannerModel = $this->gadget->model->load('Banners');
     $banners = $bannerModel->GetVisibleBanners($gid, $group['limit_count']);
     if (Jaws_Error::IsError($banners) || empty($banners)) {
         return false;
     }
     $tpl = $this->gadget->template->load('Banners.html');
     switch ($group['show_type']) {
         case 1:
         case 2:
             $type_block = 'banners_type_' . $group['show_type'];
             break;
         default:
             $type_block = 'banners';
     }
     $tpl->SetBlock($type_block);
     $tpl->SetVariable('gid', $gid);
     if ($group['show_title']) {
         $tpl->SetBlock("{$type_block}/title");
         $tpl->SetVariable('title', _t('BANNER_ACTIONS_BANNERS_TITLE', $group['title']));
         $tpl->ParseBlock("{$type_block}/title");
     }
     foreach ($banners as $banner) {
         $tpl->SetBlock("{$type_block}/banner");
         $tpl_template = new Jaws_Template();
         $tpl_template->LoadFromString('<!-- BEGIN x -->' . $banner['template'] . '<!-- END x -->');
         $tpl_template->SetBlock('x');
         $tpl_template->SetVariable('title', $banner['title']);
         if (file_exists(JAWS_DATA . $this->gadget->DataDirectory . $banner['banner'])) {
             $tpl_template->SetVariable('banner', $GLOBALS['app']->getDataURL($this->gadget->DataDirectory . $banner['banner']));
         } else {
             $tpl_template->SetVariable('banner', $banner['banner']);
         }
         if (empty($banner['url'])) {
             $tpl_template->SetVariable('link', 'javascript:void(0);');
             $tpl_template->SetVariable('target', '_self');
         } else {
             $tpl_template->SetVariable('link', $this->gadget->urlMap('Click', array('id' => $banner['id']), $abs_url));
             $tpl_template->SetVariable('target', '_blank');
         }
         $tpl_template->ParseBlock('x');
         $tpl->SetVariable('template', $tpl_template->Get());
         unset($tpl_template);
         $tpl->ParseBlock("{$type_block}/banner");
         $bannerModel->ViewBanner($banner['id']);
     }
     $tpl->ParseBlock($type_block);
     return $tpl->Get();
 }
示例#15
0
文件: Plugin.php 项目: Dulciane/jaws
 /**
  * Search callback for the album
  *
  * @access  public
  * @param   array   $data   Album data(artist and album)
  * @return  string  XHTML album image
  */
 function GetAlbumCover($data)
 {
     $albumDir = JAWS_DATA . 'AlbumCover/';
     if (!isset($data[1]) || !isset($data[2]) || empty($data[1]) || empty($data[2])) {
         return '';
     }
     $Artist = $data[1];
     $Album = $data[2];
     $img = strtolower(str_replace(' ', '', $Artist)) . '_' . strtolower(str_replace(' ', '', $Album)) . '.jpg';
     ///FIXME needs error checking
     if (!($rs = is_file($albumDir . $img))) {
         $amazonImg = $this->GetAlbumCoverFromAmazon($Artist, $Album);
         if (empty($amazonImg)) {
             $img = 'images/unknown.png';
         } elseif (!@copy($amazonImg, $albumDir . $img)) {
             //FIXME: Notify that can't copy image to cache...
             $img = Jaws_XSS::filter($amazonImg);
         } else {
             $img = JAWS_DATA . 'AlbumCover/' . $img;
         }
     } else {
         $img = JAWS_DATA . 'AlbumCover/' . $img;
     }
     $text = $Artist . ' - ' . $Album;
     return '<img src="' . $img . '" alt="' . $text . '" title="' . $text . '" />';
 }
示例#16
0
 /**
  * Get the comments messages list
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function GetMessages()
 {
     $rqst = jaws()->request->fetch(array('order', 'perpage', 'page'), 'get');
     $page = empty($rqst['page']) ? 1 : (int) $rqst['page'];
     if (!empty($rqst['perpage'])) {
         $perPage = (int) $rqst['perpage'];
         $orderBy = (int) $rqst['order'];
     } else {
         $perPage = $this->gadget->registry->fetch('comments_per_page');
         $orderBy = 0;
     }
     $model = $this->gadget->model->load('Comments');
     $comments = $model->GetComments($this->gadget->name, '', '', '', array(Comments_Info::COMMENTS_STATUS_APPROVED), $perPage, ($page - 1) * $perPage, $orderBy);
     $comments_count = $model->GetCommentsCount($this->gadget->name, '', '', '', array(Comments_Info::COMMENTS_STATUS_APPROVED));
     $tpl = $this->gadget->template->load('Comments.html');
     $tpl->SetBlock('comments');
     $tpl->SetVariable('gadget', strtolower($this->gadget->name));
     $objDate = Jaws_Date::getInstance();
     $usrModel = new Jaws_User();
     if (!Jaws_Error::IsError($comments) && $comments != null) {
         foreach ($comments as $entry) {
             $tpl->SetBlock('comments/entry');
             $tpl->SetVariable('postedby_lbl', _t('COMMENTS_POSTEDBY'));
             if ($entry['user_registered_date']) {
                 $tpl->SetBlock('comments/entry/registered_date');
                 $tpl->SetVariable('registered_date_lbl', _t('COMMENTS_USERS_REGISTERED_DATE'));
                 $tpl->SetVariable('registered_date', $objDate->Format($entry['user_registered_date'], 'd MN Y'));
                 $tpl->ParseBlock('comments/entry/registered_date');
             }
             if (!empty($entry['username'])) {
                 // user's profile
                 $tpl->SetVariable('user_url', $GLOBALS['app']->Map->GetURLFor('Users', 'Profile', array('user' => $entry['username'])));
             } else {
                 $tpl->SetVariable('user_url', Jaws_XSS::filter($entry['url']));
             }
             $nickname = empty($entry['nickname']) ? $entry['name'] : $entry['nickname'];
             $email = empty($entry['user_email']) ? $entry['email'] : $entry['user_email'];
             $tpl->SetVariable('nickname', Jaws_XSS::filter($nickname));
             $tpl->SetVariable('email', Jaws_XSS::filter($email));
             $tpl->SetVariable('username', Jaws_XSS::filter($entry['username']));
             // user's avatar
             $tpl->SetVariable('avatar', $usrModel->GetAvatar($entry['avatar'], $entry['email'], 80));
             $tpl->SetVariable('insert_time', $objDate->Format($entry['createtime']));
             $tpl->SetVariable('insert_time_iso', $objDate->ToISO($entry['createtime']));
             $tpl->SetVariable('message', Jaws_String::AutoParagraph($entry['msg_txt']));
             $tpl->ParseBlock('comments/entry');
         }
     }
     // page navigation
     $this->GetPagesNavigation($tpl, 'comments', $page, $perPage, $comments_count, _t('COMMENTS_COMMENTS_COUNT', $comments_count), 'Comments', array('perpage' => $perPage, 'order' => $orderBy));
     $tpl->ParseBlock('comments');
     return $tpl->Get();
 }
示例#17
0
文件: Files.php 项目: Dulciane/jaws
 /**
  * Action for display file info
  *
  * @access  public
  * @return  string  XHTML template content with titles and contents
  */
 function FileInfo()
 {
     $id = jaws()->request->fetch('id', 'get');
     $id = Jaws_XSS::defilter($id);
     $fModel = $this->gadget->model->load('Files');
     $dModel = $this->gadget->model->load('Directory');
     $dbInfo = $fModel->DBFileInfoByIndex($id);
     if (Jaws_Error::IsError($dbInfo) || empty($dbInfo)) {
         return false;
     }
     $date = Jaws_Date::getInstance();
     $tpl = $this->gadget->template->load('FileBrowser.html');
     $tpl->SetBlock('fileinfo');
     $Info = $fModel->GetFileProperties($dbInfo['path'], $dbInfo['filename']);
     $tpl->SetVariable('icon', $Info['mini_icon']);
     $tpl->SetVariable('name', Jaws_XSS::filter($Info['filename']));
     $tpl->SetVariable('title', Jaws_XSS::filter($dbInfo['title']));
     $tpl->SetVariable('url', Jaws_XSS::filter($Info['url']));
     $tpl->SetVariable('date', $date->Format($Info['date']));
     $tpl->SetVariable('size', $Info['size']);
     $tpl->SetVariable('text', $this->gadget->ParseText($dbInfo['description']));
     $locationTree = $dModel->GetCurrentRootDir($dbInfo['path']);
     if (Jaws_Error::IsError($locationTree)) {
         return false;
     }
     $parentPath = '';
     $tpl->SetVariable('location', _t('FILEBROWSER_LOCATION'));
     foreach ($locationTree as $path => $dir) {
         if (!empty($dir) && $path[0] == '/') {
             $path = substr($path, 1);
         }
         $dbFile = $fModel->DBFileInfo($parentPath, $dir);
         if (Jaws_Error::IsError($dbFile) || empty($dbFile)) {
             $dirTitle = $dir;
         } else {
             $dirTitle = $dbFile['title'];
         }
         $parentPath = $path;
         if (empty($path)) {
             $tpl->SetVariable('root', _t('FILEBROWSER_ROOT'));
             $tpl->SetVariable('root-path', $this->gadget->urlMap('Display', array('path' => $path), false));
         } else {
             $tpl->SetBlock('fileinfo/tree');
             $tpl->SetVariable('dir-name', $dirTitle);
             $tpl->SetVariable('dir-path', $this->gadget->urlMap('Display', array('path' => $path), false));
             $tpl->ParseBlock('fileinfo/tree');
         }
     }
     $tpl->ParseBlock('fileinfo');
     return $tpl->Get();
 }
示例#18
0
 /**
  * Build a new array with filtered data
  *
  * @access  public
  * @param   string  $filterby Filter to use(postid, author, email, url, title, comment)
  * @param   string  $filter   Filter data
  * @param   string  $status   Spam status (approved, waiting, spam)
  * @param   mixed   $limit    Data limit (numeric/boolean)
  * @return  array   Filtered Comments
  */
 function GetTrackbacksDataAsArray($filterby, $filter, $status, $limit)
 {
     $trackbacks = $this->GetFilteredTrackbacks($filterby, $filter, $status, $limit);
     if (Jaws_Error::IsError($trackbacks)) {
         return array();
     }
     $date = Jaws_Date::getInstance();
     $data = array();
     foreach ($trackbacks as $row) {
         $newRow = array();
         $newRow['__KEY__'] = $row['id'];
         $newRow['blog_name'] = '<a href="' . Jaws_XSS::filter($row['url']) . '">' . Jaws_XSS::filter($row['blog_name']) . '</a>';
         $url = BASE_SCRIPT . '?gadget=Blog&action=ViewTrackback&id=' . $row['id'];
         $newRow['title'] = '<a href="' . $url . '">' . Jaws_XSS::filter($row['title']) . '</a>';
         $newRow['created'] = $date->Format($row['createtime']);
         switch ($row['status']) {
             case 'approved':
                 $newRow['status'] = _t('COMMENTS_STATUS_APPROVED');
                 break;
             case 'waiting':
                 $newRow['status'] = _t('COMMENTS_STATUS_WAITING');
                 break;
             case 'spam':
                 $newRow['status'] = _t('COMMENTS_STATUS_SPAM');
                 break;
         }
         $link =& Piwi::CreateWidget('Link', _t('GLOBAL_EDIT'), $url, STOCK_EDIT);
         $actions = $link->Get() . '&nbsp;';
         $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript: trackbackDelete('" . $row['id'] . "');", STOCK_DELETE);
         $actions .= $link->Get() . '&nbsp;';
         $newRow['actions'] = $actions;
         $data[] = $newRow;
     }
     return $data;
 }
示例#19
0
 /**
  * Displays blog trackback to be edited
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function ViewTrackback()
 {
     $this->gadget->CheckPermission('ManageTrackbacks');
     $tModel = $this->gadget->model->loadAdmin('Trackbacks');
     $pModel = $this->gadget->model->loadAdmin('Posts');
     // Fetch the trackback
     $trackback = $tModel->GetTrackback(jaws()->request->fetch('id', 'get'));
     if (Jaws_Error::IsError($trackback)) {
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ManageTrackbacks');
     }
     // Fetch the entry
     $entry = $pModel->getEntry($trackback['parent_id']);
     if (Jaws_Error::IsError($entry)) {
         Jaws_Header::Location(BASE_SCRIPT . '?gadget=Blog&action=ManageTrackbacks');
     }
     $tpl = $this->gadget->template->loadAdmin('Trackback.html');
     $tpl->SetBlock('view_trackback');
     $tpl->SetVariable('menubar', $this->MenuBar('ManageTrackbacks'));
     $date = Jaws_Date::getInstance();
     include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
     $fieldset = new Jaws_Widgets_FieldSet(_t('BLOG_VIEW_TRACKBACK'));
     $text = '<strong>' . $entry['title'] . '</strong>';
     $staticText =& Piwi::CreateWidget('StaticEntry', _t('BLOG_TRACKBACKS_CURRENTLY_UPDATING_FOR', $text));
     $blog_name =& Piwi::CreateWidget('Entry', 'blog_name', Jaws_XSS::filter($trackback['blog_name']));
     $blog_name->SetTitle(_t('BLOG_TRACKBACK_BLOGNAME'));
     $blog_name->SetStyle('width: 400px;');
     $url =& Piwi::CreateWidget('Entry', 'url', Jaws_XSS::filter($trackback['url']));
     $url->SetStyle('direction: ltr;');
     $url->SetTitle(_t('GLOBAL_URL'));
     $url->SetStyle('width: 400px;');
     $createTime =& Piwi::CreateWidget('Entry', 'create_time', $date->Format($trackback['createtime']));
     $createTime->SetTitle(_t('GLOBAL_CREATETIME'));
     $createTime->SetStyle('direction: ltr;');
     $createTime->SetEnabled(false);
     $updateTime =& Piwi::CreateWidget('Entry', 'update_time', $date->Format($trackback['updatetime']));
     $updateTime->SetTitle(_t('GLOBAL_UPDATETIME'));
     $updateTime->SetStyle('direction: ltr;');
     $updateTime->SetEnabled(false);
     $ip =& Piwi::CreateWidget('Entry', 'ip', $trackback['ip']);
     $ip->SetTitle(_t('GLOBAL_IP'));
     $ip->SetStyle('direction: ltr;');
     $ip->SetEnabled(false);
     $subject =& Piwi::CreateWidget('Entry', 'title', Jaws_XSS::filter($trackback['title']));
     $subject->SetTitle(_t('GLOBAL_TITLE'));
     $subject->SetStyle('width: 400px;');
     $excerpt =& Piwi::CreateWidget('TextArea', 'excerpt', $trackback['excerpt']);
     $excerpt->SetRows(5);
     $excerpt->SetColumns(60);
     $excerpt->SetStyle('width: 400px;');
     $excerpt->SetTitle(_t('BLOG_TRACKBACK_EXCERPT'));
     $cancelButton =& Piwi::CreateWidget('Button', 'previewButton', _t('GLOBAL_CANCEL'), STOCK_CANCEL);
     $cancelButton->AddEvent(ON_CLICK, 'history.go(-1);');
     $buttonbox =& Piwi::CreateWidget('HBox');
     $buttonbox->SetStyle(_t('GLOBAL_LANG_DIRECTION') == 'rtl' ? 'float: left;' : 'float: right;');
     $buttonbox->PackStart($cancelButton);
     $fieldset->Add($staticText);
     $fieldset->Add($blog_name);
     $fieldset->Add($url);
     $fieldset->Add($createTime);
     $fieldset->Add($updateTime);
     $fieldset->Add($ip);
     $fieldset->Add($subject);
     $fieldset->Add($excerpt);
     $tpl->SetVariable('field', $fieldset->Get());
     $tpl->SetVariable('buttonbox', $buttonbox->Get());
     $tpl->ParseBlock('view_trackback');
     return $tpl->Get();
 }
示例#20
0
 /**
  * Displays search results
  *
  * @access  public
  * @return  string  XHTML content of search results
  */
 function Results()
 {
     $tpl = $this->gadget->template->load('Results.html');
     $tpl->SetBlock('results');
     $tpl->SetVariable('title', _t('SEARCH_RESULTS'));
     $post = jaws()->request->fetch(array('gadgets', 'all', 'exact', 'least', 'exclude', 'date'), 'get');
     $page = jaws()->request->fetch('page', 'get');
     if (is_null($page) || !is_numeric($page) || $page <= 0) {
         $page = 1;
     }
     $searchable = false;
     $model = $this->gadget->model->load('Search');
     $options = $model->parseSearch($post, $searchable);
     if ($searchable) {
         $items = $model->Search($options);
     }
     $query_string = '?gadget=Search&action=Results';
     foreach ($post as $option => $value) {
         if (!empty($value)) {
             $query_string .= '&' . $option . '=' . $value;
         }
     }
     $query_string .= '&page=';
     $results_limit = (int) $this->gadget->registry->fetch('results_limit');
     if (empty($results_limit)) {
         $results_limit = 10;
     }
     if (!$searchable) {
         $tpl->SetBlock('results/notfound');
         $min_key_len = $this->gadget->registry->fetch('Search/min_key_len');
         $tpl->SetVariable('message', _t('SEARCH_STRING_TOO_SHORT', $min_key_len));
         $tpl->ParseBlock('results/notfound');
     } elseif (count($items) > 1) {
         $tpl->SetVariable('navigation', $this->GetNumberedPageNavigation($page, $results_limit, $items['_totalItems'], $query_string));
         if (count($items) > 2) {
             $tpl->SetBlock('results/subtitle');
             $tpl->SetVariable('text', _t('SEARCH_RESULTS_SUBTITLE', $items['_totalItems'], $model->implodeSearch()));
             $tpl->ParseBlock('results/subtitle');
         }
         unset($items['_totalItems']);
         $date = Jaws_Date::getInstance();
         $max_result_len = (int) $this->gadget->registry->fetch('max_result_len');
         if (empty($max_result_len)) {
             $max_result_len = 500;
         }
         $item_counter = 0;
         foreach ($items as $gadget => $result) {
             $tpl->SetBlock('results/gadget');
             $info = Jaws_Gadget::getInstance($gadget);
             $tpl->SetVariable('gadget_result', _t('SEARCH_RESULTS_IN_GADGETS', count($result), $model->implodeSearch(), $info->title));
             $tpl->ParseBlock('results/gadget');
             foreach ($result as $item) {
                 $item_counter++;
                 if ($item_counter <= ($page - 1) * $results_limit || $item_counter > $page * $results_limit) {
                     continue;
                 }
                 $tpl->SetBlock('results/item');
                 $tpl->SetVariable('title', $item['title']);
                 $tpl->SetVariable('url', $item['url']);
                 $tpl->SetVariable('target', isset($item['outer']) && $item['outer'] ? '_blank' : '_self');
                 $tpl->SetVariable('image', $item['image']);
                 if (!isset($item['parse_text']) || $item['parse_text']) {
                     $item['snippet'] = $this->gadget->ParseText($item['snippet'], $gadget);
                 }
                 if (!isset($item['strip_tags']) || $item['strip_tags']) {
                     $item['snippet'] = strip_tags($item['snippet']);
                 }
                 $item['snippet'] = Jaws_UTF8::substr($item['snippet'], 0, $max_result_len);
                 $tpl->SetVariable('snippet', $item['snippet']);
                 $tpl->SetVariable('date', $date->Format($item['date']));
                 $tpl->ParseBlock('results/item');
             }
         }
     } else {
         $tpl->SetBlock('results/notfound');
         header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 404 Not Found");
         $tpl->SetVariable('message', _t('SEARCH_NO_RESULTS', $model->implodeSearch()));
         $tpl->ParseBlock('results/notfound');
     }
     $tpl->ParseBlock('results');
     return $tpl->Get();
 }
示例#21
0
文件: Utils.php 项目: Dulciane/jaws
 /**
  * Providing download file
  *
  * @access  public
  * @param   string  $fpath      File path
  * @param   string  $fname      File name
  * @param   string  $mimetype   File mime type
  * @param   string  $inline     Inline disposition?
  * @return  bool    Returns TRUE on success or FALSE on failure
  */
 static function Download($fpath, $fname, $mimetype = '', $inline = true)
 {
     if (false === ($fhandle = @fopen($fpath, 'rb'))) {
         return false;
     }
     $fsize = @filesize($fpath);
     $fstart = 0;
     $fstop = $fsize - 1;
     if (isset($_SERVER['HTTP_RANGE']) && !empty($_SERVER['HTTP_RANGE'])) {
         $frange = explode('-', substr($_SERVER['HTTP_RANGE'], strlen('bytes=')));
         $fstart = (int) $frange[0];
         if (isset($frange[1]) && $frange[1] > 0) {
             $fstop = (int) $frange[1];
         }
         header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 206 Partial Content");
         header('Content-Range: bytes ' . $fstart . '-' . $fstop . '/' . $fsize);
     }
     // ranges unit
     header("Accept-Ranges: bytes");
     // browser must download file from server instead of cache
     header("Expires: 0");
     header("Pragma: public");
     header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
     // content mime type
     if (empty($mimetype)) {
         // force download dialog
         header("Content-Type: application/force-download");
     } else {
         header("Content-Type: {$mimetype}");
     }
     // content disposition and filename
     $disposition = $inline ? 'inline' : 'attachment';
     header("Content-Disposition: {$disposition}; filename={$fname}");
     // content length
     header("Content-Transfer-Encoding: binary");
     header('Content-Length: ' . ($fstop - $fstart + 1));
     //jump to start position
     if ($fstart > 0) {
         fseek($fhandle, $fstart);
     }
     $fposition = $fstart;
     while (!feof($fhandle) && !connection_aborted() && connection_status() == 0 && $fposition <= $fstop) {
         $fposition += 64 * 1024;
         //64 kbytes
         print fread($fhandle, 64 * 1024);
         flush();
     }
     fclose($fhandle);
     return true;
 }
示例#22
0
文件: PHPFunctions.php 项目: uda/jaws
 function http_response_code($code = null)
 {
     static $http_status_code = 200;
     if (is_null($code)) {
         return $http_status_code;
     }
     $http_status_code = (int) $code;
     switch ($http_status_code) {
         case 100:
             $text = 'Continue';
             break;
         case 101:
             $text = 'Switching Protocols';
             break;
         case 200:
             $text = 'OK';
             break;
         case 201:
             $text = 'Created';
             break;
         case 202:
             $text = 'Accepted';
             break;
         case 203:
             $text = 'Non-Authoritative Information';
             break;
         case 204:
             $text = 'No Content';
             break;
         case 205:
             $text = 'Reset Content';
             break;
         case 206:
             $text = 'Partial Content';
             break;
         case 300:
             $text = 'Multiple Choices';
             break;
         case 301:
             $text = 'Moved Permanently';
             break;
         case 302:
             $text = 'Moved Temporarily';
             break;
         case 303:
             $text = 'See Other';
             break;
         case 304:
             $text = 'Not Modified';
             break;
         case 305:
             $text = 'Use Proxy';
             break;
         case 400:
             $text = 'Bad Request';
             break;
         case 401:
             $text = 'Unauthorized';
             break;
         case 402:
             $text = 'Payment Required';
             break;
         case 403:
             $text = 'Forbidden';
             break;
         case 404:
             $text = 'Not Found';
             break;
         case 405:
             $text = 'Method Not Allowed';
             break;
         case 406:
             $text = 'Not Acceptable';
             break;
         case 407:
             $text = 'Proxy Authentication Required';
             break;
         case 408:
             $text = 'Request Time-out';
             break;
         case 409:
             $text = 'Conflict';
             break;
         case 410:
             $text = 'Gone';
             break;
         case 411:
             $text = 'Length Required';
             break;
         case 412:
             $text = 'Precondition Failed';
             break;
         case 413:
             $text = 'Request Entity Too Large';
             break;
         case 414:
             $text = 'Request-URI Too Large';
             break;
         case 415:
             $text = 'Unsupported Media Type';
             break;
         case 500:
             $text = 'Internal Server Error';
             break;
         case 501:
             $text = 'Not Implemented';
             break;
         case 502:
             $text = 'Bad Gateway';
             break;
         case 503:
             $text = 'Service Unavailable';
             break;
         case 504:
             $text = 'Gateway Time-out';
             break;
         case 505:
             $text = 'HTTP Version not supported';
             break;
         default:
             $text = 'Unknown http status code';
             break;
     }
     header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " {$http_status_code} {$text}");
     return $http_status_code;
 }
示例#23
0
 /**
  * Generates and retrieves Date Page
  * 
  * @access  public
  * @param   mixed   $year   year
  * @param   mixed   $month  month
  * @param   mixed   $day    day
  * @return  string  XHTML template content
  */
 function ViewDatePage($year = '', $month = '', $day = '')
 {
     $get = jaws()->request->fetch(array('year', 'month', 'day', 'page'), 'get');
     $page = empty($get['page']) || $get['page'] <= 0 ? 1 : $get['page'];
     if (empty($year)) {
         if (empty($get['year'])) {
             return false;
         }
         //Month, day and year
         $year = $get['year'];
         $month = (string) $get['month'];
         $day = (string) empty($month) ? '' : $get['day'];
     }
     $bgnYear = $year;
     $endYear = empty($month) ? $year + 1 : $year;
     $bgnMonth = empty($month) ? 1 : $month;
     $endMonth = empty($month) ? 1 : (empty($day) ? $month + 1 : $month);
     $bgnDay = empty($day) ? 1 : $day;
     $endDay = empty($day) ? 1 : $day + 1;
     $objDate = Jaws_Date::getInstance();
     $min_date = $objDate->ToBaseDate($bgnYear, $bgnMonth, $bgnDay);
     $max_date = $objDate->ToBaseDate($endYear, $endMonth, $endDay);
     if (!$min_date['timestamp'] || !$max_date['timestamp']) {
         return false;
     }
     $min_date = $GLOBALS['app']->UserTime2UTC($min_date['timestamp'], 'Y-m-d H:i:s');
     $max_date = $GLOBALS['app']->UserTime2UTC($max_date['timestamp'], 'Y-m-d H:i:s');
     $pModel = $this->gadget->model->load('Posts');
     $dpModel = $this->gadget->model->load('DatePosts');
     $entries = $pModel->GetEntriesByDate($page, $min_date, $max_date);
     if (!Jaws_Error::IsError($entries)) {
         $tpl = $this->gadget->template->load('DatePosts.html');
         $tpl->SetBlock('view_date');
         if (empty($month)) {
             $title = $year;
         } else {
             if (empty($day)) {
                 $title = $objDate->MonthString($month) . ' ' . $year;
             } else {
                 $title = $objDate->MonthString($month) . ' ' . $day . ', ' . $year;
             }
         }
         $this->SetTitle($title);
         $tpl->SetVariable('title', $title);
         if ($tpl->VariableExists('page_navigation')) {
             $total = $dpModel->GetDateNumberOfPages($min_date, $max_date);
             $limit = $this->gadget->registry->fetch('last_entries_limit');
             $params = array('year' => $year, 'month' => $month, 'day' => $day);
             foreach (array_keys($params, '') as $e) {
                 unset($params[$e]);
             }
             $tpl->SetVariable('page_navigation', $this->GetNumberedPageNavigation($page, $limit, $total, 'ViewDatePage', $params));
         }
         if ($tpl->VariableExists('date_navigation')) {
             $tpl->SetVariable('date_navigation', $this->GetDateNavigation($year, $month, $day));
         }
         if (!empty($entries)) {
             foreach ($entries as $entry) {
                 $this->ShowEntry($tpl, 'view_date', $entry);
             }
         } else {
             header(Jaws_XSS::filter($_SERVER['SERVER_PROTOCOL']) . " 404 Not Found");
         }
         $tpl->ParseBlock('view_date');
         return $tpl->Get();
     } else {
         return Jaws_HTTPError::Get(404);
     }
 }
示例#24
0
 /**
  * Gets some system item information
  *
  * @access  public
  * @return  array   System information
  */
 function GetSysInfo()
 {
     $apache_modules = $this->GetApacheModules();
     return array(array('title' => 'Operating System', 'value' => @php_uname()), array('title' => 'Web Server', 'value' => Jaws_XSS::filter($_SERVER['SERVER_SOFTWARE'])), array('title' => 'Server API/Loaded modules', 'value' => php_sapi_name() . (empty($apache_modules) ? '' : '/' . $apache_modules)), array('title' => 'PHP Version', 'value' => phpversion()), array('title' => 'Loaded PHP Extensions', 'value' => $this->GetLoadedExtensions()), array('title' => 'Database Driver/Version', 'value' => $this->GetDBServerInfo(0)), array('title' => 'Database Host/Port/Name/Prefix', 'value' => $this->GetDBServerInfo(1)), array('title' => 'Free/Total disk space', 'value' => JAWS_UTILS::FormatSize(@disk_free_space(JAWS_PATH)) . '/' . JAWS_UTILS::FormatSize(@disk_total_space(JAWS_PATH))), array('title' => 'Jaws Version/Codename', 'value' => JAWS_VERSION . '/' . JAWS_VERSION_CODENAME), array('title' => 'User Agent', 'value' => Jaws_XSS::filter($_SERVER['HTTP_USER_AGENT'])));
 }
示例#25
0
 /**
  * Creates and prints the administration template
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Friends()
 {
     $this->AjaxMe('script.js');
     $tpl = $this->gadget->template->loadAdmin('Friends.html');
     $tpl->SetBlock('friends');
     $tpl->SetVariable('grid', $this->Datagrid());
     ///Config properties
     if ($this->gadget->GetPermission('UpdateProperties')) {
         $config_form =& Piwi::CreateWidget('Form', BASE_SCRIPT, 'post');
         $config_form->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Friends'));
         $config_form->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'UpdateProperties'));
         include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
         $fieldset_config = new Jaws_Widgets_FieldSet(_t('GLOBAL_PROPERTIES'));
         $fieldset_config->SetDirection('vertical');
         $limitcombo =& Piwi::CreateWidget('Combo', 'limit_random');
         $limitcombo->SetTitle(_t('FRIENDS_LIMIT_RANDOM'));
         for ($i = 1; $i <= 10; $i++) {
             $limitcombo->AddOption($i, $i);
         }
         $limit = $this->gadget->registry->fetch('limit');
         if (Jaws_Error::IsError($limit) || !$limit) {
             $limit = 10;
         }
         $limitcombo->SetDefault($limit);
         $fieldset_config->Add($limitcombo);
         $config_form->Add($fieldset_config);
         $submit_config =& Piwi::CreateWidget('Button', 'saveproperties', _t('GLOBAL_UPDATE', _t('GLOBAL_PROPERTIES')), STOCK_SAVE);
         $submit_config->SetStyle(_t('GLOBAL_LANG_DIRECTION') == 'rtl' ? 'float: left;' : 'float: right;');
         $submit_config->AddEvent(ON_CLICK, 'javascript: updateProperties(this.form);');
         $config_form->Add($submit_config);
         $tpl->SetVariable('config_form', $config_form->Get());
     }
     if ($this->gadget->GetPermission('AddFriend')) {
         $friend = array();
         $friends_form =& Piwi::CreateWidget('Form', BASE_SCRIPT, 'post', '', 'friends_form');
         $friends_form->Add(Piwi::CreateWidget('HiddenEntry', 'gadget', 'Friends'));
         $friends_form->Add(Piwi::CreateWidget('HiddenEntry', 'action', 'AddFriend'));
         $friends_form->Add(Piwi::CreateWidget('HiddenEntry', 'id', ''));
         include_once JAWS_PATH . 'include/Jaws/Widgets/FieldSet.php';
         $fieldset_friebd = new Jaws_Widgets_FieldSet(_t('FRIENDS_FRIEND'));
         $fieldset_friebd->SetDirection('vertical');
         $action = jaws()->request->fetch('action', 'get');
         $action = !(is_null($action) ? $action : '');
         $friendentry =& Piwi::CreateWidget('Entry', 'friend', isset($friend['friend']) ? Jaws_XSS::filter($friend['friend']) : '');
         $friendentry->SetTitle(_t('FRIENDS_FRIEND'));
         $friendentry->SetStyle('width: 250px;');
         $fieldset_friebd->Add($friendentry);
         $urlentry =& Piwi::CreateWidget('Entry', 'url', isset($friend['url']) ? Jaws_XSS::filter($friend['url']) : 'http://');
         $urlentry->SetTitle(_t('GLOBAL_URL'));
         $urlentry->SetStyle('direction: ltr; width: 250px;');
         $fieldset_friebd->Add($urlentry);
         $buttonbox =& Piwi::CreateWidget('HBox');
         $buttonbox->SetStyle(_t('GLOBAL_LANG_DIRECTION') == 'rtl' ? 'float: left;' : 'float: right;');
         //hig style
         $submit =& Piwi::CreateWidget('Button', 'addnewfriend', _t('GLOBAL_SAVE'), STOCK_SAVE);
         $submit->AddEvent(ON_CLICK, 'javascript: submitForm(this.form);');
         $cancel =& Piwi::CreateWidget('Button', 'cancelform', _t('GLOBAL_CANCEL'), STOCK_CANCEL);
         $cancel->AddEvent(ON_CLICK, "cleanForm(this.form);");
         $buttonbox->Add($cancel);
         $buttonbox->Add($submit);
         $friends_form->Add($fieldset_friebd);
         $friends_form->Add($buttonbox);
         $tpl->SetVariable('friend_form', $friends_form->Get());
     }
     $tpl->ParseBlock('friends');
     return $tpl->Get();
 }
示例#26
0
文件: Files.php 项目: Dulciane/jaws
 /**
  * Browses for the files & directories on the server
  *
  * @access  public
  * @return  string  XHTML template content for browing file
  */
 function BrowseFile()
 {
     $path = jaws()->request->fetch('path', 'get');
     $path = empty($path) ? '/' : $path;
     $tpl = $this->gadget->template->loadAdmin('BrowseFile.html');
     $tpl->SetBlock('browse');
     $tpl->SetVariable('page-title', $this->gadget->title);
     $tpl->SetVariable('incompleteFields', _t('GLOBAL_ERROR_INCOMPLETE_FIELDS'));
     $tpl->SetVariable('confirmFileDelete', _t('FILEBROWSER_CONFIRM_DELETE_FILE'));
     $tpl->SetVariable('confirmDirDelete', _t('FILEBROWSER_CONFIRM_DELETE_DIR'));
     $dir = _t('GLOBAL_LANG_DIRECTION');
     $tpl->SetVariable('.dir', $dir == 'rtl' ? '.' . $dir : '');
     // TODO set default value for change page address to correct location after uploading file
     $extraParams = '&amp;';
     $editor = $GLOBALS['app']->GetEditor();
     if ($editor === 'TinyMCE') {
         $tpl->SetBlock('browse/script');
         $tpl->ParseBlock('browse/script');
     } elseif ($editor === 'CKEditor') {
         $getParams = jaws()->request->fetch(array('CKEditor', 'CKEditorFuncNum', 'langCode'), 'get');
         $extraParams = '&amp;CKEditor=' . $getParams['CKEditor'] . '&amp;CKEditorFuncNum=' . $getParams['CKEditorFuncNum'] . '&amp;langCode=' . $getParams['langCode'];
         $tpl->SetVariable('ckFuncIndex', $getParams['CKEditorFuncNum']);
     }
     if ($this->gadget->GetPermission('UploadFiles')) {
         $tpl->SetBlock("browse/upload_file");
         $tpl->SetVariable('path', $path);
         $tpl->SetVariable('extra_params', $extraParams);
         $tpl->SetVariable('lbl_file_upload', _t('FILEBROWSER_UPLOAD_FILE'));
         $title =& Piwi::CreateWidget('Entry', 'file_title', '');
         $title->SetStyle('width: 200px;');
         $tpl->SetVariable('lbl_file_title', _t('GLOBAL_TITLE'));
         $tpl->SetVariable('file_title', $title->Get());
         $uploadfile =& Piwi::CreateWidget('FileEntry', 'uploadfile', '');
         $uploadfile->SetID('uploadfile');
         $tpl->SetVariable('lbl_filename', _t('FILEBROWSER_FILENAME'));
         $tpl->SetVariable('uploadfile', $uploadfile->Get());
         $btnSave =& Piwi::CreateWidget('Button', 'btn_upload_file', _t('FILEBROWSER_UPLOAD_FILE'), STOCK_SAVE);
         $btnSave->AddEvent(ON_CLICK, "javascript:saveFile();");
         $tpl->SetVariable('btn_upload_file', $btnSave->Get());
         $tpl->ParseBlock("browse/upload_file");
     }
     $fModel = $this->gadget->model->load('Files');
     $dModel = $this->gadget->model->load('Directory');
     $pathArr = $dModel->GetCurrentRootDir($path);
     if (!Jaws_Error::IsError($pathArr)) {
         foreach ($pathArr as $_path => $dir) {
             if (!empty($dir) && $_path[0] == '/') {
                 $_path = substr($_path, 1);
             }
             $url = BASE_SCRIPT . '?gadget=FileBrowser&action=BrowseFile&path=' . $_path;
             if (empty($_path)) {
                 $link =& Piwi::CreateWidget('Link', _t('FILEBROWSER_ROOT'), $url . '/' . $extraParams);
                 $tpl->SetVariable('root', $link->Get());
             } else {
                 if ($_path == $path) {
                     $link = Piwi::CreateWidget('StaticEntry', $dir);
                 } else {
                     $link = Piwi::CreateWidget('Link', $dir, $url);
                 }
                 $tpl->SetBlock('browse/path');
                 $tpl->SetVariable('directory', $link->Get());
                 $tpl->ParseBlock('browse/path');
             }
         }
     }
     $tpl->SetVariable('lbl_location', _t('FILEBROWSER_LOCATION'));
     $tpl->SetVariable('lbl_file_name', _t('FILEBROWSER_FILENAME'));
     $tpl->SetVariable('lbl_file_size', _t('FILEBROWSER_SIZE'));
     $tpl->SetVariable('lbl_action', _t('GLOBAL_ACTIONS'));
     $files = $dModel->ReadDir($path);
     if (!Jaws_Error::IsError($files)) {
         foreach ($files as $file) {
             $tpl->SetBlock('browse/file');
             // Icon
             $icon =& Piwi::CreateWidget('Image', $file['mini_icon']);
             $icon->SetID('');
             $tpl->SetVariable('icon', $icon->Get());
             // Directory / File
             if ($file['is_dir']) {
                 $url = BASE_SCRIPT . '?gadget=FileBrowser&action=BrowseFile&path=' . $file['relative'] . $extraParams;
                 $link =& Piwi::CreateWidget('Link', $file['filename'], $url);
                 $link->SetID('');
                 $link->SetTitle($file['title']);
                 $tpl->SetVariable('file_name', $link->Get());
                 if ($this->gadget->GetPermission('ManageDirectories')) {
                     $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript:deleteDir('" . $file['filename'] . "');", STOCK_DELETE);
                     $tpl->SetVariable('action', $link->Get());
                 }
             } else {
                 if (empty($file['id'])) {
                     $furl = Jaws_XSS::filter($file['url']);
                 } else {
                     $fid = empty($file['fast_url']) ? $file['id'] : Jaws_XSS::filter($file['fast_url']);
                     $furl = $this->gadget->urlMap('Download', array('id' => $fid));
                 }
                 $link =& Piwi::CreateWidget('Link', $file['filename'], "javascript:selectFile('{$furl}', '{$file['title']}', '{$editor}')");
                 $tpl->SetVariable('file_name', $link->Get());
                 if ($this->gadget->GetPermission('ManageFiles')) {
                     $link =& Piwi::CreateWidget('Link', _t('GLOBAL_DELETE'), "javascript:deleteFile('" . $file['filename'] . "');", STOCK_DELETE);
                     $tpl->SetVariable('action', $link->Get());
                 }
             }
             // File Size
             $tpl->SetVariable('file_size', $file['size']);
             $tpl->ParseBlock('browse/file');
         }
     }
     $tpl->ParseBlock('browse');
     return $tpl->Get();
 }
示例#27
0
文件: HTTPError.php 项目: uda/jaws
 /**
  * Get HTTP status reponse
  *
  * @access  public
  * @param   int     $code       Status code
  * @param   string  $title      Reponse page title
  * @param   string  $message    Response message
  * @return  string  HTML template content
  */
 static function Get($code, $title = null, $message = null)
 {
     header('Content-Type: text/html; charset=utf-8');
     header('Cache-Control: no-cache, must-revalidate');
     header('Pragma: no-cache');
     // Let everyone know a HTTP error has been happened
     $result = $GLOBALS['app']->Listener->Shout('HTTPError', 'HTTPError', $code, 'UrlMapper');
     if (!Jaws_Error::IsError($result) && !empty($result)) {
         $code = empty($result['code']) ? $code : $result['code'];
     }
     switch ($code) {
         case 401:
             $realm = $GLOBALS['app']->Registry->fetch('realm', 'Settings');
             jaws()->http_response_code(401);
             // using invalid authentication type for avoid popup login box
             header('WWW-Authenticate: LoginBox realm="' . $realm . '"');
             $urlLogin = $GLOBALS['app']->Map->GetURLFor('Users', 'LoginBox', array('referrer' => bin2hex(Jaws_Utils::getRequestURL(true))));
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_401') : $title;
             $message = empty($message) ? _t('GLOBAL_HTTP_ERROR_CONTENT_401', $urlLogin) : $message;
             break;
         case 403:
             jaws()->http_response_code(403);
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_403') : $title;
             $message = empty($message) ? _t('GLOBAL_HTTP_ERROR_CONTENT_403') : $message;
             break;
         case 404:
             $uri = Jaws_XSS::filter(Jaws_Utils::getRequestURL(false));
             if (empty($message)) {
                 $message = _t('GLOBAL_HTTP_ERROR_CONTENT_404', $uri);
             }
             jaws()->http_response_code(404);
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_404') : $title;
             break;
         case 410:
             jaws()->http_response_code(410);
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_410') : $title;
             $message = empty($message) ? _t('GLOBAL_HTTP_ERROR_CONTENT_410') : $message;
             break;
         case 500:
             jaws()->http_response_code(500);
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_500') : $title;
             $message = empty($message) ? _t('GLOBAL_HTTP_ERROR_CONTENT_500') : $message;
             break;
         case 503:
             jaws()->http_response_code(503);
             $title = empty($title) ? _t('GLOBAL_HTTP_ERROR_TITLE_503') : $title;
             $message = empty($message) ? _t('GLOBAL_HTTP_ERROR_CONTENT_503') : $message;
             break;
         default:
             $title = empty($title) ? _t("GLOBAL_HTTP_ERROR_TITLE_{$code}") : $title;
             $message = empty($message) ? _t("GLOBAL_HTTP_ERROR_CONTENT_{$code}") : $message;
     }
     // if current theme has a error code html file, return it, if not return the messages.
     $theme = $GLOBALS['app']->GetTheme();
     $site_name = $GLOBALS['app']->Registry->fetch('site_name', 'Settings');
     if (file_exists($theme['path'] . "{$code}.html")) {
         $tpl = new Jaws_Template();
         $tpl->Load("{$code}.html", $theme['path']);
         $tpl->SetBlock($code);
         //set global site config
         $direction = _t('GLOBAL_LANG_DIRECTION');
         $dir = $direction == 'rtl' ? '.' . $direction : '';
         $brow = $GLOBALS['app']->GetBrowserFlag();
         $brow = empty($brow) ? '' : '.' . $brow;
         $tpl->SetVariable('.dir', $dir);
         $tpl->SetVariable('.browser', $brow);
         $tpl->SetVariable('site-name', $site_name);
         $tpl->SetVariable('site-title', $site_name);
         $tpl->SetVariable('site-slogan', $GLOBALS['app']->Registry->fetch('site_slogan', 'Settings'));
         $tpl->SetVariable('site-author', $GLOBALS['app']->Registry->fetch('site_author', 'Settings'));
         $tpl->SetVariable('site-copyright', $GLOBALS['app']->Registry->fetch('copyright', 'Settings'));
         $tpl->SetVariable('site-description', $GLOBALS['app']->Registry->fetch('site_description', 'Settings'));
         $tpl->SetVariable('title', $title);
         $tpl->SetVariable('content', $message);
         $tpl->ParseBlock($code);
         return $tpl->Get();
     }
     return "<div class=\"gadget_header\"><div class=\"gadget_title\"><h3>{$title}</h3></div></div>" . "<div class=\"gadget_container\"><div class=\"content\">{$message}</div></div>";
 }
示例#28
0
文件: Jaws.php 项目: juniortux/jaws
 /**
  * Is actual agent a robot?
  *
  * @access  private
  * @return  bool    True or False
  */
 function IsAgentRobot()
 {
     static $_IsRobot;
     if (!isset($_IsRobot)) {
         $_IsRobot = false;
         $robots = explode(',', $this->Registry->fetch('robots', 'Settings'));
         $robots = array_map('strtolower', $robots);
         $uagent = strtolower(Jaws_XSS::filter($_SERVER['HTTP_USER_AGENT']));
         $ipaddr = $_SERVER['REMOTE_ADDR'];
         foreach ($robots as $robot) {
             if (!empty($robot) && ($ipaddr == $robot || strpos($uagent, $robot) !== false)) {
                 $_IsRobot = true;
                 break;
             }
         }
     }
     return $_IsRobot;
 }