Beispiel #1
0
 /**
  * Standard modular run function for OcCLE hooks.
  *
  * @param  array	The options with which the command was called
  * @param  array	The parameters with which the command was called
  * @param  array	A reference to the OcCLE filesystem object
  * @return array	Array of stdcommand, stdhtml, stdout, and stderr responses
  */
 function run($options, $parameters, &$occle_fs)
 {
     if (array_key_exists('h', $options) || array_key_exists('help', $options)) {
         return array('', do_command_help('find_codes', array('h'), array(true)), '', '');
     } else {
         if (!array_key_exists(0, $parameters)) {
             return array('', '', '', do_lang('MISSING_PARAM', '1', 'find_codes'));
         }
         $path = get_custom_file_base() . '/sources/';
         $files = array();
         if (is_dir($path)) {
             $dh = opendir($path);
             while (($file = readdir($dh)) !== false) {
                 if ($file != '.' && $file != '..') {
                     if (!is_dir($path . $file)) {
                         $contents = file_get_contents($path . $file, FILE_TEXT);
                         if (strpos($contents, $parameters[0]) !== false) {
                             $files[] = $path . $file;
                         }
                     }
                     unset($contents);
                     // Got to be careful with that memory :-(
                 }
             }
             return array('', do_template('OCCLE_FIND_CODES', array('_GUID' => '3374d1a80727aecc271722f2184743d0', 'FILES' => $files)), '', '');
         } else {
             return array('', '', '', do_lang('INCOMPLETE_ERROR'));
         }
         // Directory doesn't exist
     }
 }
Beispiel #2
0
/**
 * Get a splurghified version of the specified item.
 *
 * @param  string			The name of what the key we want to reference is in our array of maps (e.g. 'id')
 * @param  array			A row of maps for data we are splurghing; this is probably just the result of $GLOBALS['SITE_DB']->query_select
 * @param  URLPATH		The stub that links will be passed through
 * @param  ID_TEXT		The page name we will be saving customised HTML under
 * @param  TIME			The time we did our last change to the data being splurghed (so it can see if we can simply decache instead of deriving)
 * @param  ?AUTO_LINK	The ID that is at the root of our tree (NULL: db_get_first_id)
 * @return string			A string of HTML that represents our splurghing (will desplurgh in the users browser)
 */
function splurgh_master_build($key_name, $map, $url_stub, $_cache_file, $last_change_time, $first_id = NULL)
{
    if (is_null($first_id)) {
        $first_id = db_get_first_id();
    }
    if (!array_key_exists($first_id, $map)) {
        return '';
    }
    if (!has_js()) {
        warn_exit(do_lang_tempcode('MSG_JS_NEEDED'));
    }
    require_javascript('javascript_splurgh');
    if (is_browser_decacheing()) {
        $last_change_time = time();
    }
    $cache_file = zone_black_magic_filterer(get_custom_file_base() . '/' . get_zone_name() . '/pages/html_custom/' . filter_naughty(user_lang()) . '/' . filter_naughty($_cache_file) . '.htm');
    if (!file_exists($cache_file) || is_browser_decacheing() || filesize($cache_file) == 0 || $last_change_time > filemtime($cache_file)) {
        $myfile = @fopen($cache_file, 'wt');
        if ($myfile === false) {
            intelligent_write_error($cache_file);
        }
        $fulltable = array();
        $splurgh = _splurgh_do_node($map, $first_id, '', $fulltable, 0);
        $page = do_template('SPLURGH', array('_GUID' => '8775edfc5a386fdf2cec69b0fc889952', 'KEY_NAME' => $key_name, 'URL_STUB' => $url_stub, 'SPLURGH' => str_replace('"', '\'', $splurgh)));
        $ev = $page->evaluate();
        if (fwrite($myfile, $ev) < strlen($ev)) {
            warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
        }
        fclose($myfile);
        fix_permissions($cache_file);
        sync_file($cache_file);
        return $ev;
    }
    return file_get_contents($cache_file, FILE_TEXT);
}
Beispiel #3
0
 /**
  * Standard interface stage of pointstore item purchase.
  *
  * @return tempcode		The UI
  */
 function action()
 {
     require_code('database_action');
     $class = str_replace('hook_pointstore_', '', strtolower(get_class($this)));
     $title = get_page_title('OCGIFTS_TITLE');
     require_code('form_templates');
     $map = NULL;
     $category = either_param('category', '');
     if ($category != '') {
         $map = array('category' => $category);
     }
     $max_rows = $GLOBALS['SITE_DB']->query_value('ocgifts', 'COUNT(*)', $map);
     $max = get_param_integer('max', 20);
     $start = get_param_integer('start', 0);
     require_code('templates_results_browser');
     $results_browser = results_browser(do_lang_tempcode('OCGIFTS_TITLE'), get_param('id'), $start, 'start', $max, 'max', $max_rows, NULL, NULL, true, true);
     $rows = $GLOBALS['SITE_DB']->query_select('ocgifts g', array('*', '(SELECT COUNT(*) FROM ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'members_gifts m WHERE m.gift_id=g.id) AS popularity'), $map, 'ORDER BY popularity DESC', $max, $start);
     $username = get_param('username', '');
     $gifts = array();
     foreach ($rows as $gift) {
         $gift_url = build_url(array('page' => 'pointstore', 'type' => 'action_done', 'id' => 'ocgifts', 'gift' => $gift['id'], 'username' => $username), '_SEARCH');
         $image_url = '';
         if (is_file(get_custom_file_base() . '/' . rawurldecode($gift['image']))) {
             $image_url = get_custom_base_url() . '/' . $gift['image'];
         }
         $gifts[] = array('NAME' => $gift['name'], 'PRICE' => integer_format($gift['price']), 'POPULARITY' => integer_format($gift['popularity']), 'GIFT_URL' => $gift_url, 'IMAGE_URL' => $image_url);
     }
     $categories = collapse_1d_complexity('category', $GLOBALS['SITE_DB']->query_select('ocgifts', array('DISTINCT category'), NULL, 'ORDER BY category'));
     return do_template('POINTSTORE_OCGIFTS_GIFTS', array('TITLE' => $title, 'GIFTS' => $gifts, 'RESULTS_BROWSER' => $results_browser, 'CATEGORY' => $category, 'CATEGORIES' => $categories));
 }
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     require_lang('bulkupload');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/bulkuploadassistant';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_adv_comcode';
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_BULK_UPLOAD');
     $title = get_page_title('BULK_UPLOAD');
     $parameter = post_param('parameter', '');
     require_code('form_templates');
     if ($parameter == '') {
         $post_url = build_url(array('page' => '_SELF'), '_SELF');
         $text = paragraph(do_lang_tempcode('BULK_UPLOAD_HELP'));
         $submit_name = do_lang_tempcode('BULK_UPLOAD');
         $fields = form_input_line(do_lang_tempcode('DIRECTORY'), do_lang_tempcode('DIRECTORY_BULK'), 'parameter', 'uploads/attachments/' . date('Y-m-d', utctime_to_usertime()), true);
         return do_template('FORM_SCREEN', array('_GUID' => '77a2ca460745145d8a1d18cf24971fea', 'SKIP_VALIDATION' => true, 'HIDDEN' => '', 'FIELDS' => $fields, 'URL' => $post_url, 'TITLE' => $title, 'TEXT' => $text, 'SUBMIT_NAME' => $submit_name));
     } else {
         breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('BULK_UPLOAD'))));
         breadcrumb_set_self(do_lang_tempcode('_RESULTS'));
         $out = $this->do_dir(get_custom_file_base() . '/' . filter_naughty($parameter, true));
         if ($out->is_empty()) {
             inform_exit(do_lang_tempcode('NO_FILES'));
         }
         return do_template('BULK_HELPER_RESULTS_SCREEN', array('_GUID' => '5d373553cf21a58f15006bd4e600a9ee', 'TITLE' => $title, 'RESULTS' => $out));
     }
 }
