当前位置: 首页>>代码示例>>PHP>>正文


PHP apache_reset_timeout函数代码示例

本文整理汇总了PHP中apache_reset_timeout函数的典型用法代码示例。如果您正苦于以下问题:PHP apache_reset_timeout函数的具体用法?PHP apache_reset_timeout怎么用?PHP apache_reset_timeout使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了apache_reset_timeout函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: chmodRecursively

/**
 * Changes the filesystem permissions of a file or a folder recursively.  Also prints out folder
 * names online on success / error and prints out filenames on error as well.
 *
 * @param string $filename absolute path to folder/file that should be chmod'ed
 * @param int $folderPermissions (octal) new permissions for folders
 * @param int $filePermissions (octal) new permissions for files
 * @param int $start unix timestamp of last webserver/php timeout counter-measure
 * @return null on success, int <> 0 on error
 */
function chmodRecursively($filename, $folderPermissions, $filePermissions, $start)
{
    $filename = rtrim($filename, '\\/');
    $error = 0;
    /* Try to prevent timeouts */
    if (time() - $start > 55) {
        if (function_exists('apache_reset_timeout')) {
            @apache_reset_timeout();
        }
        @set_time_limit(600);
        $start = time();
    }
    /*
     * Have to chmod first before the is_dir check because is_dir does a stat on the
     * file / dir which fails if the permissions are too tight.
     * Chmod to filepermissions since the majority of the chmod() calls will be for
     * files anyway and then change the permissions for folders with a second call.
     */
    if (!@chmod($filename, $filePermissions)) {
        error("[ERROR]", $filename);
        $error = 1;
    }
    if (is_dir($filename)) {
        /* For folders, we change the permissions to the right ones with a second chmod call. */
        if (!$error) {
            if (!@chmod($filename, $folderPermissions)) {
                error("[ERROR]", $filename);
                $error = 1;
            } else {
                status("[OK]", $filename);
            }
        }
        /*
         * Recurse into subdirectories: Open all files / sub-dirs and change the
         * permissions recursively.
         */
        if ($fd = opendir($filename)) {
            while (($child = readdir($fd)) !== false) {
                if ($child == '.' || $child == '..') {
                    continue;
                }
                $fullpath = "{$filename}/{$child}";
                $ret = chmodRecursively($fullpath, $folderPermissions, $filePermissions, $start);
                $error |= $ret;
            }
            closedir($fd);
        } else {
            error("Cannot open directory", $filename);
            return 1;
        }
    }
    if ($error) {
        return 1;
    }
    return null;
}
开发者ID:justinlyon,项目名称:scc,代码行数:66,代码来源:chmod.php

示例2: smtp_mail

function smtp_mail($mail_to_array, $subject, $message, $headers)
{
    global $modSettings, $webmaster_email, $txt;
    $modSettings['smtp_host'] = trim($modSettings['smtp_host']);
    // Try POP3 before SMTP?
    // !!! There's no interface for this yet.
    if ($modSettings['mail_type'] == 2 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') {
        $socket = fsockopen($modSettings['smtp_host'], 110, $errno, $errstr, 2);
        if (!$socket && (substr($modSettings['smtp_host'], 0, 5) == 'smtp.' || substr($modSettings['smtp_host'], 0, 11) == 'ssl://smtp.')) {
            $socket = fsockopen(strtr($modSettings['smtp_host'], array('smtp.' => 'pop.')), 110, $errno, $errstr, 2);
        }
        if ($socket) {
            fgets($socket, 256);
            fputs($socket, 'USER ' . $modSettings['smtp_username'] . "\r\n");
            fgets($socket, 256);
            fputs($socket, 'PASS ' . base64_decode($modSettings['smtp_password']) . "\r\n");
            fgets($socket, 256);
            fputs($socket, 'QUIT' . "\r\n");
            fclose($socket);
        }
    }
    // Try to connect to the SMTP server... if it doesn't exist, only wait three seconds.
    if (!($socket = fsockopen($modSettings['smtp_host'], empty($modSettings['smtp_port']) ? 25 : $modSettings['smtp_port'], $errno, $errstr, 3))) {
        // Maybe we can still save this?  The port might be wrong.
        if (substr($modSettings['smtp_host'], 0, 4) == 'ssl:' && (empty($modSettings['smtp_port']) || $modSettings['smtp_port'] == 25)) {
            if ($socket = fsockopen($modSettings['smtp_host'], 465, $errno, $errstr, 3)) {
                log_error($txt['smtp_port_ssl']);
            }
        }
        // Unable to connect!  Don't show any error message, but just log one and try to continue anyway.
        if (!$socket) {
            log_error($txt['smtp_no_connect'] . ': ' . $errno . ' : ' . $errstr);
            return false;
        }
    }
    // Wait for a response of 220, without "-" continuer.
    if (!server_parse(null, $socket, '220')) {
        return false;
    }
    if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '') {
        // !!! These should send the CURRENT server's name, not the mail server's!
        // EHLO could be understood to mean encrypted hello...
        if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250') {
            if (!server_parse('AUTH LOGIN', $socket, '334')) {
                return false;
            }
            // Send the username and password, encoded.
            if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334')) {
                return false;
            }
            // The password is already encoded ;)
            if (!server_parse($modSettings['smtp_password'], $socket, '235')) {
                return false;
            }
        } elseif (!server_parse('HELO ' . $modSettings['smtp_host'], $socket, '250')) {
            return false;
        }
    } else {
        // Just say "helo".
        if (!server_parse('HELO ' . $modSettings['smtp_host'], $socket, '250')) {
            return false;
        }
    }
    // Fix the message for any lines beginning with a period! (the first is ignored, you see.)
    $message = strtr($message, array("\r\n." => "\r\n.."));
    // !! Theoretically, we should be able to just loop the RCPT TO.
    $mail_to_array = array_values($mail_to_array);
    foreach ($mail_to_array as $i => $mail_to) {
        // Reset the connection to send another email.
        if ($i != 0) {
            if (!server_parse('RSET', $socket, '250')) {
                return false;
            }
        }
        // From, to, and then start the data...
        if (!server_parse('MAIL FROM: <' . (empty($modSettings['mail_from']) ? $webmaster_email : $modSettings['mail_from']) . '>', $socket, '250')) {
            return false;
        }
        if (!server_parse('RCPT TO: <' . $mail_to . '>', $socket, '250')) {
            return false;
        }
        if (!server_parse('DATA', $socket, '354')) {
            return false;
        }
        fputs($socket, 'Subject: ' . $subject . "\r\n");
        if (strlen($mail_to) > 0) {
            fputs($socket, 'To: <' . $mail_to . ">\r\n");
        }
        fputs($socket, $headers . "\r\n\r\n");
        fputs($socket, $message . "\r\n");
        // Send a ., or in other words "end of data".
        if (!server_parse('.', $socket, '250')) {
            return false;
        }
        // Almost done, almost done... don't stop me just yet!
        @set_time_limit(300);
        if (function_exists('apache_reset_timeout')) {
            apache_reset_timeout();
        }
    }
