Пример #1
0
function multibox_admin_showpage()
{
    global $main_smarty, $the_template, $db;
    force_authentication();
    $canIhaveAccess = 0;
    $canIhaveAccess = $canIhaveAccess + checklevel('god');
    if ($canIhaveAccess == 1) {
        define('pagename', 'multibox_admin');
        $main_smarty->assign('pagename', pagename);
        define('modulename', 'multibox_admin');
        $main_smarty->assign('modulename', modulename);
        $navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel');
        $navwhere['link1'] = getmyurl('admin', '');
        $main_smarty->display(multibox_admin_tpl_path . '/blank.tpl');
        $main_smarty = do_sidebar($main_smarty);
        $sql = "SELECT * FROM " . table_totals;
        $results = $db->get_results($sql);
        $main_smarty->assign('results', object_2_array($results));
        if (isset($_REQUEST['action'])) {
            $main_smarty->assign('action', $_REQUEST['action']);
            totals_regenerate();
            $sql = "SELECT * FROM " . table_totals;
            $results = $db->get_results($sql);
            $main_smarty->assign('new_results', object_2_array($results));
        }
        $main_smarty->assign('navbar_where', $navwhere);
        $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
        $main_smarty->assign('tpl_center', multibox_admin_tpl_path . 'multibox_main');
        $main_smarty->display($template_dir . '/admin/admin.tpl');
    } else {
        echo "Page Forbidden";
    }
}
Пример #2
0
function object_2_array($result)
{
    $array = array();
    foreach ($result as $key => $value) {
        if (is_object($value)) {
            $array[$key] = object_2_array($value);
        } elseif (is_array($value)) {
            $array[$key] = object_2_array($value);
        } else {
            $array[$key] = $value;
        }
    }
    return $array;
}
Пример #3
0
function friends_activity(&$vars)
{
    global $db, $main_smarty;
    $author_id = $vars['author_id'];
    $linkid = $vars['link_id'];
    //for friends voting activity
    include_once mnminclude . 'friend.php';
    $friend = new Friend();
    $sql = 'SELECT ' . table_votes . '.*, ' . table_users . '.user_id FROM ' . table_votes . ' INNER JOIN ' . table_users . ' ON ' . table_votes . '.vote_user_id = ' . table_users . '.user_id WHERE (((' . table_votes . '.vote_value)>0) AND ((' . table_votes . '.vote_link_id)=' . $linkid . ') AND (' . table_votes . '.vote_type= "links"));';
    $voters = $db->get_results($sql);
    $voters = object_2_array($voters);
    foreach ($voters as $key => $val) {
        $voteduserid = $val['user_id'];
        if ($voteduserid == $friend->get_friend_status($author_id)) {
            $vars['value'] = true;
        }
        $main_smarty->assign('friendvoted', $friendvoted);
    }
}
Пример #4
0
function akismet_showpage()
{
    global $main_smarty, $the_template, $current_user, $db;
    force_authentication();
    $canIhaveAccess = 0;
    $canIhaveAccess = $canIhaveAccess + checklevel('god');
    if ($canIhaveAccess == 1) {
        if (phpnum() >= 5) {
            include_once akismet_lib_path . 'Akismet.class_5.php';
        } else {
            include_once akismet_lib_path . 'Akismet.class_4.php';
        }
        $navwhere['text1'] = 'Akismet';
        $navwhere['link1'] = URL_akismet;
        define('pagename', 'akismet');
        $main_smarty->assign('pagename', pagename);
        define('modulename', 'akismet');
        $main_smarty->assign('modulename', modulename);
        if (isset($_REQUEST['view'])) {
            $view = sanitize($_REQUEST['view'], 3);
        } else {
            $view = '';
        }
        if ($view == '') {
            $wordpress_key = get_misc_data('wordpress_key');
            if ($wordpress_key == '') {
                header('Location: ' . URL_akismet . '&view=manageKey');
            }
            $spam_links = get_misc_data('spam_links');
            if ($spam_links != '') {
                $spam_links = unserialize(get_misc_data('spam_links'));
            } else {
                $spam_links = array();
            }
            $main_smarty->assign('spam_links', $spam_links);
            $main_smarty->assign('spam_links_count', count($spam_links));
            $spam_comments = get_misc_data('spam_comments');
            if ($spam_comments != '') {
                $spam_comments = unserialize(get_misc_data('spam_comments'));
            } else {
                $spam_comments = array();
            }
            $main_smarty->assign('spam_comments', $spam_comments);
            $main_smarty->assign('spam_comments_count', count($spam_comments));
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'main');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'manageKey') {
            $wordpress_key = get_misc_data('wordpress_key');
            $main_smarty->assign('wordpress_key', $wordpress_key);
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageKey');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'updateKey') {
            if (isset($_REQUEST['key'])) {
                $wordpress_key = sanitize($_REQUEST['key'], 3);
            } else {
                $wordpress_key = '';
            }
            misc_data_update('wordpress_key', $wordpress_key);
            header('Location: ' . URL_akismet);
        }
        if ($view == 'manageSpam') {
            $spam_links = get_misc_data('spam_links');
            if ($spam_links != '') {
                $spam_links = unserialize(get_misc_data('spam_links'));
            } else {
                $spam_links = array();
            }
            if (count($spam_links) > 0) {
                $sql = "SELECT " . table_links . ".* FROM " . table_links . " WHERE ";
                $sql .= 'link_id IN (' . implode(',', $spam_links) . ')';
                $link_data = $db->get_results($sql);
                $main_smarty->assign('link_data', object_2_array($link_data));
            } else {
                header('Location: ' . URL_akismet);
            }
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpam');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'manageSettings') {
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSettings');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        /*
        if($view == 'isSpam'){
        	if(isset($_REQUEST['link_id'])){$link_id = sanitize($_REQUEST['link_id'], 3);}else{$link_id='';}
        
        	$spam_links = get_misc_data('spam_links');
        	$spam_links = unserialize(get_misc_data('spam_links'));
        
        	unset($spam_links[$link_id]);
        	misc_data_update('spam_links', serialize($spam_links));
        
        	$link = new Link;
        	$link->id = $link_id;
        	$link->read(FALSE);
        	$link->status = 'discard';
        	$link->store();
        
        	header('Location: ' . URL_akismet . '&view=manageSpam');
        }
        
        if($view == 'isNotSpam'){
        	if(isset($_REQUEST['link_id'])){$link_id = sanitize($_REQUEST['link_id'], 3);}else{$link_id='';}
        
        	$spam_links = get_misc_data('spam_links');
        	$spam_links = unserialize(get_misc_data('spam_links'));
        
        	unset($spam_links[$link_id]);
        	misc_data_update('spam_links', serialize($spam_links));
        
        	$link = new Link;
        	$link->id = $link_id;
        	$link->read(FALSE);
        	$link->status = 'queued';
        	$link->store();
        
        	header('Location: ' . URL_akismet . '&view=manageSpam');
        }
        
        if($view == 'addSpam'){
        
        	$spam_links[1] = 1;
        	misc_data_update('spam_links', serialize($spam_links));
        	header('Location: ' . URL_akismet . '&view=manageSpam');
        
        }
        */
        if ($view == 'manageSpamcomments') {
            $spam_comments = get_misc_data('spam_comments');
            if ($spam_comments != '') {
                $spam_comments = unserialize(get_misc_data('spam_comments'));
            } else {
                $spam_comments = array();
            }
            if (count($spam_comments) > 0) {
                $sql = "SELECT * FROM " . table_prefix . "spam_comments WHERE ";
                $sql .= 'linkid IN (' . implode(',', $spam_comments) . ')';
                $link_data = $db->get_results($sql);
                $user_cmt = new User();
                $user_cmt_link = new Link();
                $spam_output .= ' <form name="bulk_moderate" action="' . URL_akismet_isSpamcomment . '&action=bulkmod" method="post">';
                $spam_output .= "<table>";
                $spam_output .= "<tr><th>Author</th><th>Body</th><th>this is spam</th><th>this is NOT spam</th></tr>";
                if ($link_data) {
                    foreach ($link_data as $spam_cmts) {
                        $user_cmt->id = $spam_cmts->userid;
                        $user_cmt->read();
                        $user_name = $user_cmt->username;
                        $user_cmt_link->id = $spam_cmts->linkid;
                        $user_cmt_link->read();
                        $spam_output .= "<tr>";
                        $spam_output .= "<td>" . $user_name . "</td>";
                        $spam_output .= "<td>" . save_text_to_html($spam_cmts->cmt_content) . "</td>";
                        $spam_output .= '<td><center><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="spamcomment"></center></td>';
                        $spam_output .= '<td><center><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="notspamcomment"></center></td>';
                        $spam_output .= "</tr>";
                    }
                }
                $spam_output .= "</table>";
                $spam_output .= '<p align="right"><input type="submit" name="submit" value="Change Status" class="log2" /></p>';
                $spam_output .= "</form>";
                $main_smarty->assign('spam_output', $spam_output);
                $main_smarty->assign('link_data', object_2_array($link_data));
            } else {
                header('Location: ' . URL_akismet);
            }
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpamcomments');
            $main_smarty->display($the_template . '/pligg.tpl');
        }
        if ($view == 'isSpam') {
            if ($_GET['action'] == "bulkmod") {
                if (isset($_POST['submit'])) {
                    $spam = array();
                    foreach ($_POST["spam"] as $k => $v) {
                        $spam[intval($k)] = $v;
                    }
                    foreach ($spam as $key => $value) {
                        if ($value == "spam") {
                            if (isset($key)) {
                                $link_id = sanitize($key, 3);
                            } else {
                                $link_id = '';
                            }
                            $spam_links = get_misc_data('spam_links');
                            $spam_links = unserialize(get_misc_data('spam_links'));
                            $key = array_search($link_id, $spam_links);
                            unset($spam_links[$key]);
                            misc_data_update('spam_links', serialize($spam_links));
                            $link = new Link();
                            $link->id = $link_id;
                            $link->read();
                            $link->status = 'discard';
                            $link->store();
                            $user = new User();
                            $user->id = $link->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($link->url);
                            $akismet->setCommentContent($link->content);
                            $akismet->setPermalink(getmyurl('story', $link->id));
                            $akismet->submitSpam();
                        } elseif ($value == "notspam") {
                            if (isset($key)) {
                                $link_id = sanitize($key, 3);
                            } else {
                                $link_id = '';
                            }
                            $spam_links = get_misc_data('spam_links');
                            $spam_links = unserialize(get_misc_data('spam_links'));
                            $key = array_search($link_id, $spam_links);
                            unset($spam_links[$key]);
                            misc_data_update('spam_links', serialize($spam_links));
                            $link = new Link();
                            $link->id = $link_id;
                            $link->read(FALSE);
                            $link->status = 'queued';
                            $link->store();
                            $user = new User();
                            $user->id = $link->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($link->url);
                            $akismet->setCommentContent($link->content);
                            $akismet->setPermalink(getmyurl('story', $link->id));
                            $akismet->submitHam();
                        }
                    }
                }
            }
            header('Location: ' . URL_akismet . '&view=manageSpam');
        }
        if ($view == 'isSpamcomment') {
            if ($_GET['action'] == "bulkmod") {
                if (isset($_POST['submit'])) {
                    $spamcomment = array();
                    foreach ($_POST["spamcomment"] as $k => $v) {
                        $spamcomment[intval($k)] = $v;
                    }
                    foreach ($spamcomment as $key => $value) {
                        if ($value == "spamcomment") {
                            if (isset($key)) {
                                $link_id = sanitize($key, 3);
                            } else {
                                $link_id = '';
                            }
                            global $db;
                            $spam_comments = get_misc_data('spam_comments');
                            $spam_comments = unserialize(get_misc_data('spam_comments'));
                            $key = array_search($link_id, $spam_comments);
                            unset($spam_comments[$key]);
                            $sql_result = "Select * from " . table_prefix . "spam_comments where auto_id=" . $link_id;
                            $result_arr = $db->get_results($sql_result);
                            if ($result_arr) {
                                foreach ($result_arr as $result_arr_comments) {
                                    $link = new Link();
                                    $link->id = $result_arr_comments->linkid;
                                    $link->read();
                                    $user = new User();
                                    $user->id = $result_arr_comments->userid;
                                    $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($link->url);
                                    $akismet->setCommentContent($result_arr_comments->cmt_content);
                                    $akismet->setPermalink(getmyurl('story', $link->id));
                                    $akismet->submitSpam();
                                }
                            }
                            misc_data_update('spam_comments', serialize($spam_comments));
                            $db->query(' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id);
                        } elseif ($value == "notspamcomment") {
                            if (isset($key)) {
                                $link_id = sanitize($key, 3);
                            } else {
                                $link_id = '';
                            }
                            global $db;
                            $spam_comments = get_misc_data('spam_comments');
                            $spam_comments = unserialize(get_misc_data('spam_comments'));
                            $key = array_search($link_id, $spam_comments);
                            unset($spam_comments[$key]);
                            $sql_result = " Select * from " . table_prefix . "spam_comments where auto_id={$link_id}";
                            $result_arr = $db->get_results($sql_result);
                            if ($result_arr) {
                                foreach ($result_arr as $result_arr_comments) {
                                    $link = new Link();
                                    $link->id = $result_arr_comments->linkid;
                                    $link->read();
                                    $user = new User();
                                    $user->id = $result_arr_comments->userid;
                                    $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($link->url);
                                    $akismet->setCommentContent($result_arr_comments->cmt_content);
                                    $akismet->setPermalink(getmyurl('story', $link->id));
                                    $akismet->submitHam();
                                    $sql = "INSERT INTO " . table_comments . " (comment_parent, comment_user_id, comment_link_id , comment_date, comment_randkey, comment_content) VALUES ({$result_arr_comments->cmt_parent}, {$result_arr_comments->userid}, {$result_arr_comments->linkid}, now(), '{$result_arr_comments->cmt_rand}', '{$result_arr_comments->cmt_content}')";
                                    $db->query($sql);
                                }
                            }
                            misc_data_update('spam_comments', serialize($spam_comments));
                            $sql_delete = ' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id;
                            $db->query($sql_delete);
                            $link->adjust_comment(1);
                            $link->store();
                        }
                    }
                }
                header('Location: ' . URL_akismet . '&view=manageSpamcomments');
            }
        }
    }
}
Пример #5
0
function object_2_array($result)
{
    // using this because i'm not sure if (array)$user will work in php 4
    // i'm not sure if we even need all this but it makes my code work
    $array = array();
    foreach ($result as $key => $value) {
        if (is_object($value)) {
            $array[$key] = object_2_array($value);
        } elseif (is_array($value)) {
            $array[$key] = object_2_array($value);
        } else {
            $array[$key] = $value;
        }
    }
    return $array;
}
Пример #6
0
function category_display()
{
    global $db;
    $maincategory = $db->get_results("select * from " . table_categories . "");
    $maincategory = object_2_array($maincategory);
    foreach ($maincategory as $id => $rs) {
        $maincategory[$id]['safename'] = $rs['category_safe_name'];
        $maincategory[$id]['id'] = $rs['category_id'];
        $maincategory[$id]['parent'] = $rs['category_parent'];
        $maincategory[$id]['order'] = $rs['category_order'];
        $childcategory = $db->get_results("select * from " . table_categories . " where category_parent =" . $rs['category_id']);
        //echo "select * from ".table_categories." where category_parent =".$rs['category_id'];
        $childcategory = object_2_array($childcategory);
        foreach ($childcategory as $id => $rc) {
            $childcategory[$id]['safename'] = $rc['category_safe_name'];
            $childcategory[$id]['id'] = $rc['category_id'];
            $childcategory[$id]['parent'] = $rc['category_parent'];
        }
    }
    return $maincategory;
}
Пример #7
0
function show_profile()
{
    global $user, $main_smarty, $the_template, $CSRF, $db;
    $CSRF->create('profile_change', true, true);
    // assign avatar source to smarty
    $main_smarty->assign('UseAvatars', do_we_use_avatars());
    $main_smarty->assign('Avatar', $avatars = get_avatar('all', '', $user->username, $user->email));
    $main_smarty->assign('Avatar_ImgLarge', $avatars['large']);
    $main_smarty->assign('Avatar_ImgSmall', $avatars['small']);
    // module system hook
    $vars = '';
    check_actions('profile_show', $vars);
    // assign profile information to smarty
    $main_smarty->assign('user_id', $user->id);
    $main_smarty->assign('user_email', $user->email);
    $main_smarty->assign('user_login', $user->username);
    $main_smarty->assign('user_names', $user->names);
    $main_smarty->assign('user_username', $user->username);
    $main_smarty->assign('userlevel', $user->level);
    $main_smarty->assign('user_url', $user->url);
    $main_smarty->assign('user_publicemail', $user->public_email);
    $main_smarty->assign('user_location', $user->location);
    $main_smarty->assign('user_occupation', $user->occupation);
    $main_smarty->assign('user_facebook', $user->facebook);
    $main_smarty->assign('user_twitter', $user->twitter);
    $main_smarty->assign('user_linkedin', $user->linkedin);
    $main_smarty->assign('user_googleplus', $user->googleplus);
    $main_smarty->assign('user_skype', $user->skype);
    $main_smarty->assign('user_pinterest', $user->pinterest);
    $main_smarty->assign('user_karma', $user->karma);
    $main_smarty->assign('user_joined', get_date($user->date));
    $main_smarty->assign('user_avatar_source', $user->avatar_source);
    $user->all_stats();
    $main_smarty->assign('user_total_links', $user->total_links);
    $main_smarty->assign('user_published_links', $user->published_links);
    $main_smarty->assign('user_total_comments', $user->total_comments);
    $main_smarty->assign('user_total_votes', $user->total_votes);
    $main_smarty->assign('user_published_votes', $user->published_votes);
    // If the user language setting is NULL, present the site's default language file
    $main_smarty->assign('user_language', !empty($user->language) ? $user->language : pligg_language);
    $languages = array();
    $files = glob("languages/*.conf");
    foreach ($files as $file) {
        if (preg_match('/lang_(.+?)\\.conf/', $file, $m)) {
            $languages[] = $m[1];
        }
    }
    $main_smarty->assign('languages', $languages);
    // pagename
    define('pagename', 'user_edit');
    $main_smarty->assign('pagename', pagename);
    $main_smarty->assign('form_action', $_SERVER["PHP_SELF"]);
    // User Settings
    $user_categories = explode(",", $user->extra_field['user_categories']);
    $categorysql = "SELECT * FROM " . table_categories . " where category__auto_id!='0' ";
    $results = $db->get_results($categorysql);
    $results = object_2_array($results);
    $category = array();
    foreach ($results as $key => $val) {
        $category[] = $val['category_name'];
    }
    #	$sor = $_GET['err'];
    #	if($sor == 1)
    #	{
    #		$err = "You have to select at least 1 category";
    #		$main_smarty->assign('err', $err);
    #	}
    $main_smarty->assign('category', $results);
    $main_smarty->assign('user_category', $user_categories);
    $main_smarty->assign('view_href', 'submitted');
    if (Allow_User_Change_Templates) {
        $dir = "templates";
        $templates = array();
        foreach (scandir($dir) as $file) {
            if (strstr($file, ".") !== 0 && file_exists("{$dir}/{$file}/header.tpl")) {
                $templates[] = $file;
            }
        }
        $main_smarty->assign('templates', $templates);
        $main_smarty->assign('current_template', sanitize($_COOKIE['template'], 3));
        $main_smarty->assign('Allow_User_Change_Templates', Allow_User_Change_Templates);
    }
    // show the template
    $main_smarty->assign('tpl_center', $the_template . '/user_settings_center');
    $main_smarty->display($the_template . '/pligg.tpl');
}
Пример #8
0
    $main_smarty->assign('view_href', '');
    $main_smarty->assign('nav_mg', 4);
} else {
    $main_smarty->assign('nav_mg', 3);
}
$main_smarty->assign('page_header', $page_header);
$main_smarty->assign('posttitle', $post_title);
/*** view for Search Users ***/
if ($view == 'search') {
    if (isset($_REQUEST['keyword'])) {
        $keyword = $db->escape(sanitize(trim($_REQUEST['keyword']), 3));
    }
    if ($keyword) {
        $searchsql = "SELECT * FROM " . table_users . " where (user_login LIKE '%" . $keyword . "%' OR public_email LIKE '%" . $keyword . "%') AND user_level!='Spammer' ";
        $results = $db->get_results($searchsql);
        $results = object_2_array($results);
        foreach ($results as $key => $val) {
            if ($val['user_login'] != 'anonymous' || $val['user_lastip'] > 0) {
                $results[$key]['Avatar'] = get_avatar('large', "", $val['user_login'], $val['user_email']);
                $results[$key]['add_friend'] = getmyurl('user_add_remove', $val['user_login'], 'addfriend');
                $results[$key]['remove_friend'] = getmyurl('user_add_remove', $val['user_login'], 'removefriend');
                $results[$key]['status'] = $friend->get_friend_status($val['user_id']);
            } else {
                unset($results[$key]);
            }
        }
        $main_smarty->assign('userlist', $results);
    }
    $main_smarty->assign('search', $keyword);
    $main_smarty->assign('page_header', $user->username);
    $navwhere['text3'] = $main_smarty->get_config_vars('PLIGG_Visual_Search_SearchResults') . ' ' . $keyword;
Пример #9
0
function akismet_showpage()
{
    global $main_smarty, $the_template, $current_user, $db;
    force_authentication();
    $canIhaveAccess = 0;
    $canIhaveAccess = $canIhaveAccess + checklevel('admin');
    if ($canIhaveAccess == 1) {
        $navwhere['text1'] = 'Akismet';
        $navwhere['link1'] = URL_akismet;
        define('pagename', 'akismet');
        $main_smarty->assign('pagename', pagename);
        define('modulename', 'akismet');
        $main_smarty->assign('modulename', modulename);
        if (isset($_REQUEST['view'])) {
            $view = sanitize($_REQUEST['view'], 3);
        } else {
            $view = '';
        }
        if ($view == '') {
            $wordpress_key = get_misc_data('wordpress_key');
            if ($wordpress_key == '') {
                header('Location: ' . URL_akismet . '&view=manageKey');
                die;
            }
            $main_smarty->assign('spam_links_count', akismet_get_link_count());
            $main_smarty->assign('spam_comments_count', akismet_get_comment_count());
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'main');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'updateKey') {
            if ($_REQUEST['key']) {
                $wordpress_key = sanitize($_REQUEST['key'], 3);
                // Verify key before save
                if (phpnum() >= 5) {
                    include akismet_lib_path . 'Akismet.class_5.php';
                    $akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key);
                    if (!$akismet->isKeyValid()) {
                        $main_smarty->assign('error', 1);
                    } else {
                        misc_data_update('wordpress_key', $wordpress_key);
                    }
                } else {
                    include akismet_lib_path . 'Akismet.class_4.php';
                    $akismet = new Akismet(my_base_url . my_pligg_base, $wordpress_key);
                    if (!$akismet->_isValidApiKey($wordpress_key)) {
                        $main_smarty->assign('error', 1);
                    } else {
                        misc_data_update('wordpress_key', $wordpress_key);
                    }
                }
            } else {
                $wordpress_key = '';
                misc_data_update('wordpress_key', $wordpress_key);
            }
            $view = 'manageKey';
        }
        if ($view == 'manageKey') {
            $wordpress_key = get_misc_data('wordpress_key');
            $main_smarty->assign('wordpress_key', $wordpress_key);
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageKey');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'manageSpam') {
            $sql = "SELECT " . table_links . ".*, " . table_users . ".user_login FROM " . table_links . " \r\n\t\t\t\t\tLEFT JOIN " . table_users . " ON link_author=user_id \r\n\t\t\t\t\tLEFT JOIN " . table_prefix . "spam_links ON linkid=link_id\r\n\t\t\t\t\tWHERE !ISNULL(linkid)";
            $link_data = $db->get_results($sql);
            if (sizeof($link_data)) {
                $main_smarty->assign('link_data', object_2_array($link_data));
            } else {
                header("Location: " . my_pligg_base . "/admin/admin_index.php");
                //				header('Location: ' . URL_akismet);
                die;
            }
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpam');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'manageSettings') {
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSettings');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if ($view == 'manageSpamcomments') {
            $sql = "SELECT * FROM " . table_prefix . "spam_comments ";
            $link_data = $db->get_results($sql);
            if (sizeof($link_data)) {
                $user_cmt = new User();
                $user_cmt_link = new Link();
                $spam_output .= ' <form name="bulk_moderate" action="' . URL_akismet_isSpamcomment . '&action=bulkmod" method="post">';
                $spam_output .= '<table class="table table-bordered table-striped">';
                $spam_output .= "<thead>\r\n\t\t\t\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t\t\t\t<th>Author</th>\r\n\t\t\t\t\t\t\t\t\t\t<th>Content</th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:65px;text-align:center;'><input type='checkbox' name='all1' onclick='mark_all_spam();' style='display:none;'><a onclick='mark_all_spam();' style='cursor:pointer;text-decoration:none;'>Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t\t<th style='width:80px;text-align:center;'><input type='checkbox' name='all2' onclick='mark_all_notspam();' style='display:none;'><a onclick='mark_all_notspam();' style='cursor:pointer;text-decoration:none;'>Not Spam</a></th>\r\n\t\t\t\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t\t\t<tbody>";
                foreach ($link_data as $spam_cmts) {
                    $user_cmt->id = $spam_cmts->userid;
                    $user_cmt->read();
                    $user_name = $user_cmt->username;
                    $user_cmt_link->id = $spam_cmts->linkid;
                    $user_cmt_link->read();
                    $spam_output .= "<tr>";
                    $spam_output .= "\t<td>" . $user_name . "</td>";
                    $spam_output .= "\t<td><a href='story.php?id=" . ($user_cmt_link->id = $spam_cmts->linkid . "'>" . save_text_to_html($spam_cmts->cmt_content) . "</a></td>");
                    $spam_output .= '	<td style="text-align:center;"><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="spamcomment"></td>';
                    $spam_output .= '	<td style="text-align:center;"><input type="radio" name="spamcomment[' . $spam_cmts->auto_id . ']" id="spamcomment-' . $spam_cmts->auto_id . '" value="notspamcomment"></td>';
                    $spam_output .= "</tr>";
                }
                $spam_output .= "</tbody></table>";
                $spam_output .= '<p align="right" style="margin-top:10px;"><input type="submit" name="submit" value="Apply Changes" class="btn btn-default" /></p>';
                $spam_output .= "</form>";
                $main_smarty->assign('spam_output', $spam_output);
                $main_smarty->assign('link_data', object_2_array($link_data));
            } else {
                header("Location: " . my_pligg_base . "/admin/admin_index.php");
                //				header('Location: ' . URL_akismet);
                die;
            }
            $main_smarty = do_sidebar($main_smarty, $navwhere);
            $main_smarty->assign('posttitle', " / " . $main_smarty->get_config_vars('PLIGG_Visual_Header_AdminPanel'));
            $main_smarty->assign('tpl_center', akismet_tpl_path . 'manageSpamcomments');
            $main_smarty->display($template_dir . '/admin/admin.tpl');
        }
        if (phpnum() >= 5) {
            include_once akismet_lib_path . 'Akismet.class_5.php';
        } else {
            include_once akismet_lib_path . 'Akismet.class_4.php';
        }
        if ($view == 'isSpam') {
            if ($_GET['action'] == "bulkmod") {
                if (isset($_POST['submit'])) {
                    $spam = array();
                    foreach ($_POST["spam"] as $k => $v) {
                        $spam[intval($k)] = $v;
                    }
                    foreach ($spam as $key => $value) {
                        if (isset($key)) {
                            $link_id = sanitize($key, 3);
                        } else {
                            continue;
                        }
                        $link = new Link();
                        $link->id = $link_id;
                        $link->read();
                        $user = new User();
                        $user->id = $link->author;
                        $user->read();
                        if (phpnum() < 5) {
                            $comment = array('author' => $user->username, 'email' => $user->email, 'website' => $link->url, 'body' => $link->content, 'permalink' => my_base_url . getmyurl('story', $link->id));
                            $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $comment);
                        } else {
                            $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
                            $akismet->setCommentAuthor($user->username);
                            $akismet->setCommentAuthorEmail($user->email);
                            $akismet->setCommentAuthorURL($link->url);
                            $akismet->setCommentContent($link->content);
                            $akismet->setPermalink(my_base_url . getmyurl('story', $link->id));
                        }
                        if ($value == "spam") {
                            $link->status = 'spam';
                            $link->store();
                            killspam($user->id);
                            $akismet->submitSpam();
                        } elseif ($value == "notspam") {
                            $link->status = 'new';
                            $link->store();
                            $akismet->submitHam();
                        }
                        $db->query("DELETE FROM " . table_prefix . "spam_links WHERE linkid={$link_id}");
                    }
                }
            }
            header('Location: ' . URL_akismet . '&view=manageSpam');
            die;
        }
        if ($view == 'isSpamcomment') {
            if ($_GET['action'] == "bulkmod") {
                if (isset($_POST['submit'])) {
                    $spamcomment = array();
                    foreach ($_POST["spamcomment"] as $k => $v) {
                        $spamcomment[intval($k)] = $v;
                    }
                    foreach ($spamcomment as $key => $value) {
                        if (isset($key)) {
                            $link_id = sanitize($key, 3);
                        } else {
                            continue;
                        }
                        $sql_result = "Select * from " . table_prefix . "spam_comments where auto_id=" . $link_id;
                        $result = $db->get_row($sql_result);
                        #print_r($result);
                        $link = new Link();
                        $link->id = $result->linkid;
                        $link->read();
                        $user = new User();
                        $user->id = $result->userid;
                        $user->read();
                        #print_r($user);
                        if (phpnum() < 5) {
                            $comment = array('author' => $user->username, 'email' => $user->email, 'website' => $link->url, 'body' => $result->cmt_content, 'permalink' => my_base_url . getmyurl('story', $link->id));
                            $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'), $comment);
                        } else {
                            $akismet = new Akismet(my_base_url . my_pligg_base, get_misc_data('wordpress_key'));
                            $akismet->setCommentAuthor($user->username);
                            $akismet->setCommentAuthorEmail($user->email);
                            $akismet->setCommentAuthorURL($link->url);
                            $akismet->setCommentContent($result->cmt_content);
                            $akismet->setPermalink(my_base_url . getmyurl('story', $link->id));
                        }
                        if ($value == "spamcomment") {
                            $akismet->submitSpam();
                        } elseif ($value == "notspamcomment") {
                            $akismet->submitHam();
                            $sql = "INSERT INTO " . table_comments . " (comment_parent, comment_user_id, comment_link_id , comment_date, comment_randkey, comment_content) VALUES ('{$result->cmt_parent}', '{$result->userid}', '{$result->linkid}', now(), '{$result->cmt_rand}', '{$result->cmt_content}')";
                            $db->query($sql);
                            #print $sql;
                        }
                        $link->adjust_comment(1);
                        $link->store();
                        $db->query(' Delete from ' . table_prefix . 'spam_comments where auto_id=' . $link_id);
                    }
                }
                header('Location: ' . URL_akismet . '&view=manageSpamcomments');
                die;
            }
        }
    } else {
        header("Location: " . getmyurl('login', $_SERVER['REQUEST_URI']));
        die;
    }
}
Пример #10
0
function object_2_array($result, $cur_depth = 0, $depth_limit = 1000)
{
    // $cur_depth and $depth_limit is used for php 4 only
    // prevents the function from doing extra checking to see if
    // it should 'explore' the object further. saves a few cpu cycles
    // using this because (array)$user will not work in php 4
    $array = array();
    if (isset($result)) {
        foreach ($result as $key => $value) {
            if ($cur_depth < $depth_limit && is_object($value)) {
                $array[$key] = object_2_array($value, $cur_depth + 1, $depth_limit);
            } elseif ($cur_depth < $depth_limit && is_array($value)) {
                $array[$key] = object_2_array($value, $cur_depth + 1, $depth_limit);
            } else {
                $array[$key] = $value;
            }
        }
    }
    return $array;
}
Пример #11
0
 function read()
 {
     global $db, $current_user;
     $id = $this->id;
     if ($this->id > 0) {
         $where = "user_id = {$id}";
     } else {
         if (!empty($this->username)) {
             $where = "user_login='******'";
         }
     }
     if (!empty($where) && ($user = $db->get_row("SELECT * FROM " . table_users . " WHERE {$where}"))) {
         $this->id = $user->user_id;
         $this->username = $user->user_login;
         $this->level = $user->user_level;
         $date = $user->user_date;
         $this->date = unixtimestamp($date);
         $date = $user->user_modification;
         $this->modification = unixtimestamp($date);
         $this->pass = $user->user_pass;
         $this->email = $user->user_email;
         $this->names = $user->user_names;
         $this->lang = $user->user_lang;
         $this->karma = $user->user_karma;
         $this->public_email = $user->public_email;
         $this->location = $user->user_location;
         $this->occupation = $user->user_occupation;
         $this->url = $user->user_url;
         $this->aim = $user->user_aim;
         $this->msn = $user->user_msn;
         $this->yahoo = $user->user_yahoo;
         $this->gtalk = $user->user_gtalk;
         $this->skype = $user->user_skype;
         $this->irc = $user->user_irc;
         $this->avatar_source = $user->user_avatar_source;
         $this->read = true;
         //$this->extra_field = (array)$user; (does this work in php4 ?!?)
         $this->extra_field = object_2_array($user);
         return true;
     }
     $this->read = false;
     return false;
 }
