Пример #1
0
function gallerys_huge_it_gallery()
{
    require_once "admin/gallery_func.php";
    require_once "admin/gallery_view.php";
    if (!function_exists('print_html_nav')) {
        require_once "gallery_function/html_gallery_func.php";
    }
    if (isset($_GET["task"])) {
        $task = $_GET["task"];
    } else {
        $task = '';
    }
    if (isset($_GET["id"])) {
        $id = $_GET["id"];
    } else {
        $id = 0;
    }
    global $wpdb;
    switch ($task) {
        case 'add_cat':
            add_gallery();
            break;
        case 'gallery_video':
            if ($id) {
                gallery_video($id);
            } else {
                $id = $wpdb->get_var("SELECT MAX( id ) FROM " . $wpdb->prefix . "huge_itgallery_gallerys");
                gallery_video($id);
            }
            break;
        case 'edit_cat':
            if ($id) {
                editgallery($id);
            } else {
                $id = $wpdb->get_var("SELECT MAX( id ) FROM " . $wpdb->prefix . "huge_itgallery_gallerys");
                editgallery($id);
            }
            break;
        case 'save':
            if ($id) {
                apply_cat($id);
            }
        case 'apply':
            if ($id) {
                apply_cat($id);
                editgallery($id);
            }
            break;
        case 'remove_cat':
            removegallery($id);
            showgallery();
            break;
        default:
            showgallery();
            break;
    }
}
Пример #2
0
/**
 * The UI shows member galleries that do not exist. If it is a member gallery, and it does not exist, it'll need making, before something can be added. This gallery performs the check and makes the gallery if needed.
 *
 * @param  ID_TEXT		The gallery name
 */
