コード例 #1
0
 /**
  * Get an object from cache by IP address
  *
  * Load into cache if necessary
  *
  * @param string IP address
  * @param boolean false if you want to return false on error
  * @param boolean true if function should die on empty/null
  */
 function &get_by_ip($req_ip, $halt_on_error = false, $halt_on_empty = false)
 {
     global $DB, $Debuglog;
     if (!isset($this->ip_index[$req_ip])) {
         // not yet in cache:
         $IP = ip2int($req_ip);
         $SQL = new SQL('Get ID of IP range by IP address');
         $SQL->SELECT('aipr_ID');
         $SQL->FROM('T_antispam__iprange');
         $SQL->WHERE('aipr_IPv4start <= ' . $DB->quote($IP));
         $SQL->WHERE_and('aipr_IPv4end >= ' . $DB->quote($IP));
         $IPRange_ID = $DB->get_var($SQL->get());
         // Get object from IPRangeCache bi ID
         $IPRange = $this->get_by_ID($IPRange_ID, $halt_on_error, $halt_on_empty);
         if ($IPRange) {
             // It is in IPRangeCache
             $this->ip_index[$req_ip] = $IPRange;
         } else {
             // not in the IPRangeCache
             if ($halt_on_error) {
                 debug_die("Requested {$this->objtype} does not exist!");
             }
             $this->ip_index[$req_ip] = false;
         }
     } else {
         $Debuglog->add("Retrieving <strong>{$this->objtype}({$req_ip})</strong> from cache");
     }
     return $this->ip_index[$req_ip];
 }
コード例 #2
0
/**
 * Get number of users for newsletter from UserList filterset
 *
 * @return array 
 * 		'all' - Number of accounts in filterset
 * 		'active' - Number of active accounts in filterset
 * 		'newsletter' - Number of active accounts which accept newsletter email
 */
function get_newsletter_users_numbers()
{
    $numbers = array('all' => 0, 'active' => 0, 'newsletter' => 0);
    load_class('users/model/_userlist.class.php', 'UserList');
    // Initialize users list from session cache in order to know number of users
    $UserList = new UserList('admin');
    $UserList->memorize = false;
    $UserList->load_from_Request();
    $users_IDs = $UserList->filters['users'];
    if (count($users_IDs)) {
        // Found users in the filterset
        global $DB;
        $numbers['all'] = count($users_IDs);
        // Get number of all active users
        $SQL = new SQL();
        $SQL->SELECT('COUNT( * )');
        $SQL->FROM('T_users');
        $SQL->WHERE('user_ID IN ( ' . implode(', ', $users_IDs) . ' )');
        $SQL->WHERE_and('user_status IN ( \'activated\', \'autoactivated\' )');
        $numbers['active'] = $DB->get_var($SQL->get());
        // Get number of all active users which accept newsletter email
        $SQL = get_newsletter_users_sql($users_IDs);
        $SQL->SELECT('COUNT( * )');
        $numbers['newsletter'] = $DB->get_var($SQL->get());
    }
    return $numbers;
}
コード例 #3
0
/**
 * Get the categories list
 *
 * @param integer Parent category ID
 * @param integer Level
 * @return array Categories
 */
function fcpf_categories_select($parent_category_ID = -1, $level = 0)
{
    global $blog, $DB;
    $result_Array = array();
    $SQL = new SQL();
    $SQL->SELECT('cat_ID, cat_name');
    $SQL->FROM('T_categories');
    $SQL->WHERE('cat_blog_ID = ' . $DB->quote($blog));
    if ($parent_category_ID == -1) {
        $SQL->WHERE_and('cat_parent_ID IS NULL');
    } else {
        $SQL->WHERE('cat_parent_ID = ' . $DB->quote($parent_category_ID));
    }
    $SQL->ORDER_BY('cat_name');
    $categories = $DB->get_results($SQL->get());
    if (!empty($categories)) {
        foreach ($categories as $category) {
            $result_Array[] = array('value' => $category->cat_ID, 'label' => str_repeat('&nbsp;&nbsp;&nbsp;', $level) . $category->cat_name);
            $child_Categories_opts = fcpf_categories_select($category->cat_ID, $level + 1);
            if ($child_Categories_opts != '') {
                foreach ($child_Categories_opts as $cat) {
                    $result_Array[] = $cat;
                }
            }
        }
    }
    return $result_Array;
}
コード例 #4
0
/**
 * Uninstall b2evolution: Delete DB & Cache files
 */
function uninstall_b2evolution()
{
    global $DB;
    /* REMOVE PAGE CACHE */
    load_class('_core/model/_pagecache.class.php', 'PageCache');
    // Remove general page cache
    $PageCache = new PageCache(NULL);
    $PageCache->cache_delete();
    // Skip if T_blogs table is already deleted. Note that db_delete() will not throw any errors on missing tables.
    if ($DB->query('SHOW TABLES LIKE "T_blogs"')) {
        // Get all blogs
        $blogs_SQL = new SQL();
        $blogs_SQL->SELECT('blog_ID');
        $blogs_SQL->FROM('T_blogs');
        $blogs = $DB->get_col($blogs_SQL->get());
        $BlogCache =& get_BlogCache('blog_ID');
        foreach ($blogs as $blog_ID) {
            $Blog = $BlogCache->get_by_ID($blog_ID);
            // Remove page cache of current blog
            $PageCache = new PageCache($Blog);
            $PageCache->cache_delete();
        }
    }
    /* REMOVE DATABASE */
    db_delete();
    echo '<p>' . T_('Reset done!') . '</p>';
}
コード例 #5
0
ファイル: PostgreSQL.php プロジェクト: Nyholm/scrapbook
 /**
  * {@inheritdoc}
  */
 public function get($key, &$token = null)
 {
     $return = parent::get($key, $token);
     if ($token !== null) {
         // BYTEA data return streams - we actually need the data in
         // serialized format, not some silly stream
         $token = $this->serialize($return);
     }
     return $return;
 }
コード例 #6
0
ファイル: Highscore.php プロジェクト: roderm/mkn151
 /**
  * Return Data-Model for the View
  */
 private function getModel()
 {
     require_once 'classes/SQL.php';
     $model = new stdClass();
     $model->template = 'admin/HighscoreTable';
     $model->isAdmin = person::getPermissionName() == 'admin' ? 'true' : 'false';
     $model->gameID = $this->getGameId();
     $sql = new SQL();
     $sql->connect();
     $model->data = $sql->get("SELECT * FROM ViewHighscore ORDER BY GamerMainScore DESC");
     return $model;
 }
コード例 #7
0
ファイル: AdminKategorie.php プロジェクト: roderm/mkn151
 /**
  * Add new or edit Categories in DB
  * paramters = POST: Categorie ID and Categorie-Properties
  */
 public function saveKategorien()
 {
     require 'classes/SQL.php';
     $sql = new SQL();
     $sql->connect();
     $id = mysql_real_escape_string(htmlentities($_POST['katID']));
     $bez = mysql_real_escape_string(htmlentities($_POST['bezTxt']));
     $desc = mysql_real_escape_string(htmlentities($_POST['descTxt']));
     $returnData;
     $success = true;
     if ($id == 0 && $bez != "") {
         $sql->doThat('INSERT INTO quizCategories(bezeichnung, beschreibung) VALUES ("' . $bez . '","' . $desc . '")');
         $returnData = $sql->get('SELECT * FROM quizCategories WHERE bezeichnung="' . $bez . '" AND beschreibung="' . $desc . '" LIMIT 1');
     } elseif ($bez != "") {
         $sql->doThat('UPDATE quizCategories SET bezeichnung="' . $bez . '", beschreibung="' . $desc . '" WHERE id=' . $id);
         $returnData = $sql->get('SELECT * FROM quizCategories WHERE id=' . $id);
     } else {
         $success = false;
     }
     $arr = array('success' => $success, 'row' => array('id' => $returnData[0]->id, 'bez' => $returnData[0]->bezeichnung, 'desc' => $returnData[0]->beschreibung));
     return json_encode($arr);
 }
コード例 #8
0
ファイル: AdminQuestion.php プロジェクト: roderm/mkn151
 /**
  * Return QuestionTable-Page as HTML-View
  * parameters = POST: CategorieID
  */
 public function getQuestionTable()
 {
     require 'classes/SQL.php';
     require 'classes/view.php';
     $categorie = htmlentities($_POST['katID']);
     $model = new stdClass();
     $model->template = 'admin/QuestionTable';
     $sql = new SQL();
     $sql->connect();
     $model->data = $sql->get("SELECT * FROM ViewQuestionQuote WHERE categorie='" . $categorie . "' ORDER BY question");
     $view = new view();
     return $view->loadTemplate($model);
 }
コード例 #9
0
/**
 * Get number of users for newsletter from UserList filterset
 *
 * @return array Numbers of users:
 *     'all' - Currently selected recipients (Accounts which accept newsletter emails)
 *     'active' - Already received (Accounts which have already been sent this newsletter)
 *     'newsletter' - Ready to send (Accounts which have not been sent this newsletter yet)
 */
function get_newsletter_users_numbers()
{
    $numbers = array('all' => 0, 'active' => 0, 'newsletter' => 0);
    $users_IDs = get_filterset_user_IDs();
    if (count($users_IDs)) {
        // Found users in the filterset
        global $DB;
        $numbers['all'] = count($users_IDs);
        // Get number of all active users
        $SQL = new SQL();
        $SQL->SELECT('COUNT( * )');
        $SQL->FROM('T_users');
        $SQL->WHERE('user_ID IN ( ' . implode(', ', $users_IDs) . ' )');
        $SQL->WHERE_and('user_status IN ( \'activated\', \'autoactivated\' )');
        $numbers['active'] = $DB->get_var($SQL->get());
        // Get number of all active users which accept newsletter email
        $SQL = get_newsletter_users_sql($users_IDs);
        $SQL->SELECT('COUNT( * )');
        $numbers['newsletter'] = $DB->get_var($SQL->get());
    }
    return $numbers;
}
コード例 #10
0
 /**
  * Load permissions
  *
  * @param integer Group ID
  */
 function load($grp_ID)
 {
     global $DB, $modules;
     // Get default group permission from each module
     foreach ($modules as $module) {
         $Module =& $GLOBALS[$module . '_Module'];
         if (method_exists($Module, 'get_default_group_permissions')) {
             // Module has pluggable permissions and we can add them to the current setting
             $this->add($module, $Module->get_default_group_permissions($grp_ID), $grp_ID);
         }
     }
     if ($grp_ID != 0) {
         // Select current group permission from database
         $SQL = new SQL();
         $SQL->SELECT('*');
         $SQL->FROM('T_groups__groupsettings');
         $SQL->WHERE('gset_grp_ID = ' . $grp_ID);
         $DB->begin();
         // Set current group permissions
         $existing_perm = array();
         foreach ($DB->get_results($SQL->get()) as $row) {
             $existing_perm[] = $row->gset_name;
             $this->permission_values[$row->gset_name] = $row->gset_value;
         }
         // Set default group permission if these permissions don't exist
         $update_permissions = false;
         foreach ($this->permission_values as $name => $value) {
             if (!in_array($name, $existing_perm)) {
                 $this->set($name, $value, $grp_ID);
                 $update_permissions = true;
             }
         }
         if ($update_permissions) {
             // We can update permission as there are some new permnissions
             $this->dbupdate($grp_ID);
         }
         $DB->commit();
     }
 }
コード例 #11
0
ファイル: _domain.class.php プロジェクト: Ariflaw/b2evolution
 /**
  * Load data from Request form fields.
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_Request()
 {
     param_string_not_empty('dom_name', T_('Please enter domain name.'));
     $dom_name = get_param('dom_name');
     $this->set('name', $dom_name);
     $dom_status = param('dom_status', 'string', true);
     $this->set('status', $dom_status, true);
     $dom_type = param('dom_type', 'string', true);
     $this->set('type', $dom_type, true);
     if (!param_errors_detected()) {
         // Check domains with the same name and type
         global $Messages, $DB;
         $SQL = new SQL();
         $SQL->SELECT('dom_ID');
         $SQL->FROM('T_basedomains');
         $SQL->WHERE('dom_ID != ' . $this->ID);
         $SQL->WHERE_and('dom_name = ' . $DB->quote($dom_name));
         $SQL->WHERE_and('dom_type = ' . $DB->quote($dom_type));
         if ($DB->get_var($SQL->get())) {
             $Messages->add(T_('Domain already exists with the same name and type.'));
         }
     }
     return !param_errors_detected();
 }
コード例 #12
0
 * @copyright (c)2009-2015 by Francois Planque - {@link http://fplanque.com/}
 * Parts of this file are copyright (c)2009 by The Evo Factory - {@link http://www.evofactory.com/}.
 *
 * @package evocore
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
global $Blog;
// Create query
$SQL = new SQL();
$SQL->SELECT('t.*, IF( tb.itc_ityp_ID > 0, 1, 0 ) AS type_enabled');
$SQL->FROM('T_items__type AS t');
$SQL->FROM_add('LEFT JOIN T_items__type_coll AS tb ON itc_ityp_ID = ityp_ID AND itc_coll_ID = ' . $Blog->ID);
// Create result set:
$Results = new Results($SQL->get(), 'ityp_');
$Results->title = T_('Item/Post/Page types') . get_manual_link('managing-item-types');
// get reserved and default ids
global $default_ids;
$default_ids = ItemType::get_default_ids();
/**
 * Callback to build possible actions depending on post type id
 *
 */
function get_actions_for_itemtype($id)
{
    global $default_ids;
    $action = action_icon(T_('Duplicate this Post Type...'), 'copy', regenerate_url('action', 'ityp_ID=' . $id . '&amp;action=new'));
    if (!ItemType::is_reserved($id)) {
        // Edit all post types except of not reserved post type
        $action = action_icon(T_('Edit this Post Type...'), 'edit', regenerate_url('action', 'ityp_ID=' . $id . '&amp;action=edit')) . $action;
コード例 #13
0
$SQL->FROM_add('LEFT JOIN T_track__goalcat ON gcat_ID = goal_gcat_ID');
if (!empty($final)) {
    // We want to filter on final goals only:
    $SQL->WHERE_and('goal_redir_url IS NULL');
}
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $SQL->WHERE_and('CONCAT_WS( " ", goal_name, goal_key, goal_redir_url ) LIKE "%' . $DB->escape($s) . '%"');
}
if (!empty($cat)) {
    // We want to filter on category:
    $SQL->WHERE_and('goal_gcat_ID = ' . $DB->quote($cat));
}
// Create result set:
$Results = new Results($SQL->get(), 'goals_', '-A');
$Results->Cache =& get_GoalCache();
$Results->title = T_('Goals') . get_manual_link('goal-settings');
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_goals(&$Form)
{
    $Form->checkbox_basic_input('final', get_param('final'), T_('Final only') . ' &bull;');
    $Form->text('s', get_param('s'), 30, T_('Search'), '', 255);
    $GoalCategoryCache =& get_GoalCategoryCache(NT_('All'));
    $GoalCategoryCache->load_all();
    $Form->select_input_object('cat', get_param('cat'), $GoalCategoryCache, T_('Category'), array('allow_none' => true));
}
コード例 #14
0
ファイル: _tool.funcs.php プロジェクト: ldanielz/uesp.blog
/**
 * Create sample messages and display a process of creating
 *
 * @param integer Number of loops
 * @param integer Number of messages in each conversation
 * @param integer Number of words in each message
 * @param integer Max # of participants in a conversation
 */
function tool_create_sample_messages($num_loops, $num_messages, $num_words, $max_users)
{
    global $Messages, $DB;
    echo T_('Creating of the sample messages...');
    evo_flush();
    /**
     * Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..."
     */
    $DB->log_queries = false;
    // Get all users
    $SQL = new SQL();
    $SQL->SELECT('user_ID');
    $SQL->FROM('T_users');
    $users = $DB->get_col($SQL->get());
    if (count($users) < 2) {
        // No users
        $Messages->add(T_('At least two users must exist in DB to create the messages'), 'error');
        $action = 'show_create_messages';
        break;
    }
    $count_threads = 0;
    $count_messages = 0;
    for ($l = 0; $l < $num_loops; $l++) {
        $user_links = array();
        foreach ($users as $from_user_ID) {
            foreach ($users as $to_user_ID) {
                if ($from_user_ID == $to_user_ID || isset($user_links[(string) $from_user_ID . '-' . $to_user_ID])) {
                    continue;
                }
                $user_links[$from_user_ID . '-' . $to_user_ID] = 1;
                // Insert thread
                $DB->query('INSERT INTO T_messaging__thread ( thrd_title, thrd_datemodified )
					VALUES ( ' . $DB->quote(generate_random_key(16)) . ', ' . $DB->quote(date('Y-m-d H:i:s')) . ' )');
                $thread_ID = $DB->insert_id;
                $count_threads++;
                for ($m = 0; $m < $num_messages; $m++) {
                    $msg_text = '';
                    for ($w = 0; $w < $num_words; $w++) {
                        $msg_text .= generate_random_key(8) . ' ';
                    }
                    $message_user_ID = $m % 2 == 0 ? $from_user_ID : $to_user_ID;
                    // Insert message
                    $DB->query('INSERT INTO T_messaging__message ( msg_author_user_ID , msg_datetime, msg_thread_ID, msg_text )
						VALUES ( ' . $DB->quote($message_user_ID) . ', ' . $DB->quote(date('Y-m-d H:i:s')) . ', ' . $DB->quote($thread_ID) . ', ' . $DB->quote($msg_text) . ' )');
                    $count_messages++;
                    if ($count_messages % 100 == 0) {
                        // Display a process of creating by one dot for 100 users
                        echo ' .';
                        evo_flush();
                    }
                }
                // Insert link for thread & user
                $DB->query('INSERT INTO T_messaging__threadstatus ( tsta_thread_ID , tsta_user_ID, tsta_first_unread_msg_ID )
					VALUES ( ' . $DB->quote($thread_ID) . ', ' . $DB->quote($from_user_ID) . ', NULL ),
								 ( ' . $DB->quote($thread_ID) . ', ' . $DB->quote($to_user_ID) . ', NULL )');
            }
        }
        /** Create one conversation between all users ( limit by $max_users ) **/
        // Insert thread
        $DB->query('INSERT INTO T_messaging__thread ( thrd_title, thrd_datemodified )
			VALUES ( ' . $DB->quote(generate_random_key(16)) . ', ' . $DB->quote(date('Y-m-d H:i:s')) . ' )');
        $thread_ID = $DB->insert_id;
        $count_threads++;
        $user_number = 0;
        for ($m = 0; $m < $num_messages; $m++) {
            $msg_text = '';
            for ($w = 0; $w < $num_words; $w++) {
                $msg_text .= generate_random_key(8) . ' ';
            }
            // Insert message
            $DB->query('INSERT INTO T_messaging__message ( msg_author_user_ID , msg_datetime, msg_thread_ID, msg_text )
				VALUES ( ' . $DB->quote($users[$user_number]) . ', ' . $DB->quote(date('Y-m-d H:i:s')) . ', ' . $DB->quote($thread_ID) . ', ' . $DB->quote($msg_text) . ' )');
            $count_messages++;
            $user_number++;
            if ($user_number == count($users) || $user_number == $max_users - 1) {
                // Reset user number to start of the list
                $user_number = 0;
            }
        }
        // Insert the links between thread & users
        $threadstatuses = array();
        foreach ($users as $u => $user_ID) {
            $threadstatuses[] = '( ' . $DB->quote($thread_ID) . ', ' . $DB->quote($user_ID) . ', NULL )';
            if ($u == $max_users - 1) {
                // limit by max users in one thread
                break;
            }
        }
        $DB->query('INSERT INTO T_messaging__threadstatus ( tsta_thread_ID , tsta_user_ID, tsta_first_unread_msg_ID )
			VALUES ' . implode(', ', $threadstatuses));
    }
    echo ' OK.';
    $Messages->add(sprintf(T_('%d threads and %d messages have been created.'), $count_threads, $count_messages), 'success');
}
コード例 #15
0
    // Filter by start date
    $SQL->WHERE_and('emlog_timestamp >= ' . $DB->quote($datestart . ' 00:00:00'));
    $count_SQL->WHERE_and('emlog_timestamp >= ' . $DB->quote($datestart . ' 00:00:00'));
}
if (!empty($datestop)) {
    // Filter by end date
    $SQL->WHERE_and('emlog_timestamp <= ' . $DB->quote($datestop . ' 23:59:59'));
    $count_SQL->WHERE_and('emlog_timestamp <= ' . $DB->quote($datestop . ' 23:59:59'));
}
if (!empty($email)) {
    // Filter by email
    $email = utf8_strtolower($email);
    $SQL->WHERE_and('emlog_to LIKE ' . $DB->quote($email));
    $count_SQL->WHERE_and('emlog_to LIKE ' . $DB->quote($email));
}
$Results = new Results($SQL->get(), 'emlog_', 'D', $UserSettings->get('results_per_page'), $count_SQL->get());
$Results->title = T_('Sent emails') . get_manual_link('sent-emails');
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_email_sent(&$Form)
{
    global $datestart, $datestop, $email;
    $Form->date_input('datestartinput', $datestart, T_('From date'));
    $Form->date_input('datestopinput', $datestop, T_('To date'));
    $Form->text_input('email', $email, 40, T_('Email'));
}
$Results->filter_area = array('callback' => 'filter_email_sent', 'presets' => array('all' => array(T_('All'), $admin_url . '?ctrl=email&amp;tab=sent')));
$Results->cols[] = array('th' => T_('ID'), 'order' => 'emlog_ID', 'th_class' => 'shrinkwrap', 'td_class' => 'right', 'td' => '$emlog_ID$');
コード例 #16
0
$SQL->ORDER_BY('bloguser_ismember DESC, *, user_login, user_ID');
if (!empty($keywords)) {
    $SQL->add_search_field('user_login');
    $SQL->add_search_field('user_firstname');
    $SQL->add_search_field('user_lastname');
    $SQL->add_search_field('user_nickname');
    $SQL->add_search_field('user_email');
    $SQL->WHERE_keywords($keywords, 'AND');
}
// Display wide layout:
?>

<div id="userlist_wide" class="clear">

<?php 
$Results = new Results($SQL->get(), 'colluser_');
// Tell the Results class that we already have a form for this page:
$Results->Form =& $Form;
$Results->title = T_('User permissions');
$Results->filter_area = array('submit' => 'actionArray[filter1]', 'callback' => 'filter_collobjectlist', 'url_ignore' => 'results_colluser_page,keywords1,keywords2', 'presets' => array('all' => array(T_('All users'), regenerate_url('action,results_colluser_page,keywords1,keywords2', 'action=edit'))));
/*
 * Grouping params:
 */
$Results->group_by = 'bloguser_ismember';
$Results->ID_col = 'user_ID';
/*
 * Group columns:
 */
$Results->grp_cols[] = array('td_colspan' => 0, 'td' => '~conditional( #bloguser_ismember#, \'' . TS_('Members') . '\', \'' . TS_('Non members') . '\' )~');
/*
 * Colmun definitions:
コード例 #17
0
 /**
  * Restrict by members
  *
  * @param boolean TRUE to select only member of the current Blog
  */
 function where_members($members)
 {
     global $DB, $Blog;
     if (empty($members) || is_admin_page() || empty($Blog) || $Blog->get_setting('allow_access') != 'members') {
         // Don't restrict
         return;
     }
     // Get blog owner
     $blogowner_SQL = new SQL();
     $blogowner_SQL->SELECT('user_ID');
     $blogowner_SQL->FROM('T_users');
     $blogowner_SQL->FROM_add('INNER JOIN T_blogs ON blog_owner_user_ID = user_ID');
     $blogowner_SQL->WHERE('blog_ID = ' . $DB->quote($Blog->ID));
     // Calculate what users are members of the blog
     $userperms_SQL = new SQL();
     $userperms_SQL->SELECT('user_ID');
     $userperms_SQL->FROM('T_users');
     $userperms_SQL->FROM_add('INNER JOIN T_coll_user_perms ON ( bloguser_user_ID = user_ID AND bloguser_ismember = 1 )');
     $userperms_SQL->WHERE('bloguser_blog_ID = ' . $DB->quote($Blog->ID));
     // Calculate what user groups are members of the blog
     $usergroups_SQL = new SQL();
     $usergroups_SQL->SELECT('user_ID');
     $usergroups_SQL->FROM('T_users');
     $usergroups_SQL->FROM_add('INNER JOIN T_groups ON grp_ID = user_grp_ID');
     $usergroups_SQL->FROM_add('LEFT JOIN T_coll_group_perms ON ( bloggroup_group_ID = grp_ID AND bloggroup_ismember = 1 )');
     $usergroups_SQL->WHERE('bloggroup_blog_ID = ' . $DB->quote($Blog->ID));
     $members_count_sql = 'SELECT DISTINCT user_ID FROM ( ' . $blogowner_SQL->get() . ' UNION ' . $userperms_SQL->get() . ' UNION ' . $usergroups_SQL->get() . ' ) members';
     $this->WHERE_and('user_ID IN ( ' . $members_count_sql . ' ) ');
 }
コード例 #18
0
ファイル: anon_async.php プロジェクト: Ariflaw/b2evolution
         // Restrict a wrong request
         debug_die('Wrong request');
     }
     // Add backslash for special char of sql operator LIKE
     $q = str_replace('_', '\\_', $q);
     if (utf8_strlen($q) == 0) {
         // Don't search logins with empty request
         $usernames = array();
     } else {
         $SQL = new SQL();
         $SQL->SELECT('user_login');
         $SQL->FROM('T_users');
         $SQL->WHERE('user_login LIKE ' . $DB->quote($q . '%'));
         $SQL->WHERE_and('user_status = "activated" OR user_status = "autoactivated"');
         $SQL->ORDER_BY('user_login');
         $usernames = $DB->get_col($SQL->get());
     }
     echo evo_json_encode($usernames);
     exit(0);
     // Exit here in order to don't display the AJAX debug info after JSON formatted data
     break;
 case 'get_user_salt':
     // Get the salt of the user from the given login info
     // Note: If there are more users with the received login then give at most 3 salt values for the 3 most recently active users
     // It always returns at least one salt value to show no difference between the existing and not existing user names
     $get_widget_login_hidden_fields = param('get_widget_login_hidden_fields', 'boolean', false);
     // Check that this action request is not a CSRF hacked request:
     if (!$get_widget_login_hidden_fields) {
         // If the request was received from the normal login form check the loginsalt crumb
         $Session->assert_received_crumb('loginsalt');
     }
コード例 #19
0
load_funcs('regional/model/_regional.funcs.php');
// Get params from request
$s = param('s', 'string', '', true);
// Create query
$SQL = new SQL();
$SQL->SELECT('ctry_ID, ctry_code, ctry_name, curr_shortcut, curr_code, ctry_enabled, ctry_preferred, ctry_status, ctry_block_count');
$SQL->FROM('T_regional__country');
$SQL->FROM_add('LEFT JOIN T_regional__currency ON ctry_curr_ID=curr_ID');
$SQL->ORDER_BY('*, ctry_code ASC');
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $SQL->WHERE('CONCAT_WS( " ", ctry_code, ctry_name, curr_code ) LIKE "%' . $DB->escape($s) . '%"');
}
// Create result set:
$Results = new Results($SQL->get(), 'ctry_', '-D');
$Results->title = T_('Countries') . get_manual_link('regional-countries-tab');
/*
 * STATUS TD:
 */
function ctry_td_enabled($ctry_enabled, $ctry_ID)
{
    $r = '';
    $redirect_ctrl = param('ctrl', 'string', 'countries');
    if ($ctry_enabled == true) {
        $r .= action_icon(T_('Disable the country!'), 'bullet_full', regenerate_url('ctrl,action', 'ctrl=countries&amp;action=disable_country&amp;ctry_ID=' . $ctry_ID . '&amp;redirect_ctrl=' . $redirect_ctrl . '&amp;' . url_crumb('country')));
    } else {
        $r .= action_icon(T_('Enable the country!'), 'bullet_empty', regenerate_url('ctrl,action', 'ctrl=countries&amp;action=enable_country&amp;ctry_ID=' . $ctry_ID . '&amp;redirect_ctrl=' . $redirect_ctrl . '&amp;' . url_crumb('country')));
    }
    return $r;
}
コード例 #20
0
 /**
  * Load members of a given blog
  *
  * @todo make a UNION query when we upgrade to MySQL 4
  * @param integer Blog ID to load members for
  * @param integer Limit, 0 - for unlimit
  */
 function load_blogmembers($blog_ID, $limit = 0)
 {
     global $DB, $Debuglog;
     if (isset($this->alreadyCached['blogmembers']) && isset($this->alreadyCached['blogmembers'][$blog_ID])) {
         $Debuglog->add("Already loaded <strong>{$this->objtype}(Blog #{$blog_ID} members)</strong> into cache", 'dataobjects');
         return false;
     }
     // Clear previous users to get only the members of this blog
     $this->clear();
     // Remember this special load:
     $this->alreadyCached['blogmembers'][$blog_ID] = true;
     $Debuglog->add("Loading <strong>{$this->objtype}(Blog #{$blog_ID} members)</strong> into cache", 'dataobjects');
     // Get users which are members of the blog:
     $user_perms_SQL = new SQL();
     $user_perms_SQL->SELECT('T_users.*');
     $user_perms_SQL->FROM('T_users');
     $user_perms_SQL->FROM_add('INNER JOIN T_coll_user_perms ON user_ID = bloguser_user_ID');
     $user_perms_SQL->WHERE('bloguser_blog_ID = ' . $DB->quote($blog_ID));
     $user_perms_SQL->WHERE_and('bloguser_ismember <> 0');
     // Get users which groups are members of the blog:
     $group_perms_SQL = new SQL();
     $group_perms_SQL->SELECT('T_users.*');
     $group_perms_SQL->FROM('T_users');
     $group_perms_SQL->FROM_add('INNER JOIN T_coll_group_perms ON user_grp_ID = bloggroup_group_ID');
     $group_perms_SQL->WHERE('bloggroup_blog_ID = ' . $DB->quote($blog_ID));
     $group_perms_SQL->WHERE_and('bloggroup_ismember <> 0');
     // Union two sql queries to execute one query and save an order as one list
     $users_sql = '( ' . $user_perms_SQL->get() . ' )' . ' UNION ' . '( ' . $group_perms_SQL->get() . ' )' . ' ORDER BY user_login';
     if ($limit > 0) {
         // Limit the users
         $users_sql .= ' LIMIT ' . $limit;
     }
     $users = $DB->get_results($users_sql);
     foreach ($users as $row) {
         if (!isset($this->cache[$row->user_ID])) {
             // Save reinstatiating User if it's already been added
             $this->add(new User($row));
         }
     }
     return true;
 }
コード例 #21
0
ファイル: _cronjob.class.php プロジェクト: ldanielz/uesp.blog
 /**
  * Get status
  *
  * @return string Status
  */
 function get_status()
 {
     global $DB;
     if ($this->ID > 0) {
         $SQL = new SQL('Get status of scheduled job');
         $SQL->SELECT('clog_status');
         $SQL->FROM('T_cron__log');
         $SQL->WHERE('clog_ctsk_ID = ' . $DB->quote($this->ID));
         $status = $DB->get_var($SQL->get());
     }
     if (empty($status)) {
         // Set default status for new cron jobs and for cron jobs without log
         $status = 'pending';
     }
     return $status;
 }
コード例 #22
0
ファイル: _misc.funcs.php プロジェクト: ldanielz/uesp.blog
/**
 * Check if the login is valid (user exists)
 *
 * @param string login
 * @return boolean true if OK
 */
function user_exists($login)
{
    global $DB;
    $SQL = new SQL();
    $SQL->SELECT('COUNT(*)');
    $SQL->FROM('T_users');
    $SQL->WHERE('user_login = "******"');
    $var = $DB->get_var($SQL->get());
    return $var > 0 ? true : false;
    // PHP4 compatibility
}
コード例 #23
0
ファイル: _phpbb.funcs.php プロジェクト: ldanielz/uesp.blog
/**
 * Display subforums to select what to import
 *
 * @param object Form
 * @param integer Category ID
 * @param integer Forum parent ID
 */
function phpbb_subforums_list(&$Form, $cat_id, $forum_parent_id = 0)
{
    global $phpbb_DB, $phpbb_subforums_list_level;
    // Get the forums from phpbb database
    $forums_SQL = new SQL();
    $forums_SQL->SELECT('f.forum_id, f.forum_name');
    $forums_SQL->FROM('BB_forums f');
    $forums_SQL->FROM_add('LEFT JOIN BB_categories c ON f.cat_id = c.cat_id');
    if ($cat_id > 0) {
        // Get all top forums of the category
        $forums_SQL->WHERE('f.cat_id = ' . $phpbb_DB->quote($cat_id));
        $forums_SQL->WHERE_AND('f.forum_parent = 0');
    } elseif ($forum_parent_id > 0) {
        // Get subforums
        $forums_SQL->WHERE('f.forum_parent = ' . $phpbb_DB->quote($forum_parent_id));
    } else {
        // Wrong a call of this function
        return;
    }
    $forums_SQL->ORDER_BY('c.cat_order, f.forum_order');
    $forums = $phpbb_DB->get_results($forums_SQL->get());
    if (count($forums) == 0) {
        return;
    }
    $phpbb_subforums_list_level++;
    // Group all subforums in one div
    echo '<div class="phpbb_forums_' . $cat_id . '_' . $forum_parent_id . '">';
    $import_forums = phpbb_get_var('import_forums');
    foreach ($forums as $forum) {
        // Display forums
        $Form->checkbox_input('phpbb_forums[]', !is_array($import_forums) || in_array($forum->forum_id, $import_forums), '', array('input_prefix' => '<label>', 'input_suffix' => ' ' . $forum->forum_name . '</label>', 'value' => $forum->forum_id, 'style' => 'margin-left:' . $phpbb_subforums_list_level * 20 . 'px'));
        phpbb_subforums_list($Form, 0, $forum->forum_id);
    }
    echo '</div>';
    $phpbb_subforums_list_level--;
}
コード例 #24
0
	</p>
	<?php 
}
/*
 * Query antispam blacklist:
 */
$keywords = param('keywords', 'string', '', true);
$SQL = new SQL();
$SQL->SELECT('aspm_ID, aspm_string, aspm_source');
$SQL->FROM('T_antispam');
if (!empty($keywords)) {
    $SQL->add_search_field('aspm_string');
    $SQL->WHERE_keywords($keywords, 'AND');
}
// Create result set:
$Results = new Results($SQL->get(), 'antispam_');
$Results->title = T_('Banned keywords blacklist');
/**
 * Callback to add filters on top of the result set
 *
 * @param Form
 */
function filter_antispam(&$Form)
{
    $Form->text('keywords', get_param('keywords'), 20, T_('Keywords'), T_('Separate with space'), 50);
}
$Results->filter_area = array('callback' => 'filter_antispam', 'url_ignore' => 'results_antispam_page,keywords', 'presets' => array('all' => array(T_('All keywords'), '?ctrl=antispam')));
/*
 * Column definitions:
 */
$Results->cols[] = array('th' => T_('Keyword'), 'order' => 'aspm_string', 'td' => '%htmlspecialchars(#aspm_string#)%');
コード例 #25
0
function contacts_groups($user_ID)
{
    global $current_User, $DB, $cache_user_contacts_groups;
    if (!is_array($cache_user_contacts_groups)) {
        // Execute only first time to init cache
        $cache_user_contacts_groups = array();
        // Get contacts of current user
        $groups_SQL = new SQL();
        $groups_SQL->SELECT('cgr_ID AS ID, cgu_user_ID AS user_ID, cgr_name AS name');
        $groups_SQL->FROM('T_messaging__contact_groupusers');
        $groups_SQL->FROM_add('LEFT JOIN T_messaging__contact_groups ON cgu_cgr_ID = cgr_ID');
        $groups_SQL->WHERE('cgr_user_ID = ' . $current_User->ID);
        $groups_SQL->ORDER_BY('cgr_name');
        $groups = $DB->get_results($groups_SQL->get());
        $remove_link = url_add_param(get_dispctrl_url('contacts'), 'action=remove_user&amp;view=contacts&amp;' . url_crumb('messaging_contacts'));
        foreach ($groups as $group) {
            // Init cache for groups for each contact of current user
            $group_name = $group->name . action_icon(T_('Remove user from this group'), 'remove', url_add_param($remove_link, 'user_ID=' . $group->user_ID . '&amp;group_ID=' . $group->ID));
            if (isset($cache_user_contacts_groups[$group->user_ID])) {
                // nth group of this user
                $cache_user_contacts_groups[$group->user_ID] .= '<br />' . $group_name;
            } else {
                // first group of this user
                $cache_user_contacts_groups[$group->user_ID] = $group_name;
            }
        }
    }
    if (isset($cache_user_contacts_groups[$user_ID])) {
        // user has groups
        echo $cache_user_contacts_groups[$user_ID];
    }
}
コード例 #26
0
ファイル: _comment.class.php プロジェクト: ldanielz/uesp.blog
 /**
  * Check if comment has the replies
  */
 function has_replies()
 {
     global $cache_comments_has_replies;
     if (!isset($cache_comments_has_replies)) {
         // Init an array to cache
         $cache_comments_has_replies = array();
     }
     if (!isset($cache_comments_has_replies[$this->item_ID])) {
         // Get all comments that have the replies from DB (first time)
         global $DB;
         // Cache a result
         $SQL = new SQL();
         $SQL->SELECT('DISTINCT ( comment_in_reply_to_cmt_ID ), comment_ID');
         $SQL->FROM('T_comments');
         $SQL->WHERE('comment_in_reply_to_cmt_ID IS NOT NULL');
         $SQL->WHERE_and('comment_post_ID = ' . $this->item_ID);
         // Init an array to cache a result from current item
         $cache_comments_has_replies[$this->item_ID] = $DB->get_assoc($SQL->get());
     }
     // Get a result from cache
     return isset($cache_comments_has_replies[$this->item_ID][$this->ID]);
 }
コード例 #27
0
}
if ($r > 0) {
    // Filter by region:
    $sql_where[] = 'rgn_ID = "' . $DB->escape($r) . '"';
}
if ($sr > 0) {
    // Filter by sub-region:
    $sql_where[] = 'subrg_ID = "' . $DB->escape($sr) . '"';
}
if (count($sql_where) > 0) {
    // Some filters are applied
    $SQL->WHERE(implode(' AND ', $sql_where));
}
// Create result set:
//echo $SQL->get();
$Results = new Results($SQL->get(), 'city_', '-----A');
$Results->title = T_('Cities') . get_manual_link('countries_list');
/*
 * STATUS TD:
 */
function city_td_enabled($city_enabled, $city_ID)
{
    global $dispatcher;
    $r = '';
    if ($city_enabled == true) {
        $r .= action_icon(T_('Disable the city!'), 'bullet_full', regenerate_url('action', 'action=disable_city&amp;city_ID=' . $city_ID . '&amp;' . url_crumb('city')));
    } else {
        $r .= action_icon(T_('Enable the city!'), 'bullet_empty', regenerate_url('action', 'action=enable_city&amp;city_ID=' . $city_ID . '&amp;' . url_crumb('city')));
    }
    return $r;
}
コード例 #28
0
ファイル: _cron.funcs.php プロジェクト: Ariflaw/b2evolution
/**
 * Detect timed out cron jobs and Send notifications
 *
 * @param array Task with error
 *             'name'
 *             'message'
 */
function detect_timeout_cron_jobs($error_task = NULL)
{
    global $DB, $time_difference, $cron_timeout_delay, $admin_url;
    $SQL = new SQL('Find cron timeouts');
    $SQL->SELECT('ctsk_ID, ctsk_name, ctsk_key');
    $SQL->FROM('T_cron__log');
    $SQL->FROM_add('INNER JOIN T_cron__task ON ctsk_ID = clog_ctsk_ID');
    $SQL->WHERE('clog_status = "started"');
    $SQL->WHERE_and('clog_realstart_datetime < ' . $DB->quote(date2mysql(time() + $time_difference - $cron_timeout_delay)));
    $SQL->GROUP_BY('ctsk_ID');
    $timeout_tasks = $DB->get_results($SQL->get(), OBJECT, $SQL->title);
    $tasks = array();
    if (count($timeout_tasks) > 0) {
        $cron_jobs_names = get_cron_jobs_config('name');
        foreach ($timeout_tasks as $timeout_task) {
            if (!empty($timeout_task->ctsk_name)) {
                // Task name is defined in DB
                $task_name = $timeout_task->ctsk_name;
            } else {
                // Try to get default task name by key:
                $task_name = isset($cron_jobs_names[$timeout_task->ctsk_key]) ? $cron_jobs_names[$timeout_task->ctsk_key] : $timeout_task->ctsk_key;
            }
            $tasks[$timeout_task->ctsk_ID] = array('name' => $task_name, 'message' => NT_('Cron job has timed out.'));
        }
        // Update timed out cron jobs:
        $DB->query('UPDATE T_cron__log
			  SET clog_status = "timeout"
			WHERE clog_ctsk_ID IN ( ' . $DB->quote(array_keys($tasks)) . ' )', 'Mark timeouts in cron jobs.');
    }
    if (!is_null($error_task)) {
        // Send notification with error task
        $tasks[$error_task['ID']] = $error_task;
    }
    if (count($tasks) > 0) {
        // Send notification email about timed out and error cron jobs to users with edit options permission
        $email_template_params = array('tasks' => $tasks);
        send_admin_notification(NT_('Scheduled task error'), 'scheduled_task_error_report', $email_template_params);
    }
}
コード例 #29
0
 *
 * @version $Id: _skin_list.view.php 3328 2013-03-26 11:44:11Z yura $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// Create result set:
$SQL = new SQL();
$SQL->SELECT('T_skins__skin.*, COUNT( DISTINCT( cset_coll_ID ) ) AS nb_blogs');
$SQL->FROM('T_skins__skin LEFT JOIN T_coll_settings ON skin_ID = cset_value AND
			( cset_name = "normal_skin_ID" OR cset_name = "mobile_skin_ID" OR cset_name = "tablet_skin_ID" )');
$SQL->GROUP_BY('skin_ID');
$CountSQL = new SQL();
$CountSQL->SELECT('COUNT( * )');
$CountSQL->FROM('T_skins__skin');
$Results = new Results($SQL->get(), 'skin_', '', NULL, $CountSQL->get());
$Results->Cache =& get_SkinCache();
$Results->title = T_('Installed skins') . get_manual_link('installed_skins');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong><a href="' . regenerate_url('', 'skin_ID=$skin_ID$&amp;action=edit') . '" title="' . TS_('Edit skin properties...') . '">$skin_name$</a></strong>');
} else {
    // We have NO permission to modify:
    $Results->cols[] = array('th' => T_('Name'), 'order' => 'skin_name', 'td' => '<strong>$skin_name$</strong>');
}
$Results->cols[] = array('th' => T_('Skin type'), 'order' => 'skin_type', 'td_class' => 'center', 'td' => '$skin_type$');
$Results->cols[] = array('th' => T_('Blogs'), 'order' => 'nb_blogs', 'th_class' => 'shrinkwrap', 'td_class' => 'center', 'td' => '~conditional( (#nb_blogs# > 0), #nb_blogs#, \'&nbsp;\' )~');
$Results->cols[] = array('th' => T_('Skin Folder'), 'order' => 'skin_folder', 'td' => '$skin_folder$');
if ($current_User->check_perm('options', 'edit', false)) {
    // We have permission to modify:
    $Results->cols[] = array('th' => T_('Actions'), 'th_class' => 'shrinkwrap', 'td_class' => 'shrinkwrap', 'td' => action_icon(TS_('Edit skin properties...'), 'properties', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=edit\')%') . action_icon(TS_('Reload containers!'), 'reload', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=reload&amp;' . url_crumb('skin') . '\')%') . '~conditional( #nb_blogs# < 1, \'' . action_icon(TS_('Uninstall this skin!'), 'delete', '%regenerate_url( \'\', \'skin_ID=$skin_ID$&amp;action=delete&amp;' . url_crumb('skin') . '\')%') . '\', \'' . get_icon('delete', 'noimg') . '\' )~');
コード例 #30
0
$sql_where = array();
if (!empty($s)) {
    // We want to filter on search keyword:
    // Note: we use CONCAT_WS (Concat With Separator) because CONCAT returns NULL if any arg is NULL
    $sql_where[] = 'CONCAT_WS( " ", rgn_code, rgn_name ) LIKE "%' . $DB->escape($s) . '%"';
}
if ($c > 0) {
    // We want to filter on search country:
    $sql_where[] = 'rgn_ctry_ID = "' . $DB->escape($c) . '"';
}
if (count($sql_where) > 0) {
    // Some filters are applied
    $SQL->WHERE(implode(' AND ', $sql_where));
}
// Create result set:
$Results = new Results($SQL->get(), 'rgn_', '----A');
$Results->title = T_('Regions/States') . get_manual_link('countries_list');
/*
 * STATUS TD:
 */
function rgn_td_enabled($rgn_enabled, $rgn_ID)
{
    global $dispatcher;
    $r = '';
    if ($rgn_enabled == true) {
        $r .= action_icon(T_('Disable the region!'), 'bullet_full', regenerate_url('action', 'action=disable_region&amp;rgn_ID=' . $rgn_ID . '&amp;' . url_crumb('region')));
    } else {
        $r .= action_icon(T_('Enable the region!'), 'bullet_empty', regenerate_url('action', 'action=enable_region&amp;rgn_ID=' . $rgn_ID . '&amp;' . url_crumb('region')));
    }
    return $r;
}