/**
  * This will get the XML file from ocportal.com.
  *
  * @param  ?ID_TEXT		The ID to do under (NULL: root)
  * @return string			The XML file
  */
 function get_file($id)
 {
     $stub = get_param_integer('localhost', 0) == 1 ? get_base_url() : 'http://ocportal.com';
     $v = 'Version ' . float_to_raw_string(ocp_version_number(), 1);
     if (!is_null($id)) {
         $v = $id;
     }
     $url = $stub . '/data/ajax_tree.php?hook=choose_download&id=' . rawurlencode($v) . '&file_type=tar';
     require_code('character_sets');
     $contents = http_download_file($url);
     $utf = $GLOBALS['HTTP_CHARSET'] == 'utf-8';
     // We have to use 'U' in the regexp to work around a Chrome parser bug (we can't rely on convert_to_internal_encoding being 100% correct)
     require_code('character_sets');
     $contents = convert_to_internal_encoding($contents);
     $contents = preg_replace('#^\\s*\\<' . '\\?xml version="1.0" encoding="[^"]*"\\?' . '\\>\\<request\\>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#</request>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*has_children="false"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     $contents = preg_replace('#<category [^>]*title="Manual install required"[^>]*>[^>]*</category>#' . ($utf ? 'U' : ''), '', $contents);
     return $contents;
 }
Exemplo n.º 2
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)
 {
     require_code('version');
     require_code('version2');
     require_lang('version');
     if (array_key_exists('h', $options) || array_key_exists('help', $options)) {
         return array('', do_command_help('version', array('h', 'f', 't', 'v', 'm'), array()), '', '');
     } elseif (array_key_exists('f', $options) || array_key_exists('future', $options)) {
         return array('', get_future_version_information(), '', '');
     } elseif (array_key_exists('t', $options) || array_key_exists('time', $options)) {
         return array('', '', ocp_version_time(), '');
     } elseif ((array_key_exists('v', $options) || array_key_exists('major-version', $options)) && (!array_key_exists('m', $options) && !array_key_exists('minor-version', $options))) {
         return array('', '', ocp_version(), '');
     } elseif ((array_key_exists('m', $options) || array_key_exists('minor-version', $options)) && (!array_key_exists('v', $options) && !array_key_exists('major-version', $options))) {
         return array('', '', ocp_version_minor(), '');
     } elseif ((array_key_exists('g', $options) || array_key_exists('general-version', $options)) && (!array_key_exists('v', $options) && !array_key_exists('major-version', $options))) {
         return array('', '', ocp_version_number(), '');
     } else {
         return array('', '', ocp_version_full(), '');
     }
 }
Exemplo n.º 3
0
 /**
  * Get the version of ocPortal this addon is for
  *
  * @return float			Version number
  */
 function get_version()
 {
     return ocp_version_number();
 }