Beispiel #5
0
/**
 * Function to quickly (efficiently) check to see if there's been any chat activity.
 */
function chat_poller()
{
    $message_id = get_param_integer('message_id', -1);
    $event_id = get_param_integer('event_id', -1);
    if (file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') && filemtime(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat') > time() - 3 && ($message_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_msg.dat', FILE_TEXT)) <= $message_id) && ($event_id != -1 && file_exists(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat') && intval(file_get_contents(get_custom_file_base() . '/data_custom/modules/chat/chat_last_event.dat', FILE_TEXT)) <= $event_id)) {
        load_user_stuff();
        require_code('zones');
        // Zone is needed because zones are where all ocPortal pages reside
        require_code('config');
        // Config is needed for much active stuff
        require_code('users');
        // Users are important due to permissions
        $room_id = get_param_integer('room_id', -1);
        require_code('chat');
        chat_room_prune($room_id);
        header("Cache-Control: no-cache, must-revalidate");
        // HTTP/1.1
        header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
        // Date in the past
        header('Content-Type: application/xml');
        $output = '<?xml version="1.0" encoding="' . get_charset() . '" ?' . '>
			<response>
				<result>
					<chat_null>' . strval($room_id) . '</chat_null>
				</result>
			</response>';
        exit($output);
    }
    touch(get_custom_file_base() . '/data_custom/modules/chat/chat_last_full_check.dat');
}
Beispiel #6
0
 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('catalogues');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_fields');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_categories');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_entries');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_long_trans');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_short_trans');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_long');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_short');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_float');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_efv_integer');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_entry_linkage');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_cat_treecache');
     $GLOBALS['SITE_DB']->drop_if_exists('catalogue_childcountcache');
     $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'catalogues_category'));
     $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'catalogues_catalogue'));
     $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'catalogues'));
     deldir_contents(get_custom_file_base() . '/uploads/catalogues', true);
     delete_specific_permission('high_catalogue_entry_timeout');
     delete_menu_item_simple('_SEARCH:catalogues:type=misc');
     $cf = $GLOBALS['SITE_DB']->query_value_null_ok('menu_items', 'id', array('i_menu' => 'collab_features', 'i_url' => ''));
     if (!is_null($cf)) {
         delete_menu_item($cf);
     }
     delete_menu_item_simple('_SEARCH:catalogues:id=projects:type=index');
     delete_menu_item_simple('_SEARCH:cms_catalogues:catalogue_name=projects:type=add_entry');
 }
Beispiel #7
0
 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('download_categories');
     $GLOBALS['SITE_DB']->drop_if_exists('download_downloads');
     $GLOBALS['SITE_DB']->drop_if_exists('download_logging');
     $GLOBALS['SITE_DB']->drop_if_exists('download_licences');
     delete_config_option('maximum_download');
     delete_config_option('is_on_downloads');
     delete_config_option('show_dload_trees');
     delete_config_option('points_ADD_DOWNLOAD');
     delete_config_option('downloads_show_stats_count_total');
     delete_config_option('downloads_show_stats_count_archive');
     delete_config_option('downloads_show_stats_count_downloads');
     delete_config_option('downloads_show_stats_count_bandwidth');
     delete_config_option('immediate_downloads');
     delete_config_option('download_gallery_root');
     $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'downloads'));
     $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'downloads'));
     delete_value('download_bandwidth');
     delete_value('archive_size');
     delete_value('num_archive_downloads');
     delete_value('num_downloads_downloaded');
     deldir_contents(get_custom_file_base() . '/uploads/downloads', true);
     delete_menu_item_simple('_SEARCH:downloads:type=misc');
 }
Beispiel #8
0
/**
 * Get the list of files that need CHmodding for write access.
 *
 * @return array			The list of files
 */
