Beispiel #1
0
 function setUp()
 {
     parent::setUp();
     require_code('news');
     $this->news_id = add_news($title = 'Today', $news = "hiiiiiiiiiii", $author = 'rolly', $validated = 1, $allow_rating = 1, $allow_comments = 1, $allow_trackbacks = 1, $notes = '', $news_article = 'test article', $main_news_category = 5, $news_category = NULL, $time = '1262671781', $submitter = NULL, $views = 0, $edit_date = NULL, $id = NULL, $image = '');
     // Test the forum was actually created
     $this->assertTrue('Today' == get_translated_text($GLOBALS['SITE_DB']->query_value('news', 'title ', array('id' => $this->news_id))));
 }
function get_news_section($full = false)
{
    $test = file_get_html('tmpResult.html');
    $results = $test->find('tr[class=watch_title]');
    $continue = false || $full;
    if (count($results) == 0) {
        $continue = false;
    }
    foreach ($results as $res) {
        $tmp = analyse_news($res);
        if ($tmp == NULL) {
            continue;
        }
        if (is_new_news($tmp) == true) {
            create_news_details_file($tmp);
            add_news($tmp);
            $continue = true;
        }
    }
    return $continue;
}
Beispiel #3
0
 /**
  * The actualiser to import wordpress blog
  *
  * @return tempcode		The UI
  */
 function _import_wordpress()
 {
     check_specific_permission('mass_import', NULL, NULL, 'cms_news');
     $title = get_page_title('IMPORT_WP_DB');
     require_code('rss');
     require_code('news');
     require_code('news2');
     $GLOBALS['LAX_COMCODE'] = true;
     require_code('uploads');
     is_swf_upload(true);
     $is_validated = post_param_integer('wp_auto_validate', 0);
     $to_own_account = post_param_integer('wp_add_to_own', 0);
     //Wordpress post xml file importing method
     if (get_param('method') == 'xml') {
         $rss_url = post_param('xml_url', NULL);
         if (array_key_exists('file_novalidate', $_FILES)) {
             if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
                 $rss_url = $_FILES['file_novalidate']['tmp_name'];
             } else {
                 warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
             }
         } else {
             warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
         }
         $rss = new rss($rss_url, true);
         if (!is_null($rss->error)) {
             warn_exit($rss->error);
         }
         $cat_id = NULL;
         $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
         $NEWS_CATS = list_to_map('id', $NEWS_CATS);
         $extra_post_data = array();
         foreach ($rss->gleamed_items as $item) {
             if (!array_key_exists('category', $item)) {
                 $item['category'] = do_lang('NC_general');
             }
             $extra_post_data[] = $item;
             foreach ($NEWS_CATS as $_cat => $news_cat) {
                 if (get_translated_text($news_cat['nc_title']) == $item['category']) {
                     $cat_id = $_cat;
                 }
             }
             //Check for existing owner categories, if not create blog category for creator
             if ($to_own_account == 0) {
                 $creator = $item['author'];
                 $submitter_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($creator);
             } else {
                 $submitter_id = get_member();
             }
             //if(is_null($submitter_id))	continue;	//Skip importing posts of nonexisting users
             $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $submitter_id));
             if (is_null($cat_id)) {
                 $cat_id = add_news_category($item['category'], 'newscats/general', '', NULL);
                 $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
                 $NEWS_CATS = list_to_map('id', $NEWS_CATS);
             }
             // Add news
             add_news($item['title'], html_to_comcode($item['news']), NULL, $is_validated, 1, 1, 1, '', array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '', $owner_category_id, array($cat_id), NULL, $submitter_id, 0, time(), NULL, '');
         }
         if (url_is_local($rss_url)) {
             // Means it is a temp file
             @unlink($rss_url);
         }
     } elseif (get_param('method') == 'db') {
         import_wordpress_db();
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_BLOGS')), array('_SELF:_SELF:import_wordpress', do_lang_tempcode('IMPORT_WORDPRESS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     return inform_screen($title, do_lang_tempcode('IMPORT_WORDPRESS_DONE'));
 }
