Example #1
0
$PHORUM['DATA']['URL']['CC4'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_SIGNATURE);
$PHORUM['DATA']['URL']['CC5'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_MAIL);
$PHORUM['DATA']['URL']['CC6'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_BOARD);
$PHORUM['DATA']['URL']['CC7'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_PASSWORD);
$PHORUM['DATA']['URL']['CC8'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_UNAPPROVED);
$PHORUM['DATA']['URL']['CC9'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_FILES);
$PHORUM['DATA']['URL']['CC10'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_USERS);
$PHORUM['DATA']['URL']['CC14'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_PRIVACY);
$PHORUM['DATA']['URL']['CC15'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_GROUP_MODERATION);
$PHORUM['DATA']['URL']['CC16'] = phorum_get_url(PHORUM_CONTROLCENTER_URL, "panel=" . PHORUM_CC_GROUP_MEMBERSHIP);

// Determine if the user files functionality is available.
$PHORUM["DATA"]["MYFILES"] = ($PHORUM["file_uploads"] || $PHORUM["user"]["admin"]);

// Determine if the user is a moderator.
$PHORUM["DATA"]["MESSAGE_MODERATOR"] = (count(phorum_user_access_list(PHORUM_USER_ALLOW_MODERATE_MESSAGES)) > 0);
$PHORUM["DATA"]["USER_MODERATOR"] = phorum_user_access_allowed(PHORUM_USER_ALLOW_MODERATE_USERS);
$PHORUM["DATA"]["GROUP_MODERATOR"] = phorum_user_allow_moderate_group();
$PHORUM["DATA"]["MODERATOR"] = ($PHORUM["DATA"]["USER_MODERATOR"] + $PHORUM["DATA"]["MESSAGE_MODERATOR"] + $PHORUM["DATA"]["GROUP_MODERATOR"]) > 0;

// The form action for the common form.
$PHORUM["DATA"]["URL"]["ACTION"] = phorum_get_url(PHORUM_CONTROLCENTER_ACTION_URL);

$user = $PHORUM['user'];

// Security messures.
unset($user["password"]);
unset($user["password_temp"]);
unset($user["permissions"]);

// Format the user signature using standard message body formatting
Example #2
0
if (isset($_POST['onlyunapproved']) && is_numeric($_POST['onlyunapproved'])) {
    $showwaiting = (int)$_POST['onlyunapproved'];
} elseif(isset($PHORUM['args']['onlyunapproved']) && !empty($PHORUM["args"]['onlyunapproved']) && is_numeric($PHORUM["args"]['onlyunapproved'])) {
    $showwaiting = (int)$PHORUM['args']['onlyunapproved'];
} else {
    $showwaiting = 0;
}
$PHORUM['DATA']['SELECTED'] = $moddays;
$PHORUM['DATA']['SELECTED_2'] = $showwaiting?true:false;

// some needed vars
$numunapproved = 0;
$oldforum = $PHORUM['forum_id'];

$mod_forums = phorum_user_access_list(PHORUM_USER_ALLOW_MODERATE_MESSAGES);
$gotforums = (count($mod_forums) > 0);

$PHORUM['DATA']['PREPOST'] = array();

if ($gotforums)
    $foruminfo = phorum_db_get_forums($mod_forums,-1,$PHORUM['vroot']);
else
    $foruminfo = array();

// Make sure we have a forum name for unapproved announcements.
$foruminfo[0] = array (
    'name' => $PHORUM["DATA"]["LANG"]["Announcement"]
);