function get_chmod_array()
{
    global $LANG;
    //	if ((function_exists('ocp_enterprise')) && (ocp_enterprise()))
    //	{
    $extra_files = array('collaboration/pages/html_custom', 'collaboration/pages/html_custom/' . $LANG, 'collaboration/pages/comcode_custom', 'collaboration/pages/comcode_custom/' . $LANG);
    //	} else $extra_files=array();
    if (function_exists('find_all_hooks')) {
        $hooks = find_all_hooks('systems', 'addon_registry');
        $hook_keys = array_keys($hooks);
        foreach ($hook_keys as $hook) {
            //require_code('hooks/systems/addon_registry/'.filter_naughty_harsh($hook));
            //$object=object_factory('Hook_addon_registry_'.filter_naughty_harsh($hook));
            //$extra_files=array_merge($extra_files,$object->get_chmod_array());
            // Save memory compared to above commented code...
            $path = get_custom_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            if (!file_exists($path)) {
                $path = get_file_base() . '/sources/hooks/systems/addon_registry/' . filter_naughty_harsh($hook) . '.php';
            }
            $matches = array();
            if (preg_match('#function get_chmod_array\\(\\)\\s*\\{([^\\}]*)\\}#', file_get_contents($path), $matches) != 0) {
                if (!defined('HIPHOP_PHP')) {
                    $extra_files = array_merge($extra_files, eval($matches[1]));
                } else {
                    require_code('hooks/systems/addon_registry/' . $hook);
                    $hook = object_factory('Hook_addon_registry_' . $hook);
                    $extra_files = array_merge($extra_files, $hook->get_chmod_array());
                }
            }
        }
    }
    return array_merge($extra_files, array('safe_mode_temp', 'persistant_cache', 'data_custom/modules/admin_backup', 'data_custom/modules/chat', 'data_custom/fields.xml', 'data_custom/breadcrumbs.xml', 'data_custom/modules/admin_stats', 'data_custom/spelling/write.log', 'data_custom/spelling/output.log', 'data_custom/spelling/personal_dicts', 'themes/map.ini', 'text_custom', 'text_custom/' . $LANG, 'data_custom/modules/chat/chat_last_msg.dat', 'data_custom/modules/chat/chat_last_event.dat', 'lang_cached', 'lang_cached/' . $LANG, 'lang_custom', 'lang_custom/' . $LANG, 'data_custom/errorlog.php', 'ocp_sitemap.xml', 'data_custom/permissioncheckslog.php', 'pages/html_custom', 'site/pages/html_custom', 'docs/pages/html_custom', 'adminzone/pages/html_custom', 'forum/pages/html_custom', 'cms/pages/html_custom', 'pages/html_custom/' . $LANG, 'site/pages/html_custom/' . $LANG, 'docs/pages/html_custom/' . $LANG, 'adminzone/pages/html_custom/' . $LANG, 'forum/pages/html_custom/' . $LANG, 'cms/pages/html_custom/' . $LANG, 'pages/comcode_custom', 'site/pages/comcode_custom', 'docs/pages/comcode_custom', 'adminzone/pages/comcode_custom', 'forum/pages/comcode_custom', 'cms/pages/comcode_custom', 'pages/comcode_custom/' . $LANG, 'site/pages/comcode_custom/' . $LANG, 'docs/pages/comcode_custom/' . $LANG, 'adminzone/pages/comcode_custom/' . $LANG, 'forum/pages/comcode_custom/' . $LANG, 'cms/pages/comcode_custom/' . $LANG, 'themes/default/css_custom', 'themes/default/images_custom', 'themes/default/templates_custom', 'themes/default/templates_cached', 'themes/default/templates_cached/' . $LANG, 'themes/default/theme.ini', 'uploads/incoming', 'uploads/website_specific', 'uploads/personal_sound_effects', 'uploads/banners', 'uploads/downloads', 'uploads/galleries', 'uploads/watermarks', 'uploads/grepimages', 'uploads/galleries_thumbs', 'uploads/iotds', 'uploads/iotds_thumbs', 'uploads/catalogues', 'uploads/attachments', 'uploads/attachments_thumbs', 'uploads/auto_thumbs', 'uploads/ocf_avatars', 'uploads/ocf_cpf_upload', 'uploads/ocf_photos', 'uploads/ocf_photos_thumbs', 'uploads/filedump', 'info.php', 'exports/backups', 'exports/file_backups', 'exports/mods', 'imports/mods', 'site/pages/html_custom/' . $LANG . '/download_tree_made.htm', 'site/pages/html_custom/' . $LANG . '/cedi_tree_made.htm'));
}
Beispiel #9
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $val = get_param('name');
     $test = file_exists(get_file_base() . '/themes/' . $val) || file_exists(get_custom_file_base() . '/themes/' . $val);
     if (!$test) {
         return new ocp_tempcode();
     }
     return make_string_tempcode(str_replace(array('&lsquo;', '&rsquo;', '&ldquo;', '&rdquo;'), array('"', '"', '"', '"'), html_entity_decode(do_lang('ALREADY_EXISTS', escape_html($val)), ENT_QUOTES)));
 }
/**
 * A template has not been structurally cached, so compile it and store in the cache.
 *
 * @param  ID_TEXT			The theme the template is in the context of
 * @param  PATH				The path to the template file
 * @param  ID_TEXT			The codename of the template (e.g. foo)
 * @param  ID_TEXT			The actual codename to use for the template (e.g. thin_foo)
 * @param  LANGUAGE_NAME	The language the template is in the context of
 * @param  string				File type suffix of template file
 * @param  ?ID_TEXT			The theme to cache in (NULL: main theme)
 * @return tempcode			The compiled tempcode
 */