Beispiel #4
0
        /*
        END PRIMARY DEFENDER CALCS
        --------------------------
        */
        while ($defend[$i]["id"] > 0) {
            $l_infinitys = round(round($d_infinitys2 - $d_infinitys) * $defend[$i]["p_infinitys"]);
            $l_wraiths = round(round($d_wraiths2 - $d_wraiths) * $defend[$i]["p_wraiths"]);
            $l_warfrigs = round(round($d_warfrigs2 - $d_warfrigs) * $defend[$i]["p_warfrigs"]);
            $l_destroyers = round(round($d_destroyers2 - $d_destroyers) * $defend[$i]["p_destroyers"]);
            $l_astropods = round(round($d_astropods2 - $d_astropods) * $defend[$i]["p_astropods"]);
            #  if ($attack[$i]["astropods"]-$l_astropods-$roidscapped<0) $l_astropods = 0; else $l_astropods = $l_astropods+$roidscapped;
            $l_scorpions = round(round($d_scorpions2 - $d_scorpions) * $defend[$i]["p_scorpions"]);
            $l_cobras = round(round($d_cobras2 - $d_cobras) * $defend[$i]["p_cobras"]);
            $salvm = round($salvagem * $defend[$i]["p_sum"]);
            $salvc = round($salvagec * $defend[$i]["p_sum"]);
            add_news("Combat report", "<table border=\"1\" bordercolor=\"black\"><td>Defender(s) ({$nick} #{$id}):</td><td>Total:</td><td>Lost:</td><tr>\n\n<td>Infinitys:</td><td>{$d_infinitys2}</td><td>" . number_format($d_infinitys2 - $d_infinitys, 0) . "<tr>\n\n<td>Wraiths:</td><td>{$d_wraiths2}</td><td>" . number_format($d_wraiths2 - $d_wraiths, 0) . "<tr>\n\n<td>Warfrigs:</td><td>{$d_warfrigs2}</td><td>" . number_format($d_warfrigs2 - $d_warfrigs, 0) . "<tr>\n\n<td>Destroyer:</td><td>{$d_destroyers2}</td><td>" . number_format($d_destroyers2 - $d_destroyers, 0) . "<tr>\n\n<td>Cobras:</td><td>{$d_cobras2}</td><td>" . number_format($d_cobras2 - $d_cobras, 0) . "<tr>\n\n<td>Astropods:</td><td>{$d_astropods2}</td><td>" . number_format($d_astropods2 - $d_astropods, 0) . "<tr>\n\n<td>Scorpions:</td><td>{$d_scorpions2}</td><td>" . number_format($d_scorpions2 - $d_scorpions, 0) . "<tr>\n\n<td>Reaper cannons:</td><td>{$d_rcannons2}</td><td>" . number_format($d_rcannons2 - $d_rcannons, 0) . "<tr>\n\n<td>Avengers:</td><td>{$d_avengers2}</td><td>" . number_format($d_avengers2 - $d_avengers, 0) . "<tr>\n\n<td>Lucius stalkers:</td><td>{$d_lstalkers2}</td><td>" . number_format($d_lstalkers2 - $d_lstalkers, 0) . "<tr>\n\n<td>Attacker(s):</td><tr>\n\n<td>Infinitys:</td><td>{$infinitys2}</td><td>" . number_format($infinitys2 - $infinitys, 0) . "<tr>\n\n<td>Wraiths:</td><td>{$wraiths2}</td><td>" . number_format($wraiths2 - $wraiths, 0) . "<tr>\n\n<td>Warfrigs:</td><td>{$warfrigs2}</td><td>" . number_format($warfrigs2 - $warfrigs, 0) . "<tr>\n\n<td>Destroyers:</td><td>{$destroyers2}</td><td>" . number_format($destroyers2 - $destroyers, 0) . "<tr>\n\n<td>Astropods:</td><td>{$astropods2} ({$t_block} blocked)</td><td>" . number_format($astropods2 - $astropods, 0) . "<tr>\n\n<td>Scorpions:</td><td>{$scorpions2}</td><td>" . number_format($scorpions2 - $scorpions, 0) . "<tr>\n\n<td>Yours:</td><tr>\n\n<td>Infinitys:</td><td>" . $defend[$i]["infinitys"] . "</td><td>{$l_infinitys}<tr>\n\n<td>Wraiths:</td><td>" . $defend[$i]["wraiths"] . "</td><td>{$l_wraiths}<tr>\n\n<td>Warfrigs:</td><td>" . $defend[$i]["warfrigs"] . "</td><td>{$l_warfrigs}<tr>\n\n<td>Destroyers:</td><td>" . $defend[$i]["destroyers"] . "</td><td>{$l_destroyers}<tr>\n\n<td>Cobras:</td><td>" . $defend[$i]["cobras"] . "</td><td>{$l_cobras}<tr>\n\n<td>Astropods:</td><td>" . $defend[$i]["astropods"] . "</td><td>{$l_astropods}<tr>\n\n<td>Scorpions:</td><td>" . $defend[$i]["scorpions"] . "</td><td>{$l_scorpions}<tr>\n\n<tr>\n<td>Metal salvage:</td><td>{$salvm}</td><tr>\n<td>Crystal salvage:</td><td>{$salvc}</td><tr>\n</table>\n\n", $defend[$i]["id"]);
            $result3 = mysql_query("UPDATE " . $PA["table"] . " SET infinitys=infinitys-{$l_infinitys},wraiths=wraiths-{$l_wraiths},warfrigs=warfrigs-{$l_warfrigs},destroyers=destroyers-{$l_destroyers},astropods=astropods-{$l_astropods},scorpions=scorpions-{$l_scorpions},cobras=cobras-{$l_cobras},crystal=crystal+{$salvc},metal=metal+{$salvm} WHERE id=" . $defend[$i]["id"], $db);
            dbr(mysql_error());
            $i++;
        }
    }
    $result2 = mysql_query("UPDATE " . $PA["table"] . " SET size='{$roids}',rank={$rank} WHERE id={$id}", $db);
    dbr(mysql_error());
    $rank++;
}
$result3 = mysql_query("UPDATE " . $PA["table"] . " SET score=(crystal+metal)/200+size*1500+infinitys*200+wraiths*2000+warfrigs*3000+astropods*1600+cobras*3000+destroyers*5000+scorpions*7000+rcannons*800+avengers*1400+lstalkers*6000");
?>
Tick done!
<?php 
if ($os == "windows") {
    echo "<meta HTTP-EQUIV=\"Refresh\" content=\"{$tickertime}\">";
Beispiel #5
0
     }
     //проверяем чтоб общее кол-во страниц не было < 1, еслипользователь введет несуществующую категорию.
     //минимум 1 страница должна быть
     if ($page > $pages_count) {
         $page = $pages_count;
     }
     //если пользователь в адресную строку введет число большее чем реальное кол-во страниц
     $start_position = ($page - 1) * $perpage;
     //начальная позиция вывода товара (для запроса)
     $all_news = get_all_news($start_position, $perpage);
     break;
 case 'add_news':
     //добавление новости
     if ($_POST) {
         //проверяем были ли переданы данные из формы
         if (add_news()) {
             redirect('?view=news');
         } else {
             redirect();
         }
         //иначе редирект на эту же стр, откуда пришли
     }
     break;
 case 'edit_news':
     //редактирование новости
     $news_id = (int) $_GET['news_id'];
     $get_news = get_news($news_id);
     if ($_POST) {
         //проверяем были ли переданы данные из формы
         if (edit_news($news_id)) {
             redirect('?view=news');
Beispiel #6
0
function route($action)
{
    global $html_main_content, $title;
    show_err();
    switch ($action) {
        case '':
            main();
            break;
        case 'user_show':
            $title = print_lg('Show all users', $_SESSION['lang']);
            user_show();
            break;
        case 'user_info':
            $title = print_lg('User info', $_SESSION['lang']);
            user_info();
            break;
        case 'show_news':
            show_news();
            break;
        case 'logout':
            logout();
            break;
        case 'add_news':
            $title = print_lg('Add news', $_SESSION['lang']);
            add_news();
            break;
        case 'registration':
            $title = print_lg('Registration', $_SESSION['lang']);
            registration();
            break;
        case 'delete_news':
            delete_news();
            break;
        case 'edit_news':
            $title = print_lg('Edit news', $_SESSION['lang']);
            edit_news();
            break;
        case 'pages':
            main();
            break;
        case 'profileview':
            $title = print_lg('You information', $_SESSION['lang']);
            profileview();
            break;
        case 'delete_user':
            delete_user();
            break;
        case 'user_delete':
            user_delete();
            break;
        case 'user_edit':
            $title = print_lg('Edit user', $_SESSION['lang']);
            user_edit();
            break;
        case 'edit_language':
            $title = print_lg('Edit language', $_SESSION['lang']);
            edit_language();
            break;
        case 'delete_comments':
            delete_comments();
            break;
        case 'delete_vote':
            delete_vote();
            break;
        default:
            $html_main_content .= print_lg('Page not found', $_SESSION['lang']);
            break;
    }
}
function do_work()
{
    $num_wanted = 100000;
    require_code('config2');
    set_option('post_history_days', '0');
    // Needed for a little sanity in recent post retrieval
    set_value('disable_sunk', '1');
    // members (remember to test the username autocompleter, and birthdays)
    // authors (remember to check author autocompleter and popup author list)
    // lots of people getting notifications on a forum
    // lots of people getting notifications on a topic
    require_code('authors');
    require_code('ocf_members_action');
    require_code('notifications');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_members', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $member_id = ocf_make_member(uniqid('', true), uniqid('', true), uniqid('', true) . '@example.com', array(), intval(date('d')), intval(date('m')), intval(date('Y')), array(), NULL, NULL, 1, NULL, NULL, '', NULL, '', 0, 0, 1, '', '', '', 1, 1, NULL, 1, 1, '', NULL, '', false);
        add_author(random_line(), '', $member_id, random_text(), random_text());
        enable_notifications('ocf_topic', 'forum:' . strval(db_get_first_id()), $member_id);
        enable_notifications('ocf_topic', strval(db_get_first_id()), $member_id);
        // number of friends to a single member
        $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => db_get_first_id() + 1, 'date_and_time' => time()), false, true);
    }
    $member_id = db_get_first_id() + 2;
    // point earn list / gift points to a single member
    require_code('points2');
    for ($j = $GLOBALS['SITE_DB']->query_value('gifts', 'COUNT(*)'); $j < $num_wanted; $j++) {
        give_points(10, $member_id, mt_rand(db_get_first_id(), min(100, $num_wanted - 1)), random_line(), false, false);
    }
    // number of friends of a single member
    for ($j = intval(floatval($GLOBALS['SITE_DB']->query_value('chat_buddies', 'COUNT(*)')) / 2.0); $j < $num_wanted; $j++) {
        $GLOBALS['SITE_DB']->query_insert('chat_buddies', array('member_likes' => $member_id, 'member_liked' => $j + db_get_first_id(), 'date_and_time' => time()), false, true);
    }
    echo 'done member/authors/points/notifications/friends stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // banners
    require_code('banners2');
    for ($i = $GLOBALS['SITE_DB']->query_value('banners', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_banner(uniqid('', true), get_logo_url(), random_line(), random_text(), 100, get_base_url(), 3, '', db_get_first_id(), NULL, db_get_first_id() + 1, 1);
    }
    echo 'done banner stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // comcode pages
    require_code('files');
    require_code('files2');
    for ($i = $GLOBALS['SITE_DB']->query_value('comcode_pages', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $file = uniqid('', true);
        /*$path=get_custom_file_base().'/site/pages/comcode_custom/'.fallback_lang().'/'.$file.'.txt';
        		$myfile=fopen($path,'wt');
        		fwrite($myfile,random_text());
        		fclose($myfile);
        		sync_file($path);
        		fix_permissions($path);*/
        $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => 'site', 'the_page' => $file, 'p_parent_page' => '', 'p_validated' => 1, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => db_get_first_id(), 'p_show_as_edit' => 0));
    }
    echo 'done comcode stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // zones
    require_code('zones2');
    require_code('abstract_file_manager');
    for ($i = $GLOBALS['SITE_DB']->query_value('zones', 'COUNT(*)'); $i < min($num_wanted, 1000); $i++) {
        actual_add_zone(uniqid('', true), random_line(), 'start', random_line(), 'default', 0, 0, 0);
    }
    echo 'done zone stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // calendar events
    require_code('calendar2');
    for ($i = $GLOBALS['SITE_DB']->query_value('calendar_events', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_calendar_event(db_get_first_id(), '', NULL, 0, random_line(), random_text(), 1, 1, intval(date('Y')), intval(date('m')), intval(date('d')), 0, 0);
    }
    echo 'done event stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // chat rooms
    require_code('chat2');
    require_code('chat');
    for ($i = $GLOBALS['SITE_DB']->query_value('chat_rooms', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $room_id = add_chatroom(random_text(), random_line(), mt_rand(db_get_first_id() + 1, $num_wanted - 1), strval(db_get_first_id() + 1), '', '', '', fallback_lang());
    }
    $room_id = db_get_first_id() + 1;
    // messages in chat room
    for ($j = $GLOBALS['SITE_DB']->query_value('chat_messages', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $_message_parsed = insert_lang_comcode(random_text(), 4);
        $GLOBALS['SITE_DB']->query_insert('chat_messages', array('system_message' => 0, 'ip_address' => '', 'room_id' => $room_id, 'user_id' => db_get_first_id(), 'date_and_time' => time(), 'the_message' => $_message_parsed, 'text_colour' => get_option('chat_default_post_colour'), 'font_name' => get_option('chat_default_post_font')));
    }
    echo 'done chat stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // download categories under a subcategory
    require_code('downloads2');
    $subcat_id = add_download_category(random_line(), db_get_first_id(), random_text(), '');
    for ($i = $GLOBALS['SITE_DB']->query_value('download_categories', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_download_category(random_line(), $subcat_id, random_text(), '');
    }
    // downloads (remember to test content by the single author)
    require_code('downloads2');
    require_code('awards');
    $time = time();
    for ($i = $GLOBALS['SITE_DB']->query_value('download_downloads', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $content_id = add_download(db_get_first_id(), random_line(), get_logo_url(), random_text(), 'admin', random_text(), NULL, 1, 1, 1, 1, '', uniqid('', true) . '.jpg', 100, 110, 1);
        give_award(db_get_first_id(), strval($content_id), $time - $i);
    }
    $content_id = db_get_first_id();
    $content_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $content_id), 'site');
    for ($j = $GLOBALS['SITE_DB']->query_value('trackbacks', 'COUNT(*)'); $j < $num_wanted; $j++) {
        // trackbacks
        $GLOBALS['SITE_DB']->query_insert('trackbacks', array('trackback_for_type' => 'downloads', 'trackback_for_id' => $content_id, 'trackback_ip' => '', 'trackback_time' => time(), 'trackback_url' => '', 'trackback_title' => random_line(), 'trackback_excerpt' => random_text(), 'trackback_name' => random_line()));
        // ratings
        $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => $content_id, 'rating_member' => $j + 1, 'rating_ip' => '', 'rating_time' => time(), 'rating' => 3));
        // posts in a comment topic
        $GLOBALS['FORUM_DRIVER']->make_post_forum_topic(get_option('comments_forum_name'), 'downloads_' . strval($content_id), get_member(), random_text(), random_line(), '', do_lang('COMMENT'), $content_url->evaluate(), NULL, NULL, 1, 1);
    }
    echo 'done download stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // forums under a forum (don't test it can display, just make sure the main index still works)
    require_code('ocf_forums_action');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)'); $i < $num_wanted; $i++) {
        ocf_make_forum(random_line(), random_text(), db_get_first_id(), array(), db_get_first_id() + 3);
    }
    // forum topics
    require_code('ocf_topics_action');
    require_code('ocf_posts_action');
    require_code('ocf_forums');
    require_code('ocf_topics');
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) {
        $topic_id = ocf_make_topic(db_get_first_id(), '', '', NULL, 1, 0, 0, 0, NULL, NULL, false);
        ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, false, false);
    }
    // forum posts in a topic
    require_code('ocf_topics_action');
    require_code('ocf_posts_action');
    $topic_id = ocf_make_topic(db_get_first_id() + 1, '', '', NULL, 1, 0, 0, 0, NULL, NULL, false);
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_posts', 'COUNT(*)')) / 3.0); $i < $num_wanted; $i++) {
        ocf_make_post($topic_id, random_line(), random_text(), 0, true, 0, 0, NULL, NULL, NULL, mt_rand(db_get_first_id(), $num_wanted - 1), NULL, NULL, NULL, false, false);
    }
    echo 'done forum stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // clubs
    require_code('ocf_groups_action');
    require_code('ocf_groups');
    for ($i = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)'); $i < $num_wanted; $i++) {
        ocf_make_group(random_line(), 0, 0, 0, random_line(), '', NULL, NULL, NULL, 5, 0, 70, 50, 100, 100, 30000, 700, 25, 1, 0, 0, 0, $i, 1, 0, 1);
    }
    echo 'done club stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // galleries under a subcategory
    require_code('galleries2');
    $xsubcat_id = uniqid('', true);
    add_gallery($xsubcat_id, random_line(), random_text(), '', '', 'root');
    for ($i = $GLOBALS['SITE_DB']->query_value('galleries', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_gallery(uniqid('', true), random_line(), random_text(), '', '', $xsubcat_id);
    }
    // images
    require_code('galleries2');
    for ($i = $GLOBALS['SITE_DB']->query_value('images', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_image('', 'root', random_text(), get_logo_url(), get_logo_url(), 1, 1, 1, 1, '');
    }
    // videos / validation queue
    require_code('galleries2');
    for ($i = $GLOBALS['SITE_DB']->query_value('videos', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_video('', 'root', random_text(), get_logo_url(), get_logo_url(), 0, 1, 1, 1, '', 0, 0, 0);
    }
    echo 'done galleries stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // newsletter subscribers
    require_code('newsletter');
    for ($i = $GLOBALS['SITE_DB']->query_value('newsletter', 'COUNT(*)'); $i < $num_wanted; $i++) {
        basic_newsletter_join(uniqid('', true) . '@example.com');
    }
    echo 'done newsletter stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // polls (remember to test poll archive)
    require_code('polls');
    for ($i = $GLOBALS['SITE_DB']->query_value('poll', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $poll_id = add_poll(random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), random_line(), 10, 0, 0, 0, 0, '');
    }
    // votes on a poll
    $poll_id = db_get_first_id();
    for ($j = $GLOBALS['SITE_DB']->query_value('poll_votes', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $cast = mt_rand(1, 6);
        $ip = uniqid('', true);
        $GLOBALS['SITE_DB']->query_insert('poll_votes', array('v_poll_id' => $poll_id, 'v_voter_id' => 2, 'v_voter_ip' => $ip, 'v_vote_for' => $cast));
    }
    echo 'done polls stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // quizzes
    require_code('quiz');
    for ($i = $GLOBALS['SITE_DB']->query_value('quizzes', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_quiz(random_line(), 0, random_text(), random_text(), random_text(), '', 0, time(), NULL, 3, 300, 'SURVEY', 1, '1) Some question');
    }
    echo 'done quizzes stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // successful searches (to test the search recommender)
    // ACTUALLY: I have manually verified the code, it is an isolated portion
    // cedi pages (do a long descendant tree for some, and orphans for others)
    // cedi posts (remember to test cedi changes screen)
    require_code('cedi');
    for ($i = $GLOBALS['SITE_DB']->query_value('seedy_pages', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $page_id = cedi_add_page(random_line(), random_text(), '', 1);
        cedi_add_post($page_id, random_text(), 1, NULL, false);
    }
    echo 'done cedi stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // iotds
    require_code('iotds');
    for ($i = $GLOBALS['SITE_DB']->query_value('iotd', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_iotd(get_logo_url(), random_line(), random_text(), get_logo_url(), 1, 0, 0, 0, '');
    }
    echo 'done iotd stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // logged hack attempts
    for ($i = $GLOBALS['SITE_DB']->query_value('hackattack', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $GLOBALS['SITE_DB']->query_insert('hackattack', array('url' => get_base_url(), 'data_post' => '', 'user_agent' => '', 'referer' => '', 'user_os' => '', 'the_user' => db_get_first_id(), 'date_and_time' => time(), 'ip' => uniqid('', true), 'reason' => 'ASCII_ENTITY_URL_HACK', 'reason_param_a' => '', 'reason_param_b' => ''));
    }
    // logged hits in one day
    require_code('site');
    for ($i = $GLOBALS['SITE_DB']->query_value('stats', 'COUNT(*)'); $i < $num_wanted; $i++) {
        log_stats('/testing' . uniqid('', true), mt_rand(100, 2000));
    }
    echo 'done logs stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // blogs and news entries (remember to test both blogs [categories] list, and a list of all news entries)
    require_code('news');
    for ($i = $GLOBALS['SITE_DB']->query_value('news', 'COUNT(*)'); $i < $num_wanted; $i++) {
        add_news(random_line(), random_text(), 'admin', 1, 1, 1, 1, '', random_text(), NULL, NULL, NULL, db_get_first_id() + $i);
    }
    echo 'done news stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // support tickets
    require_code('tickets');
    require_code('tickets2');
    for ($i = intval(floatval($GLOBALS['FORUM_DB']->query_value('f_topics', 'COUNT(*)')) / 2.0); $i < $num_wanted; $i++) {
        ticket_add_post(mt_rand(db_get_first_id(), $num_wanted - 1), uniqid('', true), db_get_first_id(), random_line(), random_text(), '', '');
    }
    echo 'done tickets stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // catalogues
    require_code('catalogues2');
    $root_id = db_get_first_id();
    for ($i = $GLOBALS['SITE_DB']->query_value('catalogues', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $catalogue_name = uniqid('', true);
        $root_id = actual_add_catalogue($catalogue_name, random_line(), random_text(), mt_rand(0, 3), 1, '', 30);
    }
    // catalogue categories under a subcategory (remember to test all catalogue views: atoz, index, and root cat)
    $catalogue_name = 'products';
    $subcat_id = actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $root_id);
    for ($j = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'COUNT(*)'); $j < $num_wanted; $j++) {
        actual_add_catalogue_category($catalogue_name, random_line(), random_text(), '', $subcat_id);
    }
    echo 'done catalogue stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    // items in ecommerce store
    require_code('catalogues2');
    $cat_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => 'products'));
    $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'products')));
    for ($i = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'COUNT(*)'); $i < $num_wanted; $i++) {
        $map = array($fields[0] => random_line(), $fields[1] => uniqid('', true), $fields[2] => '1.0', $fields[3] => '1', $fields[4] => '0', $fields[5] => '1', $fields[6] => '0%', $fields[7] => get_logo_url(), $fields[8] => '2.0', $fields[9] => random_text());
        $pid = actual_add_catalogue_entry($cat_id, 1, '', 1, 1, 1, $map);
        unset($map);
    }
    // outstanding ecommerce orders
    $pid = $GLOBALS['SITE_DB']->query_value('catalogue_entries', 'MIN(id)', array('c_name' => 'products'));
    require_code('shopping');
    for ($j = $GLOBALS['SITE_DB']->query_value('shopping_cart', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $product_det = array('product_id' => $pid, 'product_name' => $fields[0], 'product_code' => $fields[1], 'price' => $fields[2], 'tax' => preg_replace('#[^\\d\\.]#', '', $fields[6]), 'description' => $fields[9], 'quantity' => mt_rand(1, 20), 'product_type' => 'catalogue_items', 'product_weight' => $fields[8]);
        $GLOBALS['SITE_DB']->query_insert('shopping_cart', array('session_id' => mt_rand(0, 1000000), 'ordered_by' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'product_id' => $product_det['product_id'], 'product_name' => $product_det['product_name'], 'product_code' => $product_det['product_code'], 'quantity' => $product_det['quantity'], 'price' => round(floatval($product_det['price']), 2), 'price_pre_tax' => $product_det['tax'], 'product_description' => $product_det['description'], 'product_type' => $product_det['product_type'], 'product_weight' => $product_det['product_weight'], 'is_deleted' => 0));
    }
    for ($j = $GLOBALS['SITE_DB']->query_value('shopping_order', 'COUNT(*)'); $j < $num_wanted; $j++) {
        $order_id = $GLOBALS['SITE_DB']->query_insert('shopping_order', array('c_member' => mt_rand(db_get_first_id() + 1, $num_wanted - 1), 'session_id' => mt_rand(0, 1000000), 'add_date' => time(), 'tot_price' => '123.00', 'order_status' => 'ORDER_STATUS_awaiting_payment', 'notes' => '', 'purchase_through' => 'purchase_module', 'transaction_id' => '', 'tax_opted_out' => 0), true);
        $GLOBALS['SITE_DB']->query_insert('shopping_order_details', array('p_id' => 123, 'p_name' => random_line(), 'p_code' => 123, 'p_type' => 'catalogue_items', 'p_quantity' => 1, 'p_price' => '12.00', 'order_id' => $order_id, 'dispatch_status' => '', 'included_tax' => '1.00'));
    }
    echo 'done store stuff' . chr(10);
    if (function_exists('gc_collect_cycles')) {
        gc_enable();
    }
    echo '{{DONE}}' . chr(10);
}
Beispiel #8
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $file_base)
 {
     require_code('news');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news_categories ORDER BY id', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     $on_same_msn = $this->on_same_msn($file_base);
     foreach ($rows as $row) {
         if (import_check_if_imported('news_category', strval($row['id']))) {
             continue;
         }
         $owner = $on_same_msn ? $row['nc_owner'] : import_id_remap_get('member', $row['nc_owner'], true);
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = add_news_category($this->get_lang_string($db, $row['nc_title']), $row['nc_img'], $row['notes'], $owner, $id);
         import_id_remap_put('news_category', strval($row['id']), $id_new);
     }
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'news_category', 'news_category');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news ORDER BY id');
     foreach ($rows as $row) {
         if (import_check_if_imported('news', strval($row['id']))) {
             continue;
         }
         $news_category = array();
         $rows2 = $db->query('SELECT news_entry_category FROM ' . $table_prefix . 'news_category_entries WHERE news_entry=' . strval((int) $row['id']));
         foreach ($rows2 as $row2) {
             $next = import_id_remap_get('news_category', strval($row2['news_entry_category']), true);
             if (!is_null($next)) {
                 $news_category[] = $next;
             }
         }
         $submitter = $on_same_msn ? $row['submitter'] : import_id_remap_get('member', $row['submitter'], true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $main_news_category = $row['news_category'];
         $main_news_category = import_id_remap_get('news_category', strval($main_news_category), true);
         if (is_null($main_news_category)) {
             $main_news_category = db_get_first_id();
         }
         $id_new = add_news($this->get_lang_string($db, $row['title']), $this->get_lang_string($db, $row['news']), $row['author'], $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $this->get_lang_string($db, $row['news_article']), $main_news_category, $news_category, $row['date_and_time'], $submitter, $row['news_views'], $row['edit_date'], $id, $row['news_image']);
         import_id_remap_put('news', strval($row['id']), $id_new);
     }
     $this->_import_review_supplement($db, $table_prefix, 'news', 'news');
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'news', 'news');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news_rss_cloud', NULL, NULL, true);
     if (!is_null($rows)) {
         foreach ($rows as $row) {
             unset($row['id']);
             $GLOBALS['SITE_DB']->query_insert('news_rss_cloud', $row);
         }
     }
 }
