示例#1
0
 function evaluate_formulas()
 {
     global $db;
     $res = $db->get_results("select * from " . table_formulas . " where type = 'report' and enabled = 1;");
     if (!$res) {
         return;
     }
     foreach ($res as $formula) {
         $reports = $this->count_all_votes("< 0");
         $votes = $this->count_all_votes("> 0");
         $from = $this->date;
         $now = time();
         $diff = $now - $from;
         $hours = $diff / 3600;
         $hours_since_submit = intval($hours * 100) / 100;
         $evalthis = 'if (' . $formula->formula . '){return "1";}else{return "0";}';
         if (eval($evalthis) == 1 && $this->status != 'spam') {
             totals_adjust_count($this->status, -1);
             totals_adjust_count('discard', 1);
             $this->status = 'discard';
             $this->store_basic();
             $vars = array('link_id' => $this->id);
             check_actions('story_discard', $vars);
         }
     }
 }
示例#2
0
    }
}
// pagename
define('pagename', 'delete');
$main_smarty->assign('pagename', pagename);
if (isset($_REQUEST['link_id'])) {
    global $db;
    $link_id = $_REQUEST['link_id'];
    if (!is_numeric($link_id)) {
        die;
    }
    $linkres = new Link();
    $linkres->id = $link_id;
    $linkres->read();
    //echo $linkres->status;
    totals_adjust_count($linkres->status, -1);
    //$linkres->store_basic();
    // module system hook
    $vars = array('link_id' => $linkres->id);
    check_actions('admin_story_delete', $vars);
    /*********find out the page slug dynamically ***********/
    $linkslugvalue = $db->get_results("SELECT " . table_links . ".link_category, " . table_categories . ".category_safe_name FROM " . table_categories . " LEFT JOIN " . table_links . " ON " . table_links . ".link_category = " . table_categories . ".category__auto_id WHERE " . table_links . ".link_id = '" . $link_id . "' LIMIT 0,1");
    $linkslug = '';
    foreach ($linkslugvalue as $slug) {
        $linkslug = $slug->category_safe_name;
    }
    if ($linkslug != '') {
        $redirectUrl = $linkslug;
    }
    if (isset($_REQUEST['pnme']) and $_REQUEST['pnme'] != 'story' and $_REQUEST['pnme'] != 'published') {
        $arr = explode("/", substr($_SERVER['HTTP_REFERER'], 0, -1));
示例#3
0
function akismet_check_submit(&$vars)
{
    if (phpnum() >= 5) {
        include akismet_lib_path . 'Akismet.class_5.php';
        $x = $x['linkres'];
        $user = new User();
        $user->id = $x->author;
        $user->read();
        $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
        $akismet->setCommentAuthor($user->username);
        $akismet->setCommentAuthorEmail($user->email);
        $akismet->setCommentAuthorURL($x->url);
        $akismet->setCommentContent($x->content);
        $akismet->setPermalink(getmyurl('story', $x->id));
        if ($akismet->isCommentSpam()) {
            // store the comment but mark it as spam (in case of a mis-diagnosis)
            $spam_links = get_misc_data('spam_links');
            if ($spam_links != '') {
                $spam_links = unserialize(get_misc_data('spam_links'));
            } else {
                $spam_links = array();
            }
            $spam_links[] = $x->id;
            misc_data_update('spam_links', serialize($spam_links));
            totals_adjust_count($x->status, -1);
            totals_adjust_count('discard', 1);
            $x->status = 'discard';
        } else {
            // echo 'not spam';
        }
    } else {
        include akismet_lib_path . 'Akismet.class_4.php';
        $x = $vars['linkres'];
        $user = new User();
        $user->id = $x->author;
        $user->read();
        $story['author'] = $user->username;
        $story['email'] = $user->email;
        $story['website'] = $x->url;
        $story['body'] = $x->content;
        $story['permalink'] = getmyurl('story', $x->id);
        $story['user_ip'] = $user->extra_field['user_lastip'];
        $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $story);
        // test for errors
        if ($akismet->errorsExist()) {
            // returns true if any errors exist
            if ($akismet->isError('AKISMET_INVALID_KEY')) {
                // echo 'invalid key';
            } elseif ($akismet->isError('AKISMET_RESPONSE_FAILED')) {
                // echo 'response failed';
            } elseif ($akismet->isError('AKISMET_SERVER_NOT_FOUND')) {
                // echo 'server not found';
            }
        } else {
            // No errors, check for spam
            if ($akismet->isSpam()) {
                // returns true if Akismet thinks the comment is spam
                $spam_links = get_misc_data('spam_links');
                if ($spam_links != '') {
                    $spam_links = unserialize(get_misc_data('spam_links'));
                } else {
                    $spam_links = array();
                }
                $spam_links[] = $x->id;
                misc_data_update('spam_links', serialize($spam_links));
            } else {
                // echo 'not spam';
            }
        }
    }
}
示例#4
0
function do_submit3()
{
    global $db;
    $linkres = new Link();
    $linkres->id = sanitize($_POST['id'], 3);
    if (!is_numeric($linkres->id)) {
        die;
    }
    if (!Submit_Complete_Step2 && $_SESSION['step'] != 2) {
        die('Wrong step');
    }
    $linkres->read();
    totals_adjust_count($linkres->status, -1);
    totals_adjust_count('queued', 1);
    $linkres->status = 'queued';
    $vars = array('linkres' => &$linkres);
    check_actions('do_submit3', $vars);
    if ($vars['linkres']->status == 'discard') {
        $vars = array('link_id' => $linkres->id);
        check_actions('story_discard', $vars);
    } elseif ($vars['linkres']->status == 'spam') {
        $vars = array('link_id' => $linkres->id);
        check_actions('story_spam', $vars);
    }
    $linkres->store_basic();
    $linkres->check_should_publish();
    if (isset($_POST['trackback']) && sanitize($_POST['trackback'], 3) != '') {
        require_once mnminclude . 'trackback.php';
        $trackres = new Trackback();
        $trackres->url = sanitize($_POST['trackback'], 3);
        $trackres->link = $linkres->id;
        $trackres->title = $linkres->title;
        $trackres->author = $linkres->author;
        $trackres->content = $linkres->content;
        $res = $trackres->send();
    }
    $vars = array('linkres' => $linkres);
    check_actions('submit_pre_redirect', $vars);
    if ($vars['redirect']) {
        header('Location: ' . $vars['redirect']);
    } elseif ($linkres->link_group_id == 0) {
        header("Location: " . getmyurl('upcoming'));
    } else {
        $redirect = getmyurl("group_story", $linkres->link_group_id);
        header("Location: {$redirect}");
    }
    die;
}
function do_the_import_stuff($feed)
{
    global $db, $dblang, $RSSImport;
    $RSSImport = new RSSImport();
    $added_one = false;
    $url = $feed->feed_url;
    $rss = fetch_rss($url);
    if ($_GET['override'] == $feed->feed_id) {
        $canIhaveAccess = 0;
        $canIhaveAccess = $canIhaveAccess + checklevel('god');
        if (!$canIhaveAccess == 1) {
            die('You are not authorized to override.');
        }
    }
    $MyArray = array();
    $Feed_Links = $RSSImport->get_feed_field_links($feed->feed_id);
    if (count($Feed_Links) > 0) {
        foreach ($Feed_Links as $link) {
            if ($link->pligg_field == 'link_title') {
                $MyArray['title'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_content') {
                $MyArray['content'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_url') {
                $MyArray['link_url'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_tags') {
                $MyArray['link_tags'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field1') {
                $MyArray['link_field1'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field2') {
                $MyArray['link_field2'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field3') {
                $MyArray['link_field3'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field4') {
                $MyArray['link_field4'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field5') {
                $MyArray['link_field5'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field6') {
                $MyArray['link_field6'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field7') {
                $MyArray['link_field7'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field8') {
                $MyArray['link_field8'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field9') {
                $MyArray['link_field9'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field10') {
                $MyArray['link_field10'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field11') {
                $MyArray['link_field11'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field12') {
                $MyArray['link_field12'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field13') {
                $MyArray['link_field13'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field14') {
                $MyArray['link_field14'] = $link->feed_field;
            }
            if ($link->pligg_field == 'link_field15') {
                $MyArray['link_field15'] = $link->feed_field;
            }
        }
        $thecount = 0;
        if ($feed->feed_last_item_first == 0) {
            $the_items = array_reverse($rss->items);
        } else {
            $the_items = $rss->items;
        }
        foreach ($the_items as $item) {
            echo "<strong>Title: " . get_val($item, $MyArray['title']) . "</strong><br/>";
            echo "<strong>Content:</strong> " . strip_tags(substr(get_val($item, $MyArray['content']), 0, 256)) . "...<br>";
            echo "<strong>URL:</strong> " . get_val($item, $MyArray['link_url']) . "<br/>";
            $skipthis = 0;
            $linkres = new Link();
            $linkres->randkey = rand(10000, 10000000);
            $linkres->status = $feed->feed_status;
            $linkres->author = $feed->feed_submitter;
            $linkres->title = get_val($item, $MyArray['title']);
            $linkres->title = strip_tags($linkres->title);
            $linkres->tags = get_val($item, $MyArray['link_tags']);
            // MJE: MOD to include title words as tags ----------------------------
            if (trim($linkres->tags) == '') {
                $temp1 = strtolower($linkres->title);
                $stopwords = file(mnmpath . '/modules/rss_import/templates/stopwords.txt');
                for ($zz = 0; $zz < count($stopwords); $zz++) {
                    $pos = strpos($temp1, $stopwords[$zz] . ' ');
                    if ($pos !== false && $pos == 0) {
                        $temp1 = str_replace(trim($stopwords[$zz]) . ' ', ' ', $temp1);
                    }
                    $temp1 = str_replace(' ' . trim($stopwords[$zz]) . ' ', ' ', $temp1);
                }
                $pos = strpos($temp1, '  ');
                while ($pos !== false) {
                    $temp1 = str_replace('  ', ' ', $temp1);
                    $pos = strpos($temp1, '  ');
                }
                $temp1 = str_replace(' ', ", ", $temp1);
                // $out = ereg_replace("[^[:alpha:]]", "", $in);
                // strip all except letters and spaces and commas
                $linkres->tags = preg_replace('/[^a-z A-Z,]+/i', '', $temp1);
            }
            //----------------------------------------------------------------------
            if (checklevel('god')) {
                $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_God;
            } elseif (checklevel('admin')) {
                $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Admin;
            } else {
                $Story_Content_Tags_To_Allow = Story_Content_Tags_To_Allow_Normal;
            }
            $linkres->title_url = makeUrlFriendly($linkres->title);
            $linkres->url = get_val($item, $MyArray['link_url']);
            $linkres->url_title = $linkres->title;
            $linkres->content = get_val($item, $MyArray['content']);
            $linkres->content = strip_tags($linkres->content, $Story_Content_Tags_To_Allow);
            $linkres->content = str_replace("\n", "<br />", $linkres->content);
            $linkres->link_field1 = get_val($item, $MyArray['link_field1']);
            $linkres->link_field2 = get_val($item, $MyArray['link_field2']);
            $linkres->link_field3 = get_val($item, $MyArray['link_field3']);
            $linkres->link_field4 = get_val($item, $MyArray['link_field4']);
            $linkres->link_field5 = get_val($item, $MyArray['link_field5']);
            $linkres->link_field6 = get_val($item, $MyArray['link_field6']);
            $linkres->link_field7 = get_val($item, $MyArray['link_field7']);
            $linkres->link_field8 = get_val($item, $MyArray['link_field8']);
            $linkres->link_field9 = get_val($item, $MyArray['link_field9']);
            $linkres->link_field10 = get_val($item, $MyArray['link_field10']);
            $linkres->link_field11 = get_val($item, $MyArray['link_field11']);
            $linkres->link_field12 = get_val($item, $MyArray['link_field12']);
            $linkres->link_field13 = get_val($item, $MyArray['link_field13']);
            $linkres->link_field14 = get_val($item, $MyArray['link_field14']);
            $linkres->link_field15 = get_val($item, $MyArray['link_field15']);
            $linkres->category = $feed->feed_category;
            //MJE: MOD
            $linkres->link_summary = utf8_substr(strip_tags($linkres->content), 0, StorySummary_ContentTruncate - 1);
            //---------
            if ($thecount >= $feed->feed_item_limit && $skipthis == 0) {
                echo "Reached import limit, skipping<HR>";
                $skipthis = 1;
            }
            if ($feed->feed_title_dupe == 0 && $skipthis == 0) {
                // 0 means don't allow, 1 means allow
                if ($linkres->duplicates_title($linkres->title) > 0) {
                    //echo "Title Match, skipping: " . $linkres->title . "<HR>";
                    echo '<span style="color:#fc0000;">Title Match, skipping</span> <hr>';
                    $skipthis = 1;
                }
            }
            if ($feed->feed_url_dupe == 0 && $linkres->url != "" && $skipthis == 0) {
                // 0 means don't allow, 1 means allow
                if ($linkres->duplicates($linkres->url) > 0) {
                    //echo "URL Match, skipping: " . $linkres->title . "<HR>";
                    echo '<span style="color:#fc0000;">URL Match, skipping</span> <hr>';
                    $skipthis = 1;
                }
            }
            if ($skipthis == 0) {
                echo "Importing <hr>";
                $added_one = true;
                $linkres->store();
                totals_adjust_count($linkres->status, 1);
                tags_insert_string($linkres->id, $dblang, $linkres->tags);
                require_once mnminclude . 'votes.php';
                if ($feed->feed_random_vote_enable == 1) {
                    $feed->feed_votes = rand($feed->feed_random_vote_min, $feed->feed_random_vote_max);
                }
                $votes = 0;
                for ($i = 1; $i <= $feed->feed_votes; $i++) {
                    $value = 1;
                    $vote = new Vote();
                    $vote->type = 'links';
                    $vote->user = 0;
                    $vote->link = $linkres->id;
                    $vote->ip = '0.0.0.' . $i;
                    $vote->value = $value;
                    $vote->insert();
                    $vote = "";
                    $votes += $value;
                    //								$vote = new Vote;
                    //								$vote->type='links';
                    //								$vote->link=$linkres->id;
                }
                $linkres->votes = $votes;
                $linkres->store_basic();
                $linkres->check_should_publish();
                $thecount = $thecount + 1;
            }
        }
        $sql = "UPDATE `" . table_feeds . "` SET `feed_last_check` = FROM_UNIXTIME(" . (time() - 300) . ") WHERE `feed_id` = {$feed->feed_id};";
        //echo $sql;
        $db->query($sql);
    } else {
        echo "Feed not fully setup, skipping <hr>";
    }
    if ($added_one) {
        return true;
    } else {
        return false;
    }
}
示例#6
0
function do_submit3()
{
    global $db;
    $linkres = new Link();
    $linkres->id = sanitize($_POST['id'], 3);
    if (!is_numeric($linkres->id)) {
        die;
    }
    $linkres->read();
    totals_adjust_count($linkres->status, -1);
    totals_adjust_count('queued', 1);
    $linkres->status = 'queued';
    $vars = array('linkres' => $linkres);
    check_actions('do_submit3', $vars);
    $linkres->store_basic();
    $linkres->check_should_publish();
    if (isset($_POST['trackback']) && sanitize($_POST['trackback'], 3) != '') {
        require_once mnminclude . 'trackback.php';
        $trackres = new Trackback();
        $trackres->url = sanitize($_POST['trackback'], 3);
        $trackres->link = $linkres->id;
        $trackres->title = $linkres->title;
        $trackres->author = $linkres->author;
        $trackres->content = $linkres->content;
        $res = $trackres->send();
    }
    if ($linkres->link_group_id == 0) {
        header("Location: " . getmyurl('upcoming'));
        die;
    } else {
        $redirect = getmyurl("group_story", $linkres->link_group_id);
        header("Location: {$redirect}");
        die;
    }
}