示例#1
0
 function setUp()
 {
     parent::setUp();
     require_code('downloads');
     require_code('downloads2');
     $this->dwn_id = add_download(db_get_first_id(), '111', 'http://www.google.com', 'Testing download', 'sujith', '', 0, 1, 1, 1, 0, '', 'apple.jpeg', 110, 0, 0, NULL, NULL, 0, 0, NULL, NULL, NULL);
     $this->assertTrue('http://www.google.com' == $GLOBALS['SITE_DB']->query_value('download_downloads', 'url', array('id' => $this->dwn_id)));
 }
示例#2
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_downloads_and_categories($db, $table_prefix, $file_base)
 {
     require_code('downloads2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_categories ORDER BY id', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         if (import_check_if_imported('download_category', strval($row['id']))) {
             continue;
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id = add_download_category($this->get_lang_string($db, $row['category']), -$row['parent_id'], $this->get_lang_string($db, $row['description']), $row['notes'], $row['rep_image'], $id);
         import_id_remap_put('download_category', strval($row['id']), $id);
     }
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'download_category', 'download_category');
     foreach ($rows as $row) {
         $id = import_id_remap_get('download_category', strval($row['id']));
         $parent_id = import_id_remap_get('download_category', $row['parent_id'], true);
         if (is_null($parent_id)) {
             $parent_id = db_get_first_id();
         }
         $GLOBALS['SITE_DB']->query_update('download_categories', array('parent_id' => $parent_id), array('id' => $id), '', 1);
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_downloads ORDER BY id');
     $on_same_msn = $this->on_same_msn($file_base);
     foreach ($rows as $row) {
         if (import_check_if_imported('download', strval($row['id']))) {
             continue;
         }
         $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();
         }
         $category_id = import_id_remap_get('download_category', strval($row['category_id']), true);
         if (is_null($category_id)) {
             $category_id = db_get_first_id();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = add_download($category_id, $this->get_lang_string($db, $row['name']), $row['url'], $this->get_lang_string($db, $row['description']), $row['author'], $this->get_lang_string($db, $row['comments']), NULL, $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $row['original_filename'], $row['file_size'], $row['download_cost'], $row['download_submitter_gets_points'], array_key_exists('download_licence', $row) ? $row['download_licence'] : NULL, $row['add_date'], $row['num_downloads'], $row['download_views'], $submitter, $row['edit_date'], $id);
         import_id_remap_put('download', strval($row['id']), $id_new);
     }
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'download', 'download');
     $this->_import_review_supplement($db, $table_prefix, 'downloads', 'download');
     foreach ($rows as $row) {
         if (!is_null($row['out_mode_id'])) {
             $out_mode_id = import_id_remap_get('download', $row['out_mode_id'], true);
             if (is_null($out_mode_id)) {
                 $out_mode_id = NULL;
             }
             $id_new = import_id_remap_get('download', strval($row['id']), true);
             if (is_null($id_new)) {
                 continue;
             }
             $GLOBALS['SITE_DB']->query_update('download_downloads', array('out_mode_id' => $out_mode_id), array('id' => $id_new), '', 1);
         }
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_logging');
     foreach ($rows as $row) {
         $id = import_id_remap_get('download', $row['id'], true);
         if (is_null($id)) {
             continue;
         }
         $user = $on_same_msn ? $row['the_user'] : import_id_remap_get('member', $row['the_user'], true);
         if (is_null($user)) {
             $user = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('download_logging', 'ip', array('id' => $id, 'the_user' => $user));
         if (is_null($test)) {
             $GLOBALS['SITE_DB']->query_insert('download_logging', array('id' => $id, 'the_user' => $user, 'ip' => $row['ip'], 'date_and_time' => $row['date_and_time']));
         }
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_licences ORDER BY id', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         $GLOBALS['SITE_DB']->query_insert('download_licences', array('l_title' => $row['l_title'], 'l_text' => $row['l_text']));
     }
 }
            $from = get_custom_file_base() . '/exports/mods/' . $file;
            $new_file = basename($file, '.tar') . $version_for_name . '.tar';
            $to = get_custom_file_base() . "/uploads/downloads/" . $new_file;
            @unlink($to);
            copy($from, $to);
            $addon_path = 'uploads/downloads/' . $new_file;
            $fsize = filesize($addon_path);
            $test = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'url', array('url' => $addon_path));
            if (is_null($test)) {
                require_code('tar');
                $tar = tar_open($from, 'rb');
                $info_file = tar_get_file($tar, 'mod.inf', true);
                $info = better_parse_ini_file(NULL, $info_file['data']);
                tar_close($tar);
                $name = $info['name'];
                $description = str_replace('\\n', "\n", $info['description']);
                $author = $info['author'];
                $url = "data_custom/addon_screenshots/" . preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar'))) . ".png";
                if (!file_exists(get_custom_file_base() . '/' . $url)) {
                    $url = "data_custom/addon_screenshots/" . strtolower(preg_replace('#^theme-#', 'theme__', preg_replace('#\\d+$#', '', basename($file, '.tar')))) . ".png";
                }
                $downid = add_download($cid, $name, $addon_path, $description, $author, '', NULL, 1, 1, 2, 1, '', $new_file, $fsize, 0, 0, NULL, NULL, 0, 0, $admin);
                if (file_exists(get_custom_file_base() . '/' . $url)) {
                    add_image('', 'download_' . strval($downid), '', str_replace(' ', '%20', $url), '', 1, 0, 0, 0, '', NULL, NULL, NULL, 0);
                }
            }
        }
    }
    closedir($dh);
    echo "All themes have been imported as downloads";
}
示例#4
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
  * @return tempcode		Import message
  */
 function import_downloads_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('downloads2');
     require_code('authors');
     //check is the comment forum configured in ocPortal
     $this->test_for_comments_forum();
     $category_id_remap = array();
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download_sections ORDER BY id');
     ocf_over_msn();
     //used to fixed the correct forum prefix
     $category_id_remap[0] = db_get_first_id();
     ocf_over_local();
     //used to fixed the correct forum prefix
     // Create categories
     $orig_parents = array();
     foreach ($rows as $row) {
         $id = import_id_remap_get('download_category', strval($row['id']), true);
         if (!is_null($id)) {
             $category_id_remap[$row['id']] = $id;
             continue;
         }
         $orig_parents[$row['id']] = array($row['father'], $row['evento'], $row['descrizione']);
         $id = add_download_category(html_entity_decode($row['evento'], ENT_QUOTES, get_charset()), db_get_first_id(), '', '', '');
         $category_id_remap[$row['id']] = $id;
         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' => 'downloads', 'category_name' => strval($id), 'group_id' => $group_id));
         }
         import_id_remap_put('download_category', strval($row['id']), $id);
     }
     foreach ($orig_parents as $cid => $bits) {
         list($orig_parent, $category, $description) = $bits;
         if ($orig_parent == 0) {
             ocf_over_msn();
             //used to fixed the correct forum prefix
             $parent_id = db_get_first_id();
             ocf_over_local();
             //used to fixed the correct forum prefix
         } else {
             $parent_id = $category_id_remap[$orig_parent];
         }
         ocf_over_msn();
         //used to fixed the correct forum prefix
         edit_download_category(html_entity_decode($category, ENT_QUOTES, get_charset()), $parent_id, html_to_comcode($description), $category_id_remap[$cid], '', '', '', '');
         ocf_over_local();
         //used to fixed the correct forum prefix
     }
     // Read in downloads
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'download');
     $rows2 = array();
     foreach ($rows as $i => $row) {
         $rows[$i]['validated'] = $row['validate'];
         $rows[$i]['date'] = $row['data'];
         $rows2[$i]['totalvotes'] = $row['rate'];
         $rows2[$i]['hits'] = $row['click'];
         $rows2[$i]['screenshot'] = $row['screen1'];
         $rows2[$i]['screenshot2'] = $row['screen2'];
     }
     // Import downloads
     foreach ($rows as $row) {
         if (import_check_if_imported('download', strval($row['id']))) {
             continue;
         }
         $original_filename = $row['file'];
         $file_parts = explode('.', $row['file']);
         $file_ext = count($file_parts) > 1 ? $file_parts[count($file_parts) - 1] : '';
         $just_filename = strlen($file_ext) > 0 ? preg_replace('#\\.' . $file_ext . '#', '', $row['file']) : $row['file'];
         $mkp_disk_name = 'mk_' . strval($row['id']) . '_' . $just_filename . '.mk';
         $save_filename = $old_base_dir . '/mkportal/modules/downloads/file/' . $mkp_disk_name;
         $copy_destination = get_custom_file_base() . '/uploads/downloads/' . $mkp_disk_name;
         if (@copy($save_filename, $copy_destination) !== false) {
             fix_permissions($copy_destination);
             sync_file($copy_destination);
         }
         $url = 'uploads/downloads/' . $mkp_disk_name;
         $comments_text = $row['demo'] == '' ? '' : do_lang('DEMO_URL') . ': ' . $row['demo'];
         $member = $row['idauth'];
         if (is_null($member)) {
             $member = get_member();
         }
         $row['name'] = @html_entity_decode($row['name'], ENT_QUOTES, get_charset());
         ocf_over_msn();
         //used to fixed the correct forum prefix
         $new_id = add_download($category_id_remap[$row['idcategoria']], $row['name'], $url, html_to_comcode($row['description']), $row['autore'], html_to_comcode($comments_text), NULL, $row['validate'], 1, 1, 1, '', $original_filename, $row['peso'], 0, 0, NULL, $row['data'], $row['downloads'], $row['click'], $member);
         ocf_over_local();
         //used to fixed the correct forum prefix
         import_id_remap_put('download', strval($row['id']), $new_id);
         //get comments forum
         $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
         // Comments
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'download_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' => 'downloads', 'id' => $new_id, 'type' => 'view'), get_module_zone('downloads'));
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'downloads_' . strval($new_id), $member, $title, html_to_comcode($post), $row['name'], do_lang('COMMENT'), $content_url->evaluate());
                 ocf_over_local();
                 //used to fixed the correct forum prefix
             }
         }
         //check is the 'galleries' addon installed first, before importing the screenshots
         if (addon_installed('galleries')) {
             // Image
             if ($row['screen1'] != '') {
                 $image_url = $row['screen1'];
                 $thumb_url = '';
                 add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validate'], 1, 1, 1, '');
             }
             // Image 2
             if ($row['screen2'] != '') {
                 $image_url = $row['screen2'];
                 $thumb_url = '';
                 add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validate'], 1, 1, 1, '');
             }
         }
         //import download rating too
         $this->_import_ratings($db, 'downloads', $row['id'], $new_id, $row['rate'], $table_prefix);
     }
     $out = do_template('IMPORT_MESSAGE', array('_GUID' => 'ff9131c37b9e4fa2cff991e3479ae867', 'MESSAGE' => do_lang_tempcode('IMPORT_REBUILD_CACHE', do_lang('IMAGE_THUMBNAILS'))));
     return $out;
 }