Beispiel #9
0
$limit = get_number_limit($pageparam, 1, $CONFIG['quote_list_limit']);
switch ($page[0]) {
    case 'add':
        if (isset($CONFIG['login_required']) && $CONFIG['login_required'] == 1 && !isset($_SESSION['logged_in'])) {
            break;
        }
        add_quote($page[1]);
        break;
    case 'edit_news':
        if (isset($_SESSION['logged_in']) && $_SESSION['level'] <= USER_ADMIN) {
            edit_news($page[1], $page[2]);
        }
        break;
    case 'add_news':
        if (isset($_SESSION['logged_in']) && $_SESSION['level'] <= USER_ADMIN) {
            add_news($page[1]);
        }
        break;
    case 'add_user':
        if (isset($_SESSION['logged_in']) && $_SESSION['level'] <= USER_SUPERUSER) {
            add_user($page[1]);
        }
        break;
    case 'register':
        if (isset($CONFIG['login_required']) && $CONFIG['login_required'] == 1) {
            register_user($page[1]);
        }
        break;
    case 'login':
        if (isset($CONFIG['login_required']) && $CONFIG['login_required'] == 1) {
            if (isset($_SESSION['logged_in'])) {
Beispiel #10
0
 /**
  * The actualiser to import news
  *
  * @return tempcode		The UI
  */
 function _import_news()
 {
     check_specific_permission('mass_import');
     $title = get_page_title('IMPORT_NEWS');
     require_code('rss');
     require_code('news');
     require_code('files');
     $GLOBALS['LAX_COMCODE'] = true;
     disable_php_memory_limit();
     $rss_url = post_param('rss_feed_url', NULL);
     require_code('uploads');
     if (is_swf_upload(true) && array_key_exists('file_novalidate', $_FILES) || array_key_exists('file_novalidate', $_FILES) && is_uploaded_file($_FILES['file_novalidate']['tmp_name'])) {
         $rss_url = $_FILES['file_novalidate']['tmp_name'];
     }
     if (is_null($rss_url)) {
         warn_exit(do_lang_tempcode('IMPROPERLY_FILLED_IN'));
     }
     $is_validated = post_param_integer('auto_validate', 0);
     $download_images = post_param_integer('download_images', 0);
     $rss = new rss($rss_url, true);
     if (!is_null($rss->error)) {
         warn_exit($rss->error);
     }
     $submitter = get_member();
     $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
     $NEWS_CATS = list_to_map('id', $NEWS_CATS);
     $extra_post_data = array();
     foreach ($rss->gleamed_items as $i => $item) {
         if (!array_key_exists('category', $item)) {
             $item['category'] = do_lang('NC_general');
         }
         $extra_post_data[] = $item;
         $cats_to_process = array($item['category']);
         if (array_key_exists('extra_categories', $item)) {
             $cats_to_process = array_merge($cats_to_process, $item['extra_categories']);
         }
         $cat_id = mixed();
         $extra_categories = array();
         foreach ($cats_to_process as $j => $cat) {
             $_cat_id = mixed();
             foreach ($NEWS_CATS as $_cat => $news_cat) {
                 if (get_translated_text($news_cat['nc_title']) == $cat) {
                     $_cat_id = $_cat;
                 }
             }
             if (is_null($_cat_id)) {
                 $_cat_id = add_news_category($cat, 'newscats/general', '', NULL);
                 // Need to reload now
                 $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
                 $NEWS_CATS = list_to_map('id', $NEWS_CATS);
             }
             if ($j == 0) {
                 $cat_id = $_cat_id;
             } else {
                 $extra_categories[] = $_cat_id;
             }
         }
         $rep_image = '';
         if (array_key_exists('rep_image', $item)) {
             $rep_image = $item['rep_image'];
             if ($download_images == 1) {
                 $stem = 'uploads/grepimages/' . basename(urldecode($rep_image));
                 $target_path = get_custom_file_base() . '/' . $stem;
                 $rep_image = 'uploads/grepimages/' . basename($rep_image);
                 while (file_exists($target_path)) {
                     $uniqid = uniqid('');
                     $stem = 'uploads/grepimages/' . $uniqid . '_' . basename(urldecode($rep_image));
                     $target_path = get_custom_file_base() . '/' . $stem;
                     $rep_image = 'uploads/grepimages/' . $uniqid . '_' . basename($rep_image);
                 }
                 $target_handle = fopen($target_path, 'wb') or intelligent_write_error($target_path);
                 $result = http_download_file($item['rep_image'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $target_handle);
                 fclose($target_handle);
             }
         }
         // Add news
         $ts = array_key_exists('clean_add_date', $item) ? $item['clean_add_date'] : (array_key_exists('add_date', $item) ? strtotime($item['add_date']) : time());
         if ($ts === false) {
             $ts = time();
         }
         // Seen in error email, it's if the add date won't parse by PHP
         $edit_date = array_key_exists('clean_edit_date', $item) ? $item['clean_edit_date'] : (array_key_exists('edit_date', $item) ? strtotime($item['edit_date']) : NULL);
         if ($edit_date === false) {
             $edit_date = NULL;
         }
         $news = array_key_exists('news', $item) ? html_to_comcode($item['news']) : '';
         $news_article = array_key_exists('news_article', $item) ? html_to_comcode($item['news_article']) : '';
         $news_id = add_news($item['title'], $news, array_key_exists('author', $item) ? $item['author'] : $GLOBALS['FORUM_DRIVER']->get_username(get_member()), $is_validated, 1, 1, 1, '', $news_article, $cat_id, $extra_categories, $ts, $submitter, 0, $edit_date, NULL, $rep_image);
         $rss->gleamed_items[$i]['import_id'] = $news_id;
         $rss->gleamed_items[$i]['import__news'] = $news;
         $rss->gleamed_items[$i]['import__news_article'] = $news_article;
     }
     foreach ($rss->gleamed_items as $i => $item) {
         $news = $item['import__news'];
         $news_article = $item['import__news_article'];
         $this->_grab_images_and_fix_links($download_images == 1, $news, $rss->gleamed_items);
         $this->_grab_images_and_fix_links($download_images == 1, $news_article, $rss->gleamed_items);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news', array('id' => $item['import_id'])), $news);
         lang_remap_comcode($GLOBALS['SITE_DB']->query_value('news', 'news_article', array('id' => $item['import_id'])), $news_article);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_NEWS')), array('_SELF:_SELF:import', do_lang_tempcode('IMPORT_NEWS'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     if (url_is_local($rss_url)) {
         // Means it is a temp file
         @unlink($rss_url);
     }
     return inform_screen($title, do_lang_tempcode('IMPORT_NEWS_DONE'));
 }
Beispiel #11
0
<?php

require_once 'dbproc.php';
if (is_ajax()) {
    if (isset($_POST["action"]) && !empty($_POST["action"])) {
        $action = $_POST["action"];
        switch ($action) {
            case "openNews":
                open_news($_POST["id"]);
                break;
            case "delNews":
                del_news($_POST["id"]);
                break;
            case "addNews":
                add_news();
                break;
        }
    }
}
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
function open_news($id)
{
    $news = DBProc::get_news_by_id($id);
    $tags = "";
    while (!empty($news["tags"])) {
        $tags = $tags . "#" . array_shift($news["tags"]);
    }
    $ret['new_content'] = '<div class="page-header">
Beispiel #12
0
<?php

include "admin/functions.php";
// Si l'url ".../index.php?page=" est vide, alors on redirige sur la bonne url.
if (empty($page)) {
    $page = 'index';
}
if (!empty($_GET)) {
    $page = htmlentities($_GET["p"]);
}
// --- AJOUT D'UNE NEWS
if (!empty($_POST) && isset($_POST["add_news"]) && $_POST["add_news"] == "1") {
    $message = addslashes($_POST["message"]);
    $dateMessage = $_POST["dateMessage"];
    $author = $_POST["author"];
    add_news($db, $message, $dateMessage, $author);
}
// --- SUPPRESSION D'UNE NEWS
if (!empty($_POST) && isset($_POST["delete_news"]) && $_POST["delete_news"] == "1") {
    $id = $_POST["id"];
    delete($db, $id, "news");
}
?>


<!DOCTYPE html>

<html lang="fr">

<head>
	<meta charset="utf-8">
<?php

include $_SERVER['DOCUMENT_ROOT'] . '/config.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/db.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/lib/session.php';
sec_session_start();
global $table_prefix;
global $dbh;
switch ($_POST['option']) {
    case 1:
        add_comment($dbh, $table_prefix);
        break;
    case 2:
        add_news($dbh, $table_prefix);
        break;
    case 3:
        remove_news($dbh, $table_prefix);
        break;
    case 4:
        send_message($dbh, $table_prefix);
        break;
    case 5:
        reply_message($dbh, $table_prefix);
        break;
    case 6:
        get_massage($dbh, $table_prefix);
        break;
}
function add_comment($dbh1, $table_prefix)
{
    if ($stmt = $dbh1->prepare("INSERT INTO  " . $table_prefix . "_comments (project_id, user_id, comment) VALUES (?, ?, ?)")) {
Beispiel #14
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     $fields = collapse_1d_complexity('id', $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('id'), array('c_name' => 'news')));
     $categories = $db->query("SELECT id,title,description,image FROM " . $table_prefix . "sections WHERE title='News'");
     foreach ($categories as $category) {
         $title = $category['title'];
         $cat_id = $GLOBALS['SITE_DB']->query_select('news_categories', array('id'), array('nc_title' => $title), '', 1);
         if (count($cat_id) == 0) {
             $cat_title = $category['title'];
             $category_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news_categories AS N ON T.id=N.nc_title AND " . db_string_equal_to('T.text_original', $cat_title));
             if (count($category_id) == 0) {
                 $desc = html_to_comcode($category['description']);
                 $id = add_news_category($category['title'], $category['image'], $desc, NULL, NULL);
             } else {
                 $id = $category_id[0]['id'];
             }
         } else {
             $id = $cat_id[0]['id'];
         }
         $rows = $db->query('SELECT * FROM ' . $table_prefix . 'content WHERE sectionid=' . strval($category['id']));
         foreach ($rows as $row) {
             $val = $row['title'];
             $news_id = $GLOBALS['SITE_DB']->query("SELECT N.id FROM " . $GLOBALS['SITE_DB']->get_table_prefix() . "translate  AS T INNER JOIN  " . $GLOBALS['SITE_DB']->get_table_prefix() . "news AS N ON T.id=N.title AND " . db_string_equal_to('T.text_original', $val) . " AND news_category=" . strval($id) . " AND news_category<>''");
             if (count($news_id) == 0) {
                 $title = $row['title'];
                 $news = html_to_comcode($row['introtext']);
                 $author = $db->query_value_null_ok('users', 'name', array('id' => $row['created_by']));
                 if (is_null($author)) {
                     $author = do_lang('UNKNOWN');
                 }
                 $access = $row['access'];
                 if ($access == 0) {
                     $validated = 1;
                 } else {
                     $validated = 0;
                 }
                 $allow_rating = 1;
                 $allow_comments = 1;
                 $allow_trackbacks = 1;
                 $notes = '';
                 $news_article = '';
                 $main_news_category = $id;
                 $news_category = NULL;
                 $datetimearr = explode(' ', $row['created']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $time = mktime($hour, $min, $sec, $month, $date, $year);
                 $submitter = import_id_remap_get('member', strval($row['created_by']));
                 $views = $row['hits'];
                 $datetimearr = explode(' ', $row['modified']);
                 $datearr = explode('-', $datetimearr[0]);
                 $timearr = explode(':', $datetimearr[1]);
                 $date = intval($datearr[2]);
                 $month = intval($datearr[1]);
                 $year = intval($datearr[0]);
                 $hour = intval($timearr[0]);
                 $min = intval($timearr[1]);
                 $sec = intval($timearr[2]);
                 $edit_date = mktime($hour, $min, $sec, $month, $date, $year);
                 $nid = NULL;
                 $image = 'newscats/' . preg_replace('#\\..*$#', '', $row['images']);
                 @mkdir(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 fix_permissions(get_custom_file_base() . '/themes/default/images_custom/newscats', 0777);
                 sync_file(get_custom_file_base() . '/themes/default/images_custom/newscats');
                 $newimagepath = get_custom_file_base() . '/themes/default/images_custom/newscats/' . rawurldecode($row['images']);
                 $oldimagepath = $old_base_dir . "/images/stories/" . rawurldecode($row['images']);
                 @copy($oldimagepath, $newimagepath);
                 fix_permissions($newimagepath);
                 sync_file($newimagepath);
                 add_news($title, $news, $author, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $news_article, $main_news_category, $news_category, $time, $submitter, $views, $edit_date, $nid, $image);
             }
         }
     }
 }
Beispiel #15
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     require_code('news2');
     // Can we comment the news?
     $rows = $db->query('SELECT articlecomm FROM ' . $table_prefix . 'config');
     $com = $rows[0]['articlecomm'];
     $forum_name = get_option('comments_forum_name');
     $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
     // Reviews (imports into 'technology')
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'reviews');
     foreach ($rows as $i => $row) {
         $rows[$i]['validated'] = 1;
     }
     $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_add');
     foreach ($rows2 as $i => $row) {
         $rows2[$i]['validated'] = 0;
         $rows2[$i]['hits'] = 0;
     }
     $rows = array_merge($rows, $rows2);
     foreach ($rows as $row) {
         $cat_id = $this->get_news_category_id(do_lang('NC_community'), 'community');
         $new_id = add_news($row['title'], $row['cover'] . chr(10) . $row['url'] . chr(10) . $row['score'], $row['reviewer'], $row['validated'], $com, 1, 1, '', html_to_comcode($row['text']), $cat_id, array(), $this->mysql_time_to_timestamp($row['date']), get_member(), $row['hits']);
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'reviews_comments WHERE rid=' . strval($row['id']) . ' ORDER BY date');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 $title = '';
                 $post = $comment['comment'];
                 $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, '[html]' . $post . '[/html]', $row['title'], do_lang('COMMENT'), $content_url->evaluate(), $this->mysql_time_to_timestamp($comment['date']));
             }
         }
     }
     // Journals (imports into community for author)
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'journal');
     foreach ($rows as $row) {
         $cat_id = $this->get_news_category_id(do_lang('JOURNAL_OF', $row['aid']), 'community');
         $new_id = add_news($row['title'], $row['cover'] . chr(10) . $row['mood'] . chr(10) . $row['status'], $row['aid'], 1, $com, 1, 1, '', html_to_comcode($row['bodytext']), $cat_id, array(), strtotime($row['pdate'] . ' ' . $row['ptime']), get_member());
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'journal_comments WHERE rid=' . $row['rid'] . ' ORDER BY date');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['aid']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 $title = '';
                 $post = $comment['comment'];
                 $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, '[html]' . $post . '[/html]', $row['title'], do_lang('COMMENT'), $content_url->evaluate(), $this->mysql_time_to_timestamp($comment['date']));
             }
         }
     }
     // Stories (creates categories). NB: Dunno what stories_cat's are, but topic's are the way to go
     $cats = $db->query('SELECT * FROM ' . $table_prefix . 'topics');
     $cat_id = array();
     foreach ($cats as $cat) {
         $image = $cat['topicimage'];
         $dot_pos = strrpos($image, '.');
         if ($dot_pos === false) {
             $dot_pos = strlen($image);
         }
         $image = substr($image, 0, $dot_pos);
         $cat_id[$cat['topicid']] = $this->get_news_category_id($cat['topictext'], $image);
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'stories');
     foreach ($rows as $i => $row) {
         $rows[$i]['validated'] = 1;
     }
     $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'autonews');
     foreach ($rows2 as $i => $row) {
         $rows2[$i]['validated'] = 0;
         $rows2[$i]['ratings'] = 0;
         $rows2[$i]['haspoll'] = 0;
     }
     $rows = array_merge($rows, $rows2);
     foreach ($rows as $row) {
         $append = '';
         if ($row['haspoll'] == 1) {
             $poll_rows = $db->query('SELECT pollTitle FROM ' . $table_prefix . 'poll_desc WHERE pollID=' . $row['pollID']);
             $poll_title = $poll_rows[0]['pollTitle'];
             $poll_id = $GLOBALS['SITE_DB']->query_value_null_ok('poll p LEFT JOIN ' . get_table_prefix() . 'translate t ON p.question=t.id', 'p.id', array('text_original' => $poll_title));
             if (is_null($poll_id)) {
                 $poll_id = 1;
             }
             // We couldn't find it (we should have imported polls first)
             $append = chr(10) . '[block="' . $poll_id . '"][/block]';
         }
         $topic = array_key_exists($row['topic'], $cat_id) ? $cat_id[$row['topic']] : db_get_first_id();
         $new_id = add_news($row['title'], $row['hometext'], $row['aid'], $row['validated'], $com, 1, 1, $row['notes'], html_to_comcode($row['bodytext']) . $append, $topic, array(), $this->mysql_time_to_timestamp($row['time']), get_member(), $row['counter']);
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'comments WHERE sid=' . $row['sid'] . ' ORDER BY date');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['name']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 $title = $comment['subject'];
                 $post = $comment['comment'];
                 $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, '[html]' . $post . '[/html]', $row['title'], do_lang('COMMENT'), $content_url->evaluate(), $this->mysql_time_to_timestamp($comment['date']));
             }
         }
         // Rating
         if ($row['ratings'] != 0) {
             $real_rating = $row['score'];
             // Same scale as ocPortal :)
             $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'news', 'rating_for_id' => strval($new_id), 'rating_member' => get_member(), 'rating_ip' => '127.0.0.1', 'rating_time' => time(), 'rating' => $real_rating));
         }
     }
 }