function _do_template($theme, $path, $codename, $_codename, $lang, $suffix, $theme_orig = NULL)
{
    if (is_null($theme_orig)) {
        $theme_orig = $theme;
    }
    $base_dir = ($theme == 'default' && ($suffix != '.css' || strpos($path, '/css_custom') === false) ? get_file_base() : get_custom_file_base()) . '/themes/';
    global $CACHE_TEMPLATES, $FILE_ARRAY, $TEMPLATE_PREVIEW_OP, $MEM_CACHE;
    if (isset($FILE_ARRAY)) {
        $html = unixify_line_format(file_array_get('themes/' . $theme . $path . $codename . $suffix));
    } else {
        $html = unixify_line_format(file_get_contents($base_dir . filter_naughty($theme . $path . $codename) . $suffix, FILE_TEXT));
    }
    if (strpos($html, '{$,Parser hint: pure}') !== false) {
        return make_string_tempcode(preg_replace('#\\{\\$,.*\\}#U', '/*no minify*/', $html));
    }
    if ($GLOBALS['SEMI_DEBUG_MODE'] && strpos($html, '.innerHTML') !== false && strpos($html, 'Parser hint: .innerHTML okay') === false) {
        require_code('site');
        attach_message('Do not use the .innerHTML property in your Javascript because it will not work in true XHTML (when the browsers real XML parser is in action). Use ocPortal\'s global setInnerHTML/getInnerHTML functions.', 'warn');
    }
    // Strip off trailing final lines from single lines templates. Editors often put these in, and it causes annoying "visible space" issues
    if (substr($html, -1, 1) == chr(10) && substr_count($html, chr(10)) == 1) {
        $html = substr($html, 0, strlen($html) - 1);
    }
    if ($TEMPLATE_PREVIEW_OP) {
        $test = post_param($codename, NULL);
        if (!is_null($test)) {
            $html = post_param($test . '_new');
        }
    }
    $result = template_to_tempcode($html, 0, false, $codename, $theme, $lang);
    if ($CACHE_TEMPLATES && ($suffix == '.tpl' || $codename == 'no_cache')) {
        if (!is_null($MEM_CACHE)) {
            persistant_cache_set(array('TEMPLATE', $theme, $lang, $_codename), $result->to_assembly(), strpos($path, 'default/templates/') !== false);
        } else {
            $path2 = get_custom_file_base() . '/themes/' . $theme_orig . '/templates_cached/' . filter_naughty($lang) . '/';
            $myfile = @fopen($path2 . filter_naughty($_codename) . $suffix . '.tcd', 'wb');
            if ($myfile === false) {
                if (@mkdir($path2, 0777)) {
                    require_code('files');
                    fix_permissions($path2, 0777);
                } else {
                    if (file_exists($path2 . filter_naughty($_codename) . $suffix . '.tcd')) {
                        warn_exit(do_lang_tempcode('WRITE_ERROR', $path2 . filter_naughty($_codename) . $suffix . '.tcd'));
                    } else {
                        warn_exit(do_lang_tempcode('WRITE_ERROR_CREATE', $path2 . filter_naughty($_codename) . $suffix . '.tcd'));
                    }
                }
            } else {
                fwrite($myfile, $result->to_assembly($lang));
                fclose($myfile);
                fix_permissions($path2 . filter_naughty($_codename) . $suffix . '.tcd');
            }
        }
    }
    return $result;
}
Beispiel #11
0
 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('iotd');
     delete_specific_permission('choose_iotd');
     $GLOBALS['SITE_DB']->query_delete('trackbacks', array('trackback_for_type' => 'iotds'));
     deldir_contents(get_custom_file_base() . '/uploads/iotds', true);
     delete_config_option('points_ADD_IOTD');
     delete_config_option('points_CHOOSE_IOTD');
     delete_config_option('iotd_update_time');
 }
Beispiel #12
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     if (has_actual_page_access(get_member(), 'admin_occle')) {
         require_code('occle');
         require_lang('occle');
         $title = get_page_title('OCCLE');
         return do_template('OCCLE_MAIN', array('COMMANDS' => '', 'SUBMIT_URL' => build_url(array('page' => 'admin_occle'), 'adminzone'), 'PROMPT' => do_lang_tempcode('COMMAND_PROMPT', escape_html($GLOBALS['FORUM_DRIVER']->get_username(get_member())))));
     }
     return new ocp_tempcode();
 }
