Example #1
0
function updaterating($sel_id)
{
    global $_TABLES;
    $voteresult = DB_query("select rating FROM {$_TABLES['filemgmt_votedata']} WHERE lid = '{$sel_id}'");
    $votesDB = DB_numROWS($voteresult);
    $totalrating = 0;
    if ($votesDB > 0) {
        while (list($rating) = DB_fetchARRAY($voteresult)) {
            $totalrating += $rating;
        }
        $finalrating = $totalrating / $votesDB;
    }
    $finalrating = number_format($finalrating, 4);
    DB_query("UPDATE {$_TABLES['filemgmt_filedetail']} SET rating='{$finalrating}', votes='{$votesDB}' WHERE lid = '{$sel_id}'");
}
Example #2
0
function nexdoc_getGroupOptions()
{
    global $_TABLES, $_FMCONF, $LANG_nexfile;
    $options = '';
    if (count($_FMCONF['excludeGroups']) > 0) {
        $excludeGroups = $_FMCONF['excludeGroups'];
        // Don't want to alter the global value
        array_walk($excludeGroups, 'wrap_each');
        $excludeGroups = implode(',', $excludeGroups);
    } else {
        $excludeGroups = '';
    }
    if (count($_FMCONF['excludeGroups']) > 0) {
        $includeCoreGroups = $_FMCONF['includeCoreGroups'];
        // Don't want to alter the global value
        array_walk($includeCoreGroups, 'wrap_each');
        $includeCoreGroups = implode(',', $includeCoreGroups);
    } else {
        $includeCoreGroups = '';
    }
    $sql = "SELECT grp_id,grp_name FROM {$_TABLES['groups']} ";
    $sql .= "WHERE (grp_gl_core = '0' ";
    if (!empty($excludeGroups)) {
        $sql .= "AND grp_name NOT IN ({$excludeGroups}) ";
    }
    $sql .= ' ) ';
    if (!empty($includeCoreGroups)) {
        $sql .= "OR ( grp_name in ({$includeCoreGroups}) ) ";
    }
    $sql .= 'ORDER BY grp_name';
    $query = DB_query($sql);
    if (DB_numROWS($query) > 0) {
        while (list($grp_id, $grp_name) = DB_fetchARRAY($query)) {
            $options .= '<option value="' . $grp_id . '">';
            $options .= $grp_name . '</option>' . LB;
        }
    } else {
        $options = '<option value="0">' . $LANG_nexfile['msg36'] . '</option>';
    }
    return $options;
}
Example #3
0
$numpages = ceil($maxrows / $show);
/*
$sql = "SELECT COUNT(*) FROM {$_TABLES['filemgmt_filedetail']} a ";
$sql .= "LEFT JOIN {$_TABLES['filemgmt_cat']} b ON a.cid=b.cid ";
$sql .= "WHERE a.cid = $cid AND status > 0 $groupsql";
list($maxrows) = DB_fetchArray(DB_query($sql));
$numpages = ceil($maxrows / $show);
*/
if ($maxrows > 0) {
    $sql = "SELECT a.lid, a.cid, a.title, a.url, a.homepage, a.version, a.size, a.submitter, a.logourl, a.status, a.date, a.hits, a.rating, a.votes, a.comments, b.description ";
    $sql .= "FROM {$_TABLES['filemgmt_filedetail']} a ";
    $sql .= "LEFT JOIN  {$_TABLES['filemgmt_filedesc']} b on a.lid=b.lid ";
    $sql .= "LEFT JOIN {$_TABLES['filemgmt_cat']} c ON a.cid=c.cid ";
    $sql .= "WHERE a.cid='" . intval($cid) . "' AND a.status > 0 {$groupsql} ORDER BY {$orderby} LIMIT {$offset}, {$show}";
    $result = DB_query($sql);
    $numrows = DB_numROWS($result);
    //if 2 or more items in result, show the sort menu
    if ($maxrows > 1) {
        $p->set_var('LANG_SORTBY', _MD_SORTBY);
        $p->set_var('LANG_TITLE', _MD_TITLE);
        $p->set_var('LANG_DATE', _MD_DATE);
        $p->set_var('LANG_RATING', _MD_RATING);
        $p->set_var('LANG_POPULARITY', _MD_POPULARITY);
        $p->set_var('LANG_CURSORTBY', _MD_CURSORTBY);
        $p->set_var('orderbyTrans', $orderbyTrans = convertorderbytrans($orderby));
        $p->parse('sort_menu', 'sortmenu');
    }
    $cssid = 1;
    for ($x = 1; $x <= $numrows; $x++) {
        list($lid, $cid, $dtitle, $url, $homepage, $version, $size, $submitter, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = DB_fetchArray($result);
        $rating = number_format($rating, 2);
Example #4
0
 function getChildTreeArray($sel_id = 0, $order = "", $parray = array(), $r_prefix = "")
 {
     $sql = "SELECT * FROM {$this->table} WHERE {$this->pid} = '{$sel_id}' {$this->filtersql} ";
     if ($order != "") {
         $sql .= " ORDER BY {$order}";
     }
     $result = DB_query($sql);
     $count = DB_numROWS($result);
     if ($count == 0) {
         return $parray;
     }
     while ($row = DB_fetchARRAY($result)) {
         $row['prefix'] = $r_prefix . ".";
         array_push($parray, $row);
         $parray = $this->getChildTreeArray($row[$this->id], $order, $parray, $row['prefix']);
     }
     return $parray;
 }
Example #5
0
function migrateComments($forum, $sid, $parent)
{
    global $verbose, $_TABLES, $_CONF, $migratedcomments;
    $sql = DB_query("SELECT sid,date,uid,title,comment from {$_TABLES['comments']} WHERE sid = '" . $sid . "' ORDER BY date ASC");
    $num_comments = DB_numROWS($sql);
    if ($verbose) {
        echo "Found {$num_comments} Comments to migrate for this topic";
    }
    $i = 0;
    while (list($sid, $commentdate, $uid, $subject, $comment) = DB_fetchARRAY($sql)) {
        $sqlid = DB_query("SELECT id from {$_TABLES['gf_topic']} ORDER BY id desc LIMIT 1");
        list($lastid) = DB_fetchARRAY($sqlid);
        $comment = prepareStringForDB($comment);
        $subject = prepareStringForDB($subject);
        $postmode = "HTML";
        $name = DB_getITEM($_TABLES['users'], 'username', "uid={$uid}");
        $email = DB_getITEM($_TABLES['users'], 'email', "uid={$uid}");
        $website = DB_getITEM($_TABLES['users'], 'homepage', "uid={$uid}");
        $datetime = explode(" ", $commentdate);
        $date = explode("-", $datetime[0]);
        $time = explode(":", $datetime[1]);
        $year = $date[0] > 1969 ? $date[0] : "2001";
        $month = $date[1];
        $day = $date[2];
        $hour = $time[0];
        $min = $time[1];
        $timestamp = mktime($hour, $min, 0, $month, $day, $year);
        $lastupdated = $timestamp;
        $migratedcomments++;
        DB_query("INSERT INTO {$_TABLES['gf_topic']} (forum,name,date,lastupdated, email, website, subject, comment, postmode, ip, mood, uid, pid, sticky, locked)\r\n            VALUES ('{$forum}','{$name}','{$timestamp}','{$lastupdated}','{$email}','{$website}','{$subject}','{$comment}','{$postmode}','','','{$uid}','{$parent}','0','0')");
        $i++;
    }
    DB_query("UPDATE {$_TABLES['gf_topic']} SET replies = {$num_comments} WHERE id={$parent}");
    return $num_comments;
}