Beispiel #16
0
function check_news_page($pagename, $description, $new)
{
    $col = 'title';
    $table = 'news';
    if (!check_url($table, $col, $pagename)) {
        return "This page already exists in Latest News";
    } else {
        return add_news($pagename, $description, $new);
    }
}
Beispiel #17
0
    if ($image) {
        $info = new SplFileInfo($image['name']);
        $image_id = add_image(array('name' => $image['name'], 'type' => $info->getExtension()));
        if ($image_id) {
            $uploads_dir = '../img/news-img/';
            $uploadfile = $uploads_dir . basename($image_id) . '.' . $info->getExtension();
            move_uploaded_file($image['tmp_name'], $uploadfile);
        }
    }
    $data['date_create'] = date('Y-m-d', time());
    $data['image_id'] = $image_id;
    $article_id = add_article($data);
    unset($data);
    $data['article_id'] = $article_id;
    $data['title'] = $_POST['title'];
    $data['addedby'] = $_POST['name'];
    $data['full_text'] = $_POST['article'];
    $lang_id = '';
    $lang = get_lang();
    $langradio = $_POST['languages'];
    foreach ($lang as $lk => $lv) {
        if ($lv['lang'] == $langradio) {
            $lang_id = $lv['id'];
        }
    }
    if ($lang_id) {
        $data['lang_id'] = $lang_id;
    }
    add_news($data);
}
require_once 'templates/add_news.template.php';
Beispiel #18
0
            if (update_news(['user' => $user_id, 'cat' => $cat, 'title' => $title, 'title_short' => $title_short, 'youtube' => $youtube, 'chpu' => $chpu, 'meta_desc' => $meta_desc, 'meta_key' => $meta_key, 'color' => $color, 'info' => $info, 'test' => $victorina, 'date' => $date, 'time' => $tm, 'style' => $style, 'text_short' => $text_short, 'text' => $text, 'phg' => $phg, 'sponsored' => $sponsored, 'copy' => $copy, 'slide' => $slide, 'slide_type' => $slide_type, 'thumbs' => $totalpath, 'img' => $read_sql, 'fb' => $fb_sql], $id)) {
                $response['photop'] = !empty($totalpath) ? $totalpath : '';
                $response['desimg'] = !empty($read_sql) ? $read_sql : '';
                $response['facebook'] = !empty($fb_sql) ? $fb_sql : '';
                $response['slide'] = json_encode(unserialize(base64_decode($slide)));
                $response['body'] = stripslashes($text);
                echo json_encode($response);
            }
        }
        if ($_POST['add'] == 1) {
            if (!empty($title) && !empty($cat)) {
                $test_chpu = $DB->getOne("SELECT count(#__news.id) FROM `#__news` WHERE `chpu`='{$chpu}'");
                if ($test_chpu > 0) {
                    $chpu = rand(100, 9999) . '_' . $chpu;
                }
                $result = add_news(['user' => $user_id, 'cat' => $cat, 'title' => $title, 'chpu' => $chpu, 'title_short' => $title_short, 'youtube' => $youtube, 'info' => $info, 'date' => $date, 'time' => $tm, 'slide' => $slide, 'slide_type' => $slide_type, 'text_short' => $text_short, 'text' => $text, 'phg' => $phg, 'sponsored' => $sponsored, 'copy' => $copy, 'moderate' => 2]);
                if ($result > 0) {
                    $response['body'] = stripslashes($text);
                    $response['id'] = $result;
                    echo json_encode($response);
                }
            } else {
                echo 1;
            }
        }
    } else {
        //$response['ajerror'] = "Facebook ფოტოს ზომა: 470x247";
        echo 0;
    }
}
if ($_POST['action'] == 'get_images_from_dir') {
Beispiel #19
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     require_code('galleries2');
     //check is the comment forum configured in ocPortal
     $this->test_for_comments_forum();
     // Can we comment the news?
     $com = 1;
     $forum_name = get_option('comments_forum_name');
     ocf_over_msn();
     //used to fixed the correct forum prefix
     $forum_id = $GLOBALS['FORUM_DRIVER']->forum_id_from_name($forum_name);
     ocf_over_local();
     //used to fixed the correct forum prefix
     /* old import reviews code, as part of the news. NOTE: now they are imported as catalogues entries
     		// Reviews (imports into 'community')
     		$rows=$db->query('SELECT r.id AS review_id, r.title AS review_title, r.description AS review_description, r.field1 AS rf1, r.field2 AS rf2, r.field3 AS rf3, r.field4 AS rf4, r.field5 AS rf5, r.field6 AS rf6, r.field7 AS rf7, r.*, rc.title AS rc_title, rc.description AS rc_description, rc.field1 AS rcf1, rc.field2 AS rcf2, rc.field3 AS rcf3, rc.field4 AS rcf4, rc.field5 AS rcf5, rc.field6 AS rcf6, rc.field7 AS rcf7, rc.* FROM '.$table_prefix.'reviews r LEFT JOIN '.$table_prefix.'reviews_sections rc ON r.id_cat=rc.id');
     
     		foreach ($rows as $row)
     		{
     			$cat_id=$this->get_news_category_id($row['review_title'],'community');
     			$review_description=$row['review_description'];
     			for ($i=1;$i<=7;$i++)
     			{
     				if (strlen($row[strval('rcf'.$i)])>0)
     				{
     					$review_description.=chr(10).$row[strval('rcf'.$i)].': '.$row[strval('rf'.$i)];
     				}
     			}
     			$review_description.=chr(10).'Views: '.strval(intval($row['click']));
     
     			ocf_over_msn(); //used to fixed the correct forum prefix
     			$new_id=add_news($row['review_title'],html_to_comcode($review_description),$row['idauth'],$row['validate'],$com,1,1,'',html_to_comcode($row['review']),$cat_id,array(),$row['date'],get_member(),$row['click']);
     			ocf_over_local(); //used to fixed the correct forum prefix
     
     
     			// Comments
     			$comments=$db->query('SELECT * FROM '.$table_prefix.'reviews_comments WHERE id='.strval($row['review_id']).' ORDER BY data');
     			if (!is_null($forum_id))
     			{
     				foreach ($comments as $comment)
     				{
     					$member=$comment['id_autore']; //$GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['userid']);
     
     					ocf_over_msn(); //used to fixed the correct forum prefix
     					if (is_null($member)) $member=$GLOBALS['FORUM_DRIVER']->get_guest_id();
     					ocf_over_local(); //used to fixed the correct forum prefix
     
     					$title='';
     					$post=$comment['testo'];
     					$content_url=build_url(array('page'=>'news','id'=>$new_id,'type'=>'view'),get_module_zone('news'));
     
     					ocf_over_msn(); //used to fixed the correct forum prefix
     					$GLOBALS['FORUM_DRIVER']->make_post_forum_topic(
     						$forum_name,
     						'news_'.strval($new_id),
     						$member,
     						$title,
     						html_to_comcode($post),
     						$row['title'],
     						do_lang('COMMENT'),
     						$content_url->evaluate()
     					);
     					ocf_over_local(); //used to fixed the correct forum prefix
     				}
     			}
     		} end of old import reviews code */
     // Blogs (imports into community for author)
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'blog');
     foreach ($rows as $row) {
         $blog_cat_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $row['creato']));
         $row['titolo'] = @html_entity_decode($row['titolo'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['autore']);
         if (is_null($submitting_member_id)) {
             $submitting_member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         ocf_over_local();
         //used to fixed the correct forum prefix
         if (is_null($blog_cat_id)) {
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $p_nc_title = insert_lang($row['titolo'], 2);
             ocf_over_local();
             //used to fixed the correct forum prefix
             $blog_cat_id = $GLOBALS['SITE_DB']->query_insert('news_categories', array('nc_title' => $p_nc_title, 'nc_img' => 'newscats/community', 'notes' => '', 'nc_owner' => $submitting_member_id), true);
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
             ocf_over_local();
             //used to fixed the correct forum prefix
             foreach (array_keys($groups) as $group_id) {
                 $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'news', 'category_name' => strval($blog_cat_id), 'group_id' => $group_id));
             }
         }
         // Blog description goes to first post in blog
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['descrizione']), $blog_cat_id, array(), $row['creato'], $submitting_member_id);
         ocf_over_local();
         //used to fixed the correct forum prefix
         $blog_posts = $db->query('SELECT * FROM ' . $table_prefix . 'blog_post WHERE id_blog=' . strval($row['id']));
         foreach ($blog_posts as $blog_post) {
             if (import_check_if_imported('blog_post', strval($blog_post['id']))) {
                 continue;
             }
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($blog_post['post']), $blog_cat_id, array(), $blog_post['data'], $submitting_member_id);
             ocf_over_local();
             //used to fixed the correct forum prefix
             import_id_remap_put('blog_post', strval($blog_post['id']), $new_id);
             //import blog rating too
             $this->_import_ratings($db, 'news', $row['id'], $new_id, $row['rate'], $table_prefix);
             // Comments
             $comments = $db->query('SELECT * FROM ' . $table_prefix . 'blog_commenti WHERE id_blog=' . strval($blog_post['id']) . ' ORDER BY data');
             if (!is_null($forum_id)) {
                 foreach ($comments as $comment) {
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                     if (is_null($member)) {
                         $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                     }
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                     $title = '';
                     $post = $comment['commento'];
                     $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, html_to_comcode($post), $row['titolo'], do_lang('COMMENT'), $content_url->evaluate());
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                 }
             }
         }
         //import blog images in personal galleries or in synch onces
         if (addon_installed('galleries')) {
             $blog_pimages = $db->query('SELECT * FROM ' . $table_prefix . 'blog_pimages WHERE iduser='******'SITE_DB']->query_value_null_ok('galleries', 'name', array('is_member_synched' => 1));
                 $root_gallery = is_null($pcc_gallery) ? 'root' : $pcc_gallery;
                 $ocp_path = get_custom_file_base();
                 //copy watermark image, to insure it is copied
                 $save_filename = $old_base_dir . 'mkportal/modules/gallery/wt.png';
                 //NOTE: this is the default watermark image in MKPortal, if customer needs to use another image, he/she needs to overwite it
                 $watermark_image = '';
                 if (file_exists($save_filename)) {
                     $copy_destination = $ocp_path . '/uploads/watermarks/wt.png';
                     @copy($save_filename, $copy_destination);
                     fix_permissions($copy_destination);
                     sync_file($copy_destination);
                     $watermark_image = get_custom_base_url() . '/uploads/watermarks/wt.png';
                 }
                 //now we need to get MKPortal settings for the watermark images
                 $conf_rows = $db->query('SELECT * FROM ' . $table_prefix . 'config WHERE ' . db_string_equal_to('chiave', 'watermark_pos') . ' OR ' . db_string_equal_to('chiave', 'watermark_enable'));
                 $watermark_pos = 2;
                 //Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal)
                 $watermark_enable = 0;
                 //by default it is disabled
                 foreach ($conf_rows as $conf_row) {
                     if (isset($conf_row['chiave']) && $conf_row['chiave'] == 'watermark_pos') {
                         $watermark_pos = $conf_row['valore'];
                         if ($watermark_pos == 1) {
                             $watermark_pos = 2;
                             //ocPortal doesn't have watermark center position, so we will use the mkPortal default position: Bottom-right
                         }
                         continue;
                     }
                     if (isset($conf_row['chiave']) && $conf_row['chiave'] == 'watermark_enable') {
                         $watermark_enable = $conf_row['valore'];
                         continue;
                     }
                 }
                 //add blog gallery if not added
                 $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['autore'] . '_blog'));
                 if (is_null($test)) {
                     $rep_image = '';
                     //set default values for the watermark positions
                     $watermark_top_left = '';
                     $watermark_top_right = '';
                     $watermark_bottom_left = '';
                     $watermark_bottom_right = '';
                     if ($watermark_enable == 1 && strlen($watermark_image) > 0 && file_exists($watermark_image)) {
                         //$watermark_pos=2; //Possible values: 0 - Top-right; 1 - Center; 2 - Bottom-right (default for MKPortal)
                         if ($watermark_pos == 2) {
                             $watermark_top_right = $watermark_image;
                         } else {
                             $watermark_bottom_right = $watermark_image;
                         }
                     }
                     $add_date = $row['creato'];
                     ocf_over_msn();
                     add_gallery($row['autore'] . '_blog', $row['titolo'], html_to_comcode($row['descrizione']), '', '', $root_gallery, 1, 0, 0, 0, $rep_image, $watermark_top_left, $watermark_top_right, $watermark_bottom_left, $watermark_bottom_right, 1, 1, false, $add_date);
                     ocf_over_local();
                 }
                 $gal_idname = $row['autore'] . '_blog';
                 foreach ($blog_pimages as $blog_pimage) {
                     if (import_check_if_imported('blog_image', strval($blog_pimage['id']))) {
                         continue;
                     }
                     $submitter = $blog_pimage['iduser'];
                     ocf_over_msn();
                     //used to fixed the correct forum prefix
                     if (is_null($submitter)) {
                         $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                     }
                     ocf_over_local();
                     //used to fixed the correct forum prefix
                     $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $blog_pimage['id'];
                     $cat_name = $row['autore'] . '_blog';
                     ocf_over_msn();
                     $comment_text = $row['titolo'] . ' ' . html_to_comcode($row['descrizione']);
                     ocf_over_local();
                     //copy image and thumbnail and apply urls
                     $url = '';
                     $thumb_url = '';
                     //image source and destination
                     $save_filename = $old_base_dir . '/mkportal/blog/images/' . strval($blog_pimage['file']);
                     $copy_destination = $ocp_path . '/uploads/galleries/' . $blog_pimage['file'];
                     copy($save_filename, $copy_destination);
                     fix_permissions($copy_destination);
                     sync_file($copy_destination);
                     $url = get_custom_base_url() . '/uploads/galleries/' . $blog_pimage['file'];
                     $thumb_url = '';
                     $id_new = add_image('', $cat_name, $comment_text, $url, $url, $row['validate'], 1, 1, 1, '', $submitter, $row['creato'], $row['creato'], $row['click'], $id);
                     import_id_remap_put('blog_image', strval($blog_pimage['id']), $id_new);
                 }
             }
         }
         //end import blog images
     }
     //end blog import
     // Stories categories, story items, and comments
     $cats = $db->query('SELECT * FROM ' . $table_prefix . 'news_sections');
     $cat_id = array();
     $image = 'general';
     foreach ($cats as $cat) {
         $cat_id[$cat['id']] = $this->get_news_category_id($cat['titolo'], $image);
     }
     $pinned_news_cat_id = $this->get_news_category_id(do_lang('PINNED_NEWS'), $image);
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news');
     foreach ($rows as $row) {
         if (import_check_if_imported('news', strval($row['id']))) {
             continue;
         }
         $topic = array_key_exists($row['idcategoria'], $cat_id) ? $cat_id[$row['idcategoria']] : db_get_first_id();
         $row['titolo'] = @html_entity_decode($row['titolo'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         if ($row['pinned'] == 1) {
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['testo']), $topic, array($pinned_news_cat_id), $row['data'], $row['idautore']);
         } else {
             $new_id = add_news($row['titolo'], '', $row['autore'], $row['validate'], 1, $com, 1, '', html_to_comcode($row['testo']), $topic, array(), $row['data'], $row['idautore']);
         }
         ocf_over_local();
         //used to fixed the correct forum prefix
         import_id_remap_put('news', strval($row['id']), $new_id);
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'news_comments WHERE identry=' . strval($row['id']) . ' ORDER BY data');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 ocf_over_local();
                 //used to fixed the correct forum prefix
                 $title = '';
                 $post = $comment['testo'];
                 $content_url = build_url(array('page' => 'news', 'id' => $new_id, 'type' => 'view'), get_module_zone('news'));
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'news_' . strval($new_id), $member, $title, html_to_comcode($post), $row['titolo'], do_lang('COMMENT'), $content_url->evaluate());
                 ocf_over_local();
                 //used to fixed the correct forum prefix
             }
         }
     }
 }