foreach($mod_forums as $forum => $rest) {
Example #3
0
function phorum_user_subscribe( $user_id, $forum_id, $thread, $type )
{
    $list=phorum_user_access_list( PHORUM_USER_ALLOW_READ );
    if(!in_array($forum_id, $list)) return;
    return phorum_db_user_subscribe( $user_id, $forum_id, $thread, $type );
}
Example #4
0
/**
 * This function searches the database for the supplied search
 * criteria and returns an array with two elements.  One is the count
 * of total messages that matched, the second is an array of the
 * messages from the results based on the $start (0 base) given and
 * the $length given.
 */

function phorum_db_search($search, $offset, $length, $match_type, $match_date, $match_forum)
{
    $PHORUM = $GLOBALS["PHORUM"];

    $start = $offset * $PHORUM["list_length"];

    $arr = array("count" => 0, "rows" => array());

    $conn = phorum_db_postgresql_connect();

    // have to check what forums they can read first.
    $allowed_forums=phorum_user_access_list(PHORUM_USER_ALLOW_READ);
    // if they are not allowed to search any forums, return the emtpy $arr;
    if(empty($allowed_forums) || ($PHORUM['forum_id']>0 && !in_array($PHORUM['forum_id'], $allowed_forums)) ) return $arr;

    // Add forum 0 (for announcements) to the allowed forums.
    $allowed_forums[] = 0;

    if($PHORUM['forum_id']!=0 && $match_forum!="ALL"){
        $forum_where=" and forum_id={$PHORUM['forum_id']}";
    } else {
        $forum_where=" and forum_id in (".implode(",", $allowed_forums).")";
    }

    if($match_type=="AUTHOR"){

        $id_table=$PHORUM['search_table']."_auth_".md5(microtime());

        $search = pg_escape_string($search);

        $sql = "SELECT message_id INTO $id_table FROM {$PHORUM['message_table']} WHERE author = '$search' $forum_where";
        if ($match_date > 0 ){
            $ts  = time() - 86400 * $match_date;
            $sql.=" and datestamp >= $ts";
        }

        $res = pg_query($conn, $sql);
        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        $sql = "ALTER TABLE $id_table ADD PRIMARY KEY (message_id)";
        $res = pg_query($conn, $sql);
   	    if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

    } else {

        if($match_type=="PHRASE"){
            $terms = array('"'.$search.'"');
        } else {
            $quote_terms=array();
            if ( strstr( $search, '"' ) ){
                //first pull out all the double quoted strings (e.g. '"iMac DV" or -"iMac DV"')
                preg_match_all( '/-*"(.*?)"/', $search, $match );
                $search = preg_replace( '/-*".*?"/', '', $search );
                $quote_terms = $match[0];
//                $quote_terms = preg_replace( '/"/', '', $match[0] );
            }

            //finally pull out the rest words in the string
            $terms = preg_split( "/\s+/", $search, 0, PREG_SPLIT_NO_EMPTY );

            //merge them all together and return
            $terms = array_merge( $terms, $quote_terms);
        }

        if(count($terms)){

            $use_key="";
            $extra_where="";

            /* using this code on larger forums has shown to make the search faster.
               However, on smaller forums, it does not appear to help and in fact
               appears to slow down searches.

            if($match_date){
                $min_time=time()-86400*$match_date;
                $sql="select min(message_id) as min_id from {$PHORUM['message_table']} where datestamp>=$min_time";
                $res=pg_query($conn, $sql);
                if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
                $min_id=pg_fetch_result($res, 0, "min_id");
#                $use_key=" use key (primary)";
                $extra_where="and message_id>=$min_id";
            }
            */

            $id_table=$PHORUM['search_table']."_ft_".md5(microtime());

            if($PHORUM["DBCONFIG"]["mysql_use_ft"]){

                if($match_type=="ALL" && count($terms)>1){
                    $against="+".pg_escape_string(implode(" +", $terms));
                } else {
                    $against=pg_escape_string(implode(" ", $terms));
                }

                $clause="MATCH (search_text) AGAINST ('$against' IN BOOLEAN MODE)";

            } else {

                if($match_type=="ALL"){
                    $conj="and";
                } else {
                    $conj="or";
                }

                foreach($terms as $id => $term) {
                    $terms[$id] = pg_escape_string($term);
                }

                $clause = "( search_text like '%".implode("%' $conj search_text like '%", $terms)."%' )";

            }

            $sql = "SELECT message_id INTO $id_table from {$PHORUM['search_table']} WHERE $clause $extra_where";
            $res = pg_query($conn, $sql);	# was mysql_unbuffered_query
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

            $sql = "ALTER TABLE $id_table ADD PRIMARY KEY (message_id)";
            $res = pg_query($conn, $sql);
            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
        }
    }


    if (isset($id_table)) {

        // create a temporary table of the messages we want
        $table = $PHORUM['search_table']."_".md5(microtime());
        $sql   = "SELECT {$PHORUM['message_table']}.message_id, {$PHORUM['message_table']}.datestamp, status, forum_id INTO $table FROM {$PHORUM['message_table']} inner join $id_table using (message_id) where status = " . PHORUM_STATUS_APPROVED . " $forum_where";

        if ($match_date > 0) {
            $ts  = time() - 86400 * $match_date;
            $sql.=" and datestamp >= $ts";
        }

        $res = pg_query($conn, $sql);
        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        $sql = "ALTER TABLE $table ADD PRIMARY KEY (forum_id, status, datestamp)";
        $res = pg_query($conn, $sql);
        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        $sql="select count(*) as count from $table";
        $res = pg_query($conn, $sql);

        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");
        $total_count=pg_fetch_result($res, 0, 0);

        $sql = "select message_id from $table order by datestamp desc limit $length offset $start";
        $res = pg_query($conn, $sql);   # was unbuffered

        if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

        $idstring="";
        while ($rec = pg_fetch_row($res)){
            $idstring.="$rec[0],";
        }
        $idstring=substr($idstring, 0, -1);

        if($idstring){
            $sql = "select * from {$PHORUM['message_table']} where message_id in ($idstring) order by datestamp desc";
            $res = pg_query($conn, $sql);  # was unbuffered

            if ($err = pg_last_error()) phorum_db_pg_last_error("$err: $sql");

            $rows = array();

            while ($rec = pg_fetch_assoc($res)){
                $rows[$rec["message_id"]] = $rec;
		        $rows[$rec["message_id"]]['closed'] = $rows[$rec["message_id"]]['closed'] == 't' ? TRUE : FALSE;
            }

            $arr = array("count" => $total_count, "rows" => $rows);
        }
    }

    return $arr;
}