//.........这里部分代码省略.........
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:101,代码来源:Subs-Post.php

示例3: html_to_bbc

function html_to_bbc($text)
{
    global $modSettings, $smcFunc, $sourcedir, $scripturl, $context;
    // Replace newlines with spaces, as that's how browsers usually interpret them.
    $text = preg_replace("~\\s*[\r\n]+\\s*~", ' ', $text);
    // Though some of us love paragraphs, the parser will do better with breaks.
    $text = preg_replace('~</p>\\s*?<p~i', '</p><br /><p', $text);
    $text = preg_replace('~</p>\\s*(?!<)~i', '</p><br />', $text);
    // Safari/webkit wraps lines in Wysiwyg in <div>'s.
    if ($context['browser']['is_webkit']) {
        $text = preg_replace(array('~<div(?:\\s(?:[^<>]*?))?' . '>~i', '</div>'), array('<br />', ''), $text);
    }
    // If there's a trailing break get rid of it - Firefox tends to add one.
    $text = preg_replace('~<br\\s?/?' . '>$~i', '', $text);
    // Remove any formatting within code tags.
    if (strpos($text, '[code') !== false) {
        $text = preg_replace('~<br\\s?/?' . '>~i', '#smf_br_spec_grudge_cool!#', $text);
        $parts = preg_split('~(\\[/code\\]|\\[code(?:=[^\\]]+)?\\])~i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
        // Only mess with stuff outside [code] tags.
        for ($i = 0, $n = count($parts); $i < $n; $i++) {
            // Value of 2 means we're inside the tag.
            if ($i % 4 == 2) {
                $parts[$i] = strip_tags($parts[$i]);
            }
        }
        $text = strtr(implode('', $parts), array('#smf_br_spec_grudge_cool!#' => '<br />'));
    }
    // Remove scripts, style and comment blocks.
    $text = preg_replace('~<script[^>]*[^/]?' . '>.*?</script>~i', '', $text);
    $text = preg_replace('~<style[^>]*[^/]?' . '>.*?</style>~i', '', $text);
    $text = preg_replace('~\\<\\!--.*?-->~i', '', $text);
    $text = preg_replace('~\\<\\!\\[CDATA\\[.*?\\]\\]\\>~i', '', $text);
    // Do the smileys ultra first!
    preg_match_all('~<img\\s+[^<>]*?id="*smiley_\\d+_([^<>]+?)[\\s"/>]\\s*[^<>]*?/*>(?:\\s)?~i', $text, $matches);
    if (!empty($matches[0])) {
        // Easy if it's not custom.
        if (empty($modSettings['smiley_enable'])) {
            $smileysfrom = array('>:D', ':D', '::)', '>:(', ':)', ';)', ';D', ':(', ':o', '8)', ':P', '???', ':-[', ':-X', ':-*', ':\'(', ':-\\', '^-^', 'O0', 'C:-)', '0:)');
            $smileysto = array('evil.gif', 'cheesy.gif', 'rolleyes.gif', 'angry.gif', 'smiley.gif', 'wink.gif', 'grin.gif', 'sad.gif', 'shocked.gif', 'cool.gif', 'tongue.gif', 'huh.gif', 'embarrassed.gif', 'lipsrsealed.gif', 'kiss.gif', 'cry.gif', 'undecided.gif', 'azn.gif', 'afro.gif', 'police.gif', 'angel.gif');
            foreach ($matches[1] as $k => $file) {
                $found = array_search($file, $smileysto);
                // Note the weirdness here is to stop double spaces between smileys.
                if ($found) {
                    $matches[1][$k] = '-[]-smf_smily_start#|#' . htmlspecialchars($smileysfrom[$found]) . '-[]-smf_smily_end#|#';
                } else {
                    $matches[1][$k] = '';
                }
            }
        } else {
            // Load all the smileys.
            $names = array();
            foreach ($matches[1] as $file) {
                $names[] = $file;
            }
            $names = array_unique($names);
            if (!empty($names)) {
                $request = smf_db_query('
					SELECT code, filename
					FROM {db_prefix}smileys
					WHERE filename IN ({array_string:smiley_filenames})', array('smiley_filenames' => $names));
                $mappings = array();
                while ($row = mysql_fetch_assoc($request)) {
                    $mappings[$row['filename']] = htmlspecialchars($row['code']);
                }
                mysql_free_result($request);
                foreach ($matches[1] as $k => $file) {
                    if (isset($mappings[$file])) {
                        $matches[1][$k] = '-[]-smf_smily_start#|#' . $mappings[$file] . '-[]-smf_smily_end#|#';
                    }
                }
            }
        }
        // Replace the tags!
        $text = str_replace($matches[0], $matches[1], $text);
        // Now sort out spaces
        $text = str_replace(array('-[]-smf_smily_end#|#-[]-smf_smily_start#|#', '-[]-smf_smily_end#|#', '-[]-smf_smily_start#|#'), ' ', $text);
    }
    // Only try to buy more time if the client didn't quit.
    if (connection_aborted() && $context['server']['is_apache']) {
        @apache_reset_timeout();
    }
    $parts = preg_split('~(<[A-Za-z]+\\s*[^<>]*?style="?[^<>"]+"?[^<>]*?(?:/?)>|</[A-Za-z]+>)~', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
    $replacement = '';
    $stack = array();
    foreach ($parts as $part) {
        if (preg_match('~(<([A-Za-z]+)\\s*[^<>]*?)style="?([^<>"]+)"?([^<>]*?(/?)>)~', $part, $matches) === 1) {
            // If it's being closed instantly, we can't deal with it...yet.
            if ($matches[5] === '/') {
                continue;
            } else {
                // Get an array of styles that apply to this element. (The strtr is there to combat HTML generated by Word.)
                $styles = explode(';', strtr($matches[3], array('&quot;' => '')));
                $curElement = $matches[2];
                $precedingStyle = $matches[1];
                $afterStyle = $matches[4];
                $curCloseTags = '';
                $extra_attr = '';
                foreach ($styles as $type_value_pair) {
                    // Remove spaces and convert uppercase letters.
                    $clean_type_value_pair = strtolower(strtr(trim($type_value_pair), '=', ':'));
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Subs-Editor.php

示例4: pauseSignatureApplySettings

/**
 * Just pause the signature applying thing.
 *
 * @todo Move to subs file
 * @todo Merge with other pause functions?
 *    pausePermsSave(), pausAttachmentMaintenance(), pauseRepairProcess()
 *
 * @param int $applied_sigs
 */
function pauseSignatureApplySettings($applied_sigs)
{
    global $context, $txt, $sig_start;
    // Try get more time...
    @set_time_limit(600);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    // Have we exhausted all the time we allowed?
    if (time() - array_sum(explode(' ', $sig_start)) < 3) {
        return;
    }
    $context['continue_get_data'] = '?action=admin;area=featuresettings;sa=sig;apply;step=' . $applied_sigs . ';' . $context['session_var'] . '=' . $context['session_id'];
    $context['page_title'] = $txt['not_done_title'];
    $context['continue_post_data'] = '';
    $context['continue_countdown'] = '2';
    $context['sub_template'] = 'not_done';
    // Specific stuff to not break this template!
    $context[$context['admin_menu_name']]['current_subsection'] = 'sig';
    // Get the right percent.
    $context['continue_percent'] = round($applied_sigs / $context['max_member'] * 100);
    // Never more than 100%!
    $context['continue_percent'] = min($context['continue_percent'], 100);
    obExit();
}
开发者ID:KeiroD,项目名称:Elkarte,代码行数:34,代码来源:ManageFeatures.controller.php

示例5: package_create_backup

function package_create_backup($id = 'backup')
{
    global $sourcedir, $boarddir, $smcFunc;
    $files = array();
    $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'ssi_examples.php', 'ssi_examples.shtml');
    foreach ($base_files as $file) {
        if (file_exists($boarddir . '/' . $file)) {
            $files[realpath($boarddir . '/' . $file)] = array(empty($_REQUEST['use_full_paths']) ? $file : $boarddir . '/' . $file, stat($boarddir . '/' . $file));
        }
    }
    $dirs = array($sourcedir => empty($_REQUEST['use_full_paths']) ? 'Sources/' : strtr($sourcedir . '/', '\\', '/'));
    $request = smf_db_query('
		SELECT value
		FROM {db_prefix}themes
		WHERE id_member = {int:no_member}
			AND variable = {string:theme_dir}', array('no_member' => 0, 'theme_dir' => 'theme_dir'));
    while ($row = mysql_fetch_assoc($request)) {
        $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'Themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
    }
    mysql_free_result($request);
    while (!empty($dirs)) {
        list($dir, $dest) = each($dirs);
        unset($dirs[$dir]);
        $listing = @dir($dir);
        if (!$listing) {
            continue;
        }
        while ($entry = $listing->read()) {
            if (preg_match('~^(\\.{1,2}|CVS|backup.*|help|images|.*\\~)$~', $entry) != 0) {
                continue;
            }
            $filepath = realpath($dir . '/' . $entry);
            if (isset($files[$filepath])) {
                continue;
            }
            $stat = stat($dir . '/' . $entry);
            if ($stat['mode'] & 040000) {
                $files[$filepath] = array($dest . $entry . '/', $stat);
                $dirs[$dir . '/' . $entry] = $dest . $entry . '/';
            } else {
                $files[$filepath] = array($dest . $entry, $stat);
            }
        }
        $listing->close();
    }
    if (!file_exists($boarddir . '/Packages/backups')) {
        mktree($boarddir . '/Packages/backups', 0777);
    }
    if (!is_writable($boarddir . '/Packages/backups')) {
        package_chmod($boarddir . '/Packages/backups');
    }
    $output_file = $boarddir . '/Packages/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id);
    $output_ext = '.tar' . (function_exists('gzopen') ? '.gz' : '');
    if (file_exists($output_file . $output_ext)) {
        $i = 2;
        while (file_exists($output_file . '_' . $i . $output_ext)) {
            $i++;
        }
        $output_file = $output_file . '_' . $i . $output_ext;
    } else {
        $output_file .= $output_ext;
    }
    @set_time_limit(300);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    if (function_exists('gzopen')) {
        $fwrite = 'gzwrite';
        $fclose = 'gzclose';
        $output = gzopen($output_file, 'wb');
    } else {
        $fwrite = 'fwrite';
        $fclose = 'fclose';
        $output = fopen($output_file, 'wb');
    }
    foreach ($files as $real_file => $file) {
        if (!file_exists($real_file)) {
            continue;
        }
        $stat = $file[1];
        if (substr($file[0], -1) == '/') {
            $stat['size'] = 0;
        }
        $current = pack('a100a8a8a8a12a12a8a1a100a6a2a32a32a8a8a155a12', $file[0], decoct($stat['mode']), sprintf('%06d', decoct($stat['uid'])), sprintf('%06d', decoct($stat['gid'])), decoct($stat['size']), decoct($stat['mtime']), '', 0, '', '', '', '', '', '', '', '', '');
        $checksum = 256;
        for ($i = 0; $i < 512; $i++) {
            $checksum += ord($current[$i]);
        }
        $fwrite($output, substr($current, 0, 148) . pack('a8', decoct($checksum)) . substr($current, 156, 511));
        if ($stat['size'] == 0) {
            continue;
        }
        $fp = fopen($real_file, 'rb');
        while (!feof($fp)) {
            $fwrite($output, fread($fp, 16384));
        }
        fclose($fp);
        $fwrite($output, pack('a' . (512 - $stat['size'] % 512), ''));
    }
    $fwrite($output, pack('a1024', ''));
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:Subs-Package.php

示例6: ThemeInstall

function ThemeInstall()
{
    global $sourcedir, $boarddir, $boardurl, $txt, $context, $settings, $modSettings, $smcFunc;
    checkSession('request');
    isAllowedTo('admin_forum');
    checkSession('request');
    require_once $sourcedir . '/Subs-Package.php';
    loadTemplate('Themes');
    if (isset($_GET['theme_id'])) {
        $result = $smcFunc['db_query']('', '
			SELECT value
			FROM {db_prefix}themes
			WHERE id_theme = {int:current_theme}
				AND id_member = {int:no_member}
				AND variable = {string:name}
			LIMIT 1', array('current_theme' => (int) $_GET['theme_id'], 'no_member' => 0, 'name' => 'name'));
        list($theme_name) = $smcFunc['db_fetch_row']($result);
        $smcFunc['db_free_result']($result);
        $context['sub_template'] = 'installed';
        $context['page_title'] = $txt['theme_installed'];
        $context['installed_theme'] = array('id' => (int) $_GET['theme_id'], 'name' => $theme_name);
        return;
    }
    if (!empty($_FILES['theme_gz']) && (!isset($_FILES['theme_gz']['error']) || $_FILES['theme_gz']['error'] != 4) || !empty($_REQUEST['theme_gz'])) {
        $method = 'upload';
    } elseif (isset($_REQUEST['theme_dir']) && rtrim(realpath($_REQUEST['theme_dir']), '/\\') != realpath($boarddir . '/Themes') && file_exists($_REQUEST['theme_dir'])) {
        $method = 'path';
    } else {
        $method = 'copy';
    }
    if (!empty($_REQUEST['copy']) && $method == 'copy') {
        // Hopefully the themes directory is writable, or we might have a problem.
        if (!is_writable($boarddir . '/Themes')) {
            fatal_lang_error('theme_install_write_error', 'critical');
        }
        $theme_dir = $boarddir . '/Themes/' . preg_replace('~[^A-Za-z0-9_\\- ]~', '', $_REQUEST['copy']);
        umask(0);
        mkdir($theme_dir, 0777);
        @set_time_limit(600);
        if (function_exists('apache_reset_timeout')) {
            @apache_reset_timeout();
        }
        // Create subdirectories for css and javascript files.
        mkdir($theme_dir . '/css', 0777);
        mkdir($theme_dir . '/scripts', 0777);
        // Copy over the default non-theme files.
        $to_copy = array('/index.php', '/index.template.php', '/css/index.css', '/css/rtl.css', '/scripts/theme.js');
        foreach ($to_copy as $file) {
            copy($settings['default_theme_dir'] . $file, $theme_dir . $file);
            @chmod($theme_dir . $file, 0777);
        }
        // And now the entire images directory!
        copytree($settings['default_theme_dir'] . '/images', $theme_dir . '/images');
        package_flush_cache();
        $theme_name = $_REQUEST['copy'];
        $images_url = $boardurl . '/Themes/' . basename($theme_dir) . '/images';
        $theme_dir = realpath($theme_dir);
        // Lets get some data for the new theme.
        $request = $smcFunc['db_query']('', '
			SELECT variable, value
			FROM {db_prefix}themes
			WHERE variable IN ({string:theme_templates}, {string:theme_layers})
				AND id_member = {int:no_member}
				AND id_theme = {int:default_theme}', array('no_member' => 0, 'default_theme' => 1, 'theme_templates' => 'theme_templates', 'theme_layers' => 'theme_layers'));
        while ($row = $smcFunc['db_fetch_assoc']($request)) {
            if ($row['variable'] == 'theme_templates') {
                $theme_templates = $row['value'];
            } elseif ($row['variable'] == 'theme_layers') {
                $theme_layers = $row['value'];
            } else {
                continue;
            }
        }
        $smcFunc['db_free_result']($request);
        // Lets add a theme_info.xml to this theme.
        $xml_info = '<' . '?xml version="1.0"?' . '>
<theme-info xmlns="http://www.simplemachines.org/xml/theme-info" xmlns:smf="http://www.simplemachines.org/">
	<!-- For the id, always use something unique - put your name, a colon, and then the package name. -->
	<id>smf:' . $smcFunc['strtolower'](str_replace(array(' '), '_', $_REQUEST['copy'])) . '</id>
	<version>' . $modSettings['smfVersion'] . '</version>
	<!-- Theme name, used purely for aesthetics. -->
	<name>' . $_REQUEST['copy'] . '</name>
	<!-- Author: your email address or contact information. The name attribute is optional. -->
	<author name="Simple Machines">info@simplemachines.org</author>
	<!-- Website... where to get updates and more information. -->
	<website>http://www.simplemachines.org/</website>
	<!-- Template layers to use, defaults to "html,body". -->
	<layers>' . (empty($theme_layers) ? 'html,body' : $theme_layers) . '</layers>
	<!-- Templates to load on startup. Default is "index". -->
	<templates>' . (empty($theme_templates) ? 'index' : $theme_templates) . '</templates>
	<!-- Base this theme off another? Default is blank, or no. It could be "default". -->
	<based-on></based-on>
</theme-info>';
        // Now write it.
        $fp = @fopen($theme_dir . '/theme_info.xml', 'w+');
        if ($fp) {
            fwrite($fp, $xml_info);
            fclose($fp);
        }
    } elseif (isset($_REQUEST['theme_dir']) && $method == 'path') {
//.........这里部分代码省略.........
开发者ID:Kheros,项目名称:MMOver,代码行数:101,代码来源:Themes.php

示例7: pausePermsSave

/**
 * Function called to briefly pause execution of directory/file chmod actions
 *
 * - Called by action_perms_save().
 *
 * @package Packages
 */
function pausePermsSave()
{
    global $context, $txt;
    // Try get more time...
    @set_time_limit(600);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    // Set up the items for the pause form
    $context['sub_template'] = 'pause_action_permissions';
    $context['page_title'] = $txt['package_file_perms_applying'];
    // And how are we progressing with our directories
    $context['remaining_items'] = count($context['method'] == 'individual' ? $context['to_process'] : $context['directory_list']);
    $context['progress_message'] = sprintf($context['method'] == 'individual' ? $txt['package_file_perms_items_done'] : $txt['package_file_perms_dirs_done'], $context['total_items'] - $context['remaining_items'], $context['total_items']);
    $context['progress_percent'] = round(($context['total_items'] - $context['remaining_items']) / $context['total_items'] * 100, 1);
    // Never more than 100%!
    $context['progress_percent'] = min($context['progress_percent'], 100);
    // And how are we progressing with files within a directory
    if ($context['method'] != 'individual' && !empty($context['total_files'])) {
        $context['file_progress_message'] = sprintf($txt['package_file_perms_files_done'], $context['file_offset'], $context['total_files']);
        $context['file_progress_percent'] = round($context['file_offset'] / $context['total_files'] * 100, 1);
        // Never more than 100%!
        $context['file_progress_percent'] = min($context['file_progress_percent'], 100);
    }
    obExit();
}
开发者ID:scripple,项目名称:Elkarte,代码行数:33,代码来源:Packages.controller.php

示例8: package_create_backup

/**
 * Creates a site backup before installing a package just in case things don't go
 * as planned.
 *
 * @package Packages
 * @param string $id
 */
function package_create_backup($id = 'backup')
{
    $db = database();
    $files = array();
    // The files that reside outside of sources, in the base, we add manually
    $base_files = array('index.php', 'SSI.php', 'agreement.txt', 'ssi_examples.php', 'ssi_examples.shtml', 'subscriptions.php', 'email_imap_cron.php', 'emailpost.php', 'emailtopic.php');
    foreach ($base_files as $file) {
        if (file_exists(BOARDDIR . '/' . $file)) {
            $files[realpath(BOARDDIR . '/' . $file)] = array(empty($_REQUEST['use_full_paths']) ? $file : BOARDDIR . '/' . $file, stat(BOARDDIR . '/' . $file));
        }
    }
    // Root directory where most of our files reside
    $dirs = array(SOURCEDIR => empty($_REQUEST['use_full_paths']) ? 'sources/' : strtr(SOURCEDIR . '/', '\\', '/'));
    // Find all installed theme directories
    $request = $db->query('', '
		SELECT value
		FROM {db_prefix}themes
		WHERE id_member = {int:no_member}
			AND variable = {string:theme_dir}', array('no_member' => 0, 'theme_dir' => 'theme_dir'));
    while ($row = $db->fetch_assoc($request)) {
        $dirs[$row['value']] = empty($_REQUEST['use_full_paths']) ? 'themes/' . basename($row['value']) . '/' : strtr($row['value'] . '/', '\\', '/');
    }
    $db->free_result($request);
    // While we have directorys to check
    while (!empty($dirs)) {
        list($dir, $dest) = each($dirs);
        unset($dirs[$dir]);
        // Get the file listing for this directory
        $listing = @dir($dir);
        if (!$listing) {
            continue;
        }
        while ($entry = $listing->read()) {
            if (preg_match('~^(\\.{1,2}|CVS|backup.*|help|images|.*\\~)$~', $entry) != 0) {
                continue;
            }
            $filepath = realpath($dir . '/' . $entry);
            if (isset($files[$filepath])) {
                continue;
            }
            $stat = stat($dir . '/' . $entry);
            // If this is a directory, add it to the dir stack for processing
            if ($stat['mode'] & 040000) {
                $files[$filepath] = array($dest . $entry . '/', $stat);
                $dirs[$dir . '/' . $entry] = $dest . $entry . '/';
            } else {
                $files[$filepath] = array($dest . $entry, $stat);
            }
        }
        $listing->close();
    }
    // Make sure we have a backup directory and its writable
    if (!file_exists(BOARDDIR . '/packages/backups')) {
        mktree(BOARDDIR . '/packages/backups', 0777);
    }
    if (!is_writable(BOARDDIR . '/packages/backups')) {
        package_chmod(BOARDDIR . '/packages/backups');
    }
    // Name the output file, yyyy-mm-dd_before_package_name.tar.gz
    $output_file = BOARDDIR . '/packages/backups/' . strftime('%Y-%m-%d_') . preg_replace('~[$\\\\/:<>|?*"\']~', '', $id);
    $output_ext = '.tar' . (function_exists('gzopen') ? '.gz' : '');
    if (file_exists($output_file . $output_ext)) {
        $i = 2;
        while (file_exists($output_file . '_' . $i . $output_ext)) {
            $i++;
        }
        $output_file = $output_file . '_' . $i . $output_ext;
    } else {
        $output_file .= $output_ext;
    }
    // Buy some more time so we have enough to create this archive
    @set_time_limit(300);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    // Set up the file output handle, try gzip first to save space
    if (function_exists('gzopen')) {
        $fwrite = 'gzwrite';
        $fclose = 'gzclose';
        $output = gzopen($output_file, 'wb');
    } else {
        $fwrite = 'fwrite';
        $fclose = 'fclose';
        $output = fopen($output_file, 'wb');
    }
    // For each file we found in the directory, we add them to a TAR archive
    foreach ($files as $real_file => $file) {
        if (!file_exists($real_file)) {
            continue;
        }
        // Check if its a directory
        $stat = $file[1];
        if (substr($file[0], -1) == '/') {
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:Package.subs.php

示例9: DumpDatabase2

function DumpDatabase2()
{
    global $db_name, $scripturl, $context, $modSettings, $crlf, $smcFunc, $db_prefix;
    // Administrators only!
    if (!allowedTo('admin_forum')) {
        fatal_lang_error('no_dump_database', 'critical');
    }
    // You can't dump nothing!
    if (!isset($_REQUEST['struct']) && !isset($_REQUEST['data'])) {
        $_REQUEST['data'] = true;
    }
    checkSession('post');
    // We will need this, badly!
    db_extend();
    // Attempt to stop from dying...
    @set_time_limit(600);
    if (@ini_get('memory_limit') < 256) {
        @ini_set('memory_limit', '256M');
    }
    // Start saving the output... (don't do it otherwise for memory reasons.)
    if (isset($_REQUEST['compress']) && function_exists('gzencode')) {
        // Make sure we're gzipping output, but then say we're not in the header ^_^.
        if (empty($modSettings['enableCompressedOutput'])) {
            @ob_start('ob_gzhandler');
        } elseif (ob_get_length() != 0) {
            ob_end_clean();
            @ob_start('ob_gzhandler');
        }
        // Send faked headers so it will just save the compressed output as a gzip.
        header('Content-Type: application/x-gzip');
        header('Accept-Ranges: bytes');
        header('Content-Encoding: none');
        // Gecko browsers... don't like this. (Mozilla, Firefox, etc.)
        if (!$context['browser']['is_gecko']) {
            header('Content-Transfer-Encoding: binary');
        }
        // The file extension will include .gz...
        $extension = '.sql.gz';
    } else {
        // Get rid of the gzipping alreading being done.
        if (!empty($modSettings['enableCompressedOutput'])) {
            @ob_end_clean();
        } elseif (function_exists('ob_clean') && ob_get_length() != 0) {
            ob_clean();
        }
        // Tell the client to save this file, even though it's text.
        header('Content-Type: ' . ($context['browser']['is_ie'] || $context['browser']['is_opera'] ? 'application/octetstream' : 'application/octet-stream'));
        header('Content-Encoding: none');
        // This time the extension should just be .sql.
        $extension = '.sql';
    }
    // This should turn off the session URL parser.
    $scripturl = '';
    // If this database is flat file and has a handler function pass it to that.
    if (!empty($smcFunc['db_get_backup'])) {
        $smcFunc['db_get_backup']();
        exit;
    }
    // Send the proper headers to let them download this file.
    header('Content-Disposition: filename="' . $db_name . '-' . (empty($_REQUEST['struct']) ? 'data' : (empty($_REQUEST['data']) ? 'structure' : 'complete')) . '_' . strftime('%Y-%m-%d') . $extension . '"');
    header('Cache-Control: private');
    header('Connection: close');
    // This makes things simpler when using it so very very often.
    $crlf = "\r\n";
    // SQL Dump Header.
    echo '-- ==========================================================', $crlf, '--', $crlf, '-- Database dump of tables in `', $db_name, '`', $crlf, '-- ', timeformat(time(), false), $crlf, '--', $crlf, '-- ==========================================================', $crlf, $crlf;
    // Get all tables in the database....
    if (preg_match('~^`(.+?)`\\.(.+?)$~', $db_prefix, $match) != 0) {
        $db = strtr($match[1], array('`' => ''));
        $dbp = str_replace('_', '\\_', $match[2]);
    } else {
        $db = false;
        $dbp = $db_prefix;
    }
    // Dump each table.
    $tables = $smcFunc['db_list_tables'](false, $db_prefix . '%');
    foreach ($tables as $tableName) {
        if (function_exists('apache_reset_timeout')) {
            @apache_reset_timeout();
        }
        // Are we dumping the structures?
        if (isset($_REQUEST['struct'])) {
            echo $crlf, '--', $crlf, '-- Table structure for table `', $tableName, '`', $crlf, '--', $crlf, $crlf, $smcFunc['db_table_sql']($tableName), ';', $crlf;
        }
        // How about the data?
        if (!isset($_REQUEST['data']) || substr($tableName, -10) == 'log_errors') {
            continue;
        }
        // Are there any rows in this table?
        $get_rows = $smcFunc['db_insert_sql']($tableName);
        // No rows to get - skip it.
        if (empty($get_rows)) {
            continue;
        }
        echo $crlf, '--', $crlf, '-- Dumping data in `', $tableName, '`', $crlf, '--', $crlf, $crlf, $get_rows, '-- --------------------------------------------------------', $crlf;
    }
    echo $crlf, '-- Done', $crlf;
    exit;
}
开发者ID:valek0972,项目名称:hackits,代码行数:99,代码来源:DumpDatabase.php

示例10: removeNonTopicMessages

/**
 * This function removes all the messages of a certain user that are *not*
 * first messages of a topic
 *
 * @param int $memID The member id
 */
function removeNonTopicMessages($memID)
{
    $db = database();
    $request = $db->query('', '
		SELECT m.id_msg
		FROM {db_prefix}messages AS m
			INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic
				AND t.id_first_msg != m.id_msg)
		WHERE m.id_member = {int:selected_member}', array('selected_member' => $memID));
    // This could take a while... but ya know it's gonna be worth it in the end.
    while ($row = $db->fetch_assoc($request)) {
        if (function_exists('apache_reset_timeout')) {
            @apache_reset_timeout();
        }
        removeMessage($row['id_msg']);
    }
    $db->free_result($request);
}
开发者ID:Ralkage,项目名称:Elkarte,代码行数:24,代码来源:Messages.subs.php

示例11: removeTopics

/**
 * Removes the passed id_topic's.
 * Permissions are NOT checked here because the function is used in a scheduled task
 *
 * @param int[]|int $topics The topics to remove (can be an id or an array of ids).
 * @param bool $decreasePostCount if true users' post count will be reduced
 * @param bool $ignoreRecycling if true topics are not moved to the recycle board (if it exists).
 */
function removeTopics($topics, $decreasePostCount = true, $ignoreRecycling = false)
{
    global $modSettings;
    $db = database();
    // Nothing to do?
    if (empty($topics)) {
        return;
    }
    // Only a single topic.
    if (is_numeric($topics)) {
        $topics = array($topics);
    }
    // Decrease the post counts for members.
    if ($decreasePostCount) {
        $requestMembers = $db->query('', '
			SELECT m.id_member, COUNT(*) AS posts
			FROM {db_prefix}messages AS m
				INNER JOIN {db_prefix}boards AS b ON (b.id_board = m.id_board)
			WHERE m.id_topic IN ({array_int:topics})
				AND m.icon != {string:recycled}
				AND b.count_posts = {int:do_count_posts}
				AND m.approved = {int:is_approved}
			GROUP BY m.id_member', array('do_count_posts' => 0, 'recycled' => 'recycled', 'topics' => $topics, 'is_approved' => 1));
        if ($db->num_rows($requestMembers) > 0) {
            while ($rowMembers = $db->fetch_assoc($requestMembers)) {
                updateMemberData($rowMembers['id_member'], array('posts' => 'posts - ' . $rowMembers['posts']));
            }
        }
        $db->free_result($requestMembers);
    }
    // Recycle topics that aren't in the recycle board...
    if (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 && !$ignoreRecycling) {
        $request = $db->query('', '
			SELECT id_topic, id_board, unapproved_posts, approved
			FROM {db_prefix}topics
			WHERE id_topic IN ({array_int:topics})
				AND id_board != {int:recycle_board}
			LIMIT ' . count($topics), array('recycle_board' => $modSettings['recycle_board'], 'topics' => $topics));
        if ($db->num_rows($request) > 0) {
            // Get topics that will be recycled.
            $recycleTopics = array();
            while ($row = $db->fetch_assoc($request)) {
                if (function_exists('apache_reset_timeout')) {
                    @apache_reset_timeout();
                }
                $recycleTopics[] = $row['id_topic'];
                // Set the id_previous_board for this topic - and make it not sticky.
                $db->query('', '
					UPDATE {db_prefix}topics
					SET id_previous_board = {int:id_previous_board}, is_sticky = {int:not_sticky}
					WHERE id_topic = {int:id_topic}', array('id_previous_board' => $row['id_board'], 'id_topic' => $row['id_topic'], 'not_sticky' => 0));
            }
            $db->free_result($request);
            // Mark recycled topics as recycled.
            $db->query('', '
				UPDATE {db_prefix}messages
				SET icon = {string:recycled}
				WHERE id_topic IN ({array_int:recycle_topics})', array('recycle_topics' => $recycleTopics, 'recycled' => 'recycled'));
            // Move the topics to the recycle board.
            require_once SUBSDIR . '/Topic.subs.php';
            moveTopics($recycleTopics, $modSettings['recycle_board']);
            // Close reports that are being recycled.
            require_once SUBSDIR . '/Moderation.subs.php';
            $db->query('', '
				UPDATE {db_prefix}log_reported
				SET closed = {int:is_closed}
				WHERE id_topic IN ({array_int:recycle_topics})', array('recycle_topics' => $recycleTopics, 'is_closed' => 1));
            updateSettings(array('last_mod_report_action' => time()));
            recountOpenReports();
            // Topics that were recycled don't need to be deleted, so subtract them.
            $topics = array_diff($topics, $recycleTopics);
        } else {
            $db->free_result($request);
        }
    }
    // Still topics left to delete?
    if (empty($topics)) {
        return;
    }
    $adjustBoards = array();
    // Find out how many posts we are deleting.
    $request = $db->query('', '
		SELECT id_board, approved, COUNT(*) AS num_topics, SUM(unapproved_posts) AS unapproved_posts,
			SUM(num_replies) AS num_replies
		FROM {db_prefix}topics
		WHERE id_topic IN ({array_int:topics})
		GROUP BY id_board, approved', array('topics' => $topics));
    while ($row = $db->fetch_assoc($request)) {
        if (!isset($adjustBoards[$row['id_board']]['num_posts'])) {
            cache_put_data('board-' . $row['id_board'], null, 120);
            $adjustBoards[$row['id_board']] = array('num_posts' => 0, 'num_topics' => 0, 'unapproved_posts' => 0, 'unapproved_topics' => 0, 'id_board' => $row['id_board']);
        }
//.........这里部分代码省略.........
开发者ID:KeiroD,项目名称:Elkarte,代码行数:101,代码来源:Topic.subs.php

示例12: pastTime

function pastTime($substep = null, $force = false)
{
    global $time_start, $command_line;
    if (isset($_GET['substep']) && $_GET['substep'] < $substep) {
        $_GET['substep'] = $substep;
    }
    if ($command_line) {
        if (time() - $time_start > 1) {
            print_line('.');
            $time_start = time();
        }
        return;
    }
    @set_time_limit(300);
    if (function_exists('apache_reset_timeout')) {
        @apache_reset_timeout();
    }
    if (time() - $time_start < 10 && !$force) {
        return;
    }
    echo '
			<em>Incomplete.</em><br />

			<h2 style="margin-top: 2ex;">Not quite done yet!</h2>
			<h3>
				This conversion has paused to avoid overloading your server, and hence not working properly.<br />
				Don\'t worry though, <strong>nothing\'s wrong</strong> - simply click the <label for="continue">continue button</label> below to start the converter from where it left off.
			</h3>

			<form action="', $_SERVER['PHP_SELF'], '?step=', $_GET['step'], isset($_GET['substep']) ? '&amp;substep=' . $_GET['substep'] : '', isset($_GET['cstep']) ? '&amp;cstep=' . $_GET['cstep'] : '', '&amp;start=', $_REQUEST['start'], '" method="post" name="autoSubmit">
				<div class="righttext" style="margin: 1ex;"><input name="b" type="submit" value="Continue" class="button_submit" /></div>
			</form>
			<script type="text/javascript"><!-- // --><![CDATA[
				window.onload = doAutoSubmit;
				var countdown = 3;

				function doAutoSubmit()
				{
					if (countdown == 0)
						document.autoSubmit.submit();
					else if (countdown == -1)
						return;

					document.autoSubmit.b.value = "Continue (" + countdown + ")";
					countdown--;

					setTimeout("doAutoSubmit();", 1000);
				}
			// ]]></script>';
    template_convert_below();
    exit;
}
开发者ID:Realms-Network,项目名称:Vanilla-2-to-SMF-2,代码行数:52,代码来源:convert.php

示例13: action_transfer

    /**
     * Maintenance function to move attachments from one directory to another
     */
    public function action_transfer()
    {
        global $modSettings, $txt;
        checkSession();
        // We will need the functions from here
        require_once SUBSDIR . '/Attachments.subs.php';
        require_once SUBSDIR . '/ManageAttachments.subs.php';
        // The list(s) of directory's that are available.
        $modSettings['attachmentUploadDir'] = unserialize($modSettings['attachmentUploadDir']);
        if (!empty($modSettings['attachment_basedirectories'])) {
            $modSettings['attachment_basedirectories'] = unserialize($modSettings['attachment_basedirectories']);
        } else {
            $modSettings['basedirectory_for_attachments'] = array();
        }
        // Clean the inputs
        $_POST['from'] = (int) $_POST['from'];
        $_POST['auto'] = !empty($_POST['auto']) ? (int) $_POST['auto'] : 0;
        $_POST['to'] = (int) $_POST['to'];
        $start = !empty($_POST['empty_it']) ? 0 : $modSettings['attachmentDirFileLimit'];
        $_SESSION['checked'] = !empty($_POST['empty_it']) ? true : false;
        // Prepare for the moving
        $limit = 501;
        $results = array();
        $dir_files = 0;
        $current_progress = 0;
        $total_moved = 0;
        $total_not_moved = 0;
        // Need to know where we are moving things from
        if (empty($_POST['from']) || empty($_POST['auto']) && empty($_POST['to'])) {
            $results[] = $txt['attachment_transfer_no_dir'];
        }
        // Same location, that's easy
        if ($_POST['from'] == $_POST['to']) {
            $results[] = $txt['attachment_transfer_same_dir'];
        }
        // No errors so determine how many we may have to move
        if (empty($results)) {
            // Get the total file count for the progress bar.
            $total_progress = getFolderAttachmentCount($_POST['from']);
            $total_progress -= $start;
            if ($total_progress < 1) {
                $results[] = $txt['attachment_transfer_no_find'];
            }
        }
        // Nothing to move (no files in source or below the max limit)
        if (empty($results)) {
            // Moving them automaticaly?
            if (!empty($_POST['auto'])) {
                $modSettings['automanage_attachments'] = 1;
                // Create sub directroys off the root or from an attachment directory?
                $modSettings['use_subdirectories_for_attachments'] = $_POST['auto'] == -1 ? 0 : 1;
                $modSettings['basedirectory_for_attachments'] = $_POST['auto'] > 0 ? $modSettings['attachmentUploadDir'][$_POST['auto']] : $modSettings['basedirectory_for_attachments'];
                // Finaly, where do they need to go
                automanage_attachments_check_directory();
                $new_dir = $modSettings['currentAttachmentUploadDir'];
            } else {
                $new_dir = $_POST['to'];
            }
            $modSettings['currentAttachmentUploadDir'] = $new_dir;
            $break = false;
            while ($break === false) {
                @set_time_limit(300);
                if (function_exists('apache_reset_timeout')) {
                    @apache_reset_timeout();
                }
                // If limits are set, get the file count and size for the destination folder
                if ($dir_files <= 0 && (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit']))) {
                    $current_dir = attachDirProperties($new_dir);
                    $dir_files = $current_dir['files'];
                    $dir_size = $current_dir['size'];
                }
                // Find some attachments to move
                list($tomove_count, $tomove) = findAttachmentsToMove($_POST['from'], $start, $limit);
                // Nothing found to move
                if ($tomove_count === 0) {
                    if (empty($current_progress)) {
                        $results[] = $txt['attachment_transfer_no_find'];
                    }
                    break;
                }
                // No more to move after this batch then set the finished flag.
                if ($tomove_count < $limit) {
                    $break = true;
                }
                // Move them
                $moved = array();
                foreach ($tomove as $row) {
                    $source = getAttachmentFilename($row['filename'], $row['id_attach'], $row['id_folder'], false, $row['file_hash']);
                    $dest = $modSettings['attachmentUploadDir'][$new_dir] . '/' . basename($source);
                    // Size and file count check
                    if (!empty($modSettings['attachmentDirSizeLimit']) || !empty($modSettings['attachmentDirFileLimit'])) {
                        $dir_files++;
                        $dir_size += !empty($row['size']) ? $row['size'] : filesize($source);
                        // If we've reached a directory limit. Do something if we are in auto mode, otherwise set an error.
                        if (!empty($modSettings['attachmentDirSizeLimit']) && $dir_size > $modSettings['attachmentDirSizeLimit'] * 1024 || !empty($modSettings['attachmentDirFileLimit']) && $dir_files > $modSettings['attachmentDirFileLimit']) {
                            // Since we're in auto mode. Create a new folder and reset the counters.
                            if (!empty($_POST['auto'])) {
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:ManageAttachments.controller.php

示例14: action_install

 /**
  * Installs new themes, either from a gzip or copy of the default.
  *
  * What it does:
  * - Puts themes in $boardurl/themes.
  * - Assumes the gzip has a root directory in it. (ie default.)
  * - Requires admin_forum.
  * - Accessed with ?action=admin;area=theme;sa=install.
  *
  * @uses ManageThemes template
  */
 public function action_install()
 {
     global $boardurl, $txt, $context, $settings, $modSettings;
     checkSession('request');
     require_once SUBSDIR . '/Themes.subs.php';
     require_once SUBSDIR . '/Package.subs.php';
     loadTemplate('ManageThemes');
     // Passed an ID, then the install is complete, lets redirect and show them
     if (isset($_GET['theme_id'])) {
         $_GET['theme_id'] = (int) $_GET['theme_id'];
         $context['sub_template'] = 'installed';
         $context['page_title'] = $txt['theme_installed'];
         $context['installed_theme'] = array('id' => $_GET['theme_id'], 'name' => getThemeName($_GET['theme_id']));
         return;
     }
     // How are we going to install this theme, from a dir, zip, copy of default?
     if (!empty($_FILES['theme_gz']) && (!isset($_FILES['theme_gz']['error']) || $_FILES['theme_gz']['error'] != 4) || !empty($_REQUEST['theme_gz'])) {
         $method = 'upload';
     } elseif (isset($_REQUEST['theme_dir']) && rtrim(realpath($_REQUEST['theme_dir']), '/\\') != realpath(BOARDDIR . '/themes') && file_exists($_REQUEST['theme_dir'])) {
         $method = 'path';
     } else {
         $method = 'copy';
     }
     // Copy the default theme?
     if (!empty($_REQUEST['copy']) && $method == 'copy') {
         // Hopefully the themes directory is writable, or we might have a problem.
         if (!is_writable(BOARDDIR . '/themes')) {
             fatal_lang_error('theme_install_write_error', 'critical');
         }
         // Make the new directory, standard characters only
         $theme_dir = BOARDDIR . '/themes/' . preg_replace('~[^A-Za-z0-9_\\- ]~', '', $_REQUEST['copy']);
         umask(0);
         mkdir($theme_dir, 0777);
         // Get some more time if we can
         @set_time_limit(600);
         if (function_exists('apache_reset_timeout')) {
             @apache_reset_timeout();
         }
         // Create the subdirectories for css, javascript and font files.
         mkdir($theme_dir . '/css', 0777);
         mkdir($theme_dir . '/scripts', 0777);
         mkdir($theme_dir . '/webfonts', 0777);
         // Copy over the default non-theme files.
         $to_copy = array('/index.php', '/index.template.php', '/scripts/theme.js');
         foreach ($to_copy as $file) {
             copy($settings['default_theme_dir'] . $file, $theme_dir . $file);
             @chmod($theme_dir . $file, 0777);
         }
         // And now the entire css, images and webfonts directories!
         copytree($settings['default_theme_dir'] . '/css', $theme_dir . '/css');
         copytree($settings['default_theme_dir'] . '/images', $theme_dir . '/images');
         copytree($settings['default_theme_dir'] . '/webfonts', $theme_dir . '/webfonts');
         package_flush_cache();
         $theme_name = $_REQUEST['copy'];
         $images_url = $boardurl . '/themes/' . basename($theme_dir) . '/images';
         $theme_dir = realpath($theme_dir);
         // Lets get some data for the new theme (default theme (1), default settings (0)).
         $theme_values = loadThemeOptionsInto(1, 0, array(), array('theme_templates', 'theme_layers'));
         // Lets add a theme_info.xml to this theme.
         write_theme_info($_REQUEST['copy'], $modSettings['elkVersion'], $theme_dir, $theme_values);
     } elseif (isset($_REQUEST['theme_dir']) && $method == 'path') {
         if (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
             fatal_lang_error('theme_install_error', false);
         }
         $theme_name = basename($_REQUEST['theme_dir']);
         $theme_dir = $_REQUEST['theme_dir'];
     } elseif ($method == 'upload') {
         // Hopefully the themes directory is writable, or we might have a problem.
         if (!is_writable(BOARDDIR . '/themes')) {
             fatal_lang_error('theme_install_write_error', 'critical');
         }
         // This happens when the admin session is gone and the user has to login again
         if (empty($_FILES['theme_gz']) && empty($_REQUEST['theme_gz'])) {
             redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
         }
         // Set the default settings...
         $theme_name = strtok(basename(isset($_FILES['theme_gz']) ? $_FILES['theme_gz']['name'] : $_REQUEST['theme_gz']), '.');
         $theme_name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $theme_name);
         $theme_dir = BOARDDIR . '/themes/' . $theme_name;
         if (isset($_FILES['theme_gz']) && is_uploaded_file($_FILES['theme_gz']['tmp_name']) && (ini_get('open_basedir') != '' || file_exists($_FILES['theme_gz']['tmp_name']))) {
             read_tgz_file($_FILES['theme_gz']['tmp_name'], BOARDDIR . '/themes/' . $theme_name, false, true);
         } elseif (isset($_REQUEST['theme_gz'])) {
             if (!isAuthorizedServer($_REQUEST['theme_gz'])) {
                 fatal_lang_error('not_valid_server');
             }
             read_tgz_file($_REQUEST['theme_gz'], BOARDDIR . '/themes/' . $theme_name, false, true);
         } else {
             redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
         }
//.........这里部分代码省略.........
开发者ID:scripple,项目名称:Elkarte,代码行数:101,代码来源:ManageThemes.controller.php

示例15: pauseRepairProcess

function pauseRepairProcess($to_fix, $max_substep = 0)
{
    global $context, $txt, $time_start;
    // More time, I need more time!
    @set_time_limit(600);
    if (function_exists('apache_reset_timeout')) {
        apache_reset_timeout();
    }
    // Errr, wait.  How much time has this taken already?
    if (time() - array_sum(explode(' ', $time_start)) < 3) {
        return;
    }
    $context['continue_get_data'] = '?action=repairboards' . (isset($_GET['fixErrors']) ? ';fixErrors' : '') . ';step=' . $_GET['step'] . ';substep=' . $_GET['substep'];
    $context['page_title'] = $txt['not_done_title'];
    $context['continue_post_data'] = '';
    $context['continue_countdown'] = '2';
    $context['sub_template'] = 'not_done';
    // Change these two if more steps are added!
    if (empty($max_substep)) {
        $context['continue_percent'] = round($_GET['step'] * 100 / 25);
    } else {
        $context['continue_percent'] = round(($_GET['step'] * 100 + $_GET['substep'] * 100 / $max_substep) / 25);
    }
    // Never more than 100%!
    $context['continue_percent'] = min($context['continue_percent'], 100);
    $_SESSION['repairboards_to_fix'] = $to_fix;
    $_SESSION['repairboards_to_fix2'] = $context['repair_errors'];
    obExit();
}
开发者ID:VBGAMER45,项目名称:SMFMods,代码行数:29,代码来源:RepairBoards.php


注:本文中的apache_reset_timeout函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。