Beispiel #20
0
 }
 $sco = round($d_scorpions2 - $d_scorpions);
 if ($sco < 0) {
     $sco = 0;
 }
 $cob = round($d_cobras2 - $d_cobras);
 if ($cob < 0) {
     $cob = 0;
 }
 if ($salvm < 0) {
     $salvm = 0;
 }
 if ($salvc < 0) {
     $salvc = 0;
 }
 add_news("Combat report", "<table border=\"1\" bordercolor=\"black\"><td>Defender(s) ({$nick} #{$id}):</td><td>Total:</td><td>Lost:</td><tr>\n\n<td>Soldiers:</td><td>{$d_infinitys2}</td><td>" . number_format($d_infinitys2 - $d_infinitys, 0) . "<tr>\n\n<td>Navy seal:</td><td>{$d_wraiths2}</td><td>" . number_format($d_wraiths2 - $d_wraiths, 0) . "<tr>\n\n<td>Warfrigates:</td><td>{$d_warfrigs2}</td><td>" . number_format($d_warfrigs2 - $d_warfrigs, 0) . "<tr>\n\n<td>Destroyers:</td><td>{$d_destroyers2}</td><td>" . number_format($d_destroyers2 - $d_destroyers, 0) . "<tr>\n\n<td>Anti thiefs:</td><td>{$d_cobras2}</td><td>" . number_format($d_cobras2 - $d_cobras, 0) . "<tr>\n\n<td>Thiefs:</td><td>{$d_astropods2}</td><td>" . number_format($d_astropods2 - $d_astropods, 0) . "<tr>\n\n<td>Scorpion:</td><td>{$d_scorpions2}</td><td>" . number_format($d_scorpions2 - $d_scorpions, 0) . "<tr>\n\n<td>Attacker(s):</td><tr>\n\n<td>Soldiers:</td><td>{$infinitys2}</td><td>" . number_format($infinitys2 - $infinitys, 0) . "<tr>\n\n<td>Navy seals:</td><td>{$wraiths2}</td><td>" . number_format($wraiths2 - $wraiths, 0) . "<tr>\n\n<td>Warfrigates:</td><td>{$warfrigs2}</td><td>" . number_format($warfrigs2 - $warfrigs, 0) . "<tr>\n\n<td>Destroyers:</td><td>{$destroyers2}</td><td>" . number_format($destroyers2 - $destroyers, 0) . "<tr>\n\n<td>Thiefs:</td><td>{$astropods2} ({$t_block} blocked)</td><td>" . number_format($astropods2 - $astropods, 0) . "<tr>\n\n<td>Scorpion:</td><td>{$scorpions2}</td><td>" . number_format($scorpions2 - $scorpions, 0) . "<tr>\n\n<td>Yours:</td><tr>\n\n<td>Soldiers:</td><td>" . $defend[$i]["infinitys"] . "</td><td>{$l_infinitys}<tr>\n\n<td>Navy seals:</td><td>" . $defend[$i]["wraiths"] . "</td><td>{$l_wraiths}<tr>\n\n<td>Warfrigates:</td><td>" . $defend[$i]["warfrigs"] . "</td><td>{$l_warfrigs}<tr>\n\n<td>Destroyers:</td><td>" . $defend[$i]["destroyers"] . "</td><td>{$l_destroyers}<tr>\n\n<td>Anti thief:</td><td>" . $defend[$i]["cobras"] . "</td><td>{$l_cobras}<tr>\n\n<td>Thiefs:</td><td>" . $defend[$i]["astropods"] . "</td><td>{$l_astropods}<tr>\n\n<td>Scorpion:</td><td>" . $defend[$i]["scorpions"] . "</td><td>{$l_scorpions}<tr>\n\n<td>Light cannons:</td><td>{$d_rcannons2}</td><td>" . number_format($d_rcannons2 - $d_rcannons, 0) . "<tr>\n\n<td>Advanced cannons:</td><td>{$d_avengers2}</td><td>" . number_format($d_avengers2 - $d_avengers, 0) . "<tr>\n\n<td>Hyper cannons:</td><td>{$d_lstalkers2}</td><td>" . number_format($d_lstalkers2 - $d_lstalkers, 0) . "<tr>\n\n<tr>\n<td>Silver salvage:</td><td>{$salvm}</td><tr>\n<td>Gold salvage:</td><td>{$salvc}</td><tr>\n<td>Roids loss:</td><tr>\n<td>Silver roids:</td><td>" . ($d_metalroid2 - $d_metalroid) . "/{$d_metalroid}</td><tr>\n<td>Gold roids:</td><td>" . ($d_crystalroid2 - $d_crystalroid) . "/{$d_crystalroid}</td><tr>\n<td>Undeveloped:</td><td>" . ($d_ui_roids2 - $d_ui_roids) . "/{$d_ui_roids}</td><tr>\n</table>\n\n", $defend[$i]["id"]);
 /* $result3 = mysql_query("UPDATE ".$PA["table"]." SET infinitys=infinitys-$l_infinitys,wraiths=wraiths-$l_wraiths,warfrigs=warfrigs-$l_warfrigs,destroyers=destroyers-$l_destroyers,astropods=astropods-$l_astropods,scorpions=scorpions-$l_scorpions,cobras=cobras-$l_cobras,rcannons=rcannons-$l_rcannons,avengers=avengers-$l_avengers,lstalkers=lstalkers-$l_lstalkers,crystal=crystal+$salvc,metal=metal+$salvm WHERE id=".$defend[$i]["id"],$db);  dbr(mysql_error());
 
 $result3 = mysql_query("UPDATE ".$PA["table"]." SET infinitys=infinitys-$inf,wraiths=wraiths-$wra,warfrigs=warfrigs-$war,destroyers=destroyers-$des,astropods=astropods-$ast,scorpions=scorpions-$sco,cobras=cobras-$cob,rcannons=rcannons-$l_rcannons,avengers=avengers-$l_avengers,lstalkers=lstalkers-$l_lstalkers,crystal=crystal+$salvc,metal=metal+$salvm WHERE id=".$defend[$i]["id"],$db);  dbr(mysql_error());*/
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET infinitys=infinitys-{$l_infinitys},wraiths=wraiths-{$l_wraiths},warfrigs=warfrigs-{$l_warfrigs},destroyers=destroyers-{$l_destroyers},astropods=astropods-{$l_astropods},scorpions=scorpions-{$l_scorpions},cobras=cobras-{$l_cobras},crystal=crystal+{$salvc},metal=metal+{$salvm} WHERE id=" . $defend[$i]["id"], $db);
 dbr(mysql_error());
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET infinitys_base=infinitys_base-{$inf},wraiths_base=wraiths_base-{$wra},warfrigs_base=warfrigs_base-{$war},destroyers_base=destroyers_base-{$des},astropods_base=astropods_base-{$ast},scorpions_base=scorpions_base-{$sco} WHERE id=" . $defend[0]["id"], $db);
 dbr(mysql_error());
 /*$result3 = mysql_query("UPDATE ".$PA["table"]." SET infinitys_base=infinitys_base-$l_infinitys,wraiths_base=wraiths_base-$l_wraiths,warfrigs_base=warfrigs_base-$l_warfrigs,destroyers_base=destroyers_base-$l_destroyers,astropods_base=astropods_base-$l_astropods,scorpions_base=scorpions-$l_scorpions WHERE id=".$defend[$i]["id"],$db);  dbr(mysql_error());*/
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET infinitys_base=0 where infinitys_base < 0 AND id=" . $defend[$i]["id"], $db);
 dbr(mysql_error());
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET cobras=0 where cobras < 0 AND id=" . $defend[$i]["id"], $db);
 dbr(mysql_error());
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET wraiths=0 where wraiths < 0 AND id=" . $defend[$i]["id"], $db);
 dbr(mysql_error());
 $result3 = mysql_query("UPDATE " . $PA["table"] . " SET wraiths_base=0 where wraiths_base < 0 AND id=" . $defend[$i]["id"], $db);
