Exemplo n.º 1
0
 function getValidItems($mid, $id = 0)
 {
     static $suspension = array();
     $full_items = array();
     if (empty($mid)) {
         return $full_items;
     }
     require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.user.php";
     $uid = is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uid") : 0;
     $ip = newbb_getIP(true);
     if (!empty($GLOBALS["xoopsModuleConfig"]['enable_usermoderate']) && !isset($suspension[$uid][$id]) && !newbb_isAdmin($id)) {
         $moderate_handler =& xoops_getmodulehandler('moderate', 'newbb');
         if ($moderate_handler->verifyUser($uid, "", $id)) {
             $suspension[$uid][$ip][$id] = 1;
         } else {
             $suspension[$uid][$ip][$id] = 0;
         }
     }
     $items = $this->getValidPerms();
     foreach ($items as $item) {
         /* skip access for suspended users */
         //if ( !empty($suspension[$uid][$ip][$id]) && in_array($item, array("post", "reply", "edit", "delete", "addpoll", "vote", "attach", "noapprove", "type")) ) continue;
         if (!empty($suspension[$uid][$ip][$id])) {
             continue;
         }
         $full_items[] = "'forum_{$item}'";
     }
     return $full_items;
 }
Exemplo n.º 2
0
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
//  Author: phppp (D.J., infomax@gmail.com)                                  //
//  URL: http://xoopsforge.com, http://xoops.org.cn                          //
//  Project: Article Project                                                 //
//  ------------------------------------------------------------------------ //
include 'header.php';
$ratinguser = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
$anonwaitdays = 1;
$ip = newbb_getIP(true);
foreach (array("topic_id", "rate", "forum") as $var) {
    ${$var} = isset($_POST[$var]) ? intval($_POST[$var]) : (isset($_GET[$var]) ? intval($_GET[$var]) : 0);
}
$topic_handler =& xoops_getmodulehandler('topic', 'newbb');
$topic_obj =& $topic_handler->get($topic_id);
if (!$topic_handler->getPermission($topic_obj->getVar("forum_id"), $topic_obj->getVar('topic_status'), "post") && !$topic_handler->getPermission($topic_obj->getVar("forum_id"), $topic_obj->getVar('topic_status'), "reply")) {
    redirect_header("javascript:history.go(-1);", 2, _NOPERM);
}
if (empty($rate)) {
    redirect_header("viewtopic.php?topic_id=" . $topic_id . "&forum=" . $forum . "", 4, _MD_NOVOTERATE);
    exit;
}
$rate_handler =& xoops_getmodulehandler("rate", $xoopsModule->getVar("dirname"));
if ($ratinguser != 0) {
    // Check if Topic POSTER is voting (UNLESS Anonymous users allowed to post)
Exemplo n.º 3
0
function xoops_module_install_newbb(&$module)
{
    /* Create a test category */
    $category_handler =& xoops_getmodulehandler('category', $module->getVar("dirname"));
    $category =& $category_handler->create();
    $category->setVar('cat_title', _MI_NEWBB_INSTALL_CAT_TITLE, true);
    $category->setVar('cat_image', "", true);
    $category->setVar('cat_description', _MI_NEWBB_INSTALL_CAT_DESC, true);
    $category->setVar('cat_url', "http://xoops.org XOOPS", true);
    if (!($cat_id = $category_handler->insert($category))) {
        return true;
    }
    /* Create a forum for test */
    $forum_handler =& xoops_getmodulehandler('forum', $module->getVar("dirname"));
    $forum =& $forum_handler->create();
    $forum->setVar('forum_name', _MI_NEWBB_INSTALL_FORUM_NAME, true);
    $forum->setVar('forum_desc', _MI_NEWBB_INSTALL_FORUM_DESC, true);
    $forum->setVar('forum_moderator', array());
    $forum->setVar('parent_forum', 0);
    $forum->setVar('cat_id', $cat_id);
    $forum->setVar('attach_maxkb', 100);
    $forum->setVar('attach_ext', "zip|jpg|gif");
    $forum->setVar('hot_threshold', 20);
    $forum_id = $forum_handler->insert($forum);
    /* Set corresponding permissions for the category and the forum */
    $module_id = $module->getVar("mid");
    $gperm_handler =& xoops_gethandler("groupperm");
    $groups_view = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
    $groups_post = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS);
    $post_items = array('post', 'reply', 'edit', 'delete', 'addpoll', 'vote', 'attach', 'noapprove', 'type');
    foreach ($groups_view as $group_id) {
        $gperm_handler->addRight("category_access", $cat_id, $group_id, $module_id);
        $gperm_handler->addRight("forum_access", $forum_id, $group_id, $module_id);
        $gperm_handler->addRight("forum_view", $forum_id, $group_id, $module_id);
    }
    foreach ($groups_post as $group_id) {
        foreach ($post_items as $item) {
            $gperm_handler->addRight("forum_" . $item, $forum_id, $group_id, $module_id);
        }
    }
    /* Create a test post */
    require_once XOOPS_ROOT_PATH . "/modules/newbb/include/functions.user.php";
    $post_handler =& xoops_getmodulehandler('post', $module->getVar("dirname"));
    $forumpost =& $post_handler->create();
    $forumpost->setVar('poster_ip', newbb_getIP());
    $forumpost->setVar('uid', $GLOBALS["xoopsUser"]->getVar("uid"));
    $forumpost->setVar('approved', 1);
    $forumpost->setVar('forum_id', $forum_id);
    $forumpost->setVar('subject', _MI_NEWBB_INSTALL_POST_SUBJECT, true);
    $forumpost->setVar('dohtml', 0);
    $forumpost->setVar('dosmiley', 1);
    $forumpost->setVar('doxcode', 1);
    $forumpost->setVar('dobr', 1);
    $forumpost->setVar('icon', "", true);
    $forumpost->setVar('attachsig', 1);
    $forumpost->setVar('post_time', time());
    $forumpost->setVar('post_text', _MI_NEWBB_INSTALL_POST_TEXT, true);
    $postid = $post_handler->insert($forumpost);
    return true;
}
Exemplo n.º 4
0
 function checkIdentity($uid = -1)
 {
     global $xoopsUser;
     $uid = $uid > -1 ? $uid : (is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
     if ($this->getVar('uid') > 0) {
         $user_ok = $uid == $this->getVar('uid') ? true : false;
     } else {
         static $user_ip;
         if (!isset($user_ip)) {
             //$user_ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']))?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
             $user_ip = newbb_getIP();
         }
         $user_ok = $user_ip == $this->getVar('poster_ip') ? true : false;
     }
     return $user_ok;
 }
Exemplo n.º 5
0
 function checkIdentity($uid = -1)
 {
     global $xoopsUser;
     $uid = $uid > -1 ? $uid : (is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
     if ($this->getVar('uid') > 0) {
         $user_ok = $uid == $this->getVar('uid') ? true : false;
     } else {
         static $user_ip;
         if (!isset($user_ip)) {
             $user_ip = newbb_getIP();
         }
         $user_ok = $user_ip == $this->getVar('poster_ip') ? true : false;
     }
     return $user_ok;
 }
Exemplo n.º 6
0
 /**
  * Get a forum list that a user is suspended, according to his uid and ip
  * Store the list into session if module cache is enabled
  * 
  * 
  * @param	int 	$uid user id
  * @param	string 	$ip user ip
  */
 function forumList($uid = -1, $ip = "")
 {
     static $forums = array();
     $uid = $uid < 0 ? is_object($GLOBALS["xoopsUser"]) ? $GLOBALS["xoopsUser"]->getVar("uid") : 0 : $uid;
     $ip = empty($ip) ? newbb_getIP(true) : $ip;
     if (isset($forums[$uid][$ip])) {
         return $forums[$uid][$ip];
     }
     if (!empty($GLOBALS["xoopsModuleConfig"]['cache_enabled'])) {
         $forums[$uid][$ip] = newbb_getsession("sf" . $uid . "_" . ip2long($ip), true);
         if (is_array($forums[$uid][$ip]) && count($forums[$uid][$ip])) {
             return $forums[$uid][$ip];
         }
     }
     $uid_criteria = empty($uid) ? "1=1" : "uid=" . intval($uid);
     if (!empty($ip)) {
         $ip_segs = explode(".", $ip);
         for ($i = 1; $i <= 4; $i++) {
             $ips[] = $this->db->quoteString(implode(".", array_slice($ip_segs, 0, $i)));
         }
         $ip_criteria = "ip IN(" . implode(",", $ips) . ")";
     } else {
         $ip_criteria = "1=1";
     }
     $expire_criteria = "mod_end > " . time();
     $sql = sprintf("SELECT forum_id, COUNT(*) AS count FROM %s WHERE (%s OR %s) AND (%s) GROUP BY forum_id", $this->db->prefix('bb_moderates'), $uid_criteria, $ip_criteria, $expire_criteria);
     if (!($result = $this->db->query($sql))) {
         return $forums[$uid][$ip] = array();
     }
     $_forums = array();
     while ($row = $this->db->fetchArray($result)) {
         if ($row["count"] > 0) {
             $_forums[$row["forum_id"]] = 1;
         }
     }
     $forums[$uid][$ip] = count($_forums) ? array_keys($_forums) : array(-1);
     if (!empty($GLOBALS["xoopsModuleConfig"]['cache_enabled'])) {
         newbb_setsession("sf" . $uid . "_" . ip2long($ip), $forums[$uid][$ip]);
     }
     return $forums[$uid][$ip];
 }
Exemplo n.º 7
0
    exit;
}
if ($xoopsModuleConfig['wol_enabled']) {
    $online_handler =& xoops_getmodulehandler('online', 'newbb');
    $online_handler->init($forum);
}
$myts =& MyTextSanitizer::getInstance();
if (isset($_POST['submit'])) {
    $report_handler =& xoops_getmodulehandler('report', 'newbb');
    $report =& $report_handler->create();
    $report->setVar('report_text', $_POST['report_text']);
    $report->setVar('post_id', $post_id);
    $report->setVar('report_time', time());
    $report->setVar('reporter_uid', is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0);
    //$report_ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']))?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
    $report->setVar('reporter_ip', newbb_getIP());
    $report->setVar('report_result', 0);
    $report->setVar('report_memo', "");
    if ($report_id = $report_handler->insert($report)) {
        $message = _MD_REPORTED;
    } else {
        $message = _MD_REPORT_ERROR;
    }
    redirect_header("viewtopic.php?forum={$forum}&amp;topic_id={$topic_id}&amp;post_id={$post_id}&amp;order={$order}&amp;viewmode={$viewmode}", 2, $message);
    exit;
} else {
    include XOOPS_ROOT_PATH . '/header.php';
    include XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
    $report_form = new XoopsThemeForm('', 'reportform', 'report.php');
    $report_form->addElement(new XoopsFormText(_MD_REPORT_TEXT, 'report_text', 80, 255), true);
    $report_form->addElement(new XoopsFormHidden('pid', $pid));
Exemplo n.º 8
0
     $_POST["ip"] = "";
 }
 if (!empty($_POST["uid"]) && $moderate_handler->getLatest($_POST["uid"]) > time() + $_POST["expire"] * 3600 * 24 || !empty($_POST["ip"]) && $moderate_handler->getLatest($_POST["ip"], false) > time() + $_POST["expire"] * 3600 * 24 || empty($_POST["uid"]) && empty($_POST["ip"])) {
 } else {
     $moderate_obj =& $moderate_handler->create();
     $moderate_obj->setVar("uid", @$_POST["uid"]);
     $moderate_obj->setVar("ip", @$_POST["ip"]);
     $moderate_obj->setVar("forum_id", $forum_id);
     $moderate_obj->setVar("mod_start", time());
     $moderate_obj->setVar("mod_end", time() + $_POST["expire"] * 3600 * 24);
     $moderate_obj->setVar("mod_desc", @$_POST["desc"]);
     if ($res = $moderate_handler->insert($moderate_obj) && !empty($forum_id) && !empty($_POST["uid"])) {
         $uname = XoopsUser::getUnameFromID($_POST["uid"]);
         $post_handler =& xoops_getmodulehandler("post", "newbb");
         $post_obj =& $post_handler->create();
         $post_obj->setVar("poster_ip", newbb_getIP());
         $post_obj->setVar("uid", empty($GLOBALS["xoopsUser"]) ? 0 : $GLOBALS["xoopsUser"]->getVar("uid"));
         $post_obj->setVar("forum_id", $forum_id);
         $post_obj->setVar("subject", sprintf(_MD_SUSPEND_SUBJECT, $uname, $_POST["expire"]));
         $post_obj->setVar("post_text", sprintf(_MD_SUSPEND_TEXT, '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $_POST["uid"] . '">' . $uname . '</a>', $_POST["expire"], @$_POST["desc"], formatTimestamp(time() + $_POST["expire"] * 3600 * 24)));
         $post_obj->setVar("dohtml", 1);
         $post_obj->setVar("dosmiley", 1);
         $post_obj->setVar("doxcode", 1);
         $post_obj->setVar("post_time", time());
         $post_handler->insert($post_obj);
         unset($post_obj);
     }
     if ($_POST["uid"] > 0) {
         $online_handler =& xoops_gethandler('online');
         $onlines =& $online_handler->getAll(new Criteria("online_uid", $_POST["uid"]));
         if (false != $onlines) {
 *
 * @copyright	The XOOPS Project http://xoops.sf.net
 * @license		http://www.fsf.org/copyleft/gpl.html GNU public license
 * @author		Taiwen Jiang (phppp or D.J.) <*****@*****.**>
 * @since		4.00
 * @version		$Id $
 * @package		module::newbb
 */
global $xoopsModule, $xoopsModuleConfig, $myts, $xoopsUser, $forum_obj;
if (!defined('XOOPS_ROOT_PATH') || !is_object($forum_obj) || !is_object($xoopsUser) || !is_object($xoopsModule)) {
    return;
}
$forum_id = $forum_obj->getVar("forum_id");
$post_handler =& xoops_getmodulehandler('post', 'newbb');
$post_obj =& $post_handler->create();
$post_obj->setVar('poster_ip', newbb_getIP());
$post_obj->setVar('uid', $xoopsUser->getVar("uid"));
$post_obj->setVar('approved', 1);
$post_obj->setVar('forum_id', $forum_id);
$subject = sprintf(_MD_WELCOME_SUBJECT, $xoopsUser->getVar('uname'));
$post_obj->setVar('subject', $subject);
$post_obj->setVar('dohtml', 1);
$post_obj->setVar('dosmiley', 1);
$post_obj->setVar('doxcode', 0);
$post_obj->setVar('dobr', 1);
$post_obj->setVar('icon', "");
$post_obj->setVar('attachsig', 1);
$post_obj->setVar('post_time', time());
$categories = array();
$module_handler =& xoops_gethandler('module');
if ($mod = @$module_handler->getByDirname('profile', true)) {
Exemplo n.º 10
0
function newbb_welcome($user = -1)
{
    global $xoopsModule, $xoopsModuleConfig, $xoopsUser, $xoopsConfig, $myts;
    if (empty($xoopsModuleConfig["welcome_forum"])) {
        return null;
    }
    if ($user == -1) {
        $user =& $xoopsUser;
    }
    if (!is_object($user) || $user->getVar('posts')) {
        return null;
    }
    $forum_handler =& xoops_getmodulehandler('forum', 'newbb');
    $forum =& $forum_handler->get($xoopsModuleConfig["welcome_forum"]);
    if (!$forum_handler->getPermission($forum)) {
        unset($forum);
        return null;
    }
    unset($forum);
    $post_handler =& xoops_getmodulehandler('post', 'newbb');
    $forumpost =& $post_handler->create();
    $forumpost->setVar('poster_ip', newbb_getIP());
    $forumpost->setVar('uid', $user->getVar("uid"));
    $forumpost->setVar('approved', 1);
    $forumpost->setVar('forum_id', $xoopsModuleConfig["welcome_forum"]);
    $subject = sprintf(_MD_WELCOME_SUBJECT, $user->getVar('uname'));
    $forumpost->setVar('subject', $subject);
    $forumpost->setVar('dohtml', 1);
    $forumpost->setVar('dosmiley', 1);
    $forumpost->setVar('doxcode', 0);
    $forumpost->setVar('dobr', 1);
    $forumpost->setVar('icon', "");
    $forumpost->setVar('attachsig', 1);
    $gperm_handler =& xoops_gethandler('groupperm');
    $groups = array(XOOPS_GROUP_ANONYMOUS, XOOPS_GROUP_USERS);
    $module_handler =& xoops_gethandler('module');
    $mod = $module_handler->getByDirname('profile');
    if (!defined("_PROFILE_MA_ALLABOUT")) {
        $mod->loadLanguage();
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    $show_ids =& $groupperm_handler->getItemIds('profile_show', $groups, $mod->getVar('mid'));
    $visible_ids =& $groupperm_handler->getItemIds('profile_visible', $groups, $mod->getVar('mid'));
    unset($mod);
    $fieldids = array_intersect($show_ids, $visible_ids);
    $profile_handler =& xoops_gethandler('profile');
    $fields =& $profile_handler->loadFields();
    $cat_handler =& xoops_getmodulehandler('category', 'profile');
    $categories =& $cat_handler->getObjects(null, true, false);
    $fieldcat_handler =& xoops_getmodulehandler('fieldcategory', 'profile');
    $fieldcats =& $fieldcat_handler->getObjects(null, true, false);
    // Add core fields
    $categories[0]['cat_title'] = sprintf(_PROFILE_MA_ALLABOUT, $user->getVar('name'));
    $avatar = trim($user->getVar('user_avatar'));
    if (!empty($avatar) && $avatar != "blank.gif") {
        $categories[0]['fields'][] = array('title' => _PROFILE_MA_AVATAR, 'value' => "<img src='" . XOOPS_UPLOAD_URL . "/" . $user->getVar('user_avatar') . "' alt='" . $user->getVar('name') . "' />");
        $weights[0][] = 0;
    }
    if ($user->getVar('user_viewemail') == 1) {
        $email = $user->getVar('email', 'E');
        $categories[0]['fields'][] = array('title' => _PROFILE_MA_EMAIL, 'value' => $email);
        $weights[0][] = 0;
    }
    // Add dynamic fields
    foreach (array_keys($fields) as $i) {
        if (in_array($fields[$i]->getVar('fieldid'), $fieldids)) {
            $catid = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? $fieldcats[$fields[$i]->getVar('fieldid')]['catid'] : 0;
            $value = $fields[$i]->getOutputValue($user);
            if (is_array($value)) {
                $value = implode('<br />', array_values($value));
            }
            if (empty($value)) {
                continue;
            }
            $categories[$catid]['fields'][] = array('title' => $fields[$i]->getVar('field_title'), 'value' => $value);
            $weights[$catid][] = isset($fieldcats[$fields[$i]->getVar('fieldid')]) ? intval($fieldcats[$fields[$i]->getVar('fieldid')]['field_weight']) : 1;
        }
    }
    foreach (array_keys($categories) as $i) {
        if (isset($categories[$i]['fields'])) {
            array_multisort($weights[$i], SORT_ASC, array_keys($categories[$i]['fields']), SORT_ASC, $categories[$i]['fields']);
        }
    }
    ksort($categories);
    $message = sprintf(_MD_WELCOME_MESSAGE, $user->getVar('uname')) . "\n\n";
    $message .= _PROFILE . ": <a href='" . XOOPS_URL . "/userinfo.php?uid=" . $user->getVar('uid') . "'><strong>" . $user->getVar('uname') . "</strong></a> ";
    $message .= " | <a href='" . XOOPS_URL . "/pmlite.php?send2=1&amp;to_userid=" . $user->getVar('uid') . "'>" . _MD_PM . "</a>\n";
    foreach ($categories as $category) {
        if (isset($category["fields"])) {
            $message .= "\n\n" . $category["cat_title"] . ":\n\n";
            foreach ($category["fields"] as $field) {
                if (empty($field["value"])) {
                    continue;
                }
                $message .= $field["title"] . ": " . $field["value"] . "\n";
            }
        }
    }
    $forumpost->setVar('post_text', $message);
    $postid = $post_handler->insert($forumpost);
    if (!empty($xoopsModuleConfig['notification_enabled'])) {
        $tags = array();
        $tags['THREAD_NAME'] = $subject;
        $tags['THREAD_URL'] = XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/viewtopic.php?post_id=' . $postid . '&amp;topic_id=' . $forumpost->getVar('topic_id') . '&amp;forum=' . $xoopsModuleConfig["welcome_forum"];
        $tags['POST_URL'] = $tags['THREAD_URL'] . '#forumpost' . $postid;
        include_once 'include/notification.inc.php';
        $forum_info = newbb_notify_iteminfo('forum', $xoopsModuleConfig["welcome_forum"]);
        $tags['FORUM_NAME'] = $forum_info['name'];
        $tags['FORUM_URL'] = $forum_info['url'];
        $notification_handler =& xoops_gethandler('notification');
        $notification_handler->triggerEvent('forum', $xoopsModuleConfig["welcome_forum"], 'new_thread', $tags);
        $notification_handler->triggerEvent('global', 0, 'new_post', $tags);
        $notification_handler->triggerEvent('forum', $xoopsModuleConfig["welcome_forum"], 'new_post', $tags);
        $tags['POST_CONTENT'] = $myts->stripSlashesGPC($message);
        $tags['POST_NAME'] = $myts->stripSlashesGPC($subject);
        $notification_handler->triggerEvent('global', 0, 'new_fullpost', $tags);
    }
    return $postid;
}
Exemplo n.º 11
0
     $isreply = 0;
     $isnew = 1;
     if (is_object($xoopsUser) && empty($_POST['noname'])) {
         $uid = $xoopsUser->getVar("uid");
     } else {
         $uid = 0;
     }
     if (isset($pid) && $pid != "") {
         $forumpost->setVar('pid', $pid);
     }
     if (!empty($topic_id)) {
         $forumpost->setVar('topic_id', $topic_id);
         $isreply = 1;
     }
     //$post_ip = (isset($_SERVER['HTTP_X_FORWARDED_FOR']))?$_SERVER['HTTP_X_FORWARDED_FOR']:$_SERVER['REMOTE_ADDR'];
     $forumpost->setVar('poster_ip', newbb_getIP());
     $forumpost->setVar('uid', $uid);
 }
 if ($topic_handler->getPermission($forum, $topic_status, 'noapprove')) {
     $approved = 1;
 } else {
     $approved = 0;
 }
 $forumpost->setVar('approved', $approved);
 $forumpost->setVar('forum_id', $forum->getVar('forum_id'));
 $subject = xoops_trim($_POST['subject']);
 $subject = $subject == '' ? _NOTITLE : $subject;
 $poster_name = !empty($_POST['poster_name']) ? xoops_trim($_POST['poster_name']) : '';
 $dohtml = !empty($_POST['dohtml']) ? 1 : 0;
 $dosmiley = !empty($_POST['dosmiley']) ? 1 : 0;
 $doxcode = !empty($_POST['doxcode']) ? 1 : 0;