function run()
{
    $file = basename(rawurldecode($_GET['url']));
    //get old media file data
    $get_old_file = $GLOBALS['SITE_DB']->query('SELECT url FROM ' . get_table_prefix() . 'videos WHERE url LIKE "uploads/galleries/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
    $type = 'galleries';
    if (!array_key_exists(0, $get_old_file)) {
        $get_old_file = $GLOBALS['SITE_DB']->query('SELECT a_url AS url FROM ' . get_table_prefix() . 'attachments WHERE a_url LIKE "uploads/attachments/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
        $type = 'attachments';
        if (!array_key_exists(0, $get_old_file)) {
            $get_old_file = $GLOBALS['SITE_DB']->query('SELECT cv_value AS url FROM ' . get_table_prefix() . 'catalogue_efv_short WHERE cv_value LIKE "uploads/catalogues/' . rawurlencode(basename(basename($file, '.m4v'), '.mp3')) . '%"');
            $type = 'catalogues';
        }
    }
    require_code('files');
    $file_handle = @fopen(get_custom_file_base() . '/uploads/' . $type . '/' . $file, 'wb') or intelligent_write_error(get_custom_file_base() . '/uploads/' . $type . '/' . $file);
    http_download_file($_GET['url'], NULL, false, false, 'ocPortal', NULL, NULL, NULL, NULL, NULL, $file_handle, NULL, NULL, 6.0);
    fclose($file_handle);
    //move the old media file to the archive directory - '/uploads/'.$type.'/archive/'
    $new_url = 'uploads/' . $type . '/' . rawurlencode($file);
    if (isset($get_old_file[0]['url']) && is_string($get_old_file[0]['url']) && $get_old_file[0]['url'] != $new_url && strlen($get_old_file[0]['url']) > 0) {
        $movedir = dirname(str_replace('/uploads/' . $type . '/', '/uploads/' . $type . '_archive_addon/', str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url'])));
        @mkdir($movedir, 0777);
        require_code('files');
        fix_permissions($movedir, 0777);
        rename(str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url']), str_replace('/uploads/' . $type . '/', '/uploads/' . $type . '_archive_addon/', str_replace('\\', '/', get_custom_file_base()) . '/' . rawurldecode($get_old_file[0]['url'])));
    }
    switch ($type) {
        case 'galleries':
            $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'videos SET video_width=600,video_height=400,url="' . db_escape_string($new_url) . '" WHERE url LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
            // Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
            break;
        case 'attachments':
            $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'attachments SET a_url="' . db_escape_string($new_url) . '" WHERE a_url LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
            // Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
            break;
        case 'catalogues':
            $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'catalogue_efv_short SET cv_value="' . db_escape_string($new_url) . '" WHERE cv_value LIKE "uploads/' . $type . '/' . db_escape_string(rawurlencode(basename(basename($file, '.m4v'), '.mp3'))) . '%"');
            // Replaces row that referenced $file without .m4v on the end (the original filename) with row that references the new $file we just copied
            break;
    }
    $transcoding_server = get_option('transcoding_server', true);
    if (is_null($transcoding_server)) {
        //add option and default value
        add_config_option('TRANSCODING_SERVER', 'transcoding_server', 'line', 'return \'http://localhost/convertor\';', 'FEATURE', 'GALLERIES');
        $transcoding_server = get_option('transcoding_server', true);
    }
    file_get_contents($transcoding_server . '/move_to_sent.php?file=' . $_GET['url']);
}
Beispiel #14
0
 /**
  * Create filename-mirrored thumbnails for the given directory stub (mirrors stub/foo with stub_thumbs/foo).
  *
  * @param  string		Directory to mirror
  */
 function directory_thumb_mirror($dir)
 {
     require_code('images');
     $full = get_custom_file_base() . '/uploads/' . $dir;
     $dh = @opendir($full);
     if ($dh !== false) {
         while (($file = readdir($dh)) !== false) {
             $target = get_custom_file_base() . '/' . $dir . '_thumbs/' . $file;
             if (!file_exists($target) && is_image($full . '/' . $file)) {
                 require_code('images');
                 convert_image($full . '/' . $file, $target, -1, -1, intval(get_option('thumb_width')));
             }
         }
     }
     closedir($dh);
 }
 /**
  * Standard modular run function.
  *
  * @return tempcode	Results
  */
 function run()
 {
     $GLOBALS['SITE_DB']->query('DELETE FROM ' . get_table_prefix() . 'theme_images WHERE path LIKE \'themes/%/images/%\'');
     persistant_cache_delete('THEME_IMAGES');
     $paths = $GLOBALS['SITE_DB']->query_select('theme_images', array('path', 'id'));
     foreach ($paths as $path) {
         if ($path['path'] == '') {
             $GLOBALS['SITE_DB']->query_delete('theme_images', $path, '', 1);
         } elseif (preg_match('#^themes/[^/]+/images_custom/+' . str_replace('#', '\\#', preg_quote($path['id'])) . '\\.#', $path['path']) != 0) {
             if (!file_exists(get_custom_file_base() . '/' . $path['path']) && !file_exists(get_file_base() . '/' . $path['path'])) {
                 $GLOBALS['SITE_DB']->query_delete('theme_images', $path, '', 1);
             }
         }
     }
     return new ocp_tempcode();
 }
Beispiel #16
0
 /**
  * Standard modular run function for do_next_menu hooks. They find links to put on standard navigation menus of the system.
  *
  * @return array			Array of links and where to show
  */
 function run()
 {
     $has_langs = false;
     $_dir = opendir(get_file_base() . '/lang/');
     $_langs = array();
     while (false !== ($file = readdir($_dir))) {
         if ($file == fallback_lang()) {
             continue;
         }
         if (!should_ignore_file('lang/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
             if (is_dir(get_file_base() . '/lang/' . $file)) {
                 $has_langs = true;
             }
         }
     }
     closedir($_dir);
     if (!in_safe_mode()) {
         $_dir = @opendir(get_custom_file_base() . '/lang_custom/');
         if ($_dir !== false) {
             while (false !== ($file = readdir($_dir))) {
                 if ($file == fallback_lang()) {
                     continue;
                 }
                 if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                     if (is_dir(get_custom_file_base() . '/lang_custom/' . $file)) {
                         $has_langs = true;
                     }
                 }
             }
             closedir($_dir);
         }
         if (get_custom_file_base() != get_file_base()) {
             $_dir = opendir(get_file_base() . '/lang_custom/');
             while (false !== ($file = readdir($_dir))) {
                 if ($file == fallback_lang()) {
                     continue;
                 }
                 if (!should_ignore_file('lang_custom/' . $file, IGNORE_ACCESS_CONTROLLERS) && strlen($file) <= 5) {
                     $has_langs = true;
                 }
             }
             closedir($_dir);
         }
     }
     return array(array('style', 'language', array('admin_lang', array('type' => 'misc'), get_module_zone('admin_lang')), do_lang_tempcode('TRANSLATE_CODE'), 'DOC_TRANSLATE'), multi_lang() ? array('style', 'language', array('admin_lang', array('type' => 'content'), get_module_zone('admin_lang')), do_lang_tempcode('TRANSLATE_CONTENT'), 'DOC_TRANSLATE_CONTENT') : NULL, !$has_langs ? NULL : array('style', 'criticise_language', array('admin_lang', array('type' => 'criticise'), get_module_zone('admin_lang')), do_lang_tempcode('CRITICISE_LANGUAGE_PACK'), 'DOC_CRITICISE_LANGUAGE_PACK'));
 }
Beispiel #17
0
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     if (function_exists('set_time_limit')) {
         @set_time_limit(0);
     }
     require_code('files');
     require_code('files2');
     $size = 0;
     $max_size = get_param_integer('max_size') * 1024 * 1024;
     $files = get_directory_contents(get_custom_file_base());
     foreach ($files as $file) {
         $filesize = filesize(get_custom_file_base() . '/' . $file);
         if ($filesize < $max_size) {
             $size += $filesize;
         }
     }
     return make_string_tempcode(clean_file_size($size));
 }
Beispiel #18
0
 /**
  * Standard function to create the standardised category tree
  *
  * @param  ID_TEXT		Notification code
  * @param  ?ID_TEXT		The ID of where we're looking under (NULL: N/A)
  * @return array 			Tree structure
  */
 function create_category_tree($notification_code, $id)
 {
     require_code('files2');
     $path = get_custom_file_base() . '/uploads/filedump';
     if (!is_null($id)) {
         $path .= '/' . $id;
     }
     $files = get_directory_contents($path, '', false, false);
     if (count($files) > 30) {
         return array();
     }
     // Too many, so don't show
     $pagelinks = array();
     foreach ($files as $file) {
         if (is_dir($path . '/' . $file)) {
             $pagelinks[] = array('id' => ($id == '' ? '' : $id . '/') . $file, 'title' => $file, 'child_count' => count($this->create_category_tree($notification_code, ($id == '' ? '' : $id . '/') . $file)));
         }
     }
     return $pagelinks;
 }
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     require_lang('newsletter');
     require_lang('javascript');
     $newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
     $_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id));
     if (is_null($_newsletter_title)) {
         return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $newsletter_title = get_translated_text($_newsletter_title);
     $address = post_param('address' . strval($newsletter_id), '');
     if ($address != '') {
         require_code('newsletter');
         require_code('type_validation');
         if (!is_valid_email_address($address)) {
             $msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS')));
             return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg));
         }
         if (!array_key_exists('path', $map)) {
             $map['path'] = 'uploads/website_specific/signup.txt';
         }
         require_code('character_sets');
         $password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), ''));
         if ($password == '') {
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO')));
         }
         if ($password == do_lang('NA')) {
             $manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter'));
             return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate()))));
         }
         require_code('mail');
         if (file_exists(get_custom_file_base() . '/' . $map['path'])) {
             $url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path'];
             mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true);
         }
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password));
     } else {
         return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url()));
     }
 }