Beispiel #21
0
/**
 * Import wordpress db
 */
function import_wordpress_db()
{
    disable_php_memory_limit();
    $data = get_wordpress_data();
    $is_validated = post_param_integer('wp_auto_validate', 0);
    $to_own_account = post_param_integer('wp_add_to_own', 0);
    // Create members
    require_code('ocf_members_action');
    require_code('ocf_groups');
    $def_grp_id = get_first_default_group();
    $cat_id = array();
    $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'), array('nc_owner' => NULL));
    $NEWS_CATS = list_to_map('id', $NEWS_CATS);
    foreach ($data as $values) {
        if (get_forum_type() == 'ocf') {
            $member_id = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $values['user_login']));
            if (is_null($member_id)) {
                if (post_param_integer('wp_import_wordpress_users', 0) == 1) {
                    $member_id = ocf_make_member($values['user_login'], $values['user_pass'], '', NULL, NULL, NULL, NULL, array(), NULL, $def_grp_id, 1, time(), time(), '', NULL, '', 0, 0, 1, '', '', '', 1, 0, '', 1, 1, '', NULL, '', false, 'wordpress');
                } else {
                    $member_id = $GLOBALS['FORUM_DRIVER']->get_member_from_username('admin');
                    // Set admin as owner
                    if (is_null($member_id)) {
                        $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id() + 1;
                    }
                }
            }
        } else {
            $member_id = $GLOBALS['FORUM_DRIVER']->get_guest_id();
        }
        // Guest user
        // If post should go to own account
        if ($to_own_account == 1) {
            $member_id = get_member();
        }
        if (array_key_exists('POSTS', $values)) {
            // Create posts in blog
            foreach ($values['POSTS'] as $post_id => $post) {
                if (array_key_exists('category', $post)) {
                    $cat_id = array();
                    foreach ($post['category'] as $cat_code => $category) {
                        $cat_code = NULL;
                        if ($category == 'Uncategorized') {
                            continue;
                        }
                        // Skip blank category creation
                        foreach ($NEWS_CATS as $id => $existing_cat) {
                            if (get_translated_text($existing_cat['nc_title']) == $category) {
                                $cat_code = $id;
                            }
                        }
                        if (is_null($cat_code)) {
                            $cat_code = add_news_category($category, 'newscats/community', $category);
                            $NEWS_CATS = $GLOBALS['SITE_DB']->query_select('news_categories', array('*'));
                            $NEWS_CATS = list_to_map('id', $NEWS_CATS);
                        }
                        $cat_id = array_merge($cat_id, array($cat_code));
                    }
                }
                $owner_category_id = $GLOBALS['SITE_DB']->query_value_null_ok('news_categories', 'id', array('nc_owner' => $member_id));
                if ($post['post_type'] == 'post') {
                    $id = add_news($post['post_title'], html_to_comcode($post['post_content']), NULL, $is_validated, 1, $post['comment_status'] == 'closed' ? 0 : 1, 1, '', html_to_comcode($post['post_content']), $owner_category_id, $cat_id, NULL, $member_id, 0, time(), NULL, '');
                } elseif ($post['post_type'] == 'page') {
                    // If dont have permission to write comcode page, skip the post
                    if (!has_submit_permission('high', get_member(), get_ip_address(), NULL, NULL)) {
                        continue;
                    }
                    require_code('comcode');
                    // Save articles as new comcode pages
                    $zone = filter_naughty(post_param('zone', 'site'));
                    $lang = filter_naughty(post_param('lang', 'EN'));
                    $file = preg_replace('/[^A-Za-z0-9]/', '_', $post['post_title']);
                    // Filter non alphanumeric charactors
                    $parent_page = post_param('parent_page', '');
                    $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
                    // Check existancy of new page
                    $submiter = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
                    if (!is_null($submiter)) {
                        continue;
                    }
                    // Skip existing titled articles	- may need change
                    require_code('submit');
                    give_submit_points('COMCODE_PAGE_ADD');
                    if (!addon_installed('unvalidated')) {
                        $is_validated = 1;
                    }
                    $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $is_validated, 'p_edit_date' => NULL, 'p_add_date' => strtotime($post['post_date']), 'p_submitter' => $member_id, 'p_show_as_edit' => 0));
                    if (!file_exists($fullpath)) {
                        $_content = html_to_comcode($post['post_content']);
                        $myfile = @fopen($fullpath, 'wt');
                        if ($myfile === false) {
                            intelligent_write_error($fullpath);
                        }
                        if (fwrite($myfile, $_content) < strlen($_content)) {
                            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                        }
                        fclose($myfile);
                        sync_file($fullpath);
                    }
                    require_code('seo2');
                    seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, post_param('meta_keywords', ''), post_param('meta_description', ''));
                    require_code('permissions2');
                    set_page_permissions_from_environment($zone, $file);
                }
                $content_url = build_url(array('page' => 'news', 'type' => 'view', 'id' => $id), get_module_zone('news'), NULL, false, false, true);
                $content_title = $post['post_title'];
                // Add comments
                if (post_param_integer('wp_import_blog_comments', 0) == 1) {
                    if (array_key_exists('COMMENTS', $post)) {
                        $submitter = NULL;
                        foreach ($post['COMMENTS'] as $comment) {
                            $submitter = $GLOBALS['FORUM_DB']->query_value_null_ok('f_members', 'id', array('m_username' => $comment['comment_author']));
                            if (is_null($submitter)) {
                                $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                            }
                            // If comment is made by a non-member, assign comment to guest account
                            $forum = is_null(get_value('comment_forum__news')) ? get_option('comments_forum_name') : get_value('comment_forum__news');
                            $result = $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum, 'news_' . strval($id), $submitter, $post['post_title'], $comment['comment_content'], $content_title, do_lang('COMMENT'), $content_url, NULL, NULL, 1, 1, false);
                        }
                    }
                }
            }
        }
    }
}
Beispiel #22
0
 /**
  * Standard import function.
  *
  * @param  object			The DB connection to import from
  * @param  string			The table prefix the target prefix is using
  * @param  PATH			The base directory we are importing from
  */
 function import_news_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('news');
     $com = 0;
     // we cannot comment the news
     //get AEF news
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'news');
     foreach ($rows as $row) {
         $author_data = $db->query('SELECT username FROM ' . $table_prefix . 'users WHERE id=' . strval($row['uid']));
         $author_name = isset($author_data[0]['username']) && $author_data[0]['username'] != '' ? $author_data[0]['username'] : '';
         $append = '';
         $topic = db_get_first_id();
         //there is no news topic/category specified in AEF
         ocf_over_msn();
         //set the proper forum driver FORUM_DB
         $news = html_to_comcode($row['news']) . $append;
         ocf_over_local();
         //return the OCF FORUM_DB
         $new_id = add_news($row['title'], $row['news'], $author_name, $row['approved'], $com, 1, 1, 'Full story: ' . $row['fullstorylink'], $news, $topic, array(), $row['time'], get_member(), 0, NULL, NULL, $row['image']);
     }
 }