Exemplo n.º 4
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)
 {
     if ($upgrade_from < 3 || is_null($upgrade_from)) {
         add_config_option('MOD_REWRITE', 'mod_rewrite', 'tick', 'return \'' . (in_array(ocp_srv('HTTP_HOST'), array('test.ocportal.com')) ? '1' : '0') . '\'; /*function_exists(\'apache_get_modules\')?\'1\':\'0\';*/', 'SITE', 'ADVANCED');
     }
     if ($upgrade_from < 4 || is_null($upgrade_from)) {
         add_config_option('SESSION_EXPIRY_TIME', 'session_expiry_time', 'integer', 'return \'1\';', 'SECURITY', 'GENERAL');
     }
     if ($upgrade_from < 5 || is_null($upgrade_from)) {
         add_config_option('TRACKBACKS', 'is_on_trackbacks', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('UNZIP_DIR', 'unzip_dir', 'line', 'return (DIRECTORY_SEPARATOR==\'/\')?\'/tmp/\':ocp_srv(\'TMP\');', 'SITE', 'ARCHIVES', 1);
         add_config_option('UNZIP_CMD', 'unzip_cmd', 'line', 'return \'/usr/bin/unzip -o @_SRC_@ -x -d @_DST_@\';', 'SITE', 'ARCHIVES', 1);
         add_config_option('ENABLED', 'smtp_sockets_use', 'tick', 'return \'0\';', 'SITE', 'SMTP', 1);
         add_config_option('HOST', 'smtp_sockets_host', 'line', 'return \'mail.yourispwhateveritis.net\';', 'SITE', 'SMTP', 1);
         add_config_option('PORT', 'smtp_sockets_port', 'line', 'return \'25\';', 'SITE', 'SMTP', 1);
         add_config_option('USERNAME', 'smtp_sockets_username', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('PASSWORD', 'smtp_sockets_password', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('EMAIL_ADDRESS', 'smtp_from_address', 'line', 'return \'\';', 'SITE', 'SMTP', 1);
         add_config_option('USE_SECURITY_IMAGES', 'use_security_images', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'GENERAL');
         add_config_option('HTTPS_SUPPORT', 'enable_https', 'tick', 'return \'0\';', 'SECURITY', 'GENERAL', 1);
         add_config_option('SEND_ERROR_EMAILS_OCPRODUCTS', 'send_error_emails_ocproducts', 'tick', 'return \'' . strval(post_param_integer('allow_reports_default', 0)) . '\';', 'SITE', 'ADVANCED', 1);
         add_config_option('LOW_DISK_SPACE_SUBJECT', 'low_space_check', 'integer', 'return \'20\';', 'SITE', 'GENERAL');
         // 20MB - very very low even for lame web hosts
         add_config_option('DETECT_LANG_FORUM', 'detect_lang_forum', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('DETECT_LANG_BROWSER', 'detect_lang_browser', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
     }
     if ($upgrade_from < 7 && !is_null($upgrade_from)) {
         $GLOBALS['SITE_DB']->query_update('config', array('eval' => 'return has_no_forum()?NULL:do_template(\'COMMENTS_DEFAULT_TEXT\');'), array('the_name' => 'comment_text'), '', 1);
         if ($GLOBALS['OPTIONS']['comment_text']['c_set'] == 0) {
             $tpl = do_template('COMMENTS_DEFAULT_TEXT');
             set_option('comment_text', $tpl->evaluate());
         }
         delete_config_option('width_left');
         delete_config_option('width_right');
         set_option('welcome_message', '[html]' . get_option('welcome_message') . '[/html]');
         set_option('closed', '[html]' . get_option('closed') . '[/html]');
         delete_config_option('xhtml_validation');
     }
     if (is_null($upgrade_from) || $upgrade_from < 7) {
         add_config_option('ALLOW_AUDIO_VIDEOS', 'allow_audio_videos', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('VALIDATION', 'validation', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         /*(((substr(ocp_srv('HTTP_HOST'),0,8)=='192.168.') || (substr(ocp_srv('HTTP_HOST'),0,7)=='10.0.0.') || (in_array(ocp_srv('HTTP_HOST'),array('localhost','test.ocportal.com'))))?'1':'0')*/
         // return (!function_exists(\'memory_get_usage()\') || (ini_get(\'memory_limit\')!=\'8M\'))?\'1\':\'0\';
         add_config_option('VALIDATION_XHTML', 'validation_xhtml', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_WCAG', 'validation_wcag', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_CSS', 'validation_css', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_JAVASCRIPT', 'validation_javascript', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_COMPAT', 'validation_compat', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('VALIDATION_EXT_FILES', 'validation_ext_files', 'tick', 'return \'0\';', 'SITE', 'VALIDATION', 1);
         add_config_option('MAX_SIZE', 'max_download_size', 'integer', 'return \'20000\';', 'SITE', 'UPLOAD');
     }
     if (is_null($upgrade_from) || $upgrade_from < 8) {
         // TODO: Move these into sms addon_registry hook, once these hooks support installation
         add_config_option('USERNAME', 'sms_username', 'line', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('PASSWORD', 'sms_password', 'line', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('API_ID', 'sms_api_id', 'integer', 'return addon_installed(\'sms\')?\'\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_LOW_LIMIT', 'sms_low_limit', 'integer', 'return addon_installed(\'sms\')?\'10\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_HIGH_LIMIT', 'sms_high_limit', 'integer', 'return addon_installed(\'sms\')?\'20\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_LOW_TRIGGER_LIMIT', 'sms_low_trigger_limit', 'integer', 'return addon_installed(\'sms\')?\'50\':NULL;', 'FEATURE', 'SMS');
         add_config_option('SMS_HIGH_TRIGGER_LIMIT', 'sms_high_trigger_limit', 'integer', 'return addon_installed(\'sms\')?\'100\':NULL;', 'FEATURE', 'SMS');
         add_config_option('ALLOWED_POST_SUBMITTERS', 'allowed_post_submitters', 'text', 'return \'\';', 'SECURITY', 'ADVANCED', 1);
         add_config_option('STRONG_FORUM_TIE', 'is_on_strong_forum_tie', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION', 1);
         add_config_option('VALIDATION_ON_PREVIEW', 'is_on_preview_validation', 'tick', 'return \'1\';', 'SITE', 'VALIDATION', 1);
         add_config_option('SHOW_INLINE_STATS', 'show_inline_stats', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
         add_config_option('SIMPLIFIED_DONEXT', 'simplified_donext', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('ANTI_LEECH', 'anti_leech', 'tick', 'return \'0\';', 'SECURITY', 'GENERAL');
         add_config_option('SSW', 'ssw', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('ADMIN_MENU', 'bottom_show_admin_menu', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('TOP_LINK', 'bottom_show_top_button', 'tick', 'return \'0\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('FEEDBACK_LINK', 'bottom_show_feedback_link', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('PRIVACY_LINK', 'bottom_show_privacy_link', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('SITEMAP_LINK', 'bottom_show_sitemap_button', 'tick', 'return \'1\';', 'FEATURE', 'BOTTOM_LINKS');
         add_config_option('COUNT_POSTSCOUNT', 'forum_show_personal_stats_posts', 'tick', 'return has_no_forum()?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('COUNT_TOPICSCOUNT', 'forum_show_personal_stats_topics', 'tick', 'return ((has_no_forum()) || (get_forum_type()!=\'ocf\'))?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('ADMIN_ZONE_LINK', 'ocp_show_personal_adminzone_link', 'tick', 'return \'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('CONCEDED_MODE_LINK', 'ocp_show_conceded_mode_link', 'tick', 'return \'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('SU', 'ocp_show_su', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('PAGE_ACTIONS', 'ocp_show_staff_page_actions', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('MY_PROFILE_LINK', 'ocf_show_profile_link', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('_USERGROUP', 'ocp_show_personal_usergroup', 'tick', 'return (get_forum_type()==\'none\')?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('LAST_HERE', 'ocp_show_personal_last_visit', 'tick', 'return has_no_forum()?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('AVATAR', 'ocp_show_avatar', 'tick', 'return ((get_forum_type()==\'none\') || ((get_forum_type()==\'ocf\') && (!addon_installed(\'ocf_member_avatars\'))))?NULL:\'0\';', 'BLOCKS', 'PERSONAL_BLOCK');
         add_config_option('PANEL_WIDTH', 'panel_width', 'line', 'return \'13.3em\';', 'THEME', 'GENERAL');
         add_config_option('PANEL_WIDTH_SPACED', 'panel_width_spaced', 'line', 'return \'14.3em\';', 'THEME', 'GENERAL');
         add_config_option('ROOT_ZONE_LOGIN_THEME', 'root_zone_login_theme', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('USE_CUSTOM_ZONE_MENU', 'use_custom_zone_menu', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('TRAY_SUPPORT', 'tray_support', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_DOCS', 'show_docs', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('CAPTCHA_NOISE', 'captcha_noise', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('CAPTCHA_ON_FEEDBACK', 'captcha_on_feedback', 'tick', 'return addon_installed(\'captcha\')?\'0\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('SHOW_POST_VALIDATION', 'show_post_validation', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('IP_FORWARDING', 'ip_forwarding', 'tick', 'return \'0\';', 'SITE', 'ENVIRONMENT');
         add_config_option('FORCE_META_REFRESH', 'force_meta_refresh', 'tick', 'return \'0\';', 'SITE', 'ENVIRONMENT');
         add_config_option('USE_CONTEXTUAL_DATES', 'use_contextual_dates', 'tick', 'return \'1\';', 'SITE', 'ADVANCED');
         add_config_option('EAGER_WYSIWYG', 'eager_wysiwyg', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('WEBSITE_EMAIL', 'website_email', 'line', '$staff_address=get_option(\'staff_address\'); $website_email=\'website@\'.get_domain(); if (substr($staff_address,-strlen(get_domain())-1)==\'@\'.get_domain()) $website_email=$staff_address; return $website_email;', 'SITE', 'EMAIL');
         add_config_option('ENVELOPER_OVERRIDE', 'enveloper_override', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('BCC', 'bcc', 'tick', 'return \'1\';', 'SITE', 'EMAIL');
         add_config_option('ALLOW_EXT_IMAGES', 'allow_ext_images', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('HTM_SHORT_URLS', 'htm_short_urls', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('IP_STRICT_FOR_SESSIONS', 'ip_strict_for_sessions', 'tick', 'return \'1\';', 'SECURITY', 'GENERAL');
         add_config_option('ENABLE_PREVIEWS', 'enable_previews', 'tick', 'return \'1\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_KEYWORD_DENSITY_CHECK', 'enable_keyword_density_check', 'tick', 'return \'0\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_SPELL_CHECK', 'enable_spell_check', 'tick', 'return function_exists(\'pspell_check\')?\'0\':NULL;', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_MARKUP_VALIDATION', 'enable_markup_validation', 'tick', 'return \'0\';', 'SITE', 'PREVIEW');
         add_config_option('ENABLE_IMAGE_FADING', 'enable_image_fading', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
     }
     if (is_null($upgrade_from) || $upgrade_from < 9) {
         add_config_option('AUTO_SUBMIT_SITEMAP', 'auto_submit_sitemap', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('USER_POSTSIZE_ERRORS', 'user_postsize_errors', 'tick', 'return is_null($old=get_value(\'no_user_postsize_errors\'))?\'1\':invert_value($old);', 'SITE', 'UPLOAD');
         add_config_option('AUTOMATIC_META_EXTRACTION', 'automatic_meta_extraction', 'tick', 'return is_null($old=get_value(\'no_auto_meta\'))?\'1\':invert_value($old);', 'SITE', 'GENERAL');
         add_config_option('IS_ON_EMOTICON_CHOOSERS', 'is_on_emoticon_choosers', 'tick', 'return is_null($old=get_value(\'no_emoticon_choosers\'))?\'1\':invert_value($old);', 'THEME', 'GENERAL');
         add_config_option('DEEPER_ADMIN_BREADCRUMBS', 'deeper_admin_breadcrumbs', 'tick', 'return is_null($old=get_value(\'no_admin_menu_assumption\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('HAS_LOW_MEMORY_LIMIT', 'has_low_memory_limit', 'tick', 'return is_null($old=get_value(\'has_low_memory_limit\'))?((ini_get(\'memory_limit\')==\'-1\' || ini_get(\'memory_limit\')==\'0\' || ini_get(\'memory_limit\')==\'\')?\'0\':NULL):$old;', 'SITE', 'ADVANCED');
         add_config_option('IS_ON_COMCODE_PAGE_CHILDREN', 'is_on_comcode_page_children', 'tick', 'return is_null($old=get_value(\'disable_comcode_page_children\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('GLOBAL_DONEXT_ICONS', 'global_donext_icons', 'tick', 'return is_null($old=get_value(\'disable_donext_global\'))?\'1\':invert_value($old);', 'SITE', 'ADVANCED');
         add_config_option('NO_STATS_WHEN_CLOSED', 'no_stats_when_closed', 'tick', 'return \'' . (substr(ocp_srv('HTTP_HOST'), 0, 8) == '192.168.' || substr(ocp_srv('HTTP_HOST'), 0, 7) == '10.0.0.' || in_array(ocp_srv('HTTP_HOST'), array('localhost', 'test.ocportal.com')) ? '0' : '1') . '\';', 'SITE', 'CLOSED_SITE');
         add_config_option('NO_BOT_STATS', 'no_bot_stats', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('FILE_SYSTEM_CACHING', 'filesystem_caching', 'tick', 'return \'0\';', 'SITE', 'CACHES');
         // Java/FTP upload
         add_config_option('ENABLE_JAVA_UPLOAD', 'java_upload', 'tick', 'return \'0\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_HOST', 'java_ftp_host', 'line', 'return ocp_srv(\'HTTP_HOST\');', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_USERNAME', 'java_username', 'line', 'return \'anonymous\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_PASSWORD', 'java_password', 'line', 'return \'someone@example.com\';', 'SITE', 'JAVA_UPLOAD');
         add_config_option('JAVA_FTP_PATH', 'java_ftp_path', 'line', 'return \'/public_html/uploads/incoming/\';', 'SITE', 'JAVA_UPLOAD');
     }
     if (is_null($upgrade_from) || $upgrade_from < 10) {
         add_config_option('ADVANCED_ADMIN_CACHE', 'advanced_admin_cache', 'tick', 'return \'0\';', 'SITE', 'CACHES');
         add_config_option('COLLAPSE_USER_ZONES', 'collapse_user_zones', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
         add_config_option('CHECK_BROKEN_URLS', 'check_broken_urls', 'tick', 'return \'1\';', 'SITE', '_COMCODE');
         add_config_option('GOOGLE_ANALYTICS', 'google_analytics', 'line', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('FIXED_WIDTH', 'fixed_width', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_CONTENT_TAGGING', 'show_content_tagging', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_CONTENT_TAGGING_INLINE', 'show_content_tagging_inline', 'tick', 'return \'0\';', 'THEME', 'GENERAL');
         add_config_option('SHOW_SCREEN_ACTIONS', 'show_screen_actions', 'tick', 'return \'1\';', 'THEME', 'GENERAL');
         add_config_option('PERSONAL_SUB_LINKS', 'ocp_show_personal_sub_links', 'tick', 'return \'1\';', 'BLOCKS', 'PERSONAL_BLOCK');
     }
     if (is_null($upgrade_from) || $upgrade_from < 11) {
         add_config_option('LONG_GOOGLE_COOKIES', 'long_google_cookies', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('REMEMBER_ME_BY_DEFAULT', 'remember_me_by_default', 'tick', 'return \'0\';', 'SITE', 'GENERAL');
         add_config_option('DETECT_JAVASCRIPT', 'detect_javascript', 'tick', 'return \'0\';', 'SITE', 'ADVANCED');
         add_config_option('MOBILE_SUPPORT', 'mobile_support', 'tick', 'return \'1\';', 'SITE', 'GENERAL');
     }
     if (is_null($upgrade_from) || $upgrade_from < 12) {
         add_config_option('MAIL_QUEUE', 'mail_queue', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('MAIL_QUEUE_DEBUG', 'mail_queue_debug', 'tick', 'return \'0\';', 'SITE', 'EMAIL');
         add_config_option('COMMENTS_TO_SHOW_IN_THREAD', 'comments_to_show_in_thread', 'integer', 'return \'30\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('MAX_THREAD_DEPTH', 'max_thread_depth', 'integer', 'return \'6\';', 'FEATURE', 'USER_INTERACTION');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 12) {
         foreach (array('send_error_emails', 'ocf_show_personal_myhome_link', 'twitter_login', 'twitter_password', 'facebook_api', 'facebook_appid', 'facebook_secret_code', 'facebook_uid', 'facebook_target_ids') as $option_to_delete) {
             delete_config_option($option_to_delete);
         }
     }
     if (is_null($upgrade_from) || $upgrade_from < 13) {
         add_config_option('COMPLEX_UPLOADER', 'complex_uploader', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('ENABLE_WYSIWYG', 'wysiwyg', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('EDITAREA', 'editarea', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('JS_OVERLAYS', 'js_overlays', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('TREE_LISTS', 'tree_lists', 'tick', 'return \'1\';', 'ACCESSIBILITY', 'GENERAL');
         add_config_option('CSS_CAPTCHA', 'css_captcha', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('CAPTCHA_SINGLE_GUESS', 'captcha_single_guess', 'tick', 'return addon_installed(\'captcha\')?\'1\':NULL;', 'SECURITY', 'SECURITY_IMAGE');
         add_config_option('ENABLE_AUTOBAN', 'autoban', 'tick', 'return \'1\';', 'SECURITY', 'GENERAL');
         add_config_option('ENABLE_LIKES', 'likes', 'tick', 'return \'0\';', 'FEATURE', 'USER_INTERACTION');
     }
     if (!is_null($upgrade_from) && $upgrade_from < 8) {
         delete_config_option('logo_map');
         $GLOBALS['SITE_DB']->query('UPDATE ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'config SET the_type=\'forum\' WHERE the_name LIKE \'' . db_encode_like('%_forum_name') . '\'');
     }
     if (is_null($upgrade_from)) {
         set_value('version', float_to_raw_string(ocp_version_number()));
         set_value('ocf_version', float_to_raw_string(ocp_version_number()));
         // Site Configuration
         //  General
         add_config_option('SITE_NAME', 'site_name', 'line', 'return do_lang(\'UNNAMED\');', 'SITE', 'GENERAL');
         add_config_option('SITE_SCOPE', 'site_scope', 'transline', 'return \'???\';', 'SITE', 'GENERAL');
         add_config_option('DESCRIPTION', 'description', 'transline', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('COPYRIGHT', 'copyright', 'transline', 'return \'Copyright &copy; \'.get_site_name().\' \'.date(\'Y\').\'\';', 'SITE', 'GENERAL');
         add_config_option('WELCOME_MESSAGE', 'welcome_message', 'transtext', 'return \'\';', 'SITE', 'GENERAL');
         add_config_option('MAIN_FORUM_NAME', 'main_forum_name', 'forum', 'return has_no_forum()?NULL:do_lang(\'DEFAULT_FORUM_TITLE\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'USER_INTERACTION');
         add_config_option('KEYWORDS', 'keywords', 'line', 'return \'\';', 'SITE', 'GENERAL');
         //  Advanced
         //add_config_option('LOGO_MAP','logo_map','text','$tpl=do_template(\'IMAGE_MAP\'); return $tpl->evaluate();','SITE','ADVANCED');
         add_config_option('GZIP_OUTPUT', 'gzip_output', 'tick', 'return \'0\';', 'SITE', 'ADVANCED', 1);
         //  Environment
         add_config_option('FORUM_IN_PORTAL', 'forum_in_portal', 'tick', 'return has_no_forum()?NULL:\'0\';', 'SITE', 'ENVIRONMENT', 1);
         add_config_option('EMAIL', 'staff_address', 'line', 'return \'staff@\'.get_domain();', 'SITE', 'EMAIL');
         add_config_option('GD', 'is_on_gd', 'tick', 'return function_exists(\'imagetypes\')?\'1\':\'0\';', 'SITE', 'ENVIRONMENT', 1);
         add_config_option('FOLDER_CREATE', 'is_on_folder_create', 'tick', 'return \'1\';', 'SITE', 'ENVIRONMENT', 1);
         //  Closed Site
         add_config_option('CLOSED_SITE', 'site_closed', 'tick', 'return \'' . (substr(ocp_srv('HTTP_HOST'), 0, 8) == '192.168.' || substr(ocp_srv('HTTP_HOST'), 0, 7) == '10.0.0.' || in_array(ocp_srv('HTTP_HOST'), array('localhost', 'test.ocportal.com')) ? '0' : '1') . '\';', 'SITE', 'CLOSED_SITE');
         add_config_option('MESSAGE', 'closed', 'transtext', 'return do_lang(\'BEING_INSTALLED\');', 'SITE', 'CLOSED_SITE');
         add_config_option('MAXIMUM_USERS', 'maximum_users', 'integer', 'return \'100\';', 'SITE', 'CLOSED_SITE', 1);
         //  Logging
         add_config_option('CC_ADDRESS', 'cc_address', 'line', 'return \'\';', 'SITE', 'EMAIL');
         // \'staff_cc@\'.get_domain()
         add_config_option('LOG_PHP_ERRORS', 'log_php_errors', 'tick', 'return \'1\';', 'SITE', 'LOGGING');
         add_config_option('DISPLAY_PHP_ERRORS', 'display_php_errors', 'tick', 'return \'0\';', 'SITE', 'LOGGING');
         // Security/Usergroup Options
         //  Uploading
         add_config_option('FILE_TYPES', 'valid_types', 'line', 'return \'swf,sql,odg,odp,odt,ods,pdf,pgp,dot,doc,ppt,csv,xls,docx,pptx,xlsx,pub,txt,log,psd,tga,tif,gif,png,ico,bmp,jpg,jpeg,flv,avi,mov,3gp,mpg,mpeg,mp4,webm,asf,wmv,zip,tar,rar,gz,wav,mp3,ogg,ogv,torrent,php,css,tpl,ini,eml,patch,diff,iso,dmg\';', 'SECURITY', 'UPLOADED_FILES');
         // fla,html,htm,svg,xml kept out for security reasons. NB: Can't add any more due to length limit.
         add_config_option('IMAGE_TYPES', 'valid_images', 'line', 'return \'jpg,jpeg,gif,png,ico\';', 'SECURITY', 'UPLOADED_FILES');
         // Feature Options
         //  User Interaction
         add_config_option('RATING', 'is_on_rating', 'tick', 'return \'1\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENTS', 'is_on_comments', 'tick', 'return has_no_forum()?NULL:\'1\';', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENTS_FORUM_NAME', 'comments_forum_name', 'forum', 'return has_no_forum()?NULL:do_lang(\'COMMENT_FORUM_NAME\',\'\',\'\',\'\',get_site_default_lang());', 'FEATURE', 'USER_INTERACTION');
         add_config_option('COMMENT_FORM_TEXT', 'comment_text', 'transtext', 'return has_no_forum()?NULL:static_evaluate_tempcode(do_template(\'COMMENTS_DEFAULT_TEXT\'));', 'FEATURE', 'USER_INTERACTION');
         //  Images
         add_config_option('THUMB_WIDTH', 'thumb_width', 'integer', 'return \'200\';', 'FEATURE', 'IMAGES');
         add_config_option('IMAGES', 'max_image_size', 'integer', 'return \'700\';', 'SITE', 'UPLOAD');
         add_config_option('USERS_ONLINE_TIME', 'users_online_time', 'integer', 'return \'5\';', 'SITE', 'LOGGING');
     }
 }
    }
    $RELATIVE_PATH = substr($FILE_BASE, ($a > $b ? $a : $b) + 1);
    $FILE_BASE = substr($FILE_BASE, 0, $a > $b ? $a : $b);
} else {
    $RELATIVE_PATH = '';
}
@chdir($FILE_BASE);
if (!is_file($FILE_BASE . '/sources/global.php')) {
    exit('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . chr(10) . '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="EN" lang="EN"><head><title>Critical startup error</title></head><body><h1>ocPortal startup error</h1><p>The second most basic ocPortal startup file, sources/global.php, could not be located. This is almost always due to an incomplete upload of the ocPortal system, so please check all files are uploaded correctly.</p><p>Once all ocPortal files are in place, ocPortal must actually be installed by running the installer. You must be seeing this message either because your system has become corrupt since installation, or because you have uploaded some but not all files from our manual installer package: the quick installer is easier, so you might consider using that instead.</p><p>ocProducts maintains full documentation for all procedures and tools, especially those for installation. These may be found on the <a href="http://ocportal.com">ocPortal website</a>. If you are unable to easily solve this problem, we may be contacted from our website and can help resolve it for you.</p><hr /><p style="font-size: 0.8em">ocPortal is a website engine created by ocProducts.</p></body></html>');
}
require $FILE_BASE . '/sources/global.php';
require_code('addons');
require_code('dump_addons');
require_code('version');
require_code('downloads2');
$version = ocp_version_number();
$version_for_name = preg_replace('/\\./', '', float_to_raw_string($version));
$get_cat = get_param('cat', NULL);
if ($get_cat === NULL) {
    exit("Please pass the category name in the URL (?cat=name).");
}
// $file_list = get_file_list_of_addons();
$addon_list = get_details_of_addons();
$parent_id = $GLOBALS['SITE_DB']->query_value_null_ok('download_categories c JOIN ' . get_table_prefix() . 'translate t ON t.id=c.category', 'c.id AS id', array('parent_id' => 1, 't.text_original' => 'Addons'));
$c_main_id = check_and_add_category($get_cat, $parent_id);
/*$cat_id=add_download_category('Themes',$c_main_id,'','','');
$all_groups=$GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
foreach (array_keys($all_groups) as $_group_id)
{
	$GLOBALS['SITE_DB']->query_insert('group_category_access',array('module_the_name'=>'downloads','category_name'=>strval($cat_id),'group_id'=>$_group_id));
}*/
Exemplo n.º 6
0
/**
 * Standard code module initialisation function.
 */
function init__global2()
{
    global $BOOTSTRAPPING, $CHECKING_SAFEMODE, $BAD_WORD_CHARS, $FIXED_WORD_CHARS, $FIXED_WORD_CHARS_HTML, $BROWSER_DECACHEING, $CHARSET, $TEMP_CHARSET, $RELATIVE_PATH, $CURRENTLY_HTTPS, $RUNNING_SCRIPT_CACHE, $SERVER_TIMEZONE, $HAS_SET_ERROR_HANDLER, $DYING_BADLY, $XSS_DETECT, $SITE_INFO, $JAVASCRIPTS, $JAVASCRIPT, $CSSS, $IN_MINIKERNEL_VERSION, $EXITING, $FILE_BASE, $MOBILE, $CACHE_TEMPLATES, $BASE_URL_HTTP, $BASE_URL_HTTPS, $WORDS_TO_FILTER, $FIELD_RESTRICTIONS, $VALID_ENCODING, $CONVERTED_ENCODING, $MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, $QUERY_LOG, $_CREATED_FILES, $CURRENT_SHARE_USER, $CACHE_FIND_SCRIPT;
    if (str_replace(array('on', 'true', 'yes'), array('1', '1', '1'), strtolower(ini_get('output_buffering'))) == '1') {
        @ob_end_clean();
    }
    if (array_key_exists('HTTP_X_REWRITE_URL', $_SERVER)) {
        foreach ($_GET as $key => $val) {
            if ($key[0] == '?') {
                unset($_GET[$key]);
                $_GET[substr($key, 1)] = $val;
            }
        }
        $_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
    } elseif (!array_key_exists('REQUEST_URI', $_SERVER) && !array_key_exists('REQUEST_URI', $_ENV)) {
        $_SERVER['REQUEST_URI'] = $_SERVER['PHP_SELF'];
        $first = true;
        foreach ($_GET as $key => $val) {
            $_SERVER['REQUEST_URI'] .= $first ? '?' : '&';
            $_SERVER['REQUEST_URI'] .= urlencode($key) . '=' . urlencode($val);
            $first = false;
        }
    }
    if (array_key_exists('SCRIPT_FILENAME', $_SERVER) && !array_key_exists('PHP_SELF', $_SERVER)) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_FILENAME'];
    } elseif (array_key_exists('SCRIPT_NAME', $_SERVER) && defined('HIPHOP_PHP')) {
        $_SERVER['PHP_SELF'] = $_SERVER['SCRIPT_NAME'];
    }
    @header('Expires: Mon, 20 Dec 1998 01:00:00 GMT');
    @header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    @header('Cache-Control: no-cache, max-age=0');
    @header('Pragma: no-cache');
    // for proxies, and also IE
    if (is_file('closed.html') && get_param_integer('keep_force_open', 0) == 0) {
        if (strpos($_SERVER['PHP_SELF'], 'upgrader.php') === false && strpos($_SERVER['PHP_SELF'], 'execute_temp.php') === false && (!isset($SITE_INFO['no_extra_closed_file']) || $SITE_INFO['no_extra_closed_file'] == '0')) {
            if (@strpos($_SERVER['SERVER_SOFTWARE'], 'IIS') === false) {
                header('HTTP/1.0 503 Service Temporarily Unavailable');
            }
            header('Location: ' . (is_file($RELATIVE_PATH . 'closed.html') ? 'closed.html' : '../closed.html'));
            exit;
        }
    }
    // Cover up holes in old PHP versions functionality
    if (!function_exists('str_word_count')) {
        /**
         * Isolate the words in the input string.
         *
         * @param  string			String to count words in
         * @param  integer		The format
         * @set    0 1 2
         * @return mixed			Typically a list - the words of the input string
         */
        function str_word_count($input, $format = 0)
        {
            //count words
            $pattern = "/[^(\\w|\\d|\\'|\"|\\.|\\!|\\?|;|,|\\|\\/|\\-\\-|:|\\&|@)]+/";
            $all_words = trim(preg_replace($pattern, ' ', $input));
            $a = array();
            $pos = 0;
            while (true) {
                $old_pos = $pos;
                $pos = strpos($all_words, ' ', $pos);
                if ($pos === false) {
                    $a[$old_pos] = substr($all_words, $old_pos);
                    break;
                }
                $a[$old_pos] = substr($all_words, $old_pos, $pos - $old_pos);
            }
            if ($format == 0) {
                return count($a);
            }
            return $a;
        }
    }
    if (!function_exists('html_entity_decode')) {
        /**
         * Decode the HTML entitity encoded input string.
         *
         * @param  string			The text to decode
         * @param  integer		The quote style code
         * @param  ?string		Character set to decode to (NULL: default)
         * @return string			The decoded text
         */
        function html_entity_decode($input, $quote_style, $charset = NULL)
        {
            unset($quote_style);
            unset($charset);
            /*			// NB: &nbsp does not go to <space>. It's not something you use with html escaping, it's for hard-space-formatting. URL's don't contain spaces, but that's due to URL escaping (%20)
            			$replace_array=array(
            				'&amp;'=>'&',
            				'&gt;'=>'>',
            				'&lt;'=>'<',
            				'&#039;'=>'\'',
            				'&quot;'=>'"',
            			);
            
            			foreach ($replace_array as $from=>$to)
            			{
            				$input=str_replace($from,$to,$input);
            			}
            
            			return $input;*/
            $trans_tbl = get_html_translation_table(HTML_ENTITIES);
            $trans_tbl = array_flip($trans_tbl);
            return strtr($input, $trans_tbl);
        }
    }
    if (version_compare(phpversion(), '4.3.0') >= 0) {
        if (!function_exists('unichrm_hex')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm_hex($matches)
            {
                return unichr(hexdec($matches[1]));
            }
        }
        if (!function_exists('unichrm')) {
            /**
             * Convert a unicode character number to a unicode string. Callback for preg_replace.
             *
             * @param  array					Regular expression match array.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichrm($matches)
            {
                return unichr(intval($matches[1]));
            }
        }
        if (!function_exists('unichr')) {
            /**
             * Convert a unicode character number to a HTML-entity enabled string, using lower ASCII characters where possible.
             *
             * @param  integer				Character number.
             * @return ~string				Converted data (false: could not convert).
             */
            function unichr($c)
            {
                if ($c <= 0x7f) {
                    return chr($c);
                } else {
                    return '#&' . strval($c) . ';';
                }
            }
        }
    }
    $BOOTSTRAPPING = 1;
    $CHECKING_SAFEMODE = false;
    $BAD_WORD_CHARS = array(chr(128), chr(130), chr(131), chr(132), chr(133), chr(134), chr(135), chr(136), chr(137), chr(138), chr(139), chr(140), chr(142), chr(145), chr(146), chr(147), chr(148), chr(149), chr(150), chr(151), chr(152), chr(153), chr(154), chr(155), chr(156), chr(158), chr(159));
    $FIXED_WORD_CHARS = array('(EUR-)', ',', '{f.}', '"', '...', '-|-', '=|=', '^', '{%o}', '{~S}', '<', 'CE', '{~Z}', "'", "'", '"', '"', '-', '-', '--', '~', '(TM)', '{~s}', '>', 'ce', '{~z}', '{.Y.}');
    // some of these are Comcode shortcuts. We can't use entities as we can't assume we're converting into Comcode.
    $FIXED_WORD_CHARS_HTML = array('&#8364;', '&#8218;', '&#402;', '&#8222;', '&hellip;', '&#8224;', '&#8225;', '&#710;', '&#8240;', '&#352;', '&#8249;', '&#338;', '&#381;', "&lsquo;", "&rsquo;", '&ldquo;', '&rdquo;', '&bull;', '&ndash;', '&mdash;', '&#732;', '&trade;', '&#353;', '&#8250;', '&#339;', '&#382;', '&#376;');
    $RUNNING_SCRIPT_CACHE = array();
    $BROWSER_DECACHEING = NULL;
    $CHARSET = NULL;
    $TEMP_CHARSET = NULL;
    $CURRENTLY_HTTPS = NULL;
    $CACHE_FIND_SCRIPT = array();
    error_reporting(E_ALL);
    @ini_set('html_errors', '1');
    @ini_set('docref_root', 'http://www.php.net/manual/en/');
    @ini_set('docref_ext', '.php');
    $SERVER_TIMEZONE = function_exists('date_default_timezone_get') ? @date_default_timezone_get() : ini_get('date.timezone');
    @ini_set('date.timezone', 'UTC');
    if (function_exists('date_default_timezone_set')) {
        date_default_timezone_set('UTC');
    }
    // Needed for HPHP
    $HAS_SET_ERROR_HANDLER = false;
    $DYING_BADLY = false;
    // If ocPortal is bailing out uncontrollably, setting this will make sure the error hander does not try and suppress
    $XSS_DETECT = function_exists('ocp_mark_as_escaped');
    $GLOBALS['DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped')) && (!array_key_exists('keep_no_debug_mode', $_GET) || $_GET['keep_no_debug_mode'] == '0');
    $GLOBALS['SEMI_DEBUG_MODE'] = (!array_key_exists('debug_mode', $SITE_INFO) || $SITE_INFO['debug_mode'] == '1') && (is_dir(get_file_base() . '/.svn') || is_dir(get_file_base() . '/.git') || function_exists('ocp_mark_as_escaped'));
    if (function_exists('set_time_limit')) {
        @set_time_limit(60);
    }
    if ($GLOBALS['DEBUG_MODE']) {
        if (function_exists('set_time_limit')) {
            @set_time_limit(10);
        }
        @ini_set('ocproducts.type_strictness', '1');
        @ini_set('ocproducts.xss_detect', '1');
    }
    if ($GLOBALS['DEBUG_MODE']) {
        require_code('developer_tools');
    }
    $JAVASCRIPTS = array('javascript' => 1, 'javascript_thumbnails' => 1);
    if ($GLOBALS['CURRENT_SHARE_USER'] !== NULL || get_domain() == 'myocp.com') {
        $JAVASCRIPTS['javascript_ajax'] = 1;
    }
    $CSSS = array('no_cache' => 1, 'global' => 1);
    // Try and make the PHP environment as we need it
    if (function_exists('set_magic_quotes_runtime')) {
        @set_magic_quotes_runtime(0);
    }
    // @'d because it's deprecated and PHP 5.3 may give an error
    @ini_set('auto_detect_line_endings', '0');
    @ini_set('include_path', '');
    @ini_set('default_socket_timeout', '60');
    @ini_set('allow_url_fopen', '0');
    @ini_set('suhosin.executor.disable_emodifier', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.multiheader', '1');
    // Extra security if suhosin is available
    @ini_set('suhosin.executor.disable_eval', '0');
    @ini_set('suhosin.executor.eval.whitelist', '');
    @ini_set('suhosin.executor.func.whitelist', '');
    // Load most basic config
    $IN_MINIKERNEL_VERSION = 0;
    $EXITING = 0;
    if (array_key_exists('use_ocf', $_GET) && running_script('upgrader')) {
        $SITE_INFO['forum_type'] = 'ocf';
        $SITE_INFO['ocf_table_prefix'] = $SITE_INFO['table_prefix'];
    }
    $CACHE_TEMPLATES = true;
    // The URL to our install (no trailing /)
    $BASE_URL_HTTP = NULL;
    $BASE_URL_HTTPS = NULL;
    $WORDS_TO_FILTER = NULL;
    $FIELD_RESTRICTIONS = NULL;
    $VALID_ENCODING = false;
    $CONVERTED_ENCODING = false;
    if (!isset($MICRO_BOOTUP)) {
        $MICRO_BOOTUP = 0;
    }
    if (!isset($MICRO_AJAX_BOOTUP)) {
        $MICRO_AJAX_BOOTUP = 0;
    }
    require_code_no_override('version');
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        //@header('X-Powered-By: ocPortal '.ocp_version_full().' (PHP '.phpversion().')');
        @header('X-Powered-By: ocPortal');
        // Better to keep it vague, for security reasons
        $QUERY_LOG = false;
        if (isset($_REQUEST['special_page_type']) && $_REQUEST['special_page_type'] == 'query') {
            $QUERY_LOG = true;
        }
    }
    // Most critical things
    require_code('support');
    // A lot of support code is present in this
    srand(make_seed());
    mt_srand(make_seed());
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            $bot_type = get_bot_type();
            if ($bot_type !== NULL && isset($SITE_INFO['fast_spider_cache']) && $SITE_INFO['fast_spider_cache'] != '0') {
                fast_spider_cache(true);
            }
        }
    }
    require_code('caches');
    // Recently taken out of 'support' so makes sense to load it here
    require_code('database');
    // There's nothing without the database
    if ((!isset($SITE_INFO['known_suexec']) || $SITE_INFO['known_suexec'] == '0') && !is_writable_wrap(get_file_base() . '/.htaccess')) {
        require_code('support2');
        if (ip_banned(get_ip_address())) {
            critical_error('BANNED');
        }
    }
    if (running_script('messages') && get_param('action', 'new') == 'new' && get_param_integer('routine_refresh', 0) == 0) {
        require_code('chat_poller');
        chat_poller();
    }
    if ($MICRO_BOOTUP == 0) {
        load_user_stuff();
    }
    // For any kind of niceness we need these. The order is chosen for complex dependency reasons - don't mess with it
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('themes');
        // Output needs to know about themes
        require_code('templates');
        // So that we can do error templates
        require_code('tempcode');
        // Output is done with tempcode
        if ($MICRO_BOOTUP == 0) {
            require_code('comcode');
            // Much output goes through comcode
        }
    }
    require_code('zones');
    // Zone is needed because zones are where all ocPortal pages reside
    require_code('config');
    // Config is needed for much active stuff
    if (get_option('collapse_user_zones', true) === '1' && $RELATIVE_PATH == 'site') {
        get_base_url();
        /*force calculation first*/
        $RELATIVE_PATH = '';
    }
    require_code('users');
    // Users are important due to permissions
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0) {
        if (running_script('index') && count($_POST) == 0) {
            if (isset($SITE_INFO['any_guest_cached_too']) && $SITE_INFO['any_guest_cached_too'] == '1' && is_guest(NULL, true)) {
                fast_spider_cache(false);
            }
        }
    }
    $CACHE_TEMPLATES = (get_option('is_on_template_cache') == '1' || get_param_integer('keep_cache', 0) == 1 || get_param_integer('cache', 0) == 1) && get_param_integer('keep_cache', NULL) !== 0 && get_param_integer('cache', NULL) !== 0;
    if ($MICRO_AJAX_BOOTUP == 0) {
        require_code('temporal');
        // Date/time functions
        require_code('files');
        // Contains fix_permissions, needed for 'lang'
        require_code('lang');
        // So that we can do language stuff (e.g. errors)
        convert_data_encodings();
        if ($MICRO_BOOTUP == 0) {
            require_code('permissions');
            // So we can check access
        }
    }
    // At this point we can display errors nicely
    $GLOBALS['SUPPRESS_ERROR_DEATH'] = false;
    set_error_handler('ocportal_error_handler');
    if (function_exists('error_get_last')) {
        register_shutdown_function('catch_fatal_errors');
    }
    $HAS_SET_ERROR_HANDLER = true;
    if ($MICRO_BOOTUP == 0) {
        if (method_exists($GLOBALS['FORUM_DRIVER'], 'forum_layer_initialise')) {
            $GLOBALS['FORUM_DRIVER']->forum_layer_initialise();
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0) {
        $JAVASCRIPT = new ocp_tempcode();
    }
    if ($MICRO_BOOTUP == 0) {
        if ($IN_MINIKERNEL_VERSION != 1 && $MICRO_AJAX_BOOTUP == 0) {
            has_cookies();
            // Will determine at early point whether we have cookie support
            get_num_users_site();
            // Will kill site if there are too many users
        }
    }
    require_code('urls');
    // URL building is crucial
    @header('Content-type: text/html; charset=' . get_charset());
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        // Before anything gets outputted
        handle_logins();
        require_code('site');
        // This powers the site (top level page generation)
        // Are we installed?
        get_option('site_name');
    }
    // Our logging (change false to true for temporarily changing it so staff get logging)
    if (get_option('log_php_errors') == '1') {
        @ini_set('log_errors', '1');
        if (addon_installed('errorlog')) {
            @ini_set('error_log', get_custom_file_base() . '/data_custom/errorlog.php');
        }
    }
    if ($MICRO_BOOTUP == 0 && $MICRO_AJAX_BOOTUP == 0 && (get_option('display_php_errors') == '1' || running_script('upgrader') || has_specific_permission(get_member(), 'see_php_errors'))) {
        @ini_set('display_errors', '1');
    } elseif (!$GLOBALS['DEBUG_MODE']) {
        @ini_set('display_errors', '0');
    }
    // G-zip?
    @ini_set('zlib.output_compression', get_option('gzip_output') == '1' ? 'On' : 'Off');
    if (function_exists('setlocale') && $MICRO_AJAX_BOOTUP == 0) {
        $locales = explode(',', do_lang('locale'));
        setlocale(LC_ALL, $locales[0]);
        @setlocale(LC_ALL, $locales);
        unset($locales);
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0 && (!isset($SITE_INFO['no_installer_checks']) || $SITE_INFO['no_installer_checks'] == '0')) {
        if (is_file(get_file_base() . '/install.php') && !is_file(get_file_base() . '/install_ok') && running_script('index')) {
            warn_exit(do_lang_tempcode('MUST_DELETE_INSTALLER'));
        }
    }
    if ($MICRO_AJAX_BOOTUP == 0 && $MICRO_BOOTUP == 0) {
        $changed_base_url = !array_key_exists('base_url', $SITE_INFO) && get_long_value('last_base_url') !== get_base_url(false);
        if (running_script('index') && (is_browser_decacheing() || $changed_base_url)) {
            require_code('view_modes');
            erase_tempcode_cache();
            erase_cached_templates(!$changed_base_url);
            erase_comcode_cache();
            erase_cached_language();
            persistant_cache_empty();
            if ($changed_base_url) {
                require_lang('zones');
                require_code('zones3');
                erase_comcode_page_cache();
                set_long_value('last_base_url', get_base_url(false));
            }
        }
        if (has_zone_access(get_member(), 'adminzone')) {
            $JAVASCRIPTS['javascript_staff'] = 1;
            $JAVASCRIPTS['javascript_ajax'] = 1;
            if (addon_installed('occle')) {
                $JAVASCRIPTS['javascript_button_occle'] = 1;
            }
        }
        if (addon_installed('realtime_rain') && get_option('bottom_show_realtime_rain_button', true) === '1') {
            $JAVASCRIPTS['javascript_button_realtime_rain'] = 1;
        }
    }
    /*ocp_memory_profile('startup');
    	$func=get_defined_functions();
    	print_r($func['user']);*/
    if (tacit_https() || is_page_https(get_zone_name(), get_page_name())) {
        @header('Cache-Control: private');
        @header('Pragma: private');
    }
    $BOOTSTRAPPING = 0;
    if ($GLOBALS['SEMI_DEBUG_MODE'] && $MICRO_AJAX_BOOTUP == 0) {
        if ($GLOBALS['SEMI_DEBUG_MODE']) {
            /*if ((mt_rand(0,2)==1) && ($GLOBALS['DEBUG_MODE']) && (running_script('index')))	We know this works now, so let's stop messing up our development speed
            		{
            			require_code('view_modes');
            			erase_cached_templates(true); // Stop anything trying to read a template cache item (E.g. CSS, JS) that might not exist!
            		}*/
            if (strpos(ocp_srv('HTTP_REFERER'), ocp_srv('HTTP_HOST')) !== false && strpos(ocp_srv('HTTP_REFERER'), 'keep_devtest') !== false && !running_script('attachment') && !running_script('upgrader') && strpos(ocp_srv('HTTP_REFERER'), 'login') === false && is_null(get_param('keep_devtest', NULL))) {
                $_GET['keep_devtest'] = '1';
                fatal_exit('URL not constructed properly: development mode in use but keep_devtest was not specified. This indicates that links have been made without build_url (in PHP) or keep_stub (in Javascript). Whilst not fatal this time, failure to use these functions can cause problems when your site goes live. See the ocPortal codebook for more details.');
            } else {
                $_GET['keep_devtest'] = '1';
            }
        }
        if (browser_matches('true_xhtml') && get_value('html5') !== '1' && get_value('html5') !== '_true' && get_param_integer('keep_no_xhtml', 0) == 0 && !running_script('upgrader')) {
            @header('Content-type: application/xhtml+xml; charset=' . get_charset());
        }
        if (isset($_CREATED_FILES)) {
            /**
             * Run after-tests for debug mode, to make sure coding standards are met.
             */
            function debug_mode_aftertests()
            {
                global $_CREATED_FILES, $_MODIFIED_FILES;
                // Use the info from ocProduct's custom PHP version to make sure that all files that were created/modified got synched as they should have been.
                foreach ($_CREATED_FILES as $file) {
                    if (substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not permission-synched: ' . $file));
                    }
                }
                foreach ($_MODIFIED_FILES as $file) {
                    if (strpos($file, '_cache') === false && substr($file, 0, strlen(get_file_base())) == get_file_base() && substr($file, -4) != '.log' && basename($file) != 'permissioncheckslog.php') {
                        @exit(escape_html('File not change-synched: ' . $file));
                    }
                }
                global $TITLE_CALLED, $SCREEN_TEMPLATE_CALLED, $EXITING;
                if (is_null($SCREEN_TEMPLATE_CALLED) && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No screen template called.'));
                }
                if (!$TITLE_CALLED && (is_null($SCREEN_TEMPLATE_CALLED) || $SCREEN_TEMPLATE_CALLED != '') && $EXITING == 0 && strpos(ocp_srv('PHP_SELF'), 'index.php') !== false) {
                    @exit(escape_html('No title used on screen.'));
                }
            }
            register_shutdown_function('debug_mode_aftertests');
        }
        if (ocp_srv('SCRIPT_FILENAME') != '' && $GLOBALS['DEBUG_MODE'] && strpos(ocp_srv('SCRIPT_FILENAME'), 'data_custom') === false) {
            if (@strlen(file_get_contents(ocp_srv('SCRIPT_FILENAME'), FILE_TEXT)) > 4500) {
                fatal_exit('Entry scripts (front controllers) should not be shoved full of code.');
            }
        }
    }
    // FirePHP console support, only for administrators
    if ((get_param_integer('keep_firephp', 0) == 1 || get_param_integer('keep_queries', 0) == 1) && ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member()) || $GLOBALS['IS_ACTUALLY_ADMIN'])) {
        require_code('firephp');
    }
    $default_memory_limit = get_value('memory_limit');
    if (is_null($default_memory_limit) || $default_memory_limit == '' || $default_memory_limit == '0' || $default_memory_limit == '-1') {
        $default_memory_limit = '64M';
    }
    @ini_set('memory_limit', $default_memory_limit);
    if (isset($GLOBALS['FORUM_DRIVER']) && $GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
        if (get_param_integer('keep_avoid_memory_limit', 0) == 1) {
            disable_php_memory_limit();
        }
        $memory_test = get_param_integer('keep_memory_limit_test', 0);
        if ($memory_test != 0 && $memory_test <= 32) {
            @ini_set('memory_limit', strval($memory_test) . 'M');
        }
    }
    if (get_option('sitewide_im', true) === '1' && running_script('index') && get_param('type', 'misc', true) != 'room') {
        require_code('chat');
        enter_chat_lobby();
    }
    // Startup hooks
    if (!running_script('upgrader')) {
        $startup_hooks = find_all_hooks('systems', 'startup');
        foreach (array_keys($startup_hooks) as $hook) {
            require_code('hooks/systems/startup/' . filter_naughty_harsh($hook));
            $ob = object_factory('Hook_startup_' . filter_naughty_harsh($hook), true);
            if ($ob === NULL) {
                continue;
            }
            $ob->run($MICRO_BOOTUP, $MICRO_AJAX_BOOTUP, 0);
        }
        if ($CURRENT_SHARE_USER !== NULL && float_to_raw_string(ocp_version_number()) != get_value('version')) {
            require_code('upgrade');
            clear_caches_2();
            version_specific();
            upgrade_modules();
            ocf_upgrade();
        }
    }
}
Exemplo n.º 7
0
/**
 * Import to ocPortal database table from the equivalent XML format.
 *
 * @param  string			Data in XML format
 * @param  boolean		Synchronise deletes as well as inserts/updates
 * @return array			List of operations performed
 */
function import_from_xml($xml_data, $delete_missing_rows = false)
{
    $parsed = new ocp_simple_xml_reader($xml_data);
    if (!is_null($parsed->error)) {
        warn_exit($parsed->error);
    }
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    $GLOBALS['NO_DB_SCOPE_CHECK'] = true;
    $ops = array();
    $insert_ids = array();
    list($root_tag, $root_attributes, , $this_children) = $parsed->gleamed;
    if ($root_tag == 'ocportal') {
        $_all_fields = $GLOBALS['SITE_DB']->query_select('db_meta', array('*'));
        $all_fields = array();
        foreach ($_all_fields as $f) {
            if (!array_key_exists($f['m_table'], $all_fields)) {
                $all_fields[$f['m_table']] = array();
            }
            $all_fields[$f['m_table']][] = $f;
        }
        $version = array_key_exists('version', $root_attributes) ? floatval($root_attributes['version']) : ocp_version_number();
        $origin = array_key_exists('origin', $root_attributes) ? $root_attributes['origin'] : get_base_url();
        $all_id_fields = array();
        $hooks = find_all_hooks('systems', 'content_meta_aware');
        foreach (array_keys($hooks) as $hook) {
            require_code('hooks/systems/content_meta_aware/' . $hook);
            $ob = object_factory('Hook_content_meta_aware_' . $hook);
            $info = $ob->info();
            if (is_null($info)) {
                continue;
            }
            if (array_key_exists('id_field', $info)) {
                $all_id_fields[$info['table']] = $info['id_field'];
            }
        }
        // Table rows
        $all_existing_data = array();
        foreach ($this_children as $table) {
            $_ops = _import_xml_row($parsed, $all_existing_data, $all_fields, $all_id_fields, $table, $insert_ids, NULL);
            $ops = array_merge($ops, $_ops);
        }
    }
    // Sync deletes
    if ($delete_missing_rows) {
        foreach ($all_existing_data as $table => $es) {
            foreach ($es as $e) {
                $GLOBALS['SITE_DB']->query_delete($table[0], $e, '', 1);
                $ops[] = array(do_lang('DELETED_FROM_TABLE', $table[0]), do_lang('RECORD_IDENTIFIED_BY', make_map_nice($e)));
            }
        }
    }
    return $ops;
}
Exemplo n.º 8
0
/**
 * Lookup error on ocportal.com, to see if there is more information.
 *
 * @param  mixed				The error message (string or tempcode)
 * @return ?string			The result from the web service (NULL: no result)
 */
function get_webservice_result($error_message)
{
    if (get_domain() == 'ocportal.com') {
        return NULL;
    }
    if (!function_exists('has_zone_access') || !has_zone_access(get_member(), 'adminzone')) {
        return NULL;
    }
    require_code('files');
    global $DONE_ONE_WEB_SERVICE;
    if ($GLOBALS['DOWNLOAD_LEVEL'] > 0 || $DONE_ONE_WEB_SERVICE) {
        return NULL;
    }
    $DONE_ONE_WEB_SERVICE = true;
    if (is_object($error_message)) {
        $error_message = $error_message->evaluate();
    }
    if ($GLOBALS['HTTP_STATUS_CODE'] == '401') {
        return NULL;
    }
    // Get message IN ENGLISH
    if (user_lang() != fallback_lang()) {
        global $LANGUAGE;
        foreach ($LANGUAGE as $_) {
            foreach ($_ as $key => $val) {
                $regexp = preg_replace('#\\\\{\\d+\\\\}#', '.*', str_replace('#', '\\#', preg_quote($val)));
                if ($regexp != '.*') {
                    if (preg_match('#' . $regexp . '#', $error_message) != 0) {
                        $_error_message = do_lang($key, '', '', '', fallback_lang(), false);
                        if (!is_null($_error_message)) {
                            $error_message = $_error_message;
                        }
                        break;
                    }
                }
            }
        }
    }
    // Talk to web service
    $brand = get_value('rebrand_name');
    if (is_null($brand)) {
        $brand = 'ocPortal';
    }
    $result = http_download_file('http://ocportal.com/uploads/website_specific/ocportal.com/scripts/errorservice.php?version=' . float_to_raw_string(ocp_version_number()) . '&error_message=' . rawurlencode($error_message) . '&product=' . rawurlencode($brand), NULL, false);
    if ($GLOBALS['HTTP_DOWNLOAD_MIME_TYPE'] != 'text/plain') {
        return NULL;
    }
    if ($result == '') {
        return NULL;
    }
    if (function_exists('ocp_mark_as_escaped')) {
        ocp_mark_as_escaped($result);
    }
    return $result;
}
Exemplo n.º 9
0
/**
 * Put data into the persistant cache.
 *
 * @param  mixed			Key
 * @param  mixed			The data
 * @param  boolean		Whether it is server-wide data
 * @param  ?integer		The expiration time in seconds. (NULL: Default expiry in 60 minutes, or never if it is server-wide).
 */
function persistant_cache_set($key, $data, $server_wide = false, $expire_secs = NULL)
{
    $server_wide = false;
    global $MEM_CACHE;
    if ($MEM_CACHE === NULL) {
        return NULL;
    }
    if ($expire_secs === NULL) {
        $expire_secs = $server_wide ? 0 : 60 * 60;
    }
    $MEM_CACHE->set(($server_wide ? 'ocp' . float_to_raw_string(ocp_version_number()) : get_file_base()) . serialize($key), $data, 0, $expire_secs);
}
Exemplo n.º 10
0
/**
 * Automatically go through full upgrade for current site.
 */
function automate_upgrade()
{
    // Database
    clear_caches_1();
    clear_caches_2();
    version_specific();
    upgrade_modules();
    // OCF
    ocf_upgrade();
    // Themes
    require_code('themes2');
    $themes = find_all_themes();
    foreach (array_keys($themes) as $theme) {
        $from = round(ocp_version_number()) - 1;
        $to = ocp_version_number();
        upgrade_theme($theme, $from, $to, false);
    }
}
Exemplo n.º 11
0
/**
 * Uninstall an addon.
 *
 * @param  string			Name of the addon
 * @param  ?array			The files to install (NULL: all)
 */
function install_addon($file, $files = NULL)
{
    $full = get_custom_file_base() . '/imports/mods/' . $file;
    require_code('zones2');
    require_code('zones3');
    require_code('tar');
    $tar = tar_open($full, 'rb');
    $info_file = tar_get_file($tar, 'mod.inf');
    if (is_null($info_file)) {
        warn_exit(do_lang_tempcode('NOT_ADDON'));
    }
    $info = better_parse_ini_file(NULL, $info_file['data']);
    $directory = tar_get_directory($tar);
    tar_extract_to_folder($tar, '', true, $files, true);
    $addon = $info['name'];
    $author = $info['author'];
    $organisation = $info['organisation'];
    $version = $info['version'];
    if ($version == '(version-synched)') {
        $version = float_to_raw_string(ocp_version_number());
    }
    $dependencies = explode(',', array_key_exists('dependencies', $info) ? $info['dependencies'] : '');
    $incompatibilities = explode(',', array_key_exists('incompatibilities', $info) ? $info['incompatibilities'] : '');
    $description = $info['description'];
    $GLOBALS['SITE_DB']->query_delete('addons', array('addon_name' => $addon), '', 1);
    $GLOBALS['SITE_DB']->query_insert('addons', array('addon_name' => $addon, 'addon_author' => $author, 'addon_organisation' => $organisation, 'addon_version' => $version, 'addon_description' => $description, 'addon_install_time' => time()));
    foreach ($dependencies as $dependency) {
        $GLOBALS['SITE_DB']->query_insert('addons_dependencies', array('addon_name' => $addon, 'addon_name_dependant_upon' => trim($dependency), 'addon_name_incompatibility' => 0));
    }
    foreach ($incompatibilities as $dependency) {
        $GLOBALS['SITE_DB']->query_insert('addons_dependencies', array('addon_name' => $addon, 'addon_name_dependant_upon' => trim($dependency), 'addon_name_incompatibility' => 1));
    }
    foreach ($directory as $dir) {
        $addon_file = $dir['path'];
        if (substr($addon_file, -1) == '/') {
            continue;
        }
        if (is_null($files) || in_array($addon_file, $files)) {
            $GLOBALS['SITE_DB']->query_insert('addons_files', array('addon_name' => $addon, 'filename' => $addon_file));
        }
    }
    // Install new zones
    $zones = array('');
    foreach ($directory as $dir) {
        $addon_file = $dir['path'];
        if (is_null($files) || in_array($addon_file, $files)) {
            $matches = array();
            if (preg_match('#(\\w*)/index.php#', $addon_file, $matches) != 0) {
                $zone = $matches[1];
                $test = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_name', array('zone_name' => $zone));
                if (is_null($test)) {
                    require_code('menus2');
                    add_menu_item_simple('zone_menu', NULL, $zone, $zone . ':', 0, 1);
                    $GLOBALS['SITE_DB']->query_insert('zones', array('zone_name' => $zone, 'zone_title' => insert_lang($zone, 1), 'zone_default_page' => 'start', 'zone_header_text' => insert_lang('???', 2), 'zone_theme' => 'default', 'zone_wide' => 0, 'zone_require_session' => 0, 'zone_displayed_in_menu' => 1));
                    $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
                    foreach (array_keys($groups) as $group_id) {
                        $GLOBALS['SITE_DB']->query_insert('group_zone_access', array('zone_name' => $zone, 'group_id' => $group_id));
                    }
                }
                $zones[] = $zone;
            }
        }
    }
    // Install new modules
    $zones = array_unique(array_merge(find_all_zones(), $zones));
    if (get_option('collapse_user_zones') == '1') {
        $zones[] = 'site';
    }
    foreach ($zones as $zone) {
        $prefix = $zone == '' ? '' : $zone . '/';
        foreach ($directory as $dir) {
            $addon_file = $dir['path'];
            if (is_null($files) || in_array($addon_file, $files)) {
                if (preg_match('#^' . $prefix . 'pages/(modules|modules\\_custom)/([^/]*)\\.php$#', $addon_file, $matches) != 0) {
                    if (!module_installed($matches[2])) {
                        reinstall_module($zone, $matches[2]);
                    }
                }
            }
        }
    }
    // Install new blocks
    foreach ($directory as $dir) {
        $addon_file = $dir['path'];
        if (is_null($files) || in_array($addon_file, $files)) {
            if (preg_match('#^(sources|sources\\_custom)/blocks/([^/]*)\\.php$#', $addon_file, $matches) != 0) {
                if (!block_installed($matches[2])) {
                    reinstall_block($matches[2]);
                }
            }
        }
    }
    // Clear some cacheing
    require_code('view_modes');
    require_code('zones2');
    require_code('zones3');
    erase_comcode_page_cache();
    erase_tempcode_cache();
    persistant_cache_empty();
    erase_cached_templates();
    erase_cached_language();
    // Load mod.php if it exists
    $_modphp_file = tar_get_file($tar, 'mod.php');
    if (!is_null($_modphp_file)) {
        $modphp_file = trim($_modphp_file['data']);
        if (!defined('HIPHOP_PHP')) {
            if (substr($modphp_file, 0, 5) == '<' . '?php') {
                $modphp_file = substr($modphp_file, 5);
            }
            if (substr($modphp_file, -2) == '?' . '>') {
                $modphp_file = substr($modphp_file, 0, strlen($modphp_file) - 2);
            }
            if (eval($modphp_file) === false) {
                fatal_exit(@strval($php_errormsg));
            }
        } else {
            $matches = array();
            $num_matches = preg_match_all('#\\$GLOBALS[\'SITE_DB\']->query_insert(\'theme_images\',array(\'id\'=>\'([^\']*)\',\'theme\'=>\'([^\']*)\',\'path\'=>\'([^\']*)\',\'lang\'=>\'([^\']*)\'),false,true);#', $modphp_file, $matches);
            for ($i = 0; $i < $num_matches; $i++) {
                $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => $matches[1][$i], 'theme' => $matches[2][$i], 'path' => $matches[3][$i], 'lang' => $matches[4][$i]), false, true);
            }
        }
    }
    tar_close($tar);
    // Call install script, if it exists
    $path = '/data_custom/' . strtolower(basename($file, '.tar')) . '_install.php';
    if (file_exists(get_file_base() . $path)) {
        require_code('files');
        http_download_file(get_base_url() . $path);
    }
    log_it('INSTALL_ADDON', $addon);
}
Exemplo n.º 12
0
 /**
  * The UI to confirm the install of an addon.
  *
  * @return tempcode		The UI
  */
 function addon_install()
 {
     $title = get_page_title('INSTALL_ADDON');
     $file = get_param('file');
     list($warnings, $files, $info) = inform_about_addon_install($file);
     $url = build_url(array('page' => '_SELF', 'type' => '_addon_install'), '_SELF');
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS'))));
     $_description = comcode_to_tempcode(str_replace('\\n', "\n", $info['description']), $GLOBALS['FORUM_DRIVER']->get_guest_id());
     if ($info['version'] == '(version-synched)') {
         $info['version'] = float_to_raw_string(ocp_version_number());
     }
     return do_template('ADDON_INSTALL_CONFIRM_SCREEN', array('_GUID' => '79b8c0e900a498cfb166392163295a07', 'TITLE' => $title, 'FILE' => $file, 'URL' => $url, 'FILES' => $files, 'WARNINGS' => $warnings, 'NAME' => $info['name'], 'AUTHOR' => $info['author'], 'ORGANISATION' => $info['organisation'], 'VERSION' => $info['version'], 'DESCRIPTION' => $_description));
 }