Esempio n. 1
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     // The counter we're using
     $name = array_key_exists('param', $map) ? $map['param'] : '';
     if ($name == '-') {
         $name = get_page_name() . ':' . get_param('type', 'misc') . ':' . get_param('id', '');
     }
     if ($name == '') {
         $name = 'hits';
     }
     $start = array_key_exists('start', $map) ? intval($map['start']) : 0;
     // Set it if it's not already
     $_current_value = get_value($name);
     if (is_null($_current_value)) {
         set_value($name, strval($start));
         $current_value = $start;
     } else {
         $current_value = intval($_current_value);
         if ($start > $current_value) {
             $current_value = $start;
             set_value($name, strval($current_value));
         }
     }
     // Hit counter?
     $hit_count = array_key_exists('hit_count', $map) ? intval($map['hit_count']) : 1;
     if ($hit_count == 1) {
         update_stat($name, 1);
     }
     return do_template('MAIN_COUNT', array('NAME' => $name, 'VALUE' => strval($current_value)));
 }
Esempio n. 2
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;
}
Esempio n. 3
0
/**
 * Add a CEDI page
 *
 * @param  SHORT_TEXT	The page title
 * @param  LONG_TEXT		The page description
 * @param  LONG_TEXT		Hidden notes pertaining to the page
 * @param  BINARY			Whether to hide the posts on the page by default
 * @param  ?MEMBER		The member doing the action (NULL: current member)
 * @return AUTO_LINK		The page ID
 */
function cedi_add_page($title, $description, $notes, $hide_posts, $member = NULL)
{
    if (is_null($member)) {
        $member = get_member();
    }
    require_code('comcode_check');
    check_comcode($description, NULL, false, NULL, true);
    if ($description != '') {
        $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => 0, 'title' => insert_lang($title, 2), 'add_date' => time()), true);
        require_code('attachments2');
        $GLOBALS['SITE_DB']->query_update('seedy_pages', array('description' => insert_lang_comcode_attachments(2, $description, 'cedi_page', strval($id), NULL, false, $member)), array('id' => $id), '', 1);
    } else {
        $id = $GLOBALS['SITE_DB']->query_insert('seedy_pages', array('submitter' => $member, 'hide_posts' => $hide_posts, 'seedy_views' => 0, 'notes' => $notes, 'description' => insert_lang($description, 2), 'title' => insert_lang($title, 2), 'add_date' => time()), true);
    }
    update_stat('num_seedy_pages', 1);
    $GLOBALS['SITE_DB']->query_insert('seedy_changes', array('the_action' => 'CEDI_ADD_PAGE', 'the_page' => $id, 'date_and_time' => time(), 'ip' => get_ip_address(), 'the_user' => $member));
    require_code('seo2');
    seo_meta_set_for_implicit('seedy_page', strval($id), array($title, $description), $description);
    dispatch_cedi_page_notification($id, 'ADD');
    return $id;
}
Esempio n. 4
0
function createAlbumsList()
{
    global $collection, $transaction_open, $numdone, $doing_search;
    debuglog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "TIMINGS", 4);
    debuglog("Starting Database Update From Collection", "TIMINGS", 4);
    $now = time();
    foreach (array_keys($collection->artists) as $artistkey) {
        do_artist_database_stuff($artistkey, false);
    }
    $dur = format_time(time() - $now);
    debuglog("Database Update From Collection Took " . $dur, "TIMINGS", 4);
    debuglog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "TIMINGS", 4);
    // Find tracks that have been removed
    if (!$doing_search) {
        debuglog("Starting Cruft Removal", "TIMINGS", 4);
        $now = time();
        debuglog("Finding tracks that have been deleted", "MYSQL", 7);
        generic_sql_query("DELETE FROM Tracktable WHERE LastModified IS NOT NULL AND TTindex NOT IN\n\t    \t(SELECT TTindex FROM Foundtracks) AND Hidden = 0", true);
        remove_cruft();
        update_stat('ListVersion', ROMPR_COLLECTION_VERSION);
        update_track_stats();
        $dur = format_time(time() - $now);
        debuglog("Cruft Removal Took " . $dur, "TIMINGS", 4);
        debuglog("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "TIMINGS", 4);
    }
    close_transaction();
}