Beispiel #20
0
/**
 * Log permission checks to the permission_checks.log file, if it exists.
 *
 * @param  MEMBER         The user checking against
 * @param  ID_TEXT        The function that was called to check a permission
 * @param  array          Parameters to this permission-checking function
 * @param  boolean        Whether the permission was held
 */
function handle_permission_check_logging($member, $op, $params, $result)
{
    global $PERMISSION_CHECK_LOGGER, $PERMISSIONS_ALREADY_LOGGED, $SITE_INFO;
    if ($PERMISSION_CHECK_LOGGER === NULL) {
        $file_path = get_custom_file_base() . '/data_custom/permissioncheckslog.php';
        if ((!isset($SITE_INFO['no_extra_logs']) || $SITE_INFO['no_extra_logs'] == '0') && is_file($file_path) && is_writable_wrap($file_path)) {
            $PERMISSION_CHECK_LOGGER = fopen($file_path, 'at');
            if (!function_exists('get_self_url')) {
                require_code('tempcode');
                require_code('urls');
            }
            $self_url = get_self_url(true);
            if (!is_string($self_url)) {
                $self_url = get_self_url_easy();
            }
            // A weirdness can happen here. If some kind of fatal error happens then output buffers can malfunction making it impossible to use Tempcode as above. So we fall back to this. (This function may be called in a fatal error due to the 'display_php_errors' permissions).
            fwrite($PERMISSION_CHECK_LOGGER, chr(10) . chr(10) . date('Y/m/d h:m:i') . ' -- ' . $self_url . ' -- ' . $GLOBALS['FORUM_DRIVER']->get_username(get_member()) . chr(10));
        } else {
            $PERMISSION_CHECK_LOGGER = false;
        }
    }
    static $fbe = NULL;
    if ($fbe === NULL) {
        $fbe = function_exists('fb');
    }
    if ($PERMISSION_CHECK_LOGGER === false && (!$fbe || get_param_integer('keep_firephp', 0) == 0)) {
        return;
    }
    $sz = serialize(array($member, $op, $params));
    if (array_key_exists($sz, $PERMISSIONS_ALREADY_LOGGED)) {
        return;
    }
    $PERMISSIONS_ALREADY_LOGGED[$sz] = 1;
    if ($result) {
        return;
    }
    require_code('permissions2');
    _handle_permission_check_logging($member, $op, $params, $result);
}
Beispiel #21
0
 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $GLOBALS['SITE_DB']->drop_if_exists('w_attempts');
     $GLOBALS['SITE_DB']->drop_if_exists('w_inventory');
     $GLOBALS['SITE_DB']->drop_if_exists('w_itemdef');
     $GLOBALS['SITE_DB']->drop_if_exists('w_items');
     $GLOBALS['SITE_DB']->drop_if_exists('w_members');
     $GLOBALS['SITE_DB']->drop_if_exists('w_messages');
     $GLOBALS['SITE_DB']->drop_if_exists('w_portals');
     $GLOBALS['SITE_DB']->drop_if_exists('w_realms');
     $GLOBALS['SITE_DB']->drop_if_exists('w_rooms');
     $GLOBALS['SITE_DB']->drop_if_exists('w_travelhistory');
     deldir_contents(get_custom_file_base() . '/uploads/ocworld', true);
     require_code('ocworld');
     if (addon_installed('pointstore')) {
         $prices = get_ocworld_prices_default();
         foreach (array_keys($prices) as $name) {
             $GLOBALS['SITE_DB']->query_delete('prices', array('name' => $name), '', 1);
         }
     }
     delete_specific_permission('administer_ocworld');
 }
