Exemplo n.º 1
0
function do_timeout_treatment($post_keyname, $check_key_treated = array())
{
    global $env_nbm, $base_url, $page, $must_repost;
    if ($env_nbm['is_sendmail_timeout']) {
        if (isset($_POST[$post_keyname])) {
            $post_count = count($_POST[$post_keyname]);
            $treated_count = count($check_key_treated);
            if ($treated_count != 0) {
                $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count);
            } else {
                $time_refresh = 0;
            }
            $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated);
            $must_repost = true;
            $page['errors'][] = l10n_dec('Execution time is out, treatment must be continue [Estimated time: %d second].', 'Execution time is out, treatment must be continue [Estimated time: %d seconds].', $time_refresh);
        }
    }
}
Exemplo n.º 2
0
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
// | General Public License for more details.                              |
// |                                                                       |
// | You should have received a copy of the GNU General Public License     |
// | along with this program; if not, write to the Free Software           |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA.                                                                  |
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) {
    die('This page cannot be loaded directly, load upgrade.php');
} else {
    if (!defined('PHPWG_IN_UPGRADE') or !PHPWG_IN_UPGRADE) {
        die('Hacking attempt!');
    }
}
$last_time = get_moment();
// will the user have to edit include/config_local.inc.php for
// prefix_thumbnail configuration parameter
$query = '
SELECT value
  FROM ' . CONFIG_TABLE . '
  WHERE param = \'prefix_thumbnail\'