Пример #12
0
 function read($data = "long")
 {
     // $data = long -- return all user data
     // $data = short -- return just basic info
     global $db, $current_user, $cached_users;
     if ($this->id > 0) {
         $where = "user_id = {$this->id}";
     } else {
         if (!empty($this->username)) {
             $where = "user_login='******'";
             // if we only know the users login, check the cache to see if it's
             // already in there and set $this->id so the code below can find it in the cache.
             foreach ($cached_users as $user) {
                 if ($user->user_login == $this->username) {
                     $this->id = $user->user_id;
                 }
             }
         }
     }
     if (!empty($where)) {
         // this is a simple cache type system
         // when we lookup a user from the DB, store the results in memory
         // in case we need to lookup that user information again
         // good for sites where the content is submitted by the same group of people
         if (isset($cached_users[$this->id])) {
             $user = $cached_users[$this->id];
         } else {
             if (!($user = $db->get_row("SELECT  *  FROM " . table_users . " WHERE {$where}"))) {
                 return false;
             }
             if ($this->id > 0) {
                 //only cache when the id is provided.
                 $cached_users[$this->id] = $user;
             }
         }
         $this->id = $user->user_id;
         $this->username = $user->user_login;
         $this->level = $user->user_level;
         $this->email = $user->user_email;
         $this->avatar_source = $user->user_avatar_source;
         // if short, then stop here
         if ($data == 'short') {
             return true;
         }
         $this->names = $user->user_names;
         $date = $user->user_date;
         $this->date = unixtimestamp($date);
         $date = $user->user_modification;
         $this->modification = unixtimestamp($date);
         $this->pass = $user->user_pass;
         $this->karma = $user->user_karma;
         $this->public_email = $user->public_email;
         $this->location = $user->user_location;
         $this->occupation = $user->user_occupation;
         $this->url = $user->user_url;
         $this->aim = $user->user_aim;
         $this->msn = $user->user_msn;
         $this->yahoo = $user->user_yahoo;
         $this->gtalk = $user->user_gtalk;
         $this->skype = $user->user_skype;
         $this->irc = $user->user_irc;
         $this->read = true;
         $this->extra_field = object_2_array($user, 0, 0);
         return true;
     }
     $this->read = false;
     return false;
 }