示例#5
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
  * @return tempcode		Import message
  */
 function import_downloads_and_categories($db, $table_prefix, $old_base_dir)
 {
     require_code('downloads2');
     require_code('downloads');
     $category_id_remap = array();
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_categories ORDER BY cid');
     $category_id_remap[0] = db_get_first_id();
     $orig_parents = array();
     foreach ($rows as $row) {
         $orig_parents[$row['cid']] = array($row['parentid'], $row['title'], $row['cdescription']);
         $id = add_download_category('', 0, '', '', '');
         $category_id_remap[$row['cid']] = $id;
         $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
         foreach (array_keys($groups) as $group_id) {
             $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'downloads', 'category_name' => strval($id), 'group_id' => $group_id));
         }
     }
     foreach ($orig_parents as $cid => $bits) {
         list($orig_parent, $category, $description) = $bits;
         if ($orig_parent == 0) {
             $parent_id = db_get_first_id();
         } else {
             $parent_id = $category_id_remap[$orig_parent];
         }
         edit_download_category($category, $parent_id, $description, $category_id_remap[$cid], '', '', '', '');
     }
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_downloads');
     foreach ($rows as $i => $row) {
         $rows[$i]['validated'] = 1;
         $rows[$i]['date'] = $this->mysql_time_to_timestamp($row['date']);
     }
     $rows2 = $db->query('SELECT * FROM ' . $table_prefix . 'downloads_newdownload');
     foreach ($rows2 as $i => $row) {
         $rows2[$i]['validated'] = 0;
         $rows2[$i]['totalvotes'] = 0;
         $rows2[$i]['hits'] = 0;
         $rows2[$i]['date'] = time();
         $rows2[$i]['screenshot'] = '';
     }
     $rows = array_merge($rows, $rows2);
     foreach ($rows as $row) {
         $url_parts = explode('/', $row['url']);
         $original_filename = rawurldecode($url_parts[count($url_parts) - 1]);
         $url = $row['url'];
         if (url_is_local($url)) {
             $url = get_custom_base_url() . '/' . $url;
         }
         $comments = '';
         $comments_rows = $db->query('SELECT editorialtext FROM ' . $table_prefix . 'downloads_editorials WHERE downloadid=' . $row['lid']);
         if (array_key_exists(0, $comments_rows)) {
             $comments = $comments_rows[0]['editorialtext'];
         }
         $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($row['submitter']);
         if (is_null($member)) {
             $member = get_member();
         }
         $new_id = add_download($category_id_remap[$row['cid']], $row['title'], $url, html_to_comcode($row['description']), $row['name'], html_to_comcode($comments), NULL, $row['validated'], 1, 1, 1, '', $original_filename, $row['filesize'], 0, 0, NULL, $row['date'], $row['hits'], $row['hits'], $member);
         if ($row['totalvotes'] != 0) {
             $real_rating = $row['downloadratingsummary'];
             // Same scale as ocPortal :)
             $GLOBALS['SITE_DB']->query_insert('rating', array('rating_for_type' => 'downloads', 'rating_for_id' => strval($new_id), 'rating_member' => get_member(), 'rating_ip' => '127.0.0.1', 'rating_time' => time(), 'rating' => $real_rating));
         }
         // Homepage->Into author
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('authors', 'url', array('author' => $row['name']));
         if (is_null($test)) {
             require_code('authors');
             add_author($row['name'], $row['homepage'], NULL, '', '');
         } else {
             $GLOBALS['SITE_DB']->query_update('authors', array('url' => $row['homepage']), array('author' => $row['name']));
         }
         // Image
         if ($row['screenshot'] != '' && addon_installed('galleries')) {
             $image_url = $row['screenshot'];
             if (url_is_local($image_url)) {
                 $image_url = get_custom_base_url() . '/' . $image_url;
             }
             $thumb_url = '';
             add_image('', 'download_' . strval($new_id), '', $image_url, $thumb_url, $row['validated'], 1, 1, 1, '');
         }
     }
     $out = do_template('IMPORT_MESSAGE', array('_GUID' => 'ff9131c37b9e4fa2cff991e3479ae867', 'MESSAGE' => do_lang_tempcode('IMPORT_REBUILD_CACHE', do_lang('IMAGE_THUMBNAILS'))));
     return $out;
 }
示例#6
0
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);
}