示例#1
0
 public static function setUpBeforeClass()
 {
     if (!extension_loaded('apc')) {
         self::markTestSkipped('APC extension is not loaded');
     }
     $php_ini = new \phpbb\php\ini();
     if (!$php_ini->get_bool('apc.enabled')) {
         self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini');
     }
     if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli')) {
         self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
     }
 }
示例#2
0
 /**
  * Original copyright information for the function from AutoMOD.
  * The function was almost totally changed by the authors of Upload Extensions.
  * @package       automod
  * @copyright (c) 2008 phpBB Group
  * @license       http://opensource.org/licenses/gpl-2.0.php GNU Public License
  *
  * @param string $action Requested action.
  * @return \filespec|bool
  */
 public function proceed_upload($action)
 {
     global $phpbb_root_path, $phpEx, $user, $request;
     //$can_upload = (@ini_get('file_uploads') == '0' || strtolower(@ini_get('file_uploads')) == 'off' || !@extension_loaded('zlib')) ? false : true;
     $user->add_lang('posting');
     // For error messages
     if (!class_exists('\\fileupload')) {
         include $phpbb_root_path . 'includes/functions_upload.' . $phpEx;
     }
     $upload = new \fileupload();
     $upload->set_allowed_extensions(array('zip'));
     // Only allow ZIP files
     // Make sure the ext/ directory exists and if it doesn't, create it
     if (!is_dir($phpbb_root_path . 'ext')) {
         if (!files::catch_errors(files::recursive_mkdir($phpbb_root_path . 'ext'))) {
             return false;
         }
     }
     if (!is_writable($phpbb_root_path . 'ext')) {
         files::catch_errors($user->lang['EXT_NOT_WRITABLE']);
         return false;
     }
     if (!is_dir(objects::$zip_dir)) {
         if (!files::catch_errors(files::recursive_mkdir(objects::$zip_dir))) {
             return false;
         }
     }
     if (!is_writable($phpbb_root_path . 'ext/' . objects::$upload_ext_name . '/tmp')) {
         if (!phpbb_chmod($phpbb_root_path . 'ext/' . objects::$upload_ext_name . '/tmp', CHMOD_READ | CHMOD_WRITE)) {
             files::catch_errors($user->lang['EXT_TMP_NOT_WRITABLE']);
             return false;
         }
     }
     $file = false;
     // Proceed with the upload
     if ($action == 'upload') {
         if (!$request->is_set("extupload", \phpbb\request\request_interface::FILES)) {
             files::catch_errors($user->lang['NO_UPLOAD_FILE']);
             return false;
         }
         $file = $upload->form_upload('extupload');
     } else {
         if ($action == 'upload_remote') {
             $php_ini = new \phpbb\php\ini();
             if (!$php_ini->get_bool('allow_url_fopen')) {
                 files::catch_errors($user->lang['EXT_ALLOW_URL_FOPEN_DISABLED']);
                 return false;
             }
             $remote_url = $request->variable('remote_upload', '');
             if (!extension_loaded('openssl') && 'https' === substr($remote_url, 0, 5)) {
                 files::catch_errors($user->lang['EXT_OPENSSL_DISABLED']);
                 return false;
             }
             $file = files::remote_upload($upload, $user, $remote_url);
         }
     }
     return $file;
 }
示例#3
0
<?php 
define('IN_DB_UPDATE', true);
/**
* @todo mysql update?
*/
// End startup code
$migrator = $phpbb_container->get('migrator');
$migrator->set_output_handler(new \phpbb\db\log_wrapper_migrator_output_handler($user, new \phpbb\db\html_migrator_output_handler($user), $phpbb_root_path . 'store/migrations_' . time() . '.log'));
$migrator->create_migrations_table();
$phpbb_extension_manager = $phpbb_container->get('ext.manager');
$migrations = $phpbb_extension_manager->get_finder()->core_path('phpbb/db/migration/data/')->extension_directory('/migrations')->get_classes();
$migrator->set_migrations($migrations);
// What is a safe limit of execution time? Half the max execution time should be safe.
//  No more than 15 seconds so the user isn't sitting and waiting for a very long time
$phpbb_ini = new \phpbb\php\ini();
$safe_time_limit = min(15, $phpbb_ini->get_int('max_execution_time') / 2);
// While we're going to try limit this to half the max execution time,
//  we want to try and take additional measures to prevent hitting the
//  max execution time (if, say, one migration step takes much longer
//  than the max execution time)
@set_time_limit(0);
while (!$migrator->finished()) {
    try {
        $migrator->update();
    } catch (\phpbb\db\migration\exception $e) {
        echo $e->getLocalisedMessage($user);
        phpbb_end_update($cache, $config);
    }
    $state = array_merge(array('migration_schema_done' => false, 'migration_data_done' => false), $migrator->last_run_migration['state']);
    // Are we approaching the time limit? If so we want to pause the update and continue after refreshing