Beispiel #22
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/ssl';
     $GLOBALS['HELPER_PANEL_TUTORIAL'] = 'tut_security';
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     require_lang('security');
     if (get_option('enable_https') == '0') {
         $_config_url = build_url(array('page' => 'admin_config', 'type' => 'category', 'id' => 'SECURITY'), get_module_zone('admin_config'));
         $config_url = $_config_url->evaluate();
         inform_exit(do_lang_tempcode('HTTPS_DISABLED', escape_html($config_url . '#group_GENERAL')));
     }
     $type = get_param('type', 'misc');
     if ($type == 'set') {
         return $this->set();
     }
     if ($type == 'misc') {
         return $this->ssl_interface();
     }
     return new ocp_tempcode();
 }
Beispiel #23
0
 /**
  * Standard modular run function.
  *
  * @param  array		A map of parameters.
  * @return tempcode	The result of execution.
  */
 function run($map)
 {
     if (!array_key_exists('param', $map)) {
         return do_lang_tempcode('NO_PARAMETER_SENT', 'param');
     }
     // can't function like that
     require_css('side_blocks');
     $type = array_key_exists('type', $map) ? $map['type'] : 'tree';
     $silent_failure = array_key_exists('silent_failure', $map) ? $map['silent_failure'] : '0';
     $tray_status = array_key_exists('tray_status', $map) ? $map['tray_status'] : '';
     if ($type != 'tree') {
         $exists = file_exists(get_file_base() . '/themes/default/templates/MENU_BRANCH_' . $type . '.tpl');
         if (!$exists) {
             $exists = file_exists(get_custom_file_base() . '/themes/default/templates_custom/MENU_BRANCH_' . $type . '.tpl');
         }
         $theme = $GLOBALS['FORUM_DRIVER']->get_theme();
         if (!$exists && $theme != 'default') {
             $exists = file_exists(get_custom_file_base() . '/themes/' . $theme . '/templates/MENU_BRANCH_' . $type . '.tpl');
             if (!$exists) {
                 $exists = file_exists(get_custom_file_base() . '/themes/' . $theme . '/templates_custom/MENU_BRANCH_' . $type . '.tpl');
             }
         }
         if (!$exists) {
             $type = 'tree';
         }
     }
     require_code('menus');
     $menu = build_stored_menu($type, $map['param'], $silent_failure == '1');
     $menu->handle_symbol_preprocessing();
     // Optimisation: we are likely to have lots of page-links in here, so we want to spawn them to be detected for mass moniker loading
     if ($menu->is_empty()) {
         return new ocp_tempcode();
     }
     if (array_key_exists('caption', $map) && $map['caption'] != '') {
         $menu = do_template('BLOCK_SIDE_STORED_MENU', array('_GUID' => 'ae46aa37a9c5a526f43b26a391164436', 'CONTENT' => $menu, 'PARAM' => $map['param'], 'TRAY_STATUS' => $tray_status, 'CAPTION' => $map['caption']));
     }
     return $menu;
 }
Beispiel #24
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (get_file_base() != get_custom_file_base()) {
         warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     }
     require_lang('menus');
     get_page_title('PHP_INFO');
     $GLOBALS['SCREEN_TEMPLATE_CALLED'] = '';
     $GLOBALS['TITLE_CALLED'] = true;
     require_lang('menus');
     $GLOBALS['HELPER_PANEL_TEXT'] = comcode_lang_string('DOC_PHP_INFO');
     ob_start();
     phpinfo();
     require_code('xhtml');
     $out = xhtmlise_html(ob_get_contents());
     ob_end_clean();
     $out = preg_replace('#<!DOCTYPE[^>]*>#s', '', preg_replace('#</body[^>]*>#', '', preg_replace('#<body[^>]*>#', '', preg_replace('#</html[^>]*>#', '', preg_replace('#<html[^>]*>#', '', $out)))));
     $matches = array();
     if (preg_match('#<style[^>]*>#', $out, $matches) != 0) {
         $offset = strpos($out, $matches[0]) + strlen($matches[0]);
         $end = strpos($out, '</style>', $offset);
         if ($end !== false) {
             $style = substr($out, $offset - strlen($matches[0]), $end - $offset + strlen('</style>') + strlen($matches[0]));
             //$GLOBALS['EXTRA_HEAD']=make_string_tempcode($style);
             $out = substr($out, 0, $offset) . substr($out, $end);
         }
     }
     $out = preg_replace('#<head[^>]*>.*</head[^>]*>#s', '', $out);
     $out = str_replace(' width="600"', ' width="100%"', $out);
     $out = preg_replace('#([^\\s<>"\']{65}&[^;]+;)#', '${1}<br />', $out);
     $out = preg_replace('#([^\\s<>"\']{95})#', '${1}<br />', $out);
     $url_parts = parse_url(get_base_url());
     $out = str_replace('<img border="0" src="/', '<img border="0" style="padding-top: 20px" src="http://' . escape_html($url_parts['host']) . '/', $out);
     require_css('phpinfo');
     require_code('xhtml');
     $ret = make_string_tempcode(xhtmlise_html($out));
     return $ret;
 }