Пример #13
0
<?php

include '../../config.php';
$id = $_REQUEST['id'];
$sql = "SELECT featured_image FROM " . table_prefix . "featured WHERE featured_id=" . $id . "";
$news = $db->get_results($sql);
$news = object_2_array($news);
ob_end_clean();
ob_start();
header("Content-type: image/jpeg");
echo $news[0]['featured_image'];
ob_end_flush();
exit;
Пример #14
0
function featured_getdata(&$vars)
{
    global $db, $main_smarty, $the_template;
    $featured_sql = "SELECT featured_id, featured_link_id, featured_enabled FROM " . table_prefix . "featured WHERE featured_enabled='Yes' ORDER BY featured_id ASC";
    $featured = $db->get_results($featured_sql);
    $featured = object_2_array($featured);
    for ($i = 0; $i < count($featured); $i++) {
        $news = null;
        $sql_news = "SELECT link_id, link_url, link_title, link_title_url, link_summary, link_date, link_votes, link_comments FROM " . table_prefix . "links WHERE link_id=" . $featured[$i]['featured_link_id'];
        $news = $db->get_results($sql_news);
        foreach ($news as $dblink) {
            $featured[$i]['link_summary'] = str_replace("\n", "<br />", $dblink->link_summary);
            $featured[$i]['link_summary'] = str_replace("’", "'", $featured[$i]['link_summary']);
            $featured[$i]['link_summary'] = str_replace("–", "-", $featured[$i]['link_summary']);
            $featured[$i]['link_summary'] = str_replace("—", "-", $featured[$i]['link_summary']);
            $featured[$i]['link_summary'] = str_replace("“", "\"", $featured[$i]['link_summary']);
            $featured[$i]['link_summary'] = str_replace("”", "\"", $featured[$i]['link_summary']);
            $featured[$i]['link_title'] = $dblink->link_title;
            $featured[$i]['link_date'] = $dblink->link_date;
            $featured[$i]['link_votes'] = $dblink->link_votes;
            $featured[$i]['link_comments'] = $dblink->link_comments;
        }
        $featured[$i]['link_url'] = my_pligg_base . "/story.php?title=" . $dblink->link_title_url;
        $sql = "SELECT * FROM " . table_prefix . "featured ORDER BY featured_id ASC";
        $news = $db->get_results($sql);
        $news = object_2_array($news);
        $main_smarty->assign('news', $news);
    }
    $main_smarty->assign('featured', $featured);
    $var = $main_smarty->fetch(featured_tpl_path . 'featured.tpl');
    $main_smarty->assign('featured', $var);
}