function make_member_gallery_if_needed($cat)
{
    // If it is a non-member gallery, it must surely exist, as we have no interface to choose non-existant ones (it's safe enough to assume it hasn't been deleted suddenly)
    if (substr($cat, 0, 7) != 'member_') {
        return;
    }
    // Test to see if it exists
    $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $cat));
    if (is_null($test)) {
        $parts = explode('_', $cat, 3);
        $member = intval($parts[1]);
        // Almost certainly going to be same as get_member(), but we might as well be general here
        if (!has_specific_permission($member, 'have_personal_category', 'cms_galleries')) {
            return;
        }
        // Find about parent (new gallery inherits)
        $parent_id = $parts[2];
        $_parent_info = $GLOBALS['SITE_DB']->query_select('galleries', array('accept_images', 'accept_videos', 'flow_mode_interface', 'fullname'), array('name' => $parent_id), '', 1);
        if (!array_key_exists(0, $_parent_info)) {
            fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
        }
        $parent_info = $_parent_info[0];
        $username = $GLOBALS['FORUM_DRIVER']->get_username($member);
        if (is_null($username)) {
            warn_exit(do_lang_tempcode('_USER_NO_EXIST', escape_html($username)));
        }
        add_gallery($cat, do_lang('PERSONAL_GALLERY_OF', $username, get_translated_text($parent_info['fullname'])), '', '', '', $parent_id, $parent_info['accept_images'], $parent_info['accept_videos'], 0, $parent_info['flow_mode_interface']);
        $rows = $GLOBALS['SITE_DB']->query_select('group_category_access', array('group_id'), array('module_the_name' => 'galleries', 'category_name' => $parent_id));
        foreach ($rows as $row) {
            $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'galleries', 'category_name' => $cat, 'group_id' => $row['group_id']));
        }
    }
}
Пример #3
0
 /**
  * Standard modular install function.
  *
  * @param  ?integer	What version we're upgrading from (NULL: new install)
  * @param  ?integer	What hack version we're upgrading from (NULL: new-install/not-upgrading-from-a-hacked-version)
  */
 function install($upgrade_from = NULL, $upgrade_from_hack = NULL)
 {
     require_code('galleries');
     require_lang('galleries');
     require_code('galleries2');
     if (is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->create_table('galleries', array('name' => '*ID_TEXT', 'description' => 'LONG_TRANS', 'teaser' => 'SHORT_TRANS', 'fullname' => 'SHORT_TRANS', 'add_date' => 'TIME', 'rep_image' => 'URLPATH', 'parent_id' => 'ID_TEXT', 'watermark_top_left' => 'URLPATH', 'watermark_top_right' => 'URLPATH', 'watermark_bottom_left' => 'URLPATH', 'watermark_bottom_right' => 'URLPATH', 'accept_images' => 'BINARY', 'accept_videos' => 'BINARY', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'notes' => 'LONG_TEXT', 'is_member_synched' => 'BINARY', 'flow_mode_interface' => 'BINARY', 'gallery_views' => 'INTEGER', 'g_owner' => '?AUTO_LINK'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_top_left', array('watermark_top_left'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_top_right', array('watermark_top_right'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_bottom_left', array('watermark_bottom_left'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'watermark_bottom_right', array('watermark_bottom_right'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'gadd_date', array('add_date'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'parent_id', array('parent_id'));
         $GLOBALS['SITE_DB']->create_table('images', array('id' => '*AUTO', 'cat' => 'ID_TEXT', 'url' => 'URLPATH', 'thumb_url' => 'URLPATH', 'comments' => 'LONG_TRANS', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'submitter' => 'USER', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'image_views' => 'INTEGER', 'title' => 'SHORT_TRANS'));
         $GLOBALS['SITE_DB']->create_index('images', 'image_views', array('image_views'));
         $GLOBALS['SITE_DB']->create_index('images', 'category_list', array('cat'));
         $GLOBALS['SITE_DB']->create_index('images', 'i_validated', array('validated'));
         $GLOBALS['SITE_DB']->create_index('images', 'xis', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('images', 'iadd_date', array('add_date'));
         add_config_option('ADD_IMAGE', 'points_ADD_IMAGE', 'integer', 'return addon_installed(\'points\')?\'100\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         add_config_option('ADD_VIDEO', 'points_ADD_VIDEO', 'integer', 'return addon_installed(\'points\')?\'100\':NULL;', 'POINTS', 'COUNT_POINTS_GIVEN');
         require_lang('galleries');
         add_menu_item_simple('main_content', NULL, 'GALLERIES', '_SEARCH:galleries:type=misc');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 3) {
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'teaser', 'SHORT_TRANS', 2);
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'rep_image', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'parent_id', 'ID_TEXT', 'root');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'accept_images', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'accept_videos', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_top_left', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_top_right', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_bottom_left', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'watermark_bottom_right', 'URLPATH');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'is_member_synched', 'BINARY');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'flow_mode_interface', 'BINARY');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'allow_rating', 'BINARY', 1);
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'allow_comments', 'SHORT_INTEGER', 1);
         $GLOBALS['SITE_DB']->add_table_field('images', 'allow_trackbacks', 'BINARY', 1);
     }
     if (is_null($upgrade_from) || $upgrade_from < 3) {
         add_specific_permission('GALLERIES', 'may_download_gallery', false);
         $GLOBALS['SITE_DB']->create_table('videos', array('id' => '*AUTO', 'cat' => 'ID_TEXT', 'url' => 'URLPATH', 'thumb_url' => 'URLPATH', 'comments' => 'LONG_TRANS', 'allow_rating' => 'BINARY', 'allow_comments' => 'SHORT_INTEGER', 'allow_trackbacks' => 'BINARY', 'notes' => 'LONG_TEXT', 'submitter' => 'USER', 'validated' => 'BINARY', 'add_date' => 'TIME', 'edit_date' => '?TIME', 'video_views' => 'INTEGER', 'video_width' => 'INTEGER', 'video_height' => 'INTEGER', 'video_length' => 'INTEGER', 'title' => 'SHORT_TRANS'));
         $GLOBALS['SITE_DB']->create_index('videos', 'video_views', array('video_views'));
         $GLOBALS['SITE_DB']->create_index('videos', 'vs', array('submitter'));
         $GLOBALS['SITE_DB']->create_index('videos', 'v_validated', array('validated'));
         $GLOBALS['SITE_DB']->create_index('videos', 'category_list', array('cat'));
         $GLOBALS['SITE_DB']->create_index('videos', 'vadd_date', array('add_date'));
         add_config_option('DEFAULT_VIDEO_WIDTH', 'default_video_width', 'integer', 'return \'320\';', 'FEATURE', 'GALLERIES');
         add_config_option('DEFAULT_VIDEO_HEIGHT', 'default_video_height', 'integer', 'return \'240\';', 'FEATURE', 'GALLERIES');
         add_config_option('MAXIMUM_IMAGE_SIZE', 'maximum_image_size', 'integer', 'return \'1024\';', 'FEATURE', 'GALLERIES');
         add_config_option('GALLERY_IMAGE_LIMIT_LOW', 'max_personal_gallery_images_low', 'integer', 'return \'5\';', 'FEATURE', 'GALLERIES');
         add_config_option('GALLERY_IMAGE_LIMIT_HIGH', 'max_personal_gallery_images_high', 'integer', 'return \'10\';', 'FEATURE', 'GALLERIES');
         add_config_option('GALLERY_VIDEO_LIMIT_LOW', 'max_personal_gallery_videos_low', 'integer', 'return \'2\';', 'FEATURE', 'GALLERIES');
         add_config_option('GALLERY_VIDEO_LIMIT_HIGH', 'max_personal_gallery_videos_high', 'integer', 'return \'5\';', 'FEATURE', 'GALLERIES');
         add_specific_permission('GALLERIES', 'high_personal_gallery_limit', false);
         add_specific_permission('GALLERIES', 'no_personal_gallery_limit', false);
         // Add root gallery
         add_gallery('root', do_lang('GALLERIES_HOME'), '', '', '', '', 1, 1, 0, 1);
         $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' => 'galleries', 'category_name' => 'root', 'group_id' => $group_id));
         }
     }
     if (is_null($upgrade_from) || $upgrade_from < 4) {
         add_config_option('GALLERIES', 'galleries_show_stats_count_galleries', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('IMAGES', 'galleries_show_stats_count_images', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('VIDEOS', 'galleries_show_stats_count_videos', 'tick', 'return addon_installed(\'stats_block\')?\'0\':NULL;', 'BLOCKS', 'STATISTICS');
         add_config_option('SHOW_EMPTY_GALLERIES', 'show_empty_galleries', 'tick', 'return \'1\';', 'FEATURE', 'GALLERIES');
         add_config_option('GALLERY_NAME_ORDER', 'gallery_name_order', 'tick', 'return \'0\';', 'FEATURE', 'GALLERIES');
     }
     if (is_null($upgrade_from) || $upgrade_from < 5) {
         add_config_option('GALLERY_SELECTORS', 'gallery_selectors', 'line', 'return is_null($old=get_value(\'gallery_selectors\'))?\'12,24,36,64,128\':$old;', 'FEATURE', 'GALLERIES');
         add_config_option('REVERSE_THUMB_ORDER', 'reverse_thumb_order', 'tick', 'return is_null($old=get_value(\'reverse_thumb_order\'))?\'0\':$old;', 'FEATURE', 'GALLERIES');
         add_config_option('SHOW_GALLERY_COUNTS', 'show_gallery_counts', 'tick', 'return is_null($old=get_value(\'show_gallery_counts\'))?((get_forum_type()==\'ocf\')?\'0\':NULL):$old;', 'FEATURE', 'GALLERIES');
     }
     if (is_null($upgrade_from) || $upgrade_from < 6) {
         add_config_option('VIDEO_BITRATE', 'video_bitrate', 'integer', 'return \'1000\';', 'FEATURE', 'TRANSCODING');
         add_config_option('AUDIO_BITRATE', 'audio_bitrate', 'integer', 'return \'192\';', 'FEATURE', 'TRANSCODING');
         add_config_option('VIDEO_WIDTH_SETTING', 'video_width_setting', 'integer', 'return \'720\';', 'FEATURE', 'TRANSCODING');
         add_config_option('VIDEO_HEIGHT_SETTING', 'video_height_setting', 'integer', 'return \'480\';', 'FEATURE', 'TRANSCODING');
         $GLOBALS['SITE_DB']->create_index('videos', 'ftjoin_vcomments', array('comments'));
         $GLOBALS['SITE_DB']->create_index('images', 'ftjoin_icomments', array('comments'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'ftjoin_gfullname', array('fullname'));
         $GLOBALS['SITE_DB']->create_index('galleries', 'ftjoin_gdescrip', array('description'));
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         $old_option = get_option('ffmpeg_path', true);
         if (is_null($old_option)) {
             $old_option = '';
         }
         delete_config_option('ffmpeg_path');
         add_config_option('TRANSCODING_ZENCODER_API_KEY', 'transcoding_zencoder_api_key', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING');
         add_config_option('TRANSCODING_ZENCODER_FTP_PATH', 'transcoding_zencoder_ftp_path', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING');
         add_config_option('TRANSCODING_SERVER', 'transcoding_server', 'line', 'return \'\';', 'FEATURE', 'TRANSCODING');
         add_config_option('FFMPEG_PATH', 'ffmpeg_path', 'line', 'return \'' . addslashes($old_option) . '\';', 'FEATURE', 'TRANSCODING');
         $GLOBALS['SITE_DB']->create_table('video_transcoding', array('t_id' => '*ID_TEXT', 't_error' => 'LONG_TEXT', 't_url' => 'URLPATH', 't_table' => 'ID_TEXT', 't_url_field' => 'ID_TEXT', 't_orig_filename_field' => 'ID_TEXT', 't_width_field' => 'ID_TEXT', 't_height_field' => 'ID_TEXT', 't_output_filename' => 'ID_TEXT'));
     }
     if (!is_null($upgrade_from) && $upgrade_from < 7) {
         $GLOBALS['SITE_DB']->add_table_field('videos', 'title', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->add_table_field('images', 'title', 'SHORT_TRANS');
         $GLOBALS['SITE_DB']->create_index('images', 'ftjoin_dtitle', array('title'));
         $GLOBALS['SITE_DB']->create_index('videos', 'ftjoin_dtitle', array('title'));
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'gallery_views', 'INTEGER');
         $GLOBALS['SITE_DB']->add_table_field('galleries', 'g_owner', '?USER');
     }
 }
Пример #4
0
/**
 * Add a download.
 *
 * @param  AUTO_LINK			The ID of the category the download is to be in
 * @param  SHORT_TEXT		The name of the download
 * @param  URLPATH			The URL to the download
 * @param  LONG_TEXT			The description of the download
 * @param  ID_TEXT			The author of the download (not necessarily same as the submitter)
 * @param  LONG_TEXT			The comments for the download
 * @param  ?AUTO_LINK		The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting (NULL: none)
 * @param  BINARY				Whether the download has been validated
 * @param  BINARY				Whether the download may be rated
 * @param  SHORT_INTEGER	Whether comments are allowed (0=no, 1=yes, 2=review style)
 * @param  BINARY				Whether the download may be trackbacked
 * @param  LONG_TEXT			Hidden notes pertaining to the download
 * @param  SHORT_TEXT		The downloads original filename (the URL may be obfuscated)
 * @param  integer			The file size of the download (we can't really detect this in real-time for remote URLs)
 * @param  integer			The cost of the download that members will have to pay to get it
 * @param  BINARY				Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building)
 * @param  ?AUTO_LINK		The licence to use (NULL: none)
 * @param  ?TIME				The add date for the download (NULL: now)
 * @param  integer			The number of downloads that this download has had
 * @param  integer			The number of views that this download has had
 * @param  ?MEMBER			The submitter (NULL: current user)
 * @param  ?TIME				The edit date (NULL: never)
 * @param  ?AUTO_LINK		Force an ID (NULL: don't force an ID)
 * @return AUTO_LINK			The ID of the newly added download
 */
function add_download($category_id, $name, $url, $description, $author, $comments, $out_mode_id, $validated, $allow_rating, $allow_comments, $allow_trackbacks, $notes, $original_filename, $file_size, $cost, $submitter_gets_points, $licence = NULL, $add_date = NULL, $num_downloads = 0, $views = 0, $submitter = NULL, $edit_date = NULL, $id = NULL)
{
    if (is_null($add_date)) {
        $add_date = time();
    }
    if (is_null($submitter)) {
        $submitter = get_member();
    }
    if ($file_size == 0 || url_is_local($url)) {
        if (url_is_local($url)) {
            $file_size = @filesize(get_custom_file_base() . '/' . rawurldecode($url)) or $file_size = NULL;
        } else {
            $file_size = @filesize($url) or $file_size = NULL;
        }
    }
    $met = @ini_get('max_execution_time');
    $data_mash = $url == '' ? '' : create_data_mash($url, NULL, get_file_extension($original_filename));
    if (function_exists('set_time_limit')) {
        @set_time_limit($met);
    }
    if (!addon_installed('unvalidated')) {
        $validated = 1;
    }
    $map = array('download_data_mash' => $data_mash, 'download_licence' => $licence, 'rep_image' => '', 'edit_date' => $edit_date, 'download_submitter_gets_points' => $submitter_gets_points, 'download_cost' => $cost, 'original_filename' => $original_filename, 'download_views' => $views, 'allow_rating' => $allow_rating, 'allow_comments' => $allow_comments, 'allow_trackbacks' => $allow_trackbacks, 'notes' => $notes, 'submitter' => $submitter, 'default_pic' => 1, 'num_downloads' => $num_downloads, 'out_mode_id' => $out_mode_id, 'category_id' => $category_id, 'name' => insert_lang($name, 2), 'url' => $url, 'description' => insert_lang_comcode($description, 3), 'author' => $author, 'comments' => insert_lang_comcode($comments, 3), 'validated' => $validated, 'add_date' => $add_date, 'file_size' => $file_size);
    if (!is_null($id)) {
        $map['id'] = $id;
    }
    $id = $GLOBALS['SITE_DB']->query_insert('download_downloads', $map, true);
    require_code('seo2');
    seo_meta_set_for_implicit('downloads_download', strval($id), array($name, $description, $comments), $description);
    // Make its gallery
    if (addon_installed('galleries') && !running_script('stress_test_loader')) {
        $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => 'download_' . strval($id)));
        if (is_null($test)) {
            require_code('galleries2');
            $download_gallery_root = get_option('download_gallery_root');
            if (is_null($download_gallery_root)) {
                $download_gallery_root = 'root';
            }
            add_gallery('download_' . strval($id), do_lang('GALLERY_FOR_DOWNLOAD', $name), '', '', '', $download_gallery_root);
        }
    }
    // Stat
    update_stat('num_archive_downloads', 1);
    if ($file_size > 0) {
        update_stat('archive_size', $file_size);
    }
    if ($validated == 1) {
        require_lang('downloads');
        require_code('notifications');
        $subject = do_lang('DOWNLOAD_NOTIFICATION_MAIL_SUBJECT', get_site_name(), $name);
        $self_url = build_url(array('page' => 'downloads', 'type' => 'entry', 'id' => $id), get_module_zone('downloads'), NULL, false, false, true);
        $mail = do_lang('DOWNLOAD_NOTIFICATION_MAIL', comcode_escape(get_site_name()), comcode_escape($name), array(comcode_escape($self_url->evaluate())));
        dispatch_notification('download', strval($category_id), $subject, $mail);
    }
    log_it('ADD_DOWNLOAD', strval($id), $name);
    decache('main_recent_downloads');
    decache('main_top_downloads');
    decache('main_download_category');
    decache('main_download_tease');
    return $id;
}
Пример #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
  */
 function import_images_and_galleries($db, $table_prefix, $file_base)
 {
     require_code('galleries2');
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'galleries', NULL, NULL, true);
     if (is_null($rows)) {
         return;
     }
     foreach ($rows as $row) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['name']));
         if (is_null($test)) {
             add_gallery($row['name'], $this->get_lang_string($db, $row['fullname']), $this->get_lang_string($db, $row['description']), $this->get_lang_string($db, $row['teaser']), $row['notes'], $row['parent_id'], $row['accept_images'], $row['accept_videos'], $row['is_member_synched'], $row['flow_mode_interface'], $row['rep_image'], $row['watermark_top_left'], $row['watermark_top_right'], $row['watermark_bottom_left'], $row['watermark_bottom_right'], $row['allow_rating'], $row['allow_comments'], false, $row['add_date']);
         }
     }
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'gallery', NULL);
     $this->_import_review_supplement($db, $table_prefix, 'galleries', NULL);
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'images ORDER BY id');
     $on_same_msn = $this->on_same_msn($file_base);
     foreach ($rows as $row) {
         if (import_check_if_imported('image', 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();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = add_image(array_key_exists('title', $row) ? $row['title'] : '', $row['cat'], $this->get_lang_string($db, $row['comments']), $row['url'], $row['thumb_url'], $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $submitter, $row['add_date'], $row['edit_date'], $row['image_views'], $id);
         import_id_remap_put('image', strval($row['id']), $id_new);
     }
     $this->_import_review_supplement($db, $table_prefix, 'images', 'image');
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'image', NULL);
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'videos ORDER BY id');
     foreach ($rows as $row) {
         if (import_check_if_imported('video', 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();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         $id_new = add_video(array_key_exists('title', $row) ? $row['title'] : '', $row['cat'], $this->get_lang_string($db, $row['comments']), $row['url'], $row['thumb_url'], $row['validated'], $row['allow_rating'], $row['allow_comments'], $row['allow_trackbacks'], $row['notes'], $row['video_length'], $row['video_width'], $row['video_height'], $submitter, $row['add_date'], $row['edit_date'], $row['video_views'], $id);
         import_id_remap_put('video', strval($row['id']), $id_new);
     }
     $this->_import_review_supplement($db, $table_prefix, 'videos', 'video');
     $this->_import_catalogue_entry_linkage($db, $table_prefix, 'video', NULL);
 }
Пример #6
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_images_and_galleries($db, $table_prefix, $old_base_dir)
 {
     require_code('galleries2');
     //check is the comment forum configured in ocPortal
     $this->test_for_comments_forum();
     $ocp_path = get_custom_file_base();
     //copy watermark image
     $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
     $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 ($rows as $row) {
         if ($row['chiave'] == 'watermark_pos') {
             $watermark_pos = $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 ($row['chiave'] == 'watermark_enable') {
             $watermark_enable = $row['valore'];
             continue;
         }
     }
     //add galleries first
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'gallery_events');
     //for some strange reason the gallery categories are called events
     foreach ($rows as $row) {
         $test = $GLOBALS['SITE_DB']->query_value_null_ok('galleries', 'name', array('name' => $row['evento']));
         if (is_null($test)) {
             $rep_image = '';
             $add_date = $db->query_value_null_ok('gallery', 'MIN(data)', array('evento' => $row['id']));
             $add_date = !is_null($add_date) ? $add_date : time();
             //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 - 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;
                 }
             }
             $row['evento'] = @html_entity_decode($row['evento'], ENT_QUOTES, get_charset());
             //find is there already a personal category container
             $pcc_gallery = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('name' => 'gallery_' . strval($row['father'])));
             $main_gallery = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('parent_id' => ''));
             $root_gallery = isset($pcc_gallery[0]['name']) && strlen($pcc_gallery[0]['name']) > 0 ? $pcc_gallery[0]['name'] : isset($main_gallery[0]['name']) && strlen($main_gallery[0]['name']) > 0 ? $main_gallery[0]['name'] : 'root';
             $check_gallery_imported = $GLOBALS['SITE_DB']->query_select('galleries', NULL, array('name' => 'gallery_' . strval($row['id'])));
             if (!array_key_exists(0, $check_gallery_imported)) {
                 add_gallery('gallery_' . strval($row['id']), $row['evento'], '', '', '', $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);
             }
         }
     }
     //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
     //now we need to import the images
     $rows = $db->query('SELECT * FROM ' . $table_prefix . 'gallery ORDER BY id');
     // NB: In MKPortal "gallery" is the images table, and "gallery_events" is the galleries table
     foreach ($rows as $row) {
         if (import_check_if_imported('image', strval($row['id']))) {
             continue;
         }
         $submitter = $row['idauth'];
         //import_id_remap_get('member',$GLOBALS['FORUM_DRIVER']->get_member_from_username($row['autore']),true);
         if (is_null($submitter)) {
             $submitter = $GLOBALS['FORUM_DRIVER']->get_guest_id();
         }
         $id = get_param_integer('keep_preserve_ids', 0) == 0 ? NULL : $row['id'];
         ocf_over_msn();
         $comment_text = html_to_comcode($row['titolo'] . ' ' . $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/modules/gallery/album/' . $row['file'];
         $copy_destination = $ocp_path . '/uploads/galleries/' . $row['file'];
         //image thumbnail source and destination
         $save_tfilename = $old_base_dir . '/mkportal/modules/gallery/album/t_' . $row['file'];
         $copy_tdestination = $ocp_path . '/uploads/galleries_thumbs/' . $row['file'];
         if (@copy($save_filename, $copy_destination) !== false) {
             fix_permissions($copy_destination);
             sync_file($copy_destination);
         }
         if (@copy($save_tfilename, $copy_tdestination) !== false) {
             fix_permissions($copy_tdestination);
             sync_file($copy_tdestination);
         }
         $url = get_custom_base_url() . '/uploads/galleries/' . $row['file'];
         $thumb_url = get_custom_base_url() . '/uploads/galleries_thumbs/' . $row['file'];
         $id_new = add_image('', 'gallery_' . strval($row['evento']), $comment_text, $url, $url, $row['validate'], 1, 1, 1, '', $submitter, $row['data'], NULL, $row['click'], $id);
         import_id_remap_put('image', strval($row['id']), $id_new);
         //import comments for image
         $comments = $db->query('SELECT * FROM ' . $table_prefix . 'gallery_comments WHERE identry=' . strval($row['id']) . ' ORDER BY data');
         if (!is_null($forum_id)) {
             foreach ($comments as $comment) {
                 $member = $GLOBALS['FORUM_DRIVER']->get_member_from_username($comment['autore']);
                 if (is_null($member)) {
                     $member = $GLOBALS['FORUM_DRIVER']->get_guest_id();
                 }
                 $title = '';
                 $post = $comment['testo'];
                 $content_url = build_url(array('page' => 'galleries', 'id' => $id_new, 'type' => 'view'), get_module_zone('galleries'));
                 ocf_over_msn();
                 //used to fixed the correct forum prefix
                 $GLOBALS['FORUM_DRIVER']->make_post_forum_topic($forum_name, 'galleries_' . strval($id_new), $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 gallery rating too
         $this->_import_ratings($db, 'galleries', $row['id'], $id_new, $row['rate'], $table_prefix);
     }
 }
Пример #7
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);
}
Пример #8
0
 /**
  * Standard aed_module add actualiser.
  *
  * @return ID_TEXT		The entry added
  */
 function add_actualisation()
 {
     $name = post_param('name');
     $fullname = post_param('fullname');
     $description = post_param('description');
     $teaser = post_param('teaser', '');
     $notes = post_param('notes', '');
     $parent_id = post_param('parent_id');
     $accept_images = post_param_integer('accept_images', 0);
     $accept_videos = post_param_integer('accept_videos', 0);
     $is_member_synched = post_param_integer('is_member_synched', 0);
     $flow_mode_interface = post_param_integer('flow_mode_interface', 0);
     $urls = get_url('image_url', 'rep_image', 'uploads/grepimages', 0, OCP_UPLOAD_IMAGE);
     $url = $urls[0];
     $watermark_top_left = get_url('', 'watermark_top_left', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
     $watermark_top_right = get_url('', 'watermark_top_right', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
     $watermark_bottom_left = get_url('', 'watermark_bottom_left', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
     $watermark_bottom_right = get_url('', 'watermark_bottom_right', 'uploads/watermarks', 0, OCP_UPLOAD_IMAGE);
     $allow_rating = post_param_integer('allow_rating', 0);
     $allow_comments = post_param_integer('allow_comments', 0);
     $g_owner_name = post_param('g_owner', NULL);
     if (is_null($g_owner_name)) {
         $g_owner = get_member();
     } else {
         $g_owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($g_owner_name);
     }
     add_gallery($name, $fullname, $description, $teaser, $notes, $parent_id, $accept_images, $accept_videos, $is_member_synched, $flow_mode_interface, $url, $watermark_top_left[0], $watermark_top_right[0], $watermark_bottom_left[0], $watermark_bottom_right[0], $allow_rating, $allow_comments, false, time(), $g_owner);
     $this->set_permissions($name);
     return $name;
 }