Beispiel #25
0
 /**
  * Standard modular run function.
  *
  * @return tempcode	The result of execution.
  */
 function run()
 {
     if (!addon_installed('filedump')) {
         return new ocp_tempcode();
     }
     if (!file_exists(get_custom_file_base() . '/uploads/filedump')) {
         return new ocp_tempcode();
     }
     require_lang('filedump');
     require_code('files2');
     $bits = new ocp_tempcode();
     if (get_option('filedump_show_stats_count_total_files', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('COUNT_FILES'), 'VALUE' => integer_format(count(get_directory_contents(get_custom_file_base() . '/uploads/filedump'))))));
     }
     if (get_option('filedump_show_stats_count_total_space', true) == '1') {
         $bits->attach(do_template('BLOCK_SIDE_STATS_SUBLINE', array('KEY' => do_lang_tempcode('DISK_USAGE'), 'VALUE' => clean_file_size(get_directory_size(get_custom_file_base() . '/uploads/filedump')))));
     }
     if ($bits->is_empty()) {
         return new ocp_tempcode();
     }
     $section = do_template('BLOCK_SIDE_STATS_SECTION', array('SECTION' => do_lang_tempcode('FILE_DUMP'), 'CONTENT' => $bits));
     return $section;
 }
 /**
  * Standard modular run function for snippet hooks. Generates XHTML to insert into a page using AJAX.
  *
  * @return tempcode  The snippet
  */
 function run()
 {
     $theme = get_param('theme');
     $equation = get_param('css_equation');
     require_code('themewizard');
     $css_path = get_custom_file_base() . '/themes/' . $theme . '/css_custom/global.css';
     if (!file_exists($css_path)) {
         $css_path = get_file_base() . '/themes/default/css/global.css';
     }
     $css_file_contents = file_get_contents($css_path, FILE_TEXT);
     $seed = find_theme_seed($theme);
     $dark = strpos($css_file_contents, '#000000; /* {$,wizard, 100% W/B} */') !== false;
     $colours = calculate_theme($seed, $theme, 'equations', 'colours', $dark);
     $parsed_equation = parse_css_colour_expression($equation);
     if (is_null($parsed_equation)) {
         return make_string_tempcode('');
     }
     $answer = execute_css_colour_expression($parsed_equation, $colours[0]);
     if (is_null($answer)) {
         return make_string_tempcode('');
     }
     return make_string_tempcode('#' . $answer);
 }
Beispiel #27
0
/**
 * Get the currently used download bandwidth.
 *
 * @return integer		The currently used download bandwidth (forever)
 */
function get_download_bandwidth()
{
    $value = intval(get_value_newer_than('download_bandwidth', time() - 60 * 60 * 24));
    if ($value == 0) {
        $total = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'COUNT(*)', array('validated' => 1));
        if ($total > 200) {
            $value = $GLOBALS['SITE_DB']->query_value_null_ok('download_downloads', 'SUM(file_size*num_downloads)', array('validated' => 1));
        } else {
            $value = 0;
            $rows = $GLOBALS['SITE_DB']->query_select('download_downloads', array('url', 'num_downloads'), array('validated' => 1));
            foreach ($rows as $myrow) {
                if (url_is_local($myrow['url'])) {
                    $file = get_custom_file_base() . '/' . rawurldecode($myrow['url']);
                    if (file_exists($file)) {
                        $value += filesize($file) * $myrow['num_downloads'];
                    }
                }
            }
            set_value('download_bandwidth', strval($value));
        }
    }
    return $value;
}
Beispiel #28
0
/**
 * Delete the specified attachment
 *
 * @param  AUTO_LINK		The attachment ID to delete
 * @param  object			The database connection to use
 * @set    ocp forum
 */
function _delete_attachment($id, $connection)
{
    $connection->query_delete('attachment_refs', array('a_id' => $id));
    // Get attachment details
    $_attachment_info = $connection->query_select('attachments', array('a_url', 'a_thumb_url'), array('id' => $id), '', 1);
    if (!array_key_exists(0, $_attachment_info)) {
        return;
    }
    // Already gone
    $attachment_info = $_attachment_info[0];
    // Delete url and thumb_url if local
    if (url_is_local($attachment_info['a_url']) && substr($attachment_info['a_url'], 0, 19) == 'uploads/attachments') {
        $url = rawurldecode($attachment_info['a_url']);
        @unlink(get_custom_file_base() . '/' . $url);
        sync_file($url);
        if ($attachment_info['a_thumb_url'] != '' && strpos($attachment_info['a_thumb_url'], 'uploads/filedump/') === false) {
            $thumb_url = rawurldecode($attachment_info['a_thumb_url']);
            @unlink(get_custom_file_base() . '/' . $thumb_url);
            sync_file($thumb_url);
        }
    }
    // Delete attachment
    $connection->query_delete('attachments', array('id' => $id), '', 1);
}
 Copyright (c) ocProducts, 2004-2012
 See text/EN/licence.txt for full licencing information.
 NOTE TO PROGRAMMERS:
   Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
   **** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
*/
/*
Used to generate a database schema in the form of SQL code that can be imported into MySQL Workbench

First run this, then run SQLEditor on the files created in uploads/website_specific.
*/
require_code('relations');
$all_tables = get_all_tables();
$tables_by = get_tables_by_addon();
foreach ($tables_by as $t => $ts) {
    $path = get_custom_file_base() . '/uploads/website_specific/ocportal_erd__' . $t . '.sql';
    $myfile = fopen($path, 'wt');
    $tables = array();
    foreach ($ts as $table) {
        if (!array_key_exists($table, $all_tables)) {
            continue;
        }
        // Not installed
        $tables[$table] = $all_tables[$table];
    }
    fwrite($myfile, get_innodb_table_sql($tables, $all_tables));
    fclose($myfile);
    fix_permissions($path);
    sync_file($path);
}
$GLOBALS['SCREEN_TEMPLATE_CALLED'] = '';
 /**
  * (Plug-in replacement for memcache API) Remove all data from the persistant cache.
  */
 function flush()
 {
     $d = opendir(get_custom_file_base() . '/persistant_cache');
     while (($e = readdir($d)) !== false) {
         if (substr($e, -4) == '.gcd') {
             // Ideally we'd lock whilst we delete, but it's not stable (and the workaround would be too slow for our efficiency context). So some people reading may get errors whilst we're clearing the cache. Fortunately this is a rare op to perform.
             @unlink(get_custom_file_base() . '/persistant_cache/' . $e);
         }
     }
     closedir($d);
 }