Exemple #1
0
//更新统计数
$_SGLOBAL['db']->query('UPDATE ' . tname($modelsinfoarr['modelname'] . 'items') . ' SET viewnum=viewnum+1 WHERE itemid=\'' . $itemid . '\'');
//评论
$listcount = $item['replynum'];
$_SCONFIG['viewspace_pernum'] = intval($_SCONFIG['viewspace_pernum']);
if (!empty($modelsinfoarr['allowcomment']) && !empty($_SCONFIG['viewspace_pernum']) && $listcount) {
    $repeatids = array();
    $j = 1;
    $sql = "SELECT c.* FROM " . tname('spacecomments') . " c WHERE c.itemid='{$news['itemid']}' AND status='1' ORDER BY c.dateline " . ($_SCONFIG['commorderby'] ? 'DESC' : 'ASC') . " LIMIT 0, {$_SCONFIG['viewspace_pernum']}";
    $query = $_SGLOBAL['db']->query($sql);
    while ($comment = $_SGLOBAL['db']->fetch_array($query)) {
        $comment = formatcomment($comment, $repeatids);
        $comment['num'] = $j++;
        $commentlist[] = $comment;
        if (!empty($comment['firstcid']) && !in_array($comment['firstcid'], $repeatids)) {
            $repeatids[] = $comment['firstcid'];
        }
    }
}
if (allowfeed()) {
    $addfeedcheck = addfeedcheck(8) ? 'checked="checked"' : '';
}
$a_url = A_URL;
//模板
if (empty($modelsinfoarr['tpl'])) {
    $tpldir = 'model/data/' . $modelsinfoarr['modelname'];
} else {
    $tpldir = 'mthemes/' . $modelsinfoarr['tpl'];
}
include template($tpldir . '/view.html.php', 1);
ob_out();
function feedurllogic($entryurl)
{
    global $newfeedid;
    global $newidadd;
    global $lmenuexist;
    //echo 'feedlogic';
    // first find out xml feed source rss and atom,  post and comments.
    $feedsource = findrssxmllink($entryurl);
    //print_r($feedsource);
    // has any xml feeds been found
    if ($feedsource) {
        $addalready = alreadyaddurl($entryurl);
        // if the url has been added already then do nothing, else go through a whole lot of logic
        if (isset($addalready)) {
            //echo 'allready add';
            // then process further with personalize logic
            feedexistadd($addalready, $entryurl);
            //echo 'already in database';
            $newfeedid = $addalready;
            $_SESSION[me_url] = $entryurl;
            $_SESSION[mefid] = $newfeedid;
            //echo $newfeedid.'setting session existing';
        } else {
            // add new url and process scores, stats, melife etc
            // if got back url add it
            if ($entryurl) {
                //echo 'new add';
                $before = addfeedcheck();
                // could check feedid too
                // we have a list of feeds, try rss then atom, if not fed in then we cannot process for now.
                if ($feedsource[rss]) {
                    //echo 'rss feed add try';
                    //echo $feedsource[rss][0];
                    //error_reporting(5);
                    fof_add_feed($feedsource[rss][0]);
                    $newidadd = alreadyaddurl($entryurl);
                    if ($newidadd && $newidadd !== $before) {
                        //echo 'before process new';
                        $newfeedid = alreadyaddurl($entryurl);
                        //echo $newfeedid;
                        processnewurl($entryurl, $newfeedid);
                        //echo 'after newprocess add';
                        // generate new individual perpeergroup
                        indivtopfivelife($newfeedid);
                        indivmostlikeme($newfeedid);
                        keepfeed($newfeedid);
                        //echo 'successful rss';
                        $addedfeed = 1;
                    }
                    if ($addedfeed !== 1) {
                        //echo 'atom feed try adding';
                        fof_add_feed($feedsource[atom][0]);
                        $newfeedid = alreadyaddurl($entryurl);
                        if ($newfeedid && $newfeedid !== $before) {
                            processnewurl($entryurl, $newfeedid);
                            // generate new individual perpeergroup
                            indivtopfivelife($newfeedid);
                            indivmostlikeme($newfeedid);
                            keepfeed($newfeedid);
                            //echo 'successful atom';
                            $atomaddedfeed = 1;
                        }
                        // closes if
                        // one last try, let feed reader have a go at find the xml feed file
                        if ($atomaddedfeed !== 1) {
                            //echo 'letting rss feed reader have a go with source url';
                            fof_add_feed($entryurl);
                            $newfeedid = alreadyaddurl($entryurl);
                            if ($newfeedid && $newfeedid !== $before) {
                                processnewurl($entryurl, $newfeedid);
                                // generate new individual perpeergroup
                                indivtopfivelife($newfeedid);
                                indivmostlikeme($newfeedid);
                                keepfeed($newfeedid);
                                //echo 'successful feed reader attempt';
                                $feedreaderyes = 1;
                            } else {
                                echo '<b>mepath can not add the feed for the blog right now, please try again or accept our apology for it not working.</b>';
                            }
                        }
                    }
                    // closes if
                    if ($addedfeed == 1 || $atomaddedfeed == 1 || $feedreaderyes == 1) {
                        $_SESSION[me_url] = $entryurl;
                        $_SESSION[mefid] = $newfeedid;
                        //echo $newfeedid.'setting session';
                        $topfivem = $_SESSION[topmenu];
                        // now need to add manually added back lifestlye menu items not included by mepath in the individuals users top5. (obviously mepath would not want this outcome if they blog out the lifestlye in question ie. mepath has got it wrong).
                        // compare topmenubefore with current menu.
                        //echo 'existing menu<br />';
                        //print_r($lmenuexist);
                        //echo 'existing menu after<br />';
                        comptop5man($lmenuexist, $topfivem);
                        $db->query = "INSERT INTO " . RSSDATA . ".rssjoin (userid, feedsid) VALUES ('{$_SESSION['user_id']}', '{$newfeedid}')";
                        // execute query grouped words
                        $savejoinrss = mysql_query($db->query) or die("Error in query: {$db->query}. " . mysql_error());
                        //echo $db->query;
                        // need array to contain top lifesytle and save so on return personalized lifestyle menu is presented
                        // need to differenciate between man add items and autotop5
                        $toplifestle = $_SESSION[newtopm];
                        $db->query = "INSERT INTO " . RSSDATA . ".userlife (userid, lifestyleid, humadd) VALUES ";
                        foreach ($toplifestle as $toplsi => $mortf) {
                            $db->query .= " ('{$_SESSION['user_id']}', '{$toplsi}', '{$mortf}'), ";
                        }
                        $db->query = substr($db->query, 0, strLen($db->query) - 2);
                        //this will eat the last comma
                        $resultlmenu = mysql_query($db->query) or die("Error in query: {$db->query}. " . mysql_error());
                        //echo $db->query;
                        // RUN ALL INPUT TESTS
                        newurltest($newfeedid);
                    }
                    // closes if a feed has been added.
                }
            }
        }
        // closes first else
    } else {
        //echo 'letting rss feed reader have a go with source url  TWO';
        $before = alreadyaddurl($entryurl);
        fof_add_feed($entryurl);
        $newfeedid = alreadyaddurl($entryurl);
        if ($newfeedid && $newfeedid !== $before) {
            processnewurl($entryurl, $newfeedid);
            // generate new individual perpeergroup
            indivtopfivelife($newfeedid);
            indivmostlikeme($newfeedid);
            keepfeed($newfeedid);
            //echo 'successful feed reader attempt TWO';
            $feedreaderyes = 1;
        } else {
            echo '<b>mepath can not find an xml blog feed right now, please try again or accept our apology for it not working.</b>';
        }
        // closes else
        if ($feedreaderyes == 1) {
            $_SESSION[me_url] = $entryurl;
            $_SESSION[mefid] = $newfeedid;
            $topfivem = $_SESSION[topmenu];
            // now need to add manually added back lifestlye menu items not included by mepath in the individuals users top5. (obviously mepath would not want this outcome if they blog out the lifestlye in question ie. mepath has got it wrong).
            // compare topmenubefore with current menu.
            comptop5man($lmenuexist, $topfivem);
            $db->query = "INSERT INTO " . RSSDATA . ".rssjoin (userid, feedsid) VALUES ('{$_SESSION['user_id']}', '{$newfeedid}')";
            // execute query grouped words
            $savejoinrss = mysql_query($db->query) or die("Error in query: {$db->query}. " . mysql_error());
            //echo $db->query;
            // need array to contain top lifesytle and save so on return personalized lifestyle menu is presented
            // need to differenciate between man add items and autotop5
            $toplifestle = $_SESSION[newtopm];
            $db->query = "INSERT INTO " . RSSDATA . ".userlife (userid, lifestyleid, humadd) VALUES ";
            foreach ($toplifestle as $toplsi => $mortf) {
                $db->query .= " ('{$_SESSION['user_id']}', '{$toplsi}', '{$mortf}'), ";
            }
            $db->query = substr($db->query, 0, strLen($db->query) - 2);
            //this will eat the last comma
            $resultlmenu = mysql_query($db->query) or die("Error in query: {$db->query}. " . mysql_error());
            //echo $db->query;
        }
        // closes if a feed has been added.
    }
    // closes last else
}