;';
list($prefix_thumbnail) = pwg_db_fetch_row(pwg_query($query));
// delete obsolete configuration
$query = '
DELETE
  FROM ' . PREFIX_TABLE . 'config
  WHERE param IN (
   \'prefix_thumbnail\',
   \'mail_webmaster\',
Exemplo n.º 3
0
/**
 */
function print_time($message)
{
    global $last_time;
    $new_time = get_moment();
    echo '<pre>[' . get_elapsed_time($last_time, $new_time) . ']';
    echo ' ' . $message;
    echo '</pre>';
    flush();
    $last_time = $new_time;
}
Exemplo n.º 4
0
                    foreach (explode(',', $data[$key]) as $tag_name) {
                        $tags_of[$id][] = tag_id_from_tag_name($tag_name);
                    }
                }
            }
        } else {
            $errors[] = array('path' => $element_infos['path'], 'type' => 'PWG-ERROR-NO-FS');
        }
    }
    if (!$simulate) {
        if (count($datas) > 0) {
            mass_updates(IMAGES_TABLE, array('primary' => array('id'), 'update' => array_unique(array_merge(array_diff($site_reader->get_metadata_attributes(), array('keywords', 'tags')), array('date_metadata_update')))), $datas, isset($_POST['meta_empty_overrides']) ? 0 : MASS_UPDATES_SKIP_EMPTY);
        }
        set_tags_of($tags_of);
    }
    $template->append('footer_elements', '<!-- metadata update : ' . get_elapsed_time($start, get_moment()) . ' -->');
    $template->assign('metadata_result', array('NB_ELEMENTS_DONE' => count($datas), 'NB_ELEMENTS_CANDIDATES' => count($files), 'NB_ERRORS' => count($errors)));
}
// +-----------------------------------------------------------------------+
// |                        template initialization                        |
// +-----------------------------------------------------------------------+
$template->set_filenames(array('update' => 'site_update.tpl'));
$result_title = '';
if (isset($simulate) and $simulate) {
    $result_title .= '[' . l10n('Simulation') . '] ';
}
// used_metadata string is displayed to inform admin which metadata will be
// used from files for synchronization
$used_metadata = implode(', ', $site_reader->get_metadata_attributes());
if ($site_is_remote and !isset($_POST['submit'])) {
    $used_metadata .= ' + ...';
Exemplo n.º 5
0
$template->set_filenames(array('tail' => 'footer.tpl'));
trigger_notify('loc_begin_page_tail');
$template->assign(array('VERSION' => $conf['show_version'] ? PHPWG_VERSION : '', 'PHPWG_URL' => defined('PHPWG_URL') ? PHPWG_URL : ''));
//--------------------------------------------------------------------- contact
if (!is_a_guest()) {
    $template->assign('CONTACT_MAIL', get_webmaster_mail_address());
}
//------------------------------------------------------------- generation time
$debug_vars = array();
if ($conf['show_queries']) {
    $debug_vars = array_merge($debug_vars, array('QUERIES_LIST' => $debug));
}
if ($conf['show_gt']) {
    if (!isset($page['count_queries'])) {
        $page['count_queries'] = 0;
        $page['queries_time'] = 0;
    }
    $time = get_elapsed_time($t2, get_moment());
    $debug_vars = array_merge($debug_vars, array('TIME' => $time, 'NB_QUERIES' => $page['count_queries'], 'SQL_TIME' => number_format($page['queries_time'], 3, '.', ' ') . ' s'));
}
$template->assign('debug', $debug_vars);
//------------------------------------------------------------- mobile version
if (!empty($conf['mobile_theme']) && (get_device() != 'desktop' || mobile_theme())) {
    $template->assign('TOGGLE_MOBILE_THEME_URL', add_url_params(htmlspecialchars($_SERVER['REQUEST_URI']), array('mobile' => mobile_theme() ? 'false' : 'true')));
}
trigger_notify('loc_end_page_tail');
//
// Generate the page
//
$template->parse('tail');
$template->p();
function check_sendmail_timeout()
{
    global $env_nbm;
    $env_nbm['is_sendmail_timeout'] = get_moment() - $env_nbm['start_time'] > $env_nbm['sendmail_timeout'];
    return $env_nbm['is_sendmail_timeout'];
}
Exemplo n.º 7
0
 /**
  * Same as flush() but with optional debugging.
  * @see Template::flush()
  */
 function p()
 {
     $this->flush();
     if ($this->smarty->debugging) {
         global $t2;
         $this->smarty->assign(array('AAAA_DEBUG_TOTAL_TIME__' => get_elapsed_time($t2, get_moment())));
         Smarty_Internal_Debug::display_debug($this->smarty);
     }
 }
Exemplo n.º 8
0
echo '<pre>';
for ($upgrade_id = 140; $upgrade_id <= 144; $upgrade_id++) {
    if (!file_exists(UPGRADES_PATH . '/' . $upgrade_id . '-database.php')) {
        continue;
    }
    // maybe the upgrade task has already been applied in a previous and
    // incomplete upgrade
    if (in_array($upgrade_id, $applied)) {
        continue;
    }
    unset($upgrade_description);
    echo "\n\n";
    echo '=== upgrade ' . $upgrade_id . "\n";
    // include & execute upgrade script. Each upgrade script must contain
    // $upgrade_description variable which describe briefly what the upgrade
    // script does.
    $up_start = get_moment();
    include UPGRADES_PATH . '/' . $upgrade_id . '-database.php';
    // notify upgrade (TODO change on each release)
    $query = '
INSERT INTO `' . PREFIX_TABLE . 'upgrade`
  (id, applied, description)
  VALUES
  (\'' . $upgrade_id . '\', NOW(), \'[migration from 2.6.0 to ' . PHPWG_VERSION . ', ' . get_elapsed_time($up_start, get_moment()) . '] ' . $upgrade_description . '\')
;';
    pwg_query($query);
}
echo '</pre>';
ob_end_clean();
// now we upgrade from 2.7.0
// include_once(PHPWG_ROOT_PATH.'install/upgrade_2.7.0.php');
Exemplo n.º 9
0
 private function get_resize_result($destination_filepath, $width, $height, $time = null)
 {
     return array('source' => $this->source_filepath, 'destination' => $destination_filepath, 'width' => $width, 'height' => $height, 'size' => floor(filesize($destination_filepath) / 1024) . ' KB', 'time' => $time ? number_format((get_moment() - $time) * 1000, 2, '.', ' ') . ' ms' : null, 'library' => $this->library);
 }
Exemplo n.º 10
0
// +-----------------------------------------------------------------------+
if (!defined('PHPWG_ROOT_PATH')) {
    die('Hacking attempt!');
}
$upgrade_description = 'derivatives: new organization of "upload" and "galleries" directories';
$query = '
SELECT
    id,
    path,
    tn_ext,
    has_high,
    high_filesize,
    high_width,
    high_height
  FROM ' . IMAGES_TABLE . '
;';
$result = pwg_query($query);
$starttime = get_moment();
$updates = array();
while ($row = pwg_db_fetch_assoc($result)) {
    if ('true' == $row['has_high']) {
        $high_path = dirname($row['path']) . '/pwg_high/' . basename($row['path']);
        rename($high_path, $row['path']);
        array_push($updates, array('id' => $row['id'], 'width' => $row['high_width'], 'height' => $row['high_height'], 'filesize' => $row['high_filesize']));
    }
}
if (count($updates) > 0) {
    mass_updates(IMAGES_TABLE, array('primary' => array('id'), 'update' => array('width', 'height', 'filesize')), $updates);
}
echo "\n" . $upgrade_description . sprintf(' (execution in %.3fs)', get_moment() - $starttime) . "\n";