Beispiel #23
0
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             echo manage($pdo);
         }
     }
     break;
 case 'add_source':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             echo add_source();
         }
     }
     break;
 case 'add_news':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             echo add_news($pdo);
         }
     }
     break;
 case 'save_source':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             save_source($pdo);
         }
     }
     break;
 case 'edit_source':
     if (isset($_SESSION['login']) && isset($_SESSION['permission']) && $_SESSION['permission'] == 'admin' && validRequest()) {
         if (isset($_GET['token']) && $_GET['token'] == $_SESSION['token']) {
             echo edit_source($pdo);
         }
$offset = getvalescaped("offset", 0);
$findtext = getvalescaped("findtext", "");
$date = getval("date", date("Y-m-d H:i:s"));
$title = getvalescaped("title", 0);
$body = getvalescaped("body", 0);
# get ref value from database, unless it is set to new
if (getval("ref", "") == "new") {
    $createnews = true;
} else {
    $news = get_news($ref, "", "");
    $createnews = false;
}
if (getval("save", "") != "") {
    # Save news
    if ($createnews) {
        add_news($date, $title, $body);
    } else {
        update_news($ref, $date, $title, $body);
    }
    redirect("plugins/news/pages/news_edit.php?findtext=" . $findtext . "&offset=" . $offset);
}
# Fetch news data
$news = get_news($ref, "", "");
include dirname(__FILE__) . "/../../../include/header.php";
?>

<p><a href="news_edit.php?offset=<?php 
echo $offset;
?>
&findtext=<?php 
echo $findtext;
$ref=getvalescaped("ref","",true);
$offset=getvalescaped("offset",0);
$findtext=getvalescaped("findtext","");

$date=getval("date",date("Y-m-d H:i:s"));
$title=getvalescaped("title",0);
$body=getvalescaped("body",0);

# get ref value from database, unless it is set to new 
if (getval("ref","")=="new"){$createnews=true;} else {$news=get_news($ref,"",""); $createnews=false;}


if (getval("save","")!="")
	{
	# Save news
	If ($createnews) {add_news($date,$title,$body);}
	else {update_news($ref,$date,$title,$body);}
	header("location:".$baseurl."/plugins/news/pages/news_edit.php?findtext=".$findtext."&offset=".$offset);
	}
	
# Fetch news data
$news=get_news($ref,"","");
include dirname(__FILE__)."/../../../include/header.php";
?>

<p><a href="news_edit.php?offset=<?php echo $offset?>&findtext=<?php echo $findtext?>">&lt; <?php echo $lang["news_manage"]?></a></p>

<div class="BasicsBox">
<h1><?php echo $lang["news_edit"]?></h1>

<form method=post id="mainform">