Example #1
0
/**
 * Completely recount the board statistics (useful if they become out of sync)
 */
function rebuild_stats()
{
    global $db;
    $query = $db->simple_select("forums", "SUM(threads) AS numthreads");
    $stats['numthreads'] = $db->fetch_field($query, 'numthreads');
    if (!$stats['numthreads']) {
        $stats['numthreads'] = 0;
    }
    $query = $db->simple_select("forums", "SUM(posts) AS numposts");
    $stats['numposts'] = $db->fetch_field($query, 'numposts');
    if (!$stats['numposts']) {
        $stats['numposts'] = 0;
    }
    $query = $db->simple_select("forums", "SUM(unapprovedthreads) AS numunapprovedthreads");
    $stats['numunapprovedthreads'] = $db->fetch_field($query, 'numunapprovedthreads');
    if (!$stats['numunapprovedthreads']) {
        $stats['numunapprovedthreads'] = 0;
    }
    $query = $db->simple_select("forums", "SUM(unapprovedposts) AS numunapprovedposts");
    $stats['numunapprovedposts'] = $db->fetch_field($query, 'numunapprovedposts');
    if (!$stats['numunapprovedposts']) {
        $stats['numunapprovedposts'] = 0;
    }
    $query = $db->simple_select("users", "COUNT(uid) AS users");
    $stats['numusers'] = $db->fetch_field($query, 'users');
    if (!$stats['numusers']) {
        $stats['numusers'] = 0;
    }
    update_stats($stats);
}
/**
 * Completely recount the board statistics (useful if they become out of sync)
 */
function rebuild_stats()
{
    global $db;
    $query = $db->simple_select("forums", "SUM(threads) AS numthreads, SUM(posts) AS numposts, SUM(unapprovedthreads) AS numunapprovedthreads, SUM(unapprovedposts) AS numunapprovedposts, SUM(deletedthreads) AS numdeletedthreads, SUM(deletedposts) AS numdeletedposts");
    $stats = $db->fetch_array($query);
    $query = $db->simple_select("users", "COUNT(uid) AS users");
    $stats['numusers'] = $db->fetch_field($query, 'users');
    update_stats($stats, true);
}
Example #3
0
function on_before_delete_blog_post()
{
    global $dbtable_prefix, $post_ids;
    require_once _BASEPATH_ . '/includes/classes/fileop.class.php';
    $fileop = new fileop();
    $query = "SELECT `post_id`,`fk_blog_id`,`fk_user_id`,UNIX_TIMESTAMP(`date_posted`) as `date_posted` FROM `{$dbtable_prefix}blog_posts` WHERE `post_id` IN ('" . join("','", $post_ids) . "')";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $blog_ids = array();
    $user_ids = array();
    $dates = array();
    while ($rsrow = mysql_fetch_assoc($res)) {
        if (isset($blog_ids[$rsrow['fk_blog_id']])) {
            --$blog_ids[$rsrow['fk_blog_id']];
        } else {
            $blog_ids[$rsrow['fk_blog_id']] = -1;
        }
        if (isset($user_ids[$rsrow['fk_user_id']])) {
            --$user_ids[$rsrow['fk_user_id']];
        } else {
            $user_ids[$rsrow['fk_user_id']] = -1;
        }
        $dates[$rsrow['fk_blog_id']][] = $rsrow['date_posted'];
    }
    foreach ($blog_ids as $bid => $num) {
        // blog stats
        $bid = (string) $bid;
        $query = "UPDATE `{$dbtable_prefix}user_blogs` SET `stat_posts`=`stat_posts`+{$num} WHERE `blog_id`={$bid}";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        // blog_archive
        $blog_archive = array();
        if (is_file(_CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php')) {
            include _CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php';
        }
        for ($i = 0; isset($dates[$bid][$i]); ++$i) {
            $year = (int) date('Y', $dates[$bid][$i]);
            $month = (int) date('m', $dates[$bid][$i]);
            if (isset($blog_archive[$year][$month])) {
                --$blog_archive[$year][$month];
            }
            if (empty($blog_archive[$year][$month])) {
                unset($blog_archive[$year][$month]);
            }
        }
        krsort($blog_archive, SORT_NUMERIC);
        $towrite = '<?php $blog_archive=' . var_export($blog_archive, true) . ';';
        $fileop->file_put_contents(_CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php', $towrite);
    }
    foreach ($user_ids as $uid => $num) {
        update_stats($uid, 'blog_posts', $num);
        add_member_score($uid, 'del_blog', -$num);
        // -$num because $num is already negative.
    }
}
Example #4
0
function parse_csv_sheet($xls = null, $csv_id = 0)
{
    //oks
    $csv_err = sprintf("%s.err", $xls);
    //new load
    $objPHPExcel = PHPExcel_IOFactory::load($xls);
    $sheets = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true);
    debug("INFO", "CSV-save( {$csvX} ) ->CSV-ID> {$csv_id}");
    //format the CSV here
    $csv_stats = array();
    foreach ($sheets as $csvK => $csvV) {
        $csvX++;
        debug("INFO", "CSV-save( {$csvX} ) -> raw line> " . @var_export($csvV, true));
        if (@is_array($csvV)) {
            $csvcols = array();
            //xls fmt
            if (0) {
                $alltotA = @count($csvV);
                if ($alltotA >= MAX_CSV_COLS) {
                    $csvcols = $csvV;
                    debug("INFO", "CSV-save( {$csvX} ) -> A-tot={$alltotB}; !");
                }
            }
            //pipe delimited
            $csvcols = @explode("|", $csvV["A"]);
            //ignore header
            if (@preg_match("/operator_code/i", $csvcols[1])) {
                debug("INFO", "CSV-save( {$csvX} ) -> header is ignored!" . $csvcols[0]);
                continue;
            }
            //all total
            $csv_stats['total']++;
            $alltotC = @count($csvcols);
            debug("INFO", "CSV-save( {$csvX} ) -> C-tot={$alltotC}; !");
            if ($alltotC < MAX_CSV_COLS) {
                $csv_stats['error']++;
                //err log
                $err_row = @join("|", $csvcols);
                utils_io_file_save($csv_err, "{$err_row}\n", "a+");
                debug("INFO", "CSV-save( {$csvX} ) -> record total is below as expected! {$alltotC};{$err_row}");
                continue;
            }
            //clean ?
            foreach ($csvcols as $k1 => $v1) {
                $v2 = $csvcols[$k1];
                $v2 = @preg_replace('/^"/', '', $v2);
                $v2 = @preg_replace('/"$/', '', $v2);
                $csvcols[$k1] = $v2;
            }
            //loop it here
            $xdata = null;
            $xdata["trafficrecap_id"] = $csvcols[0];
            $xdata["operator_code"] = $csvcols[1];
            $xdata["traffic_code"] = $csvcols[2];
            $xdata["job_id"] = $csvcols[3];
            $xdata["station_code"] = $csvcols[4];
            $xdata["dateshift"] = $csvcols[5];
            $xdata["shift_code"] = $csvcols[6];
            $xdata["user_code"] = $csvcols[7];
            $xdata["state"] = $csvcols[8];
            $xdata["cardtype"] = $csvcols[9];
            $xdata["manless"] = $csvcols[10];
            $xdata["member"] = $csvcols[11];
            $xdata["seccodeval"] = $csvcols[12];
            $xdata["status_id"] = $csvcols[13];
            $xdata["totalvalue"] = $csvcols[14];
            $xdata["totalvaluefine"] = $csvcols[15];
            $xdata["totalvalueest"] = $csvcols[16];
            $xdata["payment_code"] = $csvcols[17];
            $xdata["totalqty"] = $csvcols[18];
            $xdata["action_id"] = $csvcols[19];
            $xdata["useradd"] = $csvcols[20];
            $xdata["usermod"] = $csvcols[21];
            $xdata["userdel"] = $csvcols[22];
            $xdata["dateadd"] = $csvcols[23];
            $xdata["datemod"] = $csvcols[24];
            $xdata["datedel"] = $csvcols[25];
            $xdata["flag_id"] = $csvcols[26];
            $xdata["seccodetype"] = $csvcols[27];
            $xdata["traffic_name"] = $csvcols[28];
            $xdata["typetraffic_code"] = $csvcols[29];
            $xdata["member_code"] = $csvcols[30];
            $xdata["product_code"] = $csvcols[31];
            $xdata["csv_id"] = $csv_id;
            //save rec
            $pret = saveTraffic($xdata);
            if (!$pret) {
                //err log
                $err_row = @join("|", $csvcols);
                utils_io_file_save($csv_err, "{$err_row}\n", "a+");
                debug("INFO", "CSV-save() -> ignored >{$err_row} ");
                $csv_stats['error']++;
                continue;
            }
            $csv_stats['success']++;
        }
        //if arr
    }
    //for sheets
    //hit the total parsed
    $ydata["id"] = $csv_id;
    $ydata["tot"] = intval($csv_stats['total']);
    $ydata["oks"] = intval($csv_stats['success']);
    $ydata["err"] = intval($csv_stats['error']);
    $pret = update_stats($ydata);
    $dmp = @var_export($ydata, true);
    debug("INFO", "CSV-save() STATS-> {$dmp} !");
    /*
    	$CSV_STATUS_ARR  = array(
    	'0'    => 'Pending',
    	'1'    => 'Processing',
    	'2'    => 'Processed',
    	'3'    => 'Zero Rows',
    	'9'    => 'Failed',
    	);
    */
    //update status to 2
    $csv_status = 2;
    $csv_mesg = "Successfully processed!";
    //no-rows
    if ($ydata["oks"] <= 0 and $ydata["tot"] > 0) {
        $csv_status = 3;
        $csv_mesg = "No valid rows found!";
    }
    //fail
    if ($ydata["oks"] <= 0 and $ydata["tot"] <= 0) {
        $csv_status = 9;
        $csv_mesg = "Failed to parse!";
    }
    //update it now
    $upd = set_csv_summary(array('id' => $csv_id, 'status' => $csv_status, 'desc' => $csv_mesg));
}
Example #5
0
 /**
  * Delete a user in the database
  *
  * @param integer|string $user User ID or username
  * @return boolean
  */
 function removeUser($user)
 {
     // If no ID is given, we check if there is a user with the specified username
     if (!is_numeric($user)) {
         $query = $this->db->simple_select('users', 'uid', 'username=\'' . $this->dbEscape($user) . '\'');
         $user_id = $this->db->fetch_field($query, 'uid', 0);
         // User does not exist? --> False
         if (empty($user_id)) {
             return false;
         }
         $user_id = intval($user_id);
     } else {
         $user_id = intval($user);
     }
     $this->plugins->run_hooks('admin_user_users_delete');
     // Delete the user
     $this->db->update_query("posts", array('uid' => 0), "uid='{$user_id}'");
     $this->db->delete_query("userfields", "ufid='{$user_id}'");
     $this->db->delete_query("privatemessages", "uid='{$user_id}'");
     $this->db->delete_query("events", "uid='{$user_id}'");
     $this->db->delete_query("moderators", "uid='{$user_id}'");
     $this->db->delete_query("forumsubscriptions", "uid='{$user_id}'");
     $this->db->delete_query("threadsubscriptions", "uid='{$user_id}'");
     $this->db->delete_query("sessions", "uid='{$user_id}'");
     $this->db->delete_query("banned", "uid='{$user_id}'");
     $this->db->delete_query("threadratings", "uid='{$user_id}'");
     $this->db->delete_query("users", "uid='{$user_id}'");
     $this->db->delete_query("joinrequests", "uid='{$user_id}'");
     $this->db->delete_query("warnings", "uid='{$user_id}'");
     // Update forum stats
     update_stats(array('numusers' => '-1'));
     $this->plugins->run_hooks('admin_user_users_delete_commit');
     return true;
 }
Example #6
0
             $fids[] = $fid;
         }
         $fids_not_in = '';
         if (!empty($fids)) {
             $fids_not_in = "AND fid NOT IN(" . implode(',', $fids) . ")";
         }
         // Update user post count
         $query = $db->simple_select("posts", "COUNT(*) AS postnum", "uid='" . $destination_user['uid'] . "' {$fids_not_in}");
         $num = $db->fetch_array($query);
         $updated_count = array("postnum" => $num['postnum']);
         $db->update_query("users", $updated_count, "uid='{$destination_user['uid']}'");
         // Use the earliest registration date
         if ($destination_user['regdate'] > $source_user['regdate']) {
             $db->update_query("users", array('regdate' => $source_user['regdate']), "uid='{$destination_user['uid']}'");
         }
         update_stats(array('numusers' => '-1'));
         $plugins->run_hooks("admin_user_users_merge_commit");
         // Log admin action
         log_admin_action($source_user['uid'], $source_user['username'], $destination_user['uid'], $destination_user['username']);
         // Redirect!
         flash_message("<strong>{$source_user['username']}</strong> {$lang->success_merged} {$destination_user['username']}", "success");
         admin_redirect("index.php?module=user/users");
         exit;
     }
 }
 $page->add_breadcrumb_item($lang->merge_users);
 $page->output_header($lang->merge_users);
 $page->output_nav_tabs($sub_tabs, 'merge_users');
 // If we have any error messages, show them
 if ($errors) {
     $page->output_inline_error($errors);
Example #7
0
 /**
  * Provides a method to completely delete a user.
  *
  * @param array Array of user information
  * @param integer Whether if delete threads/posts or not
  * @return boolean True when successful, false if fails
  */
 function delete_user($delete_uids, $prunecontent = 0)
 {
     global $db, $plugins, $mybb, $cache;
     // Yes, validating is required.
     if (count($this->get_errors()) > 0) {
         die('The user is not valid.');
     }
     $this->delete_uids = array_map('intval', (array) $delete_uids);
     foreach ($this->delete_uids as $key => $uid) {
         if (!$uid || is_super_admin($uid) || $uid == $mybb->user['uid']) {
             // Remove super admins
             unset($this->delete_uids[$key]);
         }
     }
     $plugins->run_hooks('datahandler_user_delete_start', $this);
     $this->delete_uids = implode(',', $this->delete_uids);
     $this->delete_content();
     // Delete the user
     $query = $db->delete_query('users', "uid IN({$this->delete_uids})");
     $this->deleted_users = $db->affected_rows($query);
     // Are we removing the posts/threads of a user?
     if ((int) $prunecontent == 1) {
         $this->delete_posts();
     } else {
         // We're just updating the UID
         $db->update_query('posts', array('uid' => 0), "uid IN({$this->delete_uids})");
         $db->update_query('threads', array('uid' => 0), "uid IN({$this->delete_uids})");
     }
     // Update thread ratings
     $query = $db->query("\n\t\t\tSELECT r.*, t.numratings, t.totalratings\n\t\t\tFROM " . TABLE_PREFIX . "threadratings r\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=r.tid)\n\t\t\tWHERE r.uid IN({$this->delete_uids})\n\t\t");
     while ($rating = $db->fetch_array($query)) {
         $update_thread = array("numratings" => $rating['numratings'] - 1, "totalratings" => $rating['totalratings'] - $rating['rating']);
         $db->update_query("threads", $update_thread, "tid='{$rating['tid']}'");
     }
     $db->delete_query('threadratings', "uid IN({$this->delete_uids})");
     // Update forums & threads if user is the lastposter
     $db->update_query('forums', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");
     $db->update_query('threads', array('lastposteruid' => 0), "lastposteruid IN({$this->delete_uids})");
     $cache->update_banned();
     $cache->update_moderators();
     // Update forum stats
     update_stats(array('numusers' => '-' . $this->deleted_users));
     $this->return_values = array("deleted_users" => $this->deleted_users);
     // Update reports cache
     $cache->update_reportedcontent();
     $cache->update_awaitingactivation();
     $plugins->run_hooks("datahandler_user_delete_end", $this);
     return $this->return_values;
 }
Example #8
0
    $topass['message']['text'] = $GLOBALS['_lang'][7];
    redirect2page('info.php', $topass);
}
$output['lang_273'] = sanitize_and_format($GLOBALS['_lang'][273], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_274'] = sanitize_and_format($GLOBALS['_lang'][274], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['lang_256'] = sanitize_and_format($GLOBALS['_lang'][256], TYPE_STRING, $__field2format[TEXT_DB2DISPLAY]);
$output['return2me'] = 'profile.php';
if (!empty($_SERVER['QUERY_STRING'])) {
    $output['return2me'] .= '?' . $_SERVER['QUERY_STRING'];
}
$output['return2me'] = rawurlencode($output['return2me']);
$tpl->set_file('content', 'profile.html');
$tpl->set_var('output', $output);
$tpl->set_var('tplvars', $tplvars);
$tpl->set_loop('categs', $categs);
$tpl->set_loop('user_photos', $user_photos);
$tpl->set_loop('loop_comments', $loop_comments);
$tpl->set_loop('loop_friends', $loop_friends);
$tpl->process('content', 'content', TPL_LOOP | TPL_NOLOOP | TPL_OPTLOOP | TPL_OPTIONAL);
$tpl->drop_loop('categs');
$tpl->drop_loop('user_photos');
unset($categs);
unset($user_photos);
$tplvars['page'] = 'profile';
$tplvars['css'] = 'profile.css';
if (is_file('profile_left.php')) {
    include 'profile_left.php';
}
include 'frame.php';
update_stats($uid, 'pviews', 1);
add_member_score($uid, 'pview');
Example #9
0
    if ($invite_emails != "") {
        send_systememail('invite', $invite_emails, array($new_user->user_displayname, $new_user->user_info['user_email'], $invite_message, "<a href=\"" . $url->url_base . "signupon13.php\">" . $url->url_base . "signupon13.php</a>"), TRUE);
    }
    // SEND USER TO THANK YOU PAGE
    $task = "step5";
}
// SIGNUP TERMINAL VELOCITY POINT HOOK
($hook = SE_Hook::exists('se_signup_decide')) ? SE_Hook::call($hook, array()) : NULL;
// SHOW COMPLETION PAGE
if ($task == "step5") {
    // UNSET SIGNUP COOKIES
    setcookie("signup_id", "", 0, "/");
    setcookie("signup_email", "", 0, "/");
    setcookie("signup_password", "", 0, "/");
    // UPDATE SIGNUP STATS
    update_stats("signups");
    // DISPLAY THANK YOU
    $step = 5;
}
// SHOW FOURTH STEP
if ($task == "step4") {
    $step = 4;
    $next_task = "step4do";
    if ($setting['setting_signup_invitepage'] == 0) {
        $task = "step3";
    }
}
// SHOW THIRD STEP
if ($task == "step3") {
    $step = 3;
    $next_task = "step3do";
Example #10
0
function on_after_approve_comment()
{
    global $dbtable_prefix, $comment_ids, $comment_type, $__field2format;
    switch ($comment_type) {
        case 'blog':
            $table = "`{$dbtable_prefix}comments_blog`";
            $parent_table = "`{$dbtable_prefix}blog_posts`";
            $parent_key = "`post_id`";
            break;
        case 'photo':
            $table = "`{$dbtable_prefix}comments_photo`";
            $parent_table = "`{$dbtable_prefix}user_photos`";
            $parent_key = "`photo_id`";
            break;
        case 'user':
            $table = "`{$dbtable_prefix}comments_profile`";
            $parent_table = "`{$dbtable_prefix}user_profiles`";
            $parent_key = "`fk_user_id`";
            break;
    }
    // only for new comments (because of the processed=0)
    $query = "SELECT a.`comment_id`,a.`_user` as `comment_poster`,a.`fk_parent_id`,a.`fk_user_id`,b.`fk_user_id` as `fk_parent_owner_id` FROM {$table} a,{$parent_table} b WHERE a.`comment_id` IN ('" . join("','", $comment_ids) . "') AND a.`fk_parent_id`=b.{$parent_key} AND a.`processed`=0";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $comment_ids = array();
    // yup
    $parent_ids = array();
    $user_ids = array();
    $parent_owner_ids = array();
    $notifs = array();
    while ($rsrow = mysql_fetch_assoc($res)) {
        $comment_ids[] = $rsrow['comment_id'];
        // get only the not processed ones
        if (isset($parent_ids[$rsrow['fk_parent_id']])) {
            ++$parent_ids[$rsrow['fk_parent_id']];
        } else {
            $parent_ids[$rsrow['fk_parent_id']] = 1;
        }
        if (isset($user_ids[$rsrow['fk_user_id']])) {
            ++$user_ids[$rsrow['fk_user_id']];
        } else {
            $user_ids[$rsrow['fk_user_id']] = 1;
        }
        if ($rsrow['fk_parent_owner_id'] != $rsrow['fk_user_id']) {
            if (!isset($notifs[$rsrow['fk_parent_owner_id']])) {
                $notifs[$rsrow['fk_parent_owner_id']]['comment_poster'] = $rsrow['comment_poster'];
                $notifs[$rsrow['fk_parent_owner_id']]['comment_id'] = $rsrow['comment_id'];
                $notifs[$rsrow['fk_parent_owner_id']]['parent_id'] = $rsrow['fk_parent_id'];
            }
            if (isset($parent_owner_ids[$rsrow['fk_parent_owner_id']])) {
                ++$parent_owner_ids[$rsrow['fk_parent_owner_id']];
            } else {
                $parent_owner_ids[$rsrow['fk_parent_owner_id']] = 1;
            }
        }
    }
    // increment the number of comments of the item(s)
    if ($comment_type != 'user') {
        foreach ($parent_ids as $pid => $num) {
            $query = "UPDATE {$parent_table} SET `stat_comments`=`stat_comments`+{$num} WHERE {$parent_key}='{$pid}'";
            if (!($res = @mysql_query($query))) {
                trigger_error(mysql_error(), E_USER_ERROR);
            }
        }
    } else {
        foreach ($parent_ids as $pid => $num) {
            update_stats($pid, 'profile_comments', $num);
        }
    }
    // add the "received_comment" score to the owner of the item
    foreach ($parent_owner_ids as $uid => $num) {
        if (!empty($uid)) {
            add_member_score($uid, 'received_comment', $num);
        }
    }
    // add the "comments_made" score to the poster of the comment
    foreach ($user_ids as $uid => $num) {
        if (!empty($uid)) {
            update_stats($uid, 'comments_made', $num);
        }
    }
    // mark the posted comment(s) as not new anymore so we won't process them again next time.
    if (!empty($comment_ids)) {
        $query = "UPDATE {$table} SET `processed`=1 WHERE `comment_id` IN ('" . join("','", $comment_ids) . "')";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
    }
    // send notifications to item owners.
    foreach ($notifs as $uid => $v) {
        $notification['fk_user_id'] = $uid;
        $notification['message_type'] = MESS_SYSTEM;
        switch ($comment_type) {
            case 'blog':
                $notification['subject'] = sanitize_and_format($GLOBALS['_lang'][160], TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                $notification['message_body'] = sanitize_and_format(sprintf($GLOBALS['_lang'][161], $v['comment_poster'], $v['parent_id'], $v['comment_id']), TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                break;
            case 'photo':
                $notification['subject'] = sanitize_and_format($GLOBALS['_lang'][162], TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                $notification['message_body'] = sanitize_and_format(sprintf($GLOBALS['_lang'][163], $v['comment_poster'], $v['parent_id'], $v['comment_id']), TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                break;
            case 'user':
                $notification['subject'] = sanitize_and_format($GLOBALS['_lang'][164], TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                $notification['message_body'] = sanitize_and_format(sprintf($GLOBALS['_lang'][165], $v['comment_poster'], $v['comment_id']), TYPE_STRING, $__field2format[FIELD_TEXTFIELD]);
                break;
        }
        queue_or_send_message($notification);
    }
}
Example #11
0
 /**
  * Updates a user in the database.
  */
 function update_user()
 {
     global $db, $plugins, $cache;
     // Yes, validating is required.
     if (!$this->get_validated()) {
         die("The user needs to be validated before inserting it into the DB.");
     }
     if (count($this->get_errors()) > 0) {
         die("The user is not valid.");
     }
     $user =& $this->data;
     $user['uid'] = intval($user['uid']);
     $this->uid = $user['uid'];
     // Set up the update data.
     if (isset($user['username'])) {
         $this->user_update_data['username'] = $db->escape_string($user['username']);
     }
     if (isset($user['saltedpw'])) {
         $this->user_update_data['password'] = $user['saltedpw'];
         $this->user_update_data['salt'] = $user['salt'];
         $this->user_update_data['loginkey'] = $user['loginkey'];
     }
     if (isset($user['email'])) {
         $this->user_update_data['email'] = $user['email'];
     }
     if (isset($user['postnum'])) {
         $this->user_update_data['postnum'] = intval($user['postnum']);
     }
     if (isset($user['avatar'])) {
         $this->user_update_data['avatar'] = $db->escape_string($user['avatar']);
         $this->user_update_data['avatartype'] = $db->escape_string($user['avatartype']);
     }
     if (isset($user['usergroup'])) {
         $this->user_update_data['usergroup'] = intval($user['usergroup']);
     }
     if (isset($user['additionalgroups'])) {
         $this->user_update_data['additionalgroups'] = $db->escape_string($user['additionalgroups']);
     }
     if (isset($user['displaygroup'])) {
         $this->user_update_data['displaygroup'] = intval($user['displaygroup']);
     }
     if (isset($user['usertitle'])) {
         $this->user_update_data['usertitle'] = $db->escape_string(htmlspecialchars_uni($user['usertitle']));
     }
     if (isset($user['regdate'])) {
         $this->user_update_data['regdate'] = intval($user['regdate']);
     }
     if (isset($user['lastactive'])) {
         $this->user_update_data['lastactive'] = intval($user['lastactive']);
     }
     if (isset($user['lastvisit'])) {
         $this->user_update_data['lastvisit'] = intval($user['lastvisit']);
     }
     if (isset($user['signature'])) {
         $this->user_update_data['signature'] = $db->escape_string($user['signature']);
     }
     if (isset($user['website'])) {
         $this->user_update_data['website'] = $db->escape_string(htmlspecialchars_uni($user['website']));
     }
     if (isset($user['icq'])) {
         $this->user_update_data['icq'] = intval($user['icq']);
     }
     if (isset($user['aim'])) {
         $this->user_update_data['aim'] = $db->escape_string(htmlspecialchars_uni($user['aim']));
     }
     if (isset($user['yahoo'])) {
         $this->user_update_data['yahoo'] = $db->escape_string(htmlspecialchars_uni($user['yahoo']));
     }
     if (isset($user['msn'])) {
         $this->user_update_data['msn'] = $db->escape_string(htmlspecialchars_uni($user['msn']));
     }
     if (isset($user['bday'])) {
         $this->user_update_data['birthday'] = $user['bday'];
     }
     if (isset($user['birthdayprivacy'])) {
         $this->user_update_data['birthdayprivacy'] = $db->escape_string($user['birthdayprivacy']);
     }
     if (isset($user['style'])) {
         $this->user_update_data['style'] = intval($user['style']);
     }
     if (isset($user['timezone'])) {
         $this->user_update_data['timezone'] = $db->escape_string($user['timezone']);
     }
     if (isset($user['dateformat'])) {
         $this->user_update_data['dateformat'] = $db->escape_string($user['dateformat']);
     }
     if (isset($user['timeformat'])) {
         $this->user_update_data['timeformat'] = $db->escape_string($user['timeformat']);
     }
     if (isset($user['regip'])) {
         $this->user_update_data['regip'] = $db->escape_string($user['regip']);
     }
     if (isset($user['language'])) {
         $this->user_update_data['language'] = $db->escape_string($user['language']);
     }
     if (isset($user['away'])) {
         $this->user_update_data['away'] = $user['away']['away'];
         $this->user_update_data['awaydate'] = $db->escape_string($user['away']['date']);
         $this->user_update_data['returndate'] = $db->escape_string($user['away']['returndate']);
         $this->user_update_data['awayreason'] = $db->escape_string($user['away']['awayreason']);
     }
     if (isset($user['notepad'])) {
         $this->user_update_data['notepad'] = $db->escape_string($user['notepad']);
     }
     if (isset($user['usernotes'])) {
         $this->user_update_data['usernotes'] = $db->escape_string($user['usernotes']);
     }
     if (is_array($user['options'])) {
         foreach ($user['options'] as $option => $value) {
             $this->user_update_data[$option] = $value;
         }
     }
     if (array_key_exists('coppa_user', $user)) {
         $this->user_update_data['coppauser'] = intval($user['coppa_user']);
     }
     // First, grab the old user details for later use.
     $old_user = get_user($user['uid']);
     // If old user has new pmnotice and new user has = yes, keep old value
     if ($old_user['pmnotice'] == "2" && $this->user_update_data['pmnotice'] == 1) {
         unset($this->user_update_data['pmnotice']);
     }
     $plugins->run_hooks("datahandler_user_update", $this);
     if (count($this->user_update_data) < 1 && empty($user['user_fields'])) {
         return false;
     }
     if (count($this->user_update_data) > 0) {
         // Actual updating happens here.
         $db->update_query("users", $this->user_update_data, "uid='{$user['uid']}'");
     }
     $cache->update_moderators();
     if (isset($user['bday']) || isset($user['username'])) {
         $cache->update_birthdays();
     }
     // Maybe some userfields need to be updated?
     if (is_array($user['user_fields'])) {
         $query = $db->simple_select("userfields", "*", "ufid='{$user['uid']}'");
         $fields = $db->fetch_array($query);
         if (!$fields['ufid']) {
             $user_fields = array('ufid' => $user['uid']);
             $fields_array = $db->show_fields_from("userfields");
             foreach ($fields_array as $field) {
                 if ($field['Field'] == 'ufid') {
                     continue;
                 }
                 $user_fields[$field['Field']] = '';
             }
             $db->insert_query("userfields", $user_fields);
         }
         $db->update_query("userfields", $user['user_fields'], "ufid='{$user['uid']}'", false);
     }
     // Let's make sure the user's name gets changed everywhere in the db if it changed.
     if ($this->user_update_data['username'] != $old_user['username'] && $this->user_update_data['username'] != '') {
         $username_update = array("username" => $this->user_update_data['username']);
         $lastposter_update = array("lastposter" => $this->user_update_data['username']);
         $db->update_query("posts", $username_update, "uid='{$user['uid']}'");
         $db->update_query("threads", $username_update, "uid='{$user['uid']}'");
         $db->update_query("threads", $lastposter_update, "lastposteruid='{$user['uid']}'");
         $db->update_query("forums", $lastposter_update, "lastposteruid='{$user['uid']}'");
         $stats = $cache->read("stats");
         if ($stats['lastuid'] == $user['uid']) {
             // User was latest to register, update stats
             update_stats(array("numusers" => "+0"));
         }
     }
 }
Example #12
0
 function user_login($email, $password, $javascript_disabled = 0, $persistent = 0)
 {
     global $database, $setting;
     $this->SEUser(array(0, "", $email));
     $current_time = time();
     $login_result = 0;
     // SHOW ERROR IF JAVASCRIPT IS DIABLED
     if ($javascript_disabled) {
         $this->is_error = 31;
     } elseif ($this->user_exists == 0) {
         $this->is_error = 676;
     } elseif (!trim($password) || $this->user_password_crypt($password) != $this->user_info['user_password']) {
         $this->is_error = 676;
     } elseif (!$this->user_info['user_enabled']) {
         $this->is_error = 677;
     } elseif (!$this->user_info['user_verified'] && $setting['setting_signup_verify']) {
         $this->is_error = 678;
     } else {
         // SET LOGIN RESULT VAR
         $login_result = TRUE;
         // UPDATE USER LOGIN INFO
         $database->database_query("UPDATE se_users SET user_lastlogindate='{$current_time}', user_logins=user_logins+1, user_lastactive='{$current_time}', user_ip_lastactive='{$_SERVER['REMOTE_ADDR']}' WHERE user_id='{$this->user_info['user_id']}' LIMIT 1");
         // LOG USER IN
         $this->user_setcookies($persistent);
         // FIX VISITOR TABLE
         $visitor_ip = ip2long($_SERVER['REMOTE_ADDR']);
         $visitor_browser = addslashes(trim(substr($_SERVER['HTTP_USER_AGENT'], 0, 255)));
         $database->database_query("DELETE FROM se_visitors WHERE visitor_ip='{$visitor_ip}' && visitor_browser LIKE '{$visitor_browser}' && visitor_user_id='0'");
         // UPDATE LOGIN STATS
         update_stats("logins");
     }
     // BUMP LOG
     $database->database_query("INSERT INTO se_logins (login_email, login_date, login_ip, login_result) VALUES ('{$email}', '{$current_time}', '{$_SERVER['REMOTE_ADDR']}', '{$login_result}')");
     bumplog();
 }
    $rowspan++;
}
// Top Posters
if ($settings['forum_statistics_topposters']) {
    list($tposter_id, $tposter_name, $tposter_status, $tposter_posts) = dbarraynum(dbquery("SELECT user_id, user_name, user_status, user_posts FROM " . DB_USERS . " ORDER BY user_posts DESC LIMIT 1"));
    list($aposter_id, $aposter_name, $aposter_status, $aposter_ppday) = dbarraynum(dbquery("SELECT user_id, user_name, user_status, (user_posts/((" . time() . "-user_joined)/(24*3600))) FROM " . DB_USERS . " WHERE user_joined < (" . time() . "-(3600*24)) ORDER BY user_posts DESC LIMIT 1"));
    $rowspan++;
}
// User Stats
if ($settings['forum_statistics_userstats']) {
    pif_cache("online_users");
    $total_online = $pif_cache['online_users']['guests'] + count($pif_cache['online_users']['members']);
    list($max_online, $max_online_time) = explode(":", $stats['max_online_users']);
    if ($total_online > $max_online) {
        $stats['max_online_users'] = $total_online . ":" . time();
        update_stats();
        $max_online = $total_online;
        $max_online_time = time();
    }
    $rowspan++;
}
// Members Today Online
if ($settings['forum_statistics_todayonline']) {
    $result = dbquery("SELECT user_id, user_name, user_level, user_status FROM " . DB_USERS . " WHERE user_lastvisit > UNIX_TIMESTAMP(CURDATE()) AND user_status = '0' ORDER BY user_lastvisit DESC");
    $today_rows = dbrows($result);
    $today_online = array();
    if ($today_rows) {
        while ($data = dbarray($result)) {
            $today_online[] = array("user_id" => $data['user_id'], "user_name" => $data['user_name'], "user_level" => $data['user_level']);
        }
    }
Example #14
0
     } else {
         $result = "call error";
     }
     break;
 case "sys":
     if (isset($_GET['cmd'])) {
         $cmd = $_GET['cmd'];
         $result = sys($cmd);
     } else {
         $result = "no such cmd";
     }
     break;
 case "upstats":
     if (isset($_GET['uniqueid'])) {
         $uniqueid = $_GET['uniqueid'];
         $result = update_stats($uniqueid);
     } else {
         $result = "update error";
     }
     break;
 case "addextinfo":
     if (isset($_POST['exten'])) {
         if (isset($_POST['uname'])) {
             $exten = $_POST['exten'];
             $uname = $_POST['uname'];
             if (isset($_POST['time'])) {
                 $fromtime = $_POST['time'];
             } else {
                 $fromtime = null;
             }
             $result = add_exteninfo($exten, $uname, $fromtime);
Example #15
0
// Ignorišemo fajlove veće od 100k
$split_folder = array("OR");
//$svn_base = $workspace_path . "/svn";
$prefix = "";
// Parameters
if ($argc == 1) {
    debug_log("username missing");
    die("ERROR: userstats.php expects at least one parameter\n");
}
$username = $argv[1];
//$stat_path = $conf_base_path . "/stats/$username_efn.stats";
debug_log("read stats");
read_stats($username);
clean_stats();
debug_log("azuriraj_statistiku");
update_stats($username);
debug_log("ksort");
ksort($stats);
debug_log("file_put_contents " . $conf_base_path . "/stats/{$username}.stats");
write_stats($username);
exit(0);
// Functions
// Read stats file
function read_stats($username)
{
    global $stats, $conf_stats_path;
    $username_efn = escape_filename($username);
    $stat_file = $conf_stats_path . "/" . "{$username_efn}.stats";
    $stats = NULL;
    if (file_exists($stat_file)) {
        eval(file_get_contents($stat_file));
Example #16
0
function upgrade12_dbchanges4()
{
    global $db, $output, $mybb;
    $output->print_header("Performing Queries");
    echo "<p>Performing necessary upgrade queries..</p>";
    flush();
    $db->drop_table("spiders");
    $db->drop_table("stats");
    $collation = $db->build_create_table_collation();
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "spiders (\n\t\tsid int unsigned NOT NULL auto_increment,\n\t\tname varchar(100) NOT NULL default '',\n\t\ttheme int unsigned NOT NULL default '0',\n\t\tlanguage varchar(20) NOT NULL default '',\n\t\tusergroup int unsigned NOT NULL default '0',\n\t\tuseragent varchar(200) NOT NULL default '',\n\t\tlastvisit bigint(30) NOT NULL default '0',\n\t\tPRIMARY KEY(sid)\n\t) ENGINE=MyISAM{$collation};");
    $db->write_query("CREATE TABLE " . TABLE_PREFIX . "stats (\n\t\tdateline bigint(30) NOT NULL default '0',\n\t\tnumusers int unsigned NOT NULL default '0',\n\t\tnumthreads int unsigned NOT NULL default '0',\n\t\tnumposts int unsigned NOT NULL default '0',\n\t\tPRIMARY KEY(dateline)\n\t) ENGINE=MyISAM{$collation};");
    $db->insert_query("spiders", array('name' => 'GoogleBot', 'useragent' => 'google'));
    $db->insert_query("spiders", array('name' => 'Lycos', 'useragent' => 'lycos'));
    $db->insert_query("spiders", array('name' => 'Ask Jeeves', 'useragent' => 'ask jeeves'));
    $db->insert_query("spiders", array('name' => 'Hot Bot', 'useragent' => 'slurp@inktomi'));
    $db->insert_query("spiders", array('name' => 'What You Seek', 'useragent' => 'whatuseek'));
    $db->insert_query("spiders", array('name' => 'Archive.org', 'useragent' => 'is_archiver'));
    $db->insert_query("spiders", array('name' => 'Altavista', 'useragent' => 'scooter'));
    $db->insert_query("spiders", array('name' => 'Alexa', 'useragent' => 'ia_archiver'));
    $db->insert_query("spiders", array('name' => 'MSN Search', 'useragent' => 'msnbot'));
    $db->insert_query("spiders", array('name' => 'Yahoo!', 'useragent' => 'yahoo! slurp'));
    // DST correction changes
    $db->update_query("users", array('dst' => 1), "dst=1");
    $db->update_query("users", array('dst' => 0), "dst=0");
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users CHANGE dst dst INT(1) NOT NULL default '0'");
    if ($db->field_exists('dstcorrection', "users")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users DROP dstcorrection;");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "users ADD dstcorrection INT(1) NOT NULL default '0' AFTER dst");
    $db->update_query("users", array('dstcorrection' => 2));
    $db->update_query("adminoptions", array('cpstyle' => ''));
    if ($db->field_exists('permsset', "adminoptions") && !$db->field_exists('permissions', "adminoptions")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions CHANGE permsset permissions TEXT NOT NULL ");
    }
    $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml');
    $parser = new XMLParser($adminoptions);
    $parser->collapse_dups = 0;
    $tree = $parser->get_tree();
    // Fetch default permissions list
    $default_permissions = array();
    foreach ($tree['adminoptions'][0]['user'] as $users) {
        $uid = $users['attributes']['uid'];
        if ($uid == -4) {
            foreach ($users['permissions'][0]['module'] as $module) {
                foreach ($module['permission'] as $permission) {
                    $default_permissions[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value'];
                }
            }
            break;
        }
    }
    $convert_permissions = array("caneditsettings" => array("module" => "config", "permission" => "settings"), "caneditann" => array("module" => "forum", "permission" => "announcements"), "caneditforums" => array("module" => "forum", "permission" => "management"), "canmodposts" => array("module" => "forum", "permission" => "moderation_queue"), "caneditsmilies" => array("module" => "config", "permission" => "smilies"), "caneditpicons" => array("module" => "config", "permission" => "post_icons"), "caneditthemes" => array("module" => "style", "permission" => "themes"), "canedittemps" => array("module" => "style", "permission" => "templates"), "caneditusers" => array("module" => "user", "permission" => "view"), "caneditpfields" => array("module" => "config", "permission" => "profile_fields"), "caneditmodactions" => array("module" => "config", "permission" => "mod_tools"), "caneditugroups" => array("module" => "user", "permission" => "groups"), "caneditaperms" => array("module" => "user", "permission" => "admin_permissions"), "caneditutitles" => array("module" => "user", "permission" => "titles"), "caneditattach" => array("module" => "forum", "permission" => "attachments"), "canedithelp" => array("module" => "config", "permission" => "help_documents"), "caneditlangs" => array("module" => "config", "permission" => "languages"), "canrunmaint" => array("module" => "tools", "permission" => "recount_rebuild"), "canrundbtools" => array("module" => "tools", "permission" => "backupdb"));
    $new_permissions = $default_permissions;
    $query = $db->simple_select("adminoptions");
    while ($adminoption = $db->fetch_array($query)) {
        foreach ($adminoption as $field => $value) {
            if (strtolower(substr($field, 0, 3)) != "can") {
                continue;
            }
            if (array_key_exists($field, $convert_permissions)) {
                // Note: old adminoptions table is still yes/no - do not change me
                if ($value == "yes") {
                    $value = 1;
                } else {
                    $value = $default_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']];
                }
                $new_permissions[$convert_permissions[$field]['module']][$convert_permissions[$field]['permission']] = $value;
            }
        }
        $db->update_query("adminoptions", array('permissions' => my_serialize($new_permissions)), "uid = '{$adminoption['uid']}'");
        $new_permissions = $default_permissions;
    }
    foreach ($convert_permissions as $field => $value) {
        if ($db->field_exists($field, "adminoptions")) {
            $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions DROP {$field}");
        }
    }
    // Set default views
    if ($db->field_exists('defaultviews', "adminoptions")) {
        $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions DROP defaultviews");
    }
    $db->write_query("ALTER TABLE " . TABLE_PREFIX . "adminoptions ADD defaultviews TEXT NOT NULL");
    $db->update_query("adminoptions", array('defaultviews' => my_serialize(array('user' => 1))));
    $query = $db->simple_select("forums", "SUM(threads) AS numthreads, SUM(posts) AS numposts, SUM(unapprovedthreads) AS numunapprovedthreads, SUM(unapprovedposts) AS numunapprovedposts");
    $stats = $db->fetch_array($query);
    $query = $db->simple_select("users", "COUNT(uid) AS users");
    $stats['numusers'] = $db->fetch_field($query, 'users');
    update_stats($stats, true);
    $contents = "Done</p>";
    $contents .= "<p>Click next to continue with the upgrade process.</p>";
    $output->print_contents($contents);
    global $footer_extra;
    $footer_extra = "<script type=\"text/javascript\">\$(document).ready(function() { var button = \$('.submit_button'); if(button) { button.val('Automatically Redirecting...'); button.prop('disabled', true); button.css('color', '#aaa'); button.css('border-color', '#aaa'); document.forms[0].submit(); } });</script>";
    $output->print_footer("12_dbchanges5");
}
Example #17
0
        }
        switch ($db->type) {
            case "pgsql":
            case "sqlite":
                $db->delete_query("forums", "','||parentlist||',' LIKE '%,{$fid},%'");
                break;
            default:
                $db->delete_query("forums", "CONCAT(',',parentlist,',') LIKE '%,{$fid},%'");
        }
        $db->delete_query("threads", "fid='{$fid}' {$delquery}");
        $db->delete_query("posts", "fid='{$fid}' {$delquery}");
        $db->delete_query("moderators", "fid='{$fid}' {$delquery}");
        $db->delete_query("forumsubscriptions", "fid='{$fid}' {$delquery}");
        $db->delete_query("forumpermissions", "fid='{$fid}' {$delquery}");
        $update_stats = array('numthreads' => "-" . $stats['threads'], 'numunapprovedthreads' => "-" . $stats['unapprovedthreads'], 'numposts' => "-" . $stats['posts'], 'numunapprovedposts' => "-" . $stats['unapprovedposts']);
        update_stats($update_stats);
        $plugins->run_hooks("admin_forum_management_delete_commit");
        $cache->update_forums();
        $cache->update_moderators();
        $cache->update_forumpermissions();
        // Log admin action
        log_admin_action($forum_info['fid'], $forum_info['name']);
        flash_message($lang->success_forum_deleted, 'success');
        admin_redirect("index.php?module=forum-management");
    } else {
        $page->output_confirm_action("index.php?module=forum-management&amp;action=delete&amp;fid={$forum['fid']}", $lang->confirm_forum_deletion);
    }
}
if (!$mybb->input['action']) {
    if (!isset($mybb->input['fid'])) {
        $mybb->input['fid'] = 0;
Example #18
0
    setlocale(LC_TIME, SE_Language::info('language_setlocale'));
}
header("Content-Language: " . SE_Language::info('language_code'));
// CREATE ACTIONS CLASS
$actions = new se_actions();
// CREATE NOTIFICATION CLASS
$notify = new se_notify();
// CREATE ADS CLASS
$ads = new se_ads();
// Define SE_PAGE_AJAX in your page before the header include to not load ads or update page views
if (!defined('SE_PAGE_AJAX') && ($page == "chat_frame" || $page == "chat_ajax" || $page == "misc_js" || $page == "ad")) {
    define('SE_PAGE_AJAX', TRUE);
}
if (!defined('SE_PAGE_AJAX')) {
    // UPDATE STATS TABLE
    update_stats("views");
    // LOAD ADS
    $ads->load();
}
// CREATE GLOBAL CSS STYLES VAR (USED FOR CUSTOM USER-DEFINED PROFILE/PLUGIN STYLES)
$global_css = "";
SE_DEBUG ? $_benchmark->end('initialization') : NULL;
SE_DEBUG ? $_benchmark->start('plugins') : NULL;
// INCLUDE RELEVANT PLUGIN FILES
// AND SET PLUGIN HEADER TEMPLATES
$show_menu_user = FALSE;
$global_plugins =& SECore::getPlugins();
foreach ($global_plugins as $plugin_type => $plugin_info) {
    $plugin_vars = array();
    if (file_exists("header_{$plugin_info['plugin_type']}.php")) {
        include "header_{$plugin_info['plugin_type']}.php";
Example #19
0
function on_after_approve_blog_post()
{
    global $dbtable_prefix, $post_ids;
    require_once _BASEPATH_ . '/includes/classes/fileop.class.php';
    $fileop = new fileop();
    $query = "SELECT `post_id`,`fk_blog_id`,`fk_user_id` FROM `{$dbtable_prefix}blog_posts` WHERE `post_id` IN ('" . join("','", $post_ids) . "') AND `processed`=0";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $post_ids = array();
    // yup
    $blog_ids = array();
    $user_ids = array();
    while ($rsrow = mysql_fetch_assoc($res)) {
        $post_ids[] = $rsrow['post_id'];
        // get only the not processed ones
        if (!isset($blog_ids[$rsrow['fk_blog_id']])) {
            $blog_ids[$rsrow['fk_blog_id']] = 1;
        } else {
            ++$blog_ids[$rsrow['fk_blog_id']];
        }
        if (!isset($user_ids[$rsrow['fk_user_id']])) {
            $user_ids[$rsrow['fk_user_id']] = 1;
        } else {
            ++$user_ids[$rsrow['fk_user_id']];
        }
    }
    $year = (int) date('Y');
    $month = (int) date('m');
    foreach ($blog_ids as $bid => $num) {
        // blog stats
        $bid = (string) $bid;
        $query = "UPDATE `{$dbtable_prefix}user_blogs` SET `stat_posts`=`stat_posts`+{$num} WHERE `blog_id`={$bid}";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        // blog_archive
        $blog_archive = array();
        if (is_file(_CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php')) {
            include _CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php';
        }
        if (isset($blog_archive[$year][$month])) {
            $blog_archive[$year][$month] += $num;
        } else {
            $blog_archive[$year][$month] = $num;
        }
        krsort($blog_archive, SORT_NUMERIC);
        $towrite = '<?php $blog_archive=' . var_export($blog_archive, true) . ';';
        $fileop->file_put_contents(_CACHEPATH_ . '/blogs/' . $bid[0] . '/' . $bid . '/blog_archive.inc.php', $towrite);
    }
    foreach ($user_ids as $uid => $num) {
        update_stats($uid, 'blog_posts', $num);
        add_member_score($uid, 'add_blog', $num);
    }
    if (!empty($post_ids)) {
        $query = "UPDATE `{$dbtable_prefix}blog_posts` SET `processed`=1 WHERE `post_id` IN ('" . join("','", $post_ids) . "')";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
    }
}
Example #20
0
function record_goal($pageview_xid, $name, $value, $set_cache = 1)
{
    // this line must come first
    $rows = _get_pageview_info($pageview_xid);
    $domain = $rows[0]['domain_name'];
    $page = $rows[0]['page_name'];
    insert_goal($pageview_xid, $name, $value);
    update_stats('genome', $rows[0]['genome_id'], 0, $value);
    foreach ($rows as $row) {
        update_stats('variant', $row['variant_id'], 0, $value);
    }
    //TODO: check against a cache frequency to reduce load
    if ($set_cache) {
        set_cache($domain, $page);
    }
    return render_status('goal');
}
Example #21
0
 function update_stats()
 {
     @(include WA_ROOTDIR . '/includes/functions.stats.php');
     if (function_exists('update_stats')) {
         update_stats($this->listdata);
     }
 }
Example #22
0
function upgrade15_usernameupdate()
{
    global $db, $output, $mybb, $plugins;
    $output->print_header("Performing Queries");
    echo "<p>Performing username updates..</p>";
    flush();
    require_once MYBB_ROOT . "inc/datahandler.php";
    require_once MYBB_ROOT . "inc/datahandlers/user.php";
    // Load plugin system for datahandler
    require_once MYBB_ROOT . "inc/class_plugins.php";
    $plugins = new pluginSystem();
    $not_renameable = array();
    // Because commas can cause some problems with private message sending in usernames we have to remove them
    $query = $db->simple_select("users", "uid, username", "username LIKE '%,%'");
    while ($user = $db->fetch_array($query)) {
        $prefix = '';
        $userhandler = new UserDataHandler('update');
        do {
            $username = str_replace(',', '', $user['username']) . '_' . $prefix;
            $updated_user = array("uid" => $user['uid'], "username" => $username);
            $userhandler->set_data($updated_user);
            ++$prefix;
        } while (!$userhandler->verify_username() || $userhandler->verify_username_exists());
        if (!$userhandler->validate_user()) {
            $not_renameable[] = htmlspecialchars_uni($user['username']);
        } else {
            $db->update_query("users", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'");
            $db->update_query("posts", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'");
            $db->update_query("threads", array('username' => $db->escape_string($username)), "uid='{$user['uid']}'");
            $db->update_query("threads", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'");
            $db->update_query("forums", array('lastposter' => $db->escape_string($username)), "lastposteruid='{$user['uid']}'");
            update_stats(array("numusers" => "+0"));
        }
    }
    if (!empty($not_renameable)) {
        echo "<span style=\"color: red;\">NOTICE:</span> The following users could not be renamed automatically. Please rename these users in the Admin CP manually after the upgrade process has finished completing:<br />\n\t\t<ul>\n\t\t<li>";
        echo implode('</li>\\n<li>', $not_renameable);
        echo "</li>\n\t\t</ul>";
    }
    $contents .= "Click next to continue with the upgrade process.</p>";
    $output->print_contents($contents);
    $output->print_footer("15_done");
}
Example #23
0
ob_end_clean();
if ($send_debug_information) {
    if (!empty($errors)) {
        $responses['errors'] = $errors;
    }
    if (!empty($contents)) {
        $responses['contents'] = $contents;
    }
    if (!empty($benchmark_delta)) {
        $responses['benchmark'] = $benchmark_delta;
    }
}
$json_string = json_encode($responses);
$json_string_length = strlen($json_string);
/* ------------------------------------------------------------------------- *\
|                                                                             |
| Stats                                                                   [O] |
|                                                                             |
\* ------------------------------------------------------------------------- */
update_stats('chat_requests');
$sql = "\r\n  INSERT INTO\r\n    se_stats\r\n  (\r\n    stat_date,\r\n    stat_chat_cpu_time,\r\n    stat_chat_bandwidth\r\n  )\r\n  VALUES\r\n  (\r\n    UNIX_TIMESTAMP(CURDATE()),\r\n    '{$benchmark_delta}',\r\n    '{$json_string_length}'\r\n  ) \r\n  ON DUPLICATE KEY UPDATE\r\n    stat_chat_cpu_time=stat_chat_cpu_time+'{$benchmark_delta}',\r\n    stat_chat_bandwidth=stat_chat_bandwidth+'{$json_string_length}'\r\n";
$resource = $database->database_query($sql) or die($database->database_error());
/* ------------------------------------------------------------------------- *\
|                                                                             |
| Output                                                                  [O] |
|                                                                             |
\* ------------------------------------------------------------------------- */
//ob_end_clean();
header("Content-Type: text/x-json; charset=UTF-8");
echo $json_string;
exit;
Example #24
0
function on_before_delete_comment()
{
    global $dbtable_prefix, $comment_ids, $comment_type;
    switch ($comment_type) {
        case 'blog':
            $table = "`{$dbtable_prefix}comments_blog`";
            $parent_table = "`{$dbtable_prefix}blog_posts`";
            $parent_key = "`post_id`";
            break;
        case 'photo':
            $table = "`{$dbtable_prefix}comments_photo`";
            $parent_table = "`{$dbtable_prefix}user_photos`";
            $parent_key = "`photo_id`";
            break;
        case 'user':
            $table = "`{$dbtable_prefix}comments_profile`";
            $parent_table = "`{$dbtable_prefix}user_profiles`";
            $parent_key = "`fk_user_id`";
            break;
    }
    $query = "SELECT a.`comment_id`,a.`fk_parent_id`,a.`fk_user_id`,b.`fk_user_id` as `fk_parent_owner_id` FROM {$table} a,{$parent_table} b WHERE a.`comment_id` IN ('" . join("','", $comment_ids) . "') AND a.`fk_parent_id`=b.{$parent_key}";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $parent_ids = array();
    $user_ids = array();
    $parent_owner_ids = array();
    while ($rsrow = mysql_fetch_assoc($res)) {
        if (isset($parent_ids[$rsrow['fk_parent_id']])) {
            --$parent_ids[$rsrow['fk_parent_id']];
        } else {
            $parent_ids[$rsrow['fk_parent_id']] = -1;
        }
        if (isset($user_ids[$rsrow['fk_user_id']])) {
            --$user_ids[$rsrow['fk_user_id']];
        } else {
            $user_ids[$rsrow['fk_user_id']] = -1;
        }
        if ($rsrow['fk_parent_owner_id'] != $rsrow['fk_user_id']) {
            if (isset($parent_owner_ids[$rsrow['fk_parent_owner_id']])) {
                --$parent_owner_ids[$rsrow['fk_parent_owner_id']];
            } else {
                $parent_owner_ids[$rsrow['fk_parent_owner_id']] = -1;
            }
        }
    }
    if ($comment_type != 'user') {
        foreach ($parent_ids as $pid => $num) {
            $query = "UPDATE {$parent_table} SET `stat_comments`=`stat_comments`+{$num} WHERE {$parent_key}='{$pid}'";
            if (!($res = @mysql_query($query))) {
                trigger_error(mysql_error(), E_USER_ERROR);
            }
        }
    } else {
        foreach ($parent_ids as $pid => $num) {
            update_stats($pid, 'profile_comments', $num);
        }
    }
    foreach ($parent_owner_ids as $uid => $num) {
        if (!empty($uid)) {
            add_member_score($uid, 'removed_comment', -$num);
            // -$num because $num is already negative.
        }
    }
}
Example #25
0
function on_before_delete_photo()
{
    global $dbtable_prefix, $photo_ids;
    $query = "SELECT `photo_id`,`fk_user_id`,`is_main`,`photo`,`status` FROM `{$dbtable_prefix}user_photos` WHERE `photo_id` IN ('" . join("','", $photo_ids) . "')";
    if (!($res = @mysql_query($query))) {
        trigger_error(mysql_error(), E_USER_ERROR);
    }
    $photo_ids = array();
    // yup
    $user_ids = array();
    $scores = array();
    $score_photo = add_member_score(0, 'del_photo', 1, true);
    // just read the score, don't set anything
    $score_main_photo = add_member_score(0, 'del_main_photo', 1, true);
    // just read the score, don't set anything
    $main_photos = array();
    while ($rsrow = mysql_fetch_assoc($res)) {
        $photo_ids[] = $rsrow['photo_id'];
        // get only the not processed ones
        if ($rsrow['status'] == STAT_APPROVED) {
            // everything happens with approved photos only.
            if (isset($user_ids[$rsrow['fk_user_id']])) {
                --$user_ids[$rsrow['fk_user_id']];
            } else {
                $user_ids[$rsrow['fk_user_id']] = -1;
            }
            if (isset($scores[$rsrow['fk_user_id']])) {
                $scores[$rsrow['fk_user_id']] += empty($rsrow['is_main']) ? $score_photo : $score_main_photo;
            } else {
                $scores[$rsrow['fk_user_id']] = empty($rsrow['is_main']) ? $score_photo : $score_main_photo;
            }
            if (!empty($rsrow['is_main'])) {
                $main_photos[$rsrow['fk_user_id']] = $rsrow['photo'];
            }
        }
    }
    foreach ($user_ids as $uid => $num) {
        update_stats($uid, 'total_photos', $num);
    }
    foreach ($scores as $uid => $score) {
        add_member_score($uid, 'force', 1, false, $score);
    }
    $now = gmdate('YmdHis');
    foreach ($main_photos as $uid => $photo) {
        $query = "UPDATE `{$dbtable_prefix}user_profiles` SET `_photo`='',`last_changed`='{$now}' WHERE `fk_user_id`={$uid}";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
    }
    // this is needed to recreate caches containing the new photo
    if (!empty($main_photos)) {
        $query = "UPDATE `{$dbtable_prefix}blog_posts` SET `last_changed`='{$now}' WHERE `fk_user_id` IN (" . join(',', array_keys($main_photos)) . ")";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        $query = "UPDATE `{$dbtable_prefix}comments_blog` SET `last_changed`='{$now}' WHERE `fk_user_id` IN (" . join(',', array_keys($main_photos)) . ")";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        $query = "UPDATE `{$dbtable_prefix}comments_photo` SET `last_changed`='{$now}' WHERE `fk_user_id` IN (" . join(',', array_keys($main_photos)) . ")";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        $query = "UPDATE `{$dbtable_prefix}comments_profile` SET `last_changed`='{$now}' WHERE `fk_user_id` IN (" . join(',', array_keys($main_photos)) . ")";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
    }
}
/**
 * MyBB 1.6
 * Copyright 2010 MyBB Group, All Rights Reserved
 *
 * Website: http://mybb.com
 * License: http://mybb.com/about/license
 *
 * $Id: userpruning.php 5297 2010-12-28 22:01:14Z Tomm $
 */
function task_userpruning($task)
{
    global $db, $lang, $mybb, $cache;
    if ($mybb->settings['enablepruning'] != 1) {
        return;
    }
    // Are we pruning by posts?
    if ($mybb->settings['enableprunebyposts'] == 1) {
        $in_usergroups = array();
        $users = array();
        $usergroups = $cache->read("usergroups");
        foreach ($usergroups as $gid => $usergroup) {
            // Exclude admin, moderators, super moderators, banned
            if ($usergroup['canmodcp'] == 1 || $usergroup['cancp'] == 1 || $usergroup['issupermod'] == 1 || $usergroup['isbannedgroup'] == 1) {
                continue;
            }
            $in_usergroups[] = $gid;
        }
        // If we're not pruning unactivated users, then remove them from the criteria
        if ($mybb->settings['pruneunactived'] == 0) {
            $key = array_search('5', $in_usergroups);
            unset($in_usergroups[$key]);
        }
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneregistered']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND postnum <= " . intval($mybb->settings['prunepostcount']) . " AND usergroup IN(" . $db->escape_string(implode(',', $in_usergroups)) . ")");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    // Are we pruning unactivated users?
    if ($mybb->settings['pruneunactived'] == 1) {
        $regdate = TIME_NOW - intval($mybb->settings['dayspruneunactivated']) * 24 * 60 * 60;
        $query = $db->simple_select("users", "uid", "regdate <= " . intval($regdate) . " AND usergroup='5'");
        while ($user = $db->fetch_array($query)) {
            $users[$user['uid']] = $user['uid'];
        }
    }
    if (!empty($users)) {
        $uid_list = $db->escape_string(implode(',', $users));
        // Delete the user
        $db->delete_query("userfields", "ufid IN({$uid_list})");
        $db->delete_query("privatemessages", "uid IN({$uid_list})");
        $db->delete_query("events", "uid IN({$uid_list})");
        $db->delete_query("moderators", "id IN({$uid_list}) AND isgroup='0'");
        $db->delete_query("forumsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("threadsubscriptions", "uid IN({$uid_list})");
        $db->delete_query("sessions", "uid IN({$uid_list})");
        $db->delete_query("banned", "uid IN({$uid_list})");
        $db->delete_query("threadratings", "uid IN({$uid_list})");
        $db->delete_query("joinrequests", "uid IN({$uid_list})");
        $db->delete_query("awaitingactivation", "uid IN({$uid_list})");
        $query = $db->delete_query("users", "uid IN({$uid_list})");
        $num_deleted = $db->affected_rows($query);
        // Remove any of the user(s) uploaded avatars
        $query = $db->simple_select("users", "avatar", "uid IN ({$uid_list}) AND avatartype = 'upload'");
        if ($db->num_rows($query)) {
            while ($avatar = $db->fetch_field($query, "avatar")) {
                $avatar = substr($avatar, 2, -20);
                @unlink(MYBB_ROOT . $avatar);
            }
        }
        // Are we removing the posts/threads of a user?
        if ($mybb->settings['prunethreads'] == 1) {
            require_once MYBB_ROOT . "inc/class_moderation.php";
            $moderation = new Moderation();
            // Threads
            $query = $db->simple_select("threads", "tid", "uid IN({$uid_list})");
            while ($thread = $db->fetch_array($query)) {
                $moderation->delete_thread($thread['tid']);
            }
            // Posts
            $query = $db->simple_select("posts", "pid", "uid IN({$uid_list})");
            while ($post = $db->fetch_array($query)) {
                $moderation->delete_post($post['pid']);
            }
        } else {
            // We're just updating the UID
            $db->update_query("posts", array('uid' => 0), "uid IN({$uid_list})");
        }
        // Update forum stats
        update_stats(array('numusers' => '-' . intval($num_deleted)));
        $cache->update_moderators();
        $cache->update_banned();
    }
    add_task_log($task, $lang->task_userpruning_ran);
}
        // CREATE FRIENDSHIP
        $user->user_friend_add($owner->user_info['user_id'], $friend_status, $friend_type, $friend_explain);
        // INSERT ACTION
        if ($friend_status == 1) {
            $actions->actions_add($user, "addfriend", array($user->user_info['user_username'], $user->user_displayname, $owner->user_info['user_username'], $owner->user_displayname), array(), 0, false, "user", $user->user_info['user_id'], $user->user_info['user_privacy']);
        } else {
            $notify->notify_add($owner->user_info['user_id'], 'friendrequest', $user->user_info['user_id']);
        }
        // IF TWO-WAY CONNECTION AND NON-CONFIRMED, INSERT OTHER DIRECTION AND ACTION
        if ($direction == 2 && $friend_status == 1 && !$owner->user_friended($user->user_info['user_id'])) {
            $owner->user_friend_add($user->user_info['user_id'], $friend_status, '', '');
            $actions->actions_add($owner, "addfriend", array($owner->user_info['user_username'], $owner->user_displayname, $user->user_info['user_username'], $user->user_displayname), array(), 0, false, "user", $owner->user_info['user_id'], $owner->user_info['user_privacy']);
        }
        // SEND FRIENDSHIP EMAIL
        $owner->user_settings();
        if ($owner->usersetting_info['usersetting_notify_friendrequest']) {
            send_systememail('friendrequest', $owner->user_info['user_email'], array($owner->user_displayname, $user->user_displayname, "<a href=\"" . $url->url_base . "login.php\">" . $url->url_base . "login.php</a>"));
        }
    }
    // UPDATE STATS
    update_stats("friends");
}
// ASSIGN VARIABLES AND INCLUDE FOOTER
$smarty->assign('result', $result);
$smarty->assign('status', $status);
$smarty->assign('subpage', $subpage);
$smarty->assign('connection_types', $connection_types);
$smarty->assign('friend_type', $friend_type);
$smarty->assign('friend_type_other', $friend_type_other);
$smarty->assign('friend_explain', $friend_explain);
include "footer.php";
Example #28
0
/**
 * Updates the forum counters with a specific value (or addition/subtraction of the previous value)
 *
 * @param int The forum ID
 * @param array Array of items being updated (threads, posts, unapprovedthreads, unapprovedposts) and their value (ex, 1, +1, -1)
 */
function update_forum_counters($fid, $changes = array())
{
    global $db, $cache;
    $update_query = array();
    $counters = array('threads', 'unapprovedthreads', 'posts', 'unapprovedposts');
    // Fetch above counters for this forum
    $query = $db->simple_select("forums", implode(",", $counters), "fid='{$fid}'");
    $forum = $db->fetch_array($query);
    foreach ($counters as $counter) {
        if (array_key_exists($counter, $changes)) {
            // Adding or subtracting from previous value?
            if (substr($changes[$counter], 0, 1) == "+" || substr($changes[$counter], 0, 1) == "-") {
                $update_query[$counter] = $forum[$counter] + $changes[$counter];
            } else {
                $update_query[$counter] = $changes[$counter];
            }
            // Less than 0? That's bad
            if ($update_query[$counter] < 0) {
                $update_query[$counter] = 0;
            }
        }
    }
    // Only update if we're actually doing something
    if (count($update_query) > 0) {
        $db->update_query("forums", $update_query, "fid='" . intval($fid) . "'");
    }
    // Guess we should update the statistics too?
    $new_stats = array();
    if (array_key_exists('threads', $update_query)) {
        $threads_diff = $update_query['threads'] - $forum['threads'];
        if ($threads_diff > -1) {
            $new_stats['numthreads'] = "+{$threads_diff}";
        } else {
            $new_stats['numthreads'] = "{$threads_diff}";
        }
    }
    if (array_key_exists('unapprovedthreads', $update_query)) {
        $unapprovedthreads_diff = $update_query['unapprovedthreads'] - $forum['unapprovedthreads'];
        if ($unapprovedthreads_diff > -1) {
            $new_stats['numunapprovedthreads'] = "+{$unapprovedthreads_diff}";
        } else {
            $new_stats['numunapprovedthreads'] = "{$unapprovedthreads_diff}";
        }
    }
    if (array_key_exists('posts', $update_query)) {
        $posts_diff = $update_query['posts'] - $forum['posts'];
        if ($posts_diff > -1) {
            $new_stats['numposts'] = "+{$posts_diff}";
        } else {
            $new_stats['numposts'] = "{$posts_diff}";
        }
    }
    if (array_key_exists('unapprovedposts', $update_query)) {
        $unapprovedposts_diff = $update_query['unapprovedposts'] - $forum['unapprovedposts'];
        if ($unapprovedposts_diff > -1) {
            $new_stats['numunapprovedposts'] = "+{$unapprovedposts_diff}";
        } else {
            $new_stats['numunapprovedposts'] = "{$unapprovedposts_diff}";
        }
    }
    if (!empty($new_stats)) {
        update_stats($new_stats);
    }
    // Update last post info
    update_forum_lastpost($fid);
    $cache->update_forums();
}
Example #29
0
                     $db->delete_query("sessions", "uid='{$user['uid']}'");
                     $db->delete_query("banned", "uid='{$user['uid']}'");
                     $db->delete_query("users", "uid='{$user['uid']}'");
                     $db->delete_query("joinrequests", "uid='{$user['uid']}'");
                     $db->delete_query("warnings", "uid='{$user['uid']}'");
                     // Update thread ratings
                     $update_thread_ratings_query = $db->query("\n\t\t\t\t\t\t\t\t\tSELECT r.*, t.numratings, t.totalratings\n\t\t\t\t\t\t\t\t\tFROM " . TABLE_PREFIX . "threadratings r\n\t\t\t\t\t\t\t\t\tLEFT JOIN " . TABLE_PREFIX . "threads t ON (t.tid=r.tid)\n\t\t\t\t\t\t\t\t\tWHERE r.uid='{$user['uid']}'\n\t\t\t\t\t\t\t\t");
                     while ($rating = $db->fetch_array($update_thread_ratings_query)) {
                         $update_thread = array("numratings" => $rating['numratings'] - 1, "totalratings" => $rating['totalratings'] - $rating['rating']);
                         $db->update_query("threads", $update_thread, "tid='{$rating['tid']}'");
                     }
                     $db->delete_query("threadratings", "uid='{$user['uid']}'");
                 }
             }
             // Update forum stats, remove the cookie and redirect the user
             update_stats(array('numusers' => '-' . $to_be_deleted . ''));
             my_unsetcookie("inlinemod_useracp");
             $mybb->input['action'] = "inline_delete";
             log_admin_action($to_be_deleted);
             $lang->users_deleted = $lang->sprintf($lang->users_deleted, $to_be_deleted);
             flash_message($lang->users_deleted, 'success');
             admin_redirect("index.php?module=user-users" . $vid_url);
         }
         $to_be_deleted = count($selected);
         $lang->confirm_multidelete = $lang->sprintf($lang->confirm_multidelete, my_number_format($to_be_deleted));
         $page->output_confirm_action("index.php?module=user-users&amp;action=inline_edit&amp;inline_action=multidelete&amp;my_post_key={$mybb->post_code}&amp;processed=1", $lang->confirm_multidelete);
     }
     break;
 case 'multiprune':
     if ($mybb->input['processed'] == 1) {
         if (($mybb->input['day'] || $mybb->input['month'] || $mybb->input['year']) && $mybb->input['set']) {
Example #30
0
        }
        $query = "DELETE FROM `{$dbtable_prefix}user_inbox` WHERE `mail_id` IN ('" . $input['mail_id'] . "') AND `fk_user_id`='" . $_SESSION[_LICENSE_KEY_]['user']['user_id'] . "'";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        $query = "SELECT `fk_user_id_other` FROM `{$dbtable_prefix}user_inbox` WHERE `mail_id` IN ('" . $input['mail_id'] . "')";
        if (!($res = @mysql_query($query))) {
            trigger_error(mysql_error(), E_USER_ERROR);
        }
        // set the 'spam_sent' property of the sender(s)
        $spammers = array();
        while ($rsrow = mysql_fetch_row($res)) {
            if (!isset($spammers[$rsrow[0]])) {
                $spammers[$rsrow[0]] = 1;
            } else {
                ++$spammers[$rsrow[0]];
            }
        }
        foreach ($spammers as $k => $v) {
            update_stats($k, 'spam_sent', $v);
        }
    } elseif ($_POST['act'] == 'reply') {
        check_login_member('message_reply');
        $nextpage = 'message_send.php?mail_id=' . $input['mail_id'];
        if (!empty($input['return'])) {
            $nextpage .= '&return=' . rawurlencode($input['return']);
        }
    }
}
$nextpage = _BASEURL_ . '/' . $nextpage;
redirect2page($nextpage, $topass, '', true);