XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
jquery.php
Go to the documentation of this file.
1 <?php
20 require('../../../../mainfile.php');
21 require(XOOPS_ROOT_PATH.'/header.php');
22 
23 if (!defined('XOOPS_ROOT_PATH')) { die('Error'); }
24 
25 if ( !is_object($xoopsUser) || !is_object($xoopsModule) || !$xoopsUser->isAdmin($xoopsModule->mid()) ) exit( _NOPERM );
26 
27 if (isset($_REQUEST["op"])) {
28  $op = $_REQUEST["op"];
29 } else {
30  @$op = "default";
31 }
32 
33 switch ($op) {
34 
35  // Display post
36  case 'display_post':
37  global $xoopsDB;
38 
39  $GLOBALS['xoopsLogger']->activated = false;
40 
41  include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
42  include_once XOOPS_ROOT_PATH . '/kernel/module.php';
43  include_once XOOPS_ROOT_PATH . '/modules/system/include/functions.php';
44 
45  $tables = array();
46  // Count comments (approved only: com_status == XOOPS_COMMENT_ACTIVE)
47  $tables[] = array ('table_name' => 'xoopscomments', 'uid_column' => 'com_uid', 'criteria' => new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
48  // Count forum posts
49  if (XoopsModule::getByDirname("newbb")) {
50  $tables[] = array ('table_name' => 'bb_posts', 'uid_column' => 'uid');
51  }
52  $uid = system_CleanVars($_REQUEST, 'uid', int);
53  $total_posts = 0;
54  foreach ($tables as $table)
55  {
56  $criteria = new CriteriaCompo();
57  $criteria->add (new Criteria($table['uid_column'], $uid ));
58  if (!empty($table['criteria'])) {
59  $criteria->add ($table['criteria']);
60  }
61  $sql = "SELECT COUNT(*) AS total FROM ".$xoopsDB->prefix($table['table_name']) . ' ' . $criteria->renderWhere();
62  if ( $result = $xoopsDB->query($sql) ) {
63  if ($row = $xoopsDB->fetchArray($result)) {
64  $total_posts = $total_posts + $row['total'];
65  }
66  }
67  }
68 
69  $sql = "UPDATE ".$xoopsDB->prefix("users")." SET posts = '".$total_posts."' WHERE uid = '".$uid."'";
70  if ( !$result = $xoopsDB->queryF($sql) ) {
71  redirect_header("admin.php?fct=users",1,_AM_SYSTEM_USERS_CNUUSER);
72  } else {
73  echo $total_posts;
74  }
75  break;
76 }
77 
78 ?>