Esempio n. 1
0
 /**
  * Constructor
  *
  * @param Blog This may be NULL only when must select comments from all Blog. Use NULL carefully, because it may generate very long queries!
  * @param integer|NULL Limit
  * @param string name of cache to be used
  * @param string prefix to differentiate page/order params when multiple Results appear one same page
  * @param string Name to be used when saving the filterset (leave empty to use default for collection)
  */
 function CommentList2($Blog, $limit = 1000, $cache_name = 'CommentCache', $param_prefix = '', $filterset_name = '')
 {
     global $Settings;
     // Call parent constructor:
     parent::DataObjectList2(get_Cache($cache_name), $limit, $param_prefix, NULL);
     // Set Blog. Note: It can be NULL on ?disp=usercomments
     $this->Blog = $Blog;
     // The SQL Query object:
     $this->CommentQuery = new CommentQuery();
     $this->CommentQuery->Blog = $this->Blog;
     // The Item filter SQL Query object:
     $this->ItemQuery = new ItemQuery('T_items__item', 'post_', 'post_ID');
     // Blog can be NULL on ?disp=usercomments, in this case ItemQuery blog must be set to 0, which means all blog
     $this->ItemQuery->blog = empty($this->Blog) ? 0 : $this->Blog->ID;
     if (!empty($filterset_name)) {
         // Set the filterset_name with the filterset_name param
         $this->filterset_name = 'CommentList_filters_' . $filterset_name;
     } else {
         // Set a generic filterset_name
         $this->filterset_name = 'CommentList_filters_coll' . (!is_null($this->Blog) ? $this->Blog->ID : '0');
     }
     $this->page_param = $param_prefix . 'paged';
     // Initialize the default filter set:
     $this->set_default_filters(array('filter_preset' => NULL, 'author_IDs' => NULL, 'author' => NULL, 'author_email' => NULL, 'author_url' => NULL, 'url_match' => '=', 'include_emptyurl' => NULL, 'author_IP' => NULL, 'post_ID' => NULL, 'comment_ID' => NULL, 'comment_ID_list' => NULL, 'rating_toshow' => NULL, 'rating_turn' => 'above', 'rating_limit' => 1, 'keywords' => NULL, 'phrase' => 'AND', 'exact' => 0, 'statuses' => NULL, 'expiry_statuses' => array('active'), 'types' => array('comment', 'trackback', 'pingback'), 'orderby' => 'date', 'order' => !is_null($this->Blog) ? $this->Blog->get_setting('comments_orderdir') : 'DESC', 'comments' => $this->limit, 'page' => 1, 'featured' => NULL, 'timestamp_min' => NULL, 'timestamp_max' => NULL, 'threaded_comments' => false, 'user_perm' => NULL));
 }
Esempio n. 2
0
 /**
  * Get an array of ALL available Fileroots (not just the cached ones).
  *
  * @todo fp> it would probably make sense to refactor this as the constructor for the file roots
  * and initialize the whole cache at construction time
  *
  * @static
  *
  * @return array of FileRoots (key being the FileRoot's ID)
  */
 function get_available_FileRoots()
 {
     global $current_User;
     $r = array();
     // The user's blog (if available) is the default/first one:
     $user_FileRoot =& $this->get_by_type_and_ID('user', $current_User->ID, true);
     if ($user_FileRoot) {
         // We got a user media dir:
         $r[$user_FileRoot->ID] =& $user_FileRoot;
     }
     // blog/collection media dirs:
     $BlogCache =& get_Cache('BlogCache');
     $bloglist = $BlogCache->load_user_blogs('blog_media_browse', $current_User->ID);
     foreach ($bloglist as $blog_ID) {
         if ($Root =& $this->get_by_type_and_ID('collection', $blog_ID, true)) {
             $r[$Root->ID] =& $Root;
         }
     }
     // skins root:
     $skins_FileRoot =& $this->get_by_type_and_ID('skins', 0, false);
     if ($skins_FileRoot) {
         // We got a skins dir:
         $r[$skins_FileRoot->ID] =& $skins_FileRoot;
     }
     return $r;
 }
Esempio n. 3
0
/**
 * Helper function for "Requested URI" column
 * @param integer Blog ID
 * @param string Requested URI
 * @return string
 */
function stats_format_req_URI($hit_blog_ID, $hit_uri, $max_len = 40)
{
    if (!empty($hit_blog_ID)) {
        $BlogCache =& get_Cache('BlogCache');
        $tmp_Blog =& $BlogCache->get_by_ID($hit_blog_ID);
        $full_url = $tmp_Blog->get('baseurlroot') . $hit_uri;
    } else {
        $full_url = $hit_uri;
    }
    if (strlen($hit_uri) > $max_len) {
        $hit_uri = '...' . substr($hit_uri, -$max_len);
    }
    return '<a href="' . $full_url . '">' . $hit_uri . '</a>';
}
Esempio n. 4
0
 /**
  * Constructor
  *
  * @param integer|NULL Limit
  * @param string prefix to differentiate page/order params when multiple Results appear one same page
  * @param string Name to be used when saving the filterset (leave empty to use default)
  * @param array Query params:
  *                    'join_group'   => true,
  *                    'join_session' => false,
  *                    'join_country' => true,
  *                    'join_city'    => true,
  *                    'keywords_fields'     - Fields of users table to search by keywords
  *                    'where_status_closed' - FALSE - to don't display closed users
  *                    'where_org_ID' - ID of organization
  */
 function UserList($filterset_name = '', $limit = 20, $param_prefix = 'users_', $query_params = array())
 {
     // Call parent constructor:
     parent::DataObjectList2(get_Cache('UserCache'), $limit, $param_prefix, NULL);
     // Init query params, @see $this->query_init()
     $this->query_params = $query_params;
     if (!empty($filterset_name)) {
         // Set the filterset_name with the filterset_name param
         $this->filterset_name = 'UserList_filters_' . $filterset_name;
     } else {
         // Set a generic filterset_name
         $this->filterset_name = 'UserList_filters';
     }
     $this->order_param = 'results_' . $param_prefix . 'order';
     $this->page_param = $param_prefix . 'paged';
     // Initialize the default filter set:
     $this->set_default_filters(array('filter_preset' => NULL, 'country' => NULL, 'region' => NULL, 'subregion' => NULL, 'city' => NULL, 'membersonly' => false, 'keywords' => NULL, 'gender' => NULL, 'status_activated' => NULL, 'account_status' => NULL, 'reported' => NULL, 'custom_sender_email' => NULL, 'custom_sender_name' => NULL, 'group' => -1, 'age_min' => NULL, 'age_max' => NULL, 'userfields' => array(), 'order' => '-D', 'users' => array(), 'level_min' => NULL, 'level_max' => NULL, 'org' => NULL));
 }
Esempio n. 5
0
 /**
  * Constructor
  *
  * @param table Database row
  */
 function Link($db_row = NULL)
 {
     // Call parent constructor:
     parent::DataObject('T_links', 'link_', 'link_ID', 'datecreated', 'datemodified', 'creator_user_ID', 'lastedit_user_ID');
     if ($db_row != NULL) {
         $this->ID = $db_row->link_ID;
         $this->ltype_ID = $db_row->link_ltype_ID;
         // source of link:
         $ItemCache =& get_Cache('ItemCache');
         $this->Item =& $ItemCache->get_by_ID($db_row->link_itm_ID);
         $FileCache =& get_Cache('FileCache');
         // fp> do not halt on error. For some reason (ahem bug) a file can disappear and if we fail here then we won't be
         // able to delete the link
         $this->File =& $FileCache->get_by_ID($db_row->link_file_ID, false, false);
     } else {
         // New object:
     }
 }
 /**
  * Constructor
  *
  * @todo  add param for saved session filter set
  *
  * @param Blog
  * @param mixed Default filter set: Do not show posts before this timestamp, can be 'now'
  * @param mixed Default filter set: Do not show posts after this timestamp, can be 'now'
  * @param integer|NULL Limit
  * @param string name of cache to be used (for table prefix info)
  * @param string prefix to differentiate page/order params when multiple Results appear one same page
  * @param array restrictions for itemlist (position, contact, firm, ...) key: restriction name, value: ID of the restriction
  */
 function ItemListLight(&$Blog, $timestamp_min = NULL, $timestamp_max = NULL, $limit = 20, $cache_name = 'ItemCacheLight', $param_prefix = '', $filterset_name = '')
 {
     global $Settings, $posttypes_specialtypes;
     // Call parent constructor:
     parent::DataObjectList2(get_Cache($cache_name), $limit, $param_prefix, NULL);
     // asimo> The ItemQuery init was moved into the query_init() method
     // The SQL Query object:
     // $this->ItemQuery = new ItemQuery( $this->Cache->dbtablename, $this->Cache->dbprefix, $this->Cache->dbIDname );
     $this->Blog =& $Blog;
     if (!empty($filterset_name)) {
         // Set the filterset_name with the filterset_name param
         $this->filterset_name = 'ItemList_filters_' . $filterset_name;
     } else {
         // Set a generic filterset_name
         $this->filterset_name = 'ItemList_filters_coll' . (!is_null($this->Blog) ? $this->Blog->ID : '0');
     }
     $this->page_param = $param_prefix . 'paged';
     // Initialize the default filter set:
     $this->set_default_filters(array('filter_preset' => NULL, 'ts_min' => $timestamp_min, 'ts_max' => $timestamp_max, 'ts_created_max' => NULL, 'coll_IDs' => NULL, 'cat_array' => array(), 'cat_modifier' => NULL, 'cat_focus' => 'wide', 'tags' => NULL, 'authors' => NULL, 'authors_login' => NULL, 'assignees' => NULL, 'assignees_login' => NULL, 'author_assignee' => NULL, 'lc' => 'all', 'keywords' => NULL, 'keyword_scope' => 'title,content', 'phrase' => 'AND', 'exact' => 0, 'post_ID' => NULL, 'post_ID_list' => NULL, 'post_title' => NULL, 'ymdhms' => NULL, 'week' => NULL, 'ymdhms_min' => NULL, 'ymdhms_max' => NULL, 'statuses' => NULL, 'types' => '-' . implode(',', $posttypes_specialtypes), 'visibility_array' => get_inskin_statuses(is_null($this->Blog) ? NULL : $this->Blog->ID, 'post'), 'orderby' => !is_null($this->Blog) ? $this->Blog->get_setting('orderby') : 'datestart', 'order' => !is_null($this->Blog) ? $this->Blog->get_setting('orderdir') : 'DESC', 'unit' => !is_null($this->Blog) ? $this->Blog->get_setting('what_to_show') : 'posts', 'posts' => $this->limit, 'page' => 1, 'featured' => NULL));
 }
Esempio n. 7
0
    $login = $_POST['login'];
    $pass = $_POST['pwd'];
    unset($_POST['pwd']);
    // password will be hashed below
} elseif (isset($_GET['login'])) {
    // Trying to log in with a GET; we might only provide a user here.
    $login = $_GET['login'];
    $pass = isset($_GET['pwd']) ? $_GET['pwd'] : '';
    unset($_GET['pwd']);
    // password will be hashed below
}
$Debuglog->add('login: '******'login');
$Debuglog->add('pass: '******'' : 'not') . ' empty', 'login');
// either 'login' (normal) or 'redirect_to_backoffice' may be set here. This also helps to display the login form again, if either login or pass were empty.
$login_action = param_arrayindex('login_action');
$UserCache =& get_Cache('UserCache');
if (!empty($login_action) || !empty($login) && !empty($pass)) {
    // User is trying to login right now
    $Debuglog->add('User is trying to log in.', 'login');
    header_nocache();
    // Note: login and password cannot include '<' !
    $login = strtolower(strip_tags(remove_magic_quotes($login)));
    $pass = strip_tags(remove_magic_quotes($pass));
    $pass_md5 = md5($pass);
    /*
     * Handle javascript-hashed password:
     * If possible, the login form will hash the entered password with a salt that changes everytime.
     */
    param('pwd_salt', 'string', '');
    // just for comparison with the one from Session
    $pwd_salt_sess = $Session->get('core.pwd_salt');
Esempio n. 8
0
/**
 * Template tag: Link to an item identified by its url title / slug / name
 *
 * Note: this will query the database. Thus, in most situations it will make more sense
 * to use a hardcoded link. This tag can be useful for prototyping location independant
 * sites.
 */
function item_ink_by_urltitle($params = array())
{
    // Make sure we are not missing any param:
    $params = array_merge(array('urltitle' => NULL, 'before' => ' ', 'after' => ' ', 'text' => '#'), $params);
    /**
     * @var ItemCache
     */
    $ItemCache =& get_Cache('ItemCache');
    /**
     * @var Item
     */
    $Item =& $ItemCache->get_by_urltitle($params['urltitle'], false);
    if (empty($Item)) {
        return false;
    }
    $Item->permanent_link($params);
}
Esempio n. 9
0
}
if (!empty($_GET['__mode'])) {
    // some MT extension (AFAIK), that we do not support
    return;
}
if (empty($tb_id)) {
    trackback_response(1, 'No trackback post ID given.');
    // exits
}
if (empty($url)) {
    trackback_response(1, 'No url to your permanent entry given.');
    // exits
}
@header('Content-Type: text/xml');
$comment_post_ID = $tb_id;
$ItemCache =& get_Cache('ItemCache');
$commented_Item =& $ItemCache->get_by_ID($comment_post_ID);
if (!($Blog =& $commented_Item->get_Blog())) {
    trackback_response(1, 'Sorry, could not get the post\'s weblog.');
    // exits
}
if (!$Blog->get('allowtrackbacks')) {
    trackback_response(1, 'Sorry, this weblog does not allow you to trackback its posts.');
    // exits
}
// Commented out again, because it's comment specific: if( ! $commented_Item->can_comment( NULL ) )
// "BeforeTrackbackInsert" should be hooked instead!
if ($commented_Item->comment_status != 'open') {
    trackback_response(1, 'Sorry, this item does not accept trackbacks.');
    // exits
}
Esempio n. 10
0
 /**
  * Constructor
  *
  * Will fail if non existent User or Blog is requested.
  * But specific access permissions on (threfore existence of) this User or Blog should have been tested before anyway.
  *
  * @param string Root type: 'user', 'group' or 'collection'
  * @param integer ID of the user, the group or the collection the file belongs to...
  * @param boolean Create the directory, if it does not exist yet?
  */
 function FileRoot($root_type, $root_in_type_ID, $create = true)
 {
     // Store type:
     $this->type = $root_type;
     // Store ID in type:
     $this->in_type_ID = $root_in_type_ID;
     // Generate unique ID:
     $this->ID = FileRoot::gen_ID($root_type, $root_in_type_ID);
     switch ($root_type) {
         case 'user':
             $UserCache =& get_Cache('UserCache');
             $User =& $UserCache->get_by_ID($root_in_type_ID);
             $this->name = $User->get('preferredname');
             //.' ('. /* TRANS: short for "user" */ T_('u').')';
             $this->ads_path = $User->get_media_dir($create);
             $this->ads_url = $User->get_media_url();
             return;
         case 'collection':
             $BlogCache =& get_Cache('BlogCache');
             /**
              * @var Blog
              */
             $Blog =& $BlogCache->get_by_ID($root_in_type_ID);
             $this->name = $Blog->get('shortname');
             //.' ('. /* TRANS: short for "blog" */ T_('b').')';
             $this->ads_path = $Blog->get_media_dir($create);
             $this->ads_url = $Blog->get_media_url();
             return;
         case 'skins':
             // fp> some stuff here should go out of here... but I don't know where to put it yet. I'll see after the Skin refactoring.
             global $Settings, $Debuglog;
             /**
              * @var User
              */
             global $current_User;
             if (!$Settings->get('fm_enable_roots_skins')) {
                 // Skins root is disabled:
                 $Debuglog->add('Attempt to access skins dir, but this feature is globally disabled', 'files');
             } elseif (!$current_User->check_perm('templates')) {
                 // No perm to access templates:
                 $Debuglog->add('Attempt to access skins dir, but no permission', 'files');
             } else {
                 global $skins_path, $skins_url;
                 $this->name = T_('Skins');
                 $this->ads_path = $skins_path;
                 $this->ads_url = $skins_url;
             }
             return;
     }
     debug_die("Root_type={$root_type} not supported");
 }
Esempio n. 11
0
 * @todo Currently if you change the name of a blog it gets not reflected in the blog list buttons!
 *
 * @version $Id: coll_settings.ctrl.php,v 1.11 2008/01/21 09:35:26 fplanque Exp $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
param_action('edit');
param('tab', 'string', 'general', true);
// Check permissions on requested blog and autoselect an appropriate blog if necessary.
// This will prevent a fat error when switching tabs and you have restricted perms on blog properties.
if ($selected = autoselect_blog('blog_properties', 'edit')) {
    // We have a blog to work on:
    if (set_working_blog($selected)) {
        // Selected a new blog:
        $BlogCache =& get_Cache('BlogCache');
        $Blog =& $BlogCache->get_by_ID($blog);
    }
    /**
     * @var Blog
     */
    $edited_Blog =& $Blog;
} else {
    // We could not find a blog we have edit perms on...
    // Note: we may still have permission to edit categories!!
    // redirect to blog list:
    header_redirect('?ctrl=collections');
    // EXITED:
    $Messages->add(T_('Sorry, you have no permission to edit blog properties.'), 'error');
    $action = 'nil';
    $tab = '';
Esempio n. 12
0
/**
 * Check permissions on a given blog (by ID) and autoselect an appropriate blog
 * if necessary.
 *
 * For use in admin
 *
 * NOTE: we no longer try to set $Blog inside of the function because later global use cannot be safely guaranteed in PHP4.
 *
 * @param string Permission name that must be given to the {@link $current_User} object.
 * @param string Permission level that must be given to the {@link $current_User} object.
 * @return integer new selected blog
 */
function autoselect_blog($permname, $permlevel = 'any')
{
    global $blog;
    /**
     * @var User
     */
    global $current_User;
    $autoselected_blog = $blog;
    if ($autoselected_blog) {
        // a blog is already selected
        if (!$current_User->check_perm($permname, $permlevel, false, $autoselected_blog)) {
            // invalid blog
            // echo 'current blog was invalid';
            $autoselected_blog = 0;
        }
    }
    if (!$autoselected_blog) {
        // No blog is selected so far (or selection was invalid)...
        // Let's try to find another one:
        /**
         * @var BlogCache
         */
        $BlogCache =& get_Cache('BlogCache');
        // Get first suitable blog
        $blog_array = $BlogCache->load_user_blogs($permname, $permlevel, $current_User->ID, 'ID', 1);
        if (!empty($blog_array)) {
            $autoselected_blog = $blog_array[0];
        }
    }
    return $autoselected_blog;
}
Esempio n. 13
0
 /**
  * Constructor
  *
  * @todo  add param for saved session filter set
  *
  * @param Blog
  * @param mixed Default filter set: Do not show posts before this timestamp, can be 'now'
  * @param mixed Default filter set: Do not show posts after this timestamp, can be 'now'
  * @param integer|NULL Limit
  * @param string name of cache to be used (for table prefix info)
  * @param string prefix to differentiate page/order params when multiple Results appear one same page
  * @param array restrictions for itemlist (position, contact, firm, ...) key: restriction name, value: ID of the restriction
  */
 function ItemListLight(&$Blog, $timestamp_min = NULL, $timestamp_max = NULL, $limit = 20, $cache_name = 'ItemCacheLight', $param_prefix = '', $filterset_name = '', $restrict_to = array())
 {
     global $Settings;
     // Call parent constructor:
     parent::DataObjectList2(get_Cache($cache_name), $limit, $param_prefix, NULL);
     // The SQL Query object:
     $this->ItemQuery =& new ItemQuery($this->Cache->dbtablename, $this->Cache->dbprefix, $this->Cache->dbIDname);
     $this->Blog =& $Blog;
     if (!empty($filterset_name)) {
         // Set the filterset_name with the filterset_name param
         $this->filterset_name = 'ItemList_filters_' . $filterset_name;
     } else {
         // Set a generic filterset_name
         $this->filterset_name = 'ItemList_filters_coll' . $this->Blog->ID;
     }
     $this->page_param = $param_prefix . 'paged';
     $this->restrict_to = $restrict_to;
     // Initialize the default filter set:
     $this->set_default_filters(array('filter_preset' => NULL, 'ts_min' => $timestamp_min, 'ts_max' => $timestamp_max, 'ts_created_max' => NULL, 'cat_array' => array(), 'cat_modifier' => NULL, 'cat_focus' => 'wide', 'tags' => NULL, 'authors' => NULL, 'assignees' => NULL, 'author_assignee' => NULL, 'lc' => 'all', 'keywords' => NULL, 'phrase' => 'AND', 'exact' => 0, 'post_ID' => NULL, 'post_ID_list' => NULL, 'post_title' => NULL, 'ymdhms' => NULL, 'week' => NULL, 'ymdhms_min' => NULL, 'ymdhms_max' => NULL, 'statuses' => NULL, 'types' => '-1000', 'visibility_array' => array('published', 'protected', 'private'), 'orderby' => $this->Blog->get_setting('orderby'), 'order' => $this->Blog->get_setting('orderdir'), 'unit' => $this->Blog->get_setting('what_to_show'), 'posts' => $this->limit, 'page' => 1));
 }
Esempio n. 14
0
 function get_oauth_info($params = array())
 {
     $params = array_merge(array('type' => '', 'ID' => '', 'blog_ID' => '', 'user_ID' => ''), $params);
     if ($params['type'] == 'blog') {
         // Get from CollSettings
         $blog_ID = $params['ID'];
         $try_user = false;
     } elseif ($params['type'] == 'user') {
         // Get from UserSettings
         $user_ID = $params['ID'];
         $try_user = true;
     } else {
         // Get from any
         $blog_ID = $params['blog_ID'];
         $user_ID = $params['user_ID'];
         $try_user = true;
     }
     $r = array();
     if (!empty($blog_ID)) {
         // CollSettings
         $BlogCache =& get_Cache('BlogCache');
         $Blog =& $BlogCache->get_by_ID($blog_ID, false, false);
         if (!empty($Blog)) {
             $r['token'] = $this->get_coll_setting('twitter_token', $Blog);
             if (!empty($r['token'])) {
                 // There is already a linked twitter user in this Blog, get token secret
                 $r['token_secret'] = $this->get_coll_setting('twitter_secret', $Blog);
                 $r['contact'] = $this->get_coll_setting('twitter_contact', $Blog);
                 $r['msg_format'] = $this->get_coll_setting('twitter_msg_format', $Blog);
                 $try_user = false;
                 // Do not overwrite
             }
         }
     }
     if ($try_user && !empty($user_ID)) {
         // UserSettings
         $r['token'] = $this->UserSettings->get('twitter_token', $user_ID);
         if (!empty($r['token'])) {
             // There is already a linked twitter user in this User, get token secret
             $r['token_secret'] = $this->UserSettings->get('twitter_secret', $user_ID);
             $r['contact'] = $this->UserSettings->get('twitter_contact', $user_ID);
             $r['msg_format'] = $this->UserSettings->get('twitter_msg_format', $user_ID);
         }
     }
     return $r;
 }
Esempio n. 15
0
 /**
  * Get an array of registered users and guests.
  *
  * @return array containing number of registered users and guests ('registered' and 'guests')
  */
 function init()
 {
     if ($this->_initialized) {
         return true;
     }
     global $DB, $localtimenow, $timeout_online_user;
     $this->_count_guests = 0;
     $this->_registered_Users = array();
     $timeout_YMD = date('Y-m-d H:i:s', $localtimenow - $timeout_online_user);
     $UserCache =& get_Cache('UserCache');
     // We get all sessions that have been seen in $timeout_YMD and that have a session key.
     // NOTE: we do not use DISTINCT here, because guest users are all "NULL".
     foreach ($DB->get_results("\r\n\t\t\tSELECT sess_user_ID\r\n\t\t\t  FROM T_sessions\r\n\t\t\t WHERE sess_lastseen > '" . $timeout_YMD . "'\r\n\t\t\t   AND sess_key IS NOT NULL", OBJECT, 'Sessions: get list of relevant users.') as $row) {
         if (!empty($row->sess_user_ID) && ($User =& $UserCache->get_by_ID($row->sess_user_ID))) {
             // assign by ID so that each user is only counted once (he could use multiple user agents at the same time)
             $this->_registered_Users[$User->ID] =& $User;
             if (!$User->showonline) {
                 $this->_count_guests++;
             }
         } else {
             $this->_count_guests++;
         }
     }
     $this->_initialized = true;
 }
Esempio n. 16
0
/**
 * Template tag. Initializes internal states for the most common skin displays.
 *
 * For more specific skins, this function should not be called and
 * equivalent code should be customized within the skin.
 *
 * @param string What are we going to display. Most of the time the global $disp should be passed.
 */
function skin_init($disp)
{
    /**
     * @var Blog
     */
    global $Blog;
    global $robots_index;
    global $seo_page_type;
    global $redir, $ReqHost, $ReqURI;
    global $Chapter;
    global $Debuglog;
    /**
     * @var ItemList2
     */
    global $MainList;
    /**
     * This will give more detail when $disp == 'posts'; otherwise it will have the same content as $disp
     * @var string
     */
    global $disp_detail;
    $disp_detail = $disp;
    $Debuglog->add('skin_init: ' . $disp, 'skin');
    // This is the main template; it may be used to display very different things.
    // Do inits depending on current $disp:
    switch ($disp) {
        case 'posts':
        case 'single':
        case 'page':
        case 'feedback-popup':
            // We need to load posts for this display:
            // Note: even if we request the same post as $Item above, the following will do more restrictions (dates, etc.)
            // Init the MainList object:
            init_MainList($Blog->get_setting('posts_per_page'));
            break;
    }
    // SEO stuff:
    $seo_page_type = NULL;
    switch ($disp) {
        // CONTENT PAGES:
        case 'single':
            $seo_page_type = 'Single post page';
            break;
        case 'page':
            $seo_page_type = '"Page" page';
            break;
        case 'posts':
            // Get list of active filters:
            $active_filters = $MainList->get_active_filters();
            if (!empty($active_filters)) {
                // The current page is being filtered...
                if (array_diff($active_filters, array('page')) == array()) {
                    // This is just a follow "paged" page
                    $disp_detail = 'posts-next';
                    $seo_page_type = 'Next page';
                    if ($Blog->get_setting('paged_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                } elseif (array_diff($active_filters, array('cat_array', 'cat_modifier', 'cat_focus', 'posts', 'page')) == array()) {
                    // This is a category page
                    $disp_detail = 'posts-cat';
                    $seo_page_type = 'Category page';
                    if ($Blog->get_setting('chapter_noindex')) {
                        // We prefer robots not to index category pages:
                        $robots_index = false;
                    }
                    global $cat, $catsel;
                    if (empty($catsel) && preg_match('¤[0-9]+¤', $cat)) {
                        // We are on a single cat page:
                        // NOTE: we must have selected EXACTLY ONE CATEGORY through the cat parameter
                        // BUT: - this can resolved to including children
                        //      - selecting exactly one cat through catsel[] is NOT OK since not equivalent (will exclude children)
                        // echo 'SINGLE CAT PAGE';
                        if ($Blog->get_setting('canonical_cat_urls') && $redir == 'yes') {
                            // Check if the URL was canonical:
                            if (!isset($Chapter)) {
                                $ChapterCache =& get_Cache('ChapterCache');
                                /**
                                 * @var Chapter
                                 */
                                $Chapter =& $ChapterCache->get_by_ID($MainList->filters['cat_array'][0], false);
                            }
                            $canoncical_url = $Chapter->get_permanent_url(NULL, NULL, $MainList->get_active_filter('page'), NULL, '&');
                            if ($ReqHost . $ReqURI != $canoncical_url) {
                                // REDIRECT TO THE CANONICAL URL:
                                // fp> TODO: we're going to lose the additional params, it would be better to keep them...
                                // fp> what additional params actually?
                                header_redirect($canoncical_url, true);
                            }
                        }
                    }
                } elseif (array_diff($active_filters, array('tags', 'posts', 'page')) == array()) {
                    // This is a tag page
                    $disp_detail = 'posts-tag';
                    $seo_page_type = 'Tag page';
                    if ($Blog->get_setting('tag_noindex')) {
                        // We prefer robots not to index tag pages:
                        $robots_index = false;
                    }
                    if ($Blog->get_setting('canonical_tag_urls') && $redir == 'yes') {
                        // Check if the URL was canonical:
                        $canoncical_url = $Blog->gen_tag_url($MainList->get_active_filter('tags'), $MainList->get_active_filter('page'), '&');
                        if ($ReqHost . $ReqURI != $canoncical_url) {
                            // REDIRECT TO THE CANONICAL URL:
                            // fp> TODO: we're going to lose the additional params, it would be better to keep them...
                            // fp> what additional params actually?
                            header_redirect($canoncical_url, true);
                        }
                    }
                } elseif (array_diff($active_filters, array('ymdhms', 'week', 'page')) == array()) {
                    // This is an archive page
                    // echo 'archive page';
                    $disp_detail = 'posts-date';
                    $seo_page_type = 'Date archive page';
                    if ($Blog->get_setting('archive_noindex')) {
                        // We prefer robots not to index archive pages:
                        $robots_index = false;
                    }
                } else {
                    // Other filtered pages:
                    $disp_detail = 'posts-filtered';
                    $seo_page_type = 'Other filtered page';
                    if ($Blog->get_setting('filtered_noindex')) {
                        // We prefer robots not to index other filtered pages:
                        $robots_index = false;
                    }
                }
            } else {
                // This is the default blog page
                $disp_detail = 'posts-default';
                $seo_page_type = 'Default page';
                if ($Blog->get_setting('default_noindex')) {
                    // We prefer robots not to index archive pages:
                    $robots_index = false;
                }
            }
            break;
            // SPECIAL FEATURE PAGES:
        // SPECIAL FEATURE PAGES:
        case 'feedback-popup':
            $seo_page_type = 'Comment popup';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'arcdir':
            $seo_page_type = 'Date archive directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'catdir':
            $seo_page_type = 'Category directory';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'msgform':
            $seo_page_type = 'Contact form';
            if ($Blog->get_setting($disp . '_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
        case 'profile':
        case 'subs':
            $seo_page_type = 'Special feature page';
            if ($Blog->get_setting('special_noindex')) {
                // We prefer robots not to index these pages:
                $robots_index = false;
            }
            break;
    }
    // dummy var for backward compatibility with versions < 2.4.1 -- prevents "Undefined variable"
    global $global_Cache, $credit_links;
    $credit_links = $global_Cache->get('creds');
}
Esempio n. 17
0
/**
 * Template tag: Display the user's preferred name
 *
 * Used in result lists.
 *
 * @param integer user ID
 */
function user_preferredname($user_ID)
{
    $UserCache =& get_Cache('UserCache');
    if (!empty($user_ID) && ($User =& $UserCache->get_by_ID($user_ID))) {
        $User->disp('preferredname');
    }
}
Esempio n. 18
0
 /**
  * Resolve user ID of owner
  *
  * @return User
  */
 function &get_owner_User()
 {
     if (!isset($this->owner_User)) {
         $UserCache =& get_Cache('UserCache');
         $this->owner_User =& $UserCache->get_by_ID($this->owner_user_ID);
     }
     return $this->owner_User;
 }
Esempio n. 19
0
/**
 * Send Trackback to single URL
 *
 * trackback(-)
 *
 * @todo add autodiscovery
 */
function trackback($trackback_url, $title, $excerpt, $ID)
{
    global $app_name, $app_version, $Blog, $Messages;
    $trackback_message = T_('Sending trackback to:') . ' ' . htmlspecialchars($trackback_url) . ' ';
    $title = rawurlencode($title);
    $excerpt = rawurlencode($excerpt);
    $blog_name = rawurlencode($Blog->get('name'));
    $ItemCache =& get_Cache('ItemCache');
    $Item =& $ItemCache->get_by_ID($ID);
    $url = rawurlencode($Item->get_permanent_url('', '', '&'));
    // dis is the trackback stuff to be sent:
    $query_string = "title={$title}&url={$url}&blog_name={$blog_name}&excerpt={$excerpt}";
    // echo "url:$trackback_url<br>$sending:$query_string<br />";
    $result = '';
    if (strstr($trackback_url, '?')) {
        $Messages->add($trackback_message . '[get]', 'note');
        $trackback_url .= "&" . $query_string;
        flush();
        if ($fp = fopen($trackback_url, 'r')) {
            // blueyed>> why do we here just read the first 4kb, but in the POSTed response everything?
            // fp>> this is dirty code... I've never really reviewed it entirely. Feel free to refactor as much as needed.
            $result = fread($fp, 4096);
            fclose($fp);
            /* debug code
            			$debug_file = 'trackback.log';
            			$fp = fopen($debug_file, 'a');
            			fwrite($fp, "\n*****\nTrackback URL query:\n\n$trackback_url\n\nResponse:\n\n");
            			fwrite($fp, $result);
            			fwrite($fp, "\n\n");
            			fclose($fp);
            			*/
        }
    } else {
        $Messages->add($trackback_message . '[post]', 'note');
        $trackback_url = parse_url($trackback_url);
        if (!empty($trackback_url['host']) && !empty($trackback_url['path'])) {
            // Only try trackback if we have host and path:
            $port = isset($trackback_url['port']) ? $trackback_url['port'] : 80;
            $http_request = 'POST ' . $trackback_url['path'] . " HTTP/1.0\r\n";
            $http_request .= 'Host: ' . $trackback_url['host'] . "\r\n";
            $http_request .= 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
            $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
            $http_request .= "User-Agent: {$app_name}/{$app_version}\r\n";
            $http_request .= "\r\n";
            $http_request .= $query_string;
            flush();
            if ($fs = @fsockopen($trackback_url['host'], $port, $errno, $errst, 20)) {
                // Set timeout for data:
                if (function_exists('stream_set_timeout')) {
                    stream_set_timeout($fs, 20);
                    // PHP 4.3.0
                } else {
                    socket_set_timeout($fs, 20);
                    // PHP 4
                }
                fputs($fs, $http_request);
                $result = '';
                while (!feof($fs)) {
                    $result .= fgets($fs, 4096);
                }
                /* debug code
                			$debug_file = 'trackback.log';
                			$fp = fopen($debug_file, 'a');
                			fwrite($fp, "\n*****\nRequest:\n\n$http_request\n\nResponse:\n\n$result");
                			while(!@feof($fs)) {
                				fwrite($fp, @fgets($fs, 4096));
                			}
                			fwrite($fp, "\n\n");
                			fclose($fp);
                			*/
                fclose($fs);
            }
        }
    }
    // extract the error code and message, then make the error code readable
    if (preg_match("/<error>[\r\n\t ]*(\\d+)[\r\n\t ]*<\\/error>/", $result, $error)) {
        preg_match("/<message>(.*?)<\\/message>/", $result, $error_message);
        $message = isset($error_message[1]) ? $error_message[1] : '';
        switch ($error[1]) {
            case '0':
                $result_message = '[' . T_('Succeeded') . '] ' . $message;
                break;
            case '1':
                $result_message = '[' . T_('Failed') . '] ' . $message;
                break;
            default:
                $result_message = '[' . T_('Unknown error') . ' (' . $error[1] . ')] ' . $message;
                break;
        }
    } else {
        $result_message = T_('No valid trackback response. Maybe the given url is not a Trackback url.') . ' &quot;' . $result . '&quot;';
    }
    $Messages->add(T_('Response:') . ' ' . strip_tags($result_message), 'note');
    return $result;
}
Esempio n. 20
0
 function display_footer_container()
 {
     global $Blog, $app_version;
     if (version_compare($app_version, '4.0') < 0) {
         // b2evo 3
         $WidgetCache =& get_Cache('WidgetCache');
     } else {
         // b2evo 4 and up
         $WidgetCache =& get_WidgetCache();
     }
     $fwcount = 0;
     if ($Widget_array = $WidgetCache->get_by_coll_container($Blog->ID, 'Footer')) {
         foreach ($Widget_array as $ComponentWidget) {
             if ($ComponentWidget->enabled) {
                 $fwcount++;
             }
         }
     }
     if ($fwcount < 1) {
         $fwcount = 1;
     }
     echo '<ul class="blocks widgetcount-' . $fwcount . '">';
     // "Footer" CONTAINER EMBEDDED HERE
     skin_container(NT_('Footer'), array('block_start' => '<li class="block"><div class="block-content clearfix">', 'block_end' => '</div></li>', 'block_title_start' => '<h4 class="title">', 'block_title_end' => '</h4>', 'list_start' => '<ul>', 'list_end' => '</ul>', 'item_start' => '<li class="page_item">', 'item_end' => '</li>', 'group_start' => '<ul>', 'group_end' => '</ul>', 'notes_start' => '<div class="notes">', 'notes_end' => '</div>'));
     echo '</ul>';
 }
Esempio n. 21
0
/**
 * Get current Item for an XML-RPC request.
 *
 * @param xmlrpcmsg XML-RPC Message
 * @param integer idx of postid param
 * @return Blog or NULL
 */
function &xmlrpcs_get_Item($m, $postid_param)
{
    global $xmlrpcs_errcode, $xmlrpcs_errmsg, $xmlrpcerruser;
    $postid = $m->getParam($postid_param);
    $postid = $postid->scalarval();
    /**
     * @var ItemCache
     */
    $ItemCache =& get_Cache('ItemCache');
    /**
     * @var Item
     */
    $edited_Item =& $ItemCache->get_by_ID($postid, false, false);
    if (empty($edited_Item)) {
        // Blog not found
        $xmlrpcs_errcode = $xmlrpcerruser + 6;
        $xmlrpcs_errmsg = 'Requested post/Item (' . $postid . ') does not exist.';
        $r = NULL;
        return $r;
    }
    logIO('Requested Item: ' . $edited_Item->ID . ' - ' . $edited_Item->title);
    return $edited_Item;
}
Esempio n. 22
0
        $edited_ComponentWidget =& $WidgetCache->get_by_ID($wi_ID);
        // Take blog from here!
        // echo $edited_ComponentWidget->coll_ID;
        set_working_blog($edited_ComponentWidget->coll_ID);
        $BlogCache =& get_Cache('BlogCache');
        $Blog =& $BlogCache->get_by_ID($blog);
        break;
    default:
        debug_die('Init objects: unhandled action');
}
if (!valid_blog_requested()) {
    debug_die('Invalid blog requested');
}
$current_User->check_perm('blog_properties', 'edit', true, $blog);
// Get Skin used by current Blog:
$SkinCache =& get_Cache('SkinCache');
$Skin =& $SkinCache->get_by_ID($Blog->skin_ID);
// Make sure containers are loaded for that skin:
$container_list = $Skin->get_containers();
/**
 * Perform action:
 */
switch ($action) {
    case 'nil':
    case 'new':
    case 'edit':
        // Do nothing
        break;
    case 'create':
        // Add a Widget to container:
        if (!in_array($container, $container_list)) {
Esempio n. 23
0
 /**
  * Attempt to load meta data for all files in the list.
  *
  * Will attempt only once per file and cache the result.
  */
 function load_meta()
 {
     global $DB, $Debuglog;
     $to_load = array();
     for ($i = 0; $i < count($this->_entries); $i++) {
         // For each file:
         $loop_File =& $this->_entries[$i];
         // echo '<br>'.$loop_File->get_full_path();
         if ($loop_File->meta != 'unknown') {
             // We have already loaded meta data:
             continue;
         }
         $to_load[] = $DB->quote($loop_File->get_rdfp_rel_path());
     }
     if (count($to_load)) {
         // We have something to load...
         /**
          * @var FileCache
          */
         $FileCache =& get_Cache('FileCache');
         $rows = $DB->get_results("\r\n\t\t\t\tSELECT *\r\n\t\t\t\t  FROM T_files\r\n\t\t\t\t WHERE file_root_type = '" . $this->_FileRoot->type . "'\r\n\t\t\t\t   AND file_root_ID = " . $this->_FileRoot->in_type_ID . "\r\n\t\t\t\t   AND file_path IN (" . implode(',', $to_load) . ")", OBJECT, 'Load FileList meta data');
         if (count($rows)) {
             // Go through rows of loaded meta data...
             foreach ($rows as $row) {
                 // Retrieve matching File object:
                 /**
                  * @var File
                  */
                 $loop_File =& $FileCache->get_by_root_and_path($row->file_root_type, $row->file_root_ID, $row->file_path);
                 // Associate meta data to File object:
                 $loop_File->load_meta(false, $row);
             }
         }
     }
     // For all Files that still have no meta data, memorize that we could not find any meta data
     for ($i = 0; $i < count($this->_entries); $i++) {
         // For each file:
         $loop_File =& $this->_entries[$i];
         if ($loop_File->meta == 'unknown') {
             $loop_File->meta = 'notfound';
         }
     }
     // Has sth been loaded?
     return count($to_load) && count($rows);
 }
Esempio n. 24
0
 /**
  * Returns list of buttons for available Collections (aka Blogs) to work on.
  *
  * @return string HTML
  */
 function get_bloglist_buttons($title = '')
 {
     global $current_User, $blog, $pagenow;
     $max_buttons = 7;
     if (empty($this->coll_list_permname)) {
         // We have not requested a list of blogs to be displayed
         return;
     }
     // Prepare url params:
     $url_params = '?';
     $form_params = '';
     foreach ($this->coll_list_url_params as $name => $value) {
         $url_params .= $name . '=' . $value . '&amp;';
         $form_params .= '<input type="hidden" name="' . $name . '" value="' . $value . '" />';
     }
     $template = $this->get_template('CollectionList');
     $BlogCache =& get_Cache('BlogCache');
     $blog_array = $BlogCache->load_user_blogs($this->coll_list_permname, $this->coll_list_permlevel);
     $buttons = '';
     $select_options = '';
     $count = 0;
     $current_is_displayed = false;
     foreach ($blog_array as $l_blog_ID) {
         // Loop through all blogs that match the requested permission:
         $l_Blog =& $BlogCache->get_by_ID($l_blog_ID);
         $count++;
         if ($count < $max_buttons || $current_is_displayed && $count == $max_buttons || $l_blog_ID == $blog) {
             // Not too many yet OR current blog, add blog as a button:
             $buttons .= $template[$l_blog_ID == $blog ? 'beforeEachSel' : 'beforeEach'];
             $buttons .= '<a href="' . $url_params . 'blog=' . $l_blog_ID . '" class="' . ($l_blog_ID == $blog ? 'CurrentBlog' : 'OtherBlog') . '"';
             if (!is_null($this->coll_list_onclick)) {
                 // We want to include an onclick attribute:
                 $buttons .= ' onclick="' . sprintf($this->coll_list_onclick, $l_blog_ID) . '"';
             }
             $buttons .= '>' . $l_Blog->dget('shortname', 'htmlbody') . '</a> ';
             if ($l_blog_ID == $blog) {
                 $current_is_displayed = true;
                 $buttons .= $template['afterEachSel'];
             } else {
                 $buttons .= $template['afterEach'];
             }
         }
         // Add item select list:
         $select_options .= '<option value="' . $l_blog_ID . '"';
         if ($l_blog_ID == $blog) {
             $select_options .= ' selected="selected"';
         }
         $select_options .= '>' . $l_Blog->dget('shortname', 'formvalue') . '</option>';
     }
     $r = $template['before'];
     $r .= $title;
     if (!empty($this->coll_list_all_title)) {
         // We want to add an "all" button
         $r .= $template[$blog == 0 ? 'beforeEachSel' : 'beforeEach'];
         $r .= '<a href="' . $this->coll_list_all_url . '" class="' . ($blog == 0 ? 'CurrentBlog' : 'OtherBlog') . '">' . $this->coll_list_all_title . '</a> ';
         $r .= $template[$blog == 0 ? 'afterEachSel' : 'afterEach'];
     }
     $r .= $template['buttons_start'];
     $r .= $buttons;
     $r .= $template['buttons_end'];
     $r .= $template['select_start'];
     if ($count > $max_buttons) {
         // We could not display all blogs as buttons
         $r .= '<form action="' . $pagenow . '" method="get">';
         $r .= $form_params;
         $r .= '<select name="blog" onchange="';
         if (empty($this->coll_list_onclick)) {
             // Just submit...
             $r .= 'this.form.submit();';
         } else {
             $r .= sprintf($this->coll_list_onclick, 'this.value');
         }
         $r .= '">' . $select_options . '</select>';
         $r .= '<noscript><input type="submit" value="Go" /></noscript></form>';
     }
     $r .= $template['select_end'];
     $r .= $template['after'];
     return $r;
 }
Esempio n. 25
0
 }
 $DB->begin();
 $new_User =& new User();
 $new_User->set('login', $login);
 $new_User->set('pass', md5($pass1));
 // encrypted
 $new_User->set('nickname', $login);
 $new_User->set_email($email);
 $new_User->set('ip', $Hit->IP);
 $new_User->set('domain', $Hit->get_remote_host(true));
 $new_User->set('browser', $Hit->user_agent);
 $new_User->set_datecreated($localtimenow);
 $new_User->set('locale', $locale);
 $newusers_grp_ID = $Settings->get('newusers_grp_ID');
 // echo $newusers_grp_ID;
 $GroupCache =& get_Cache('GroupCache');
 $new_user_Group =& $GroupCache->get_by_ID($newusers_grp_ID);
 // echo $new_user_Group->disp('name');
 $new_User->set_Group($new_user_Group);
 // Determine if the user must validate before using the system:
 $new_User->set('validated', !$Settings->get('newusers_mustvalidate'));
 $new_User->dbinsert();
 $new_user_ID = $new_User->ID;
 // we need this to "rollback" user creation if there's no DB transaction support
 // TODO: Optionally auto create a blog (handle this together with the LDAP plugin)
 // TODO: Optionally auto assign rights
 // Actions to be appended to the user registration transaction:
 if ($Plugins->trigger_event_first_false('AppendUserRegistrTransact', array('User' => &$new_User))) {
     // TODO: notify the plugins that have been called before about canceling of the event?!
     $DB->rollback();
     // Delete, in case there's no transaction support:
Esempio n. 26
0
	<?php 
$Form->switch_layout(NULL);
$Form->end_fieldset();
// ############################ WORKFLOW #############################
if ($Blog->get_setting('use_workflow')) {
    // We want to use workflow properties for this blog:
    $Form->begin_fieldset(T_('Workflow properties'), array('id' => 'itemform_workflow_props'));
    echo '<div id="itemform_edit_timestamp" class="edit_fieldgroup">';
    $Form->switch_layout('linespan');
    $Form->select_object('item_priority', NULL, $edited_Item, T_('Priority'), '', true, '', 'priority_options');
    echo ' ';
    // allow wrapping!
    $Form->select_object('item_assigned_user_ID', NULL, $edited_Item, T_('Assigned to'), '', true, '', 'get_assigned_user_options');
    echo ' ';
    // allow wrapping!
    $ItemStatusCache =& get_Cache('ItemStatusCache');
    $Form->select_options('item_st_ID', $ItemStatusCache->get_option_list($edited_Item->pst_ID, true), T_('Task status'));
    echo ' ';
    // allow wrapping!
    $Form->date('item_deadline', $edited_Item->get('datedeadline'), T_('Deadline'));
    $Form->switch_layout(NULL);
    echo '</div>';
    $Form->end_fieldset();
}
// ####################### ADDITIONAL ACTIONS #########################
if (isset($Blog) && $Blog->get('allowtrackbacks')) {
    $Form->begin_fieldset(T_('Additional actions'), array('id' => 'itemform_additional_actions'));
    // --------------------------- TRACKBACK --------------------------------------
    ?>
		<div id="itemform_trackbacks">
			<label for="trackback_url"><strong><?php 
Esempio n. 27
0
function stats_blog_name()
{
    global $row_stats;
    $BlogCache =& get_Cache('BlogCache');
    $Blog =& $BlogCache->get_by_ID($row_stats['hit_blog_ID']);
    $Blog->disp('name');
}
Esempio n. 28
0
/**
 * Load an image from a file into memory
 *
 * @param string pathname of image file
 * @param string
 * @return array resource image handle or NULL
 */
function load_image($path, $mimetype)
{
    // yabs> GD library uses shedloads of memory
    // fp> 256M is way too high to sneak this in here. There should be some checks in the systems page to warn against low memory conditions. Also i'm not sure it makes sense to bump memory just for images. If you allow memory you might as well allow it for anything. Anyways, this is too much to be snuk in.
    // @ini_set('memory_limit', '256M'); // artificially inflate memory if we can
    $err = NULL;
    $imh = NULL;
    $function = NULL;
    $image_info = getimagesize($path);
    if (!$image_info || $image_info['mime'] != $mimetype) {
        $FiletypeCache = get_Cache('FiletypeCache');
        $correct_Filetype = $FiletypeCache->get_by_mimetype($image_info['mime']);
        $correct_extension = array_shift($correct_Filetype->get_extensions());
        $path_info = pathinfo($path);
        $wrong_extension = $path_info['extension'];
        $err = '!' . $correct_extension . ' extension mismatch: use .' . $correct_extension . ' instead of .' . $wrong_extension;
    } else {
        $mime_function = array('image/jpeg' => 'imagecreatefromjpeg', 'image/gif' => 'imagecreatefromgif', 'image/png' => 'imagecreatefrompng');
        if (isset($mime_function[$mimetype])) {
            $function = $mime_function[$mimetype];
        } else {
            // Unrecognized mime type
            $err = '!Unsupported format ' . $mimetype . ' (load_image)';
        }
    }
    //pre_dump( $function );
    if ($function) {
        // Call GD built-in function to load image
        // fp> Note: sometimes this GD call will die and there is no real way to recover :/
        load_funcs('tools/model/_system.funcs.php');
        $memory_limit = system_check_memory_limit();
        $curr_mem_usage = memory_get_usage(true);
        // Calculate the aproximative memory size which would be required to create the image resource
        if ($memory_limit - $curr_mem_usage < 4 * $image_info[0] * $image_info[1]) {
            // Don't try to load the image into the memory because it would cause 'Allowed memory size exhausted' error
            return array("!Cannot resize too large image", false);
        }
        $imh = $function($path);
    }
    if ($imh === false) {
        trigger_error('load_image failed: ' . $path . ' / ' . $mimetype);
        // DEBUG
        // e.g. "imagecreatefromjpeg(): $FILE is not a valid JPEG file"
        $err = '!load_image failed (no valid image?)';
    }
    if ($err) {
        error_log('load_image failed: ' . substr($err, 1) . ' (' . $path . ' / ' . $mimetype . ')');
    }
    return array($err, $imh);
}
Esempio n. 29
0
 /**
  * Automagically login every user as "demouser" who is not logged in and does not
  * try to currently.
  *
  * To enable/test it, change the "if-0" check below to "if( 1 )".
  *
  * @see Plugin::AlternateAuthentication()
  */
 function AlternateAuthentication()
 {
     if (0) {
         global $Session, $Messages;
         $UserCache =& get_Cache('UserCache');
         if ($demo_User =& $UserCache->get_by_login('demouser')) {
             // demouser exists:
             $Session->set_User($demo_User);
             $Messages->add('Logged in as demouser.', 'success');
             return true;
         }
     }
 }
Esempio n. 30
0
 * @var GeneralSettings
 */
global $Settings;
global $dispatcher;
$sql = 'SELECT T_blogs.*, user_login
					FROM T_blogs INNER JOIN T_users ON blog_owner_user_ID = user_ID';
if (!$current_User->check_perm('blogs', 'view')) {
    // We do not have perm to view all blogs... we need to restrict to those we're a member of:
    $sql .= " LEFT JOIN T_coll_user_perms ON (blog_advanced_perms <> 0\r\n\t\t       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND blog_ID = bloguser_blog_ID\r\n\t\t       \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND bloguser_user_ID = {$current_User->ID} )\r\n\t\t       LEFT JOIN T_coll_group_perms ON (blog_advanced_perms <> 0\r\n\t\t          \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND blog_ID = bloggroup_blog_ID\r\n\t\t          \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tAND bloggroup_group_ID = {$current_User->group_ID} )\r\n\t\t       WHERE blog_owner_user_ID = {$current_User->ID}\r\n\t\t       \t\t\t\tOR bloguser_ismember <> 0\r\n\t\t\t\t\t\t\t\t \tOR bloggroup_ismember <> 0";
    $no_results = T_('Sorry, you have no permission to edit/view any blog\'s properties.');
} else {
    $no_results = T_('No blog has been created yet!');
}
// Create result set:
$Results =& new Results($sql, 'blog_');
$Results->Cache =& get_Cache('BlogCache');
$Results->title = T_('Blog list');
$Results->no_results_text = $no_results;
if ($current_User->check_perm('blogs', 'create')) {
    $Results->global_icon(T_('New blog...'), 'new', url_add_param($dispatcher, 'ctrl=collections&amp;action=new'), T_('New blog...'), 3, 4);
}
$Results->cols[] = array('th' => T_('ID'), 'order' => 'blog_ID', 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => '$blog_ID$');
function disp_coll_name($coll_name, $coll_ID)
{
    global $current_User, $ctrl;
    if ($ctrl == 'dashboard') {
        // Dashboard
        $edit_url = regenerate_url('ctrl', 'ctrl=dashboard&amp;blog=' . $coll_ID);
        $r = '<a href="' . $edit_url . '">';
        $r .= $coll_name;
        $r .= '</a>';