本文整理汇总了PHP中update_stats函数的典型用法代码示例。如果您正苦于以下问题:PHP update_stats函数的具体用法?PHP update_stats怎么用?PHP update_stats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_stats函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: rebuild_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");
$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);
}
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:33,代码来源:functions_rebuild.php
示例2: rebuild_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);
}
开发者ID:olada,项目名称:mybbintegrator,代码行数:12,代码来源:functions_rebuild.php
示例3: on_before_delete_blog_post
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.
}
}
开发者ID:babae,项目名称:etano,代码行数:57,代码来源:blog_posts_delete.php
示例4: parse_csv_sheet
//.........这里部分代码省略.........
$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));
}
开发者ID:bayugyug,项目名称:unov2,代码行数:101,代码来源:misc.php
示例5: removeUser
/**
* 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;
}
开发者ID:NoiSek,项目名称:ArFlux,代码行数:40,代码来源:class.MyBBIntegrator.php
示例6: IN
$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);
开发者ID:benn0034,项目名称:SHIELDsite2.old,代码行数:31,代码来源:users.php
示例7: delete_user
/**
* 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;
}
开发者ID:olada,项目名称:mybbintegrator,代码行数:56,代码来源:user.php
示例8: redirect2page
$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');
开发者ID:babae,项目名称:etano,代码行数:31,代码来源:profile.php
示例9: send_systememail
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";
开发者ID:amitjoy,项目名称:nitd-network,代码行数:31,代码来源:signupon13.php
示例10: on_after_approve_comment
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]);
//.........这里部分代码省略.........
开发者ID:babae,项目名称:etano,代码行数:101,代码来源:comment_addedit.php
示例11: update_user
//.........这里部分代码省略.........
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"));
}
}
}
开发者ID:GeorgeLVP,项目名称:mybb,代码行数:101,代码来源:user.php
示例12: user_login
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();
}
开发者ID:amitjoy,项目名称:nitd-network,代码行数:35,代码来源:class_user.php
示例13: list
$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']);
}
}
开发者ID:MichaelFichtner,项目名称:RadioLaFamilia,代码行数:31,代码来源:forum_statistics.php
示例14: sys
} 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);
开发者ID:xavi06,项目名称:My-ops-doc,代码行数:31,代码来源:server.php
示例15: array
// 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));
开发者ID:vljubovic,项目名称:c9etf,代码行数:31,代码来源:userstats.php
示例16: upgrade12_dbchanges4
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;
}
}
|
请发表评论