本文整理汇总了PHP中evo_flush函数的典型用法代码示例。如果您正苦于以下问题:PHP evo_flush函数的具体用法?PHP evo_flush怎么用?PHP evo_flush使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了evo_flush函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: phpbb_log
/**
* Print out the log message on the screen
*
* @param string Message
* @param string Type: message|error|warning
* @param string Text after message
* @param string Text before message
*/
function phpbb_log($message, $type = 'message', $nl = '<br />', $bl = '')
{
switch ($type) {
case 'error':
echo $bl . '<span class="red">' . $message . '</span>' . $nl;
break;
case 'warning':
echo $bl . '<span class="orange">' . T_('WARNING: ') . $message . '</span>' . $nl;
break;
default:
echo $bl . $message . $nl;
break;
}
evo_flush();
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:23,代码来源:_phpbb.funcs.php
示例2: db_delete
/**
* db_delete(-)
*/
function db_delete()
{
global $DB, $db_config, $tableprefix;
echo "Disabling foreign key checks...<br />\n";
$DB->query('SET FOREIGN_KEY_CHECKS=0');
foreach ($db_config['aliases'] as $alias => $tablename) {
echo "Dropping {$tablename} table...<br />\n";
evo_flush();
$DB->query('DROP TABLE IF EXISTS ' . $tablename);
}
// Get remaining tables with the same prefix and delete them as well. Probably these tables are some b2evolution plugins tables.
$remaining_tables = $DB->get_col('SHOW TABLES FROM `' . $db_config['name'] . '` LIKE "' . $tableprefix . '%"');
foreach ($remaining_tables as $tablename) {
echo "Dropping {$tablename} table...<br />\n";
evo_flush();
$DB->query('DROP TABLE IF EXISTS ' . $tablename);
}
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:21,代码来源:_functions_delete.php
示例3: tool_test_flush
/**
* Test a flush function
*/
function tool_test_flush()
{
for ($i = 1; $i <= 30; $i++) {
echo T_('Sleeping for 1 second...') . '<br />';
evo_flush();
sleep(1);
}
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:11,代码来源:_tool.funcs.php
示例4: pre_dump
/**
* Wrap pre tag around {@link var_dump()} for better debugging.
*
* @param $var__var__var__var__,... mixed variable(s) to dump
* @return true
*/
function pre_dump($var__var__var__var__)
{
global $is_cli;
#echo 'pre_dump(): '.debug_get_backtrace(); // see where a pre_dump() comes from
$func_num_args = func_num_args();
$count = 0;
if (!empty($is_cli)) {
// CLI, no encoding of special chars:
$count = 0;
foreach (func_get_args() as $lvar) {
var_dump($lvar);
$count++;
if ($count < $func_num_args) {
// Put newline between arguments
echo "\n";
}
}
} elseif (function_exists('xdebug_var_dump')) {
// xdebug already does fancy displaying:
// no limits:
$old_var_display_max_children = ini_set('xdebug.var_display_max_children', -1);
// default: 128
$old_var_display_max_data = ini_set('xdebug.var_display_max_data', -1);
// max string length; default: 512
$old_var_display_max_depth = ini_set('xdebug.var_display_max_depth', -1);
// default: 3
echo "\n<div style=\"padding:1ex;border:1px solid #00f;\">\n";
foreach (func_get_args() as $lvar) {
xdebug_var_dump($lvar);
$count++;
if ($count < $func_num_args) {
// Put HR between arguments
echo "<hr />\n";
}
}
echo '</div>';
// restore xdebug settings:
ini_set('xdebug.var_display_max_children', $old_var_display_max_children);
ini_set('xdebug.var_display_max_data', $old_var_display_max_data);
ini_set('xdebug.var_display_max_depth', $old_var_display_max_depth);
} else {
$orig_html_errors = ini_set('html_errors', 0);
// e.g. xdebug would use fancy html, if this is on; we catch (and use) xdebug explicitly above, but just in case
echo "\n<pre style=\"padding:1ex;border:1px solid #00f;\">\n";
foreach (func_get_args() as $lvar) {
ob_start();
var_dump($lvar);
// includes "\n"; do not use var_export() because it does not detect recursion by design
$buffer = ob_get_contents();
ob_end_clean();
echo htmlspecialchars($buffer);
$count++;
if ($count < $func_num_args) {
// Put HR between arguments
echo "<hr />\n";
}
}
echo "</pre>\n";
ini_set('html_errors', $orig_html_errors);
}
evo_flush();
return true;
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:69,代码来源:_misc.funcs.php
示例5: remove_after_upgrade
/**
* Remove files/folders after upgrade, See file upgrade_policy.conf
*/
function remove_after_upgrade()
{
global $basepath, $conf_path;
$upgrade_removed_files = get_upgrade_config('remove');
echo '<h4>' . T_('Cleaning up...') . '</h4>';
evo_flush();
if (is_string($upgrade_removed_files)) {
// Errors on opening of upgrade_policy.conf
$config_error = $upgrade_removed_files;
} elseif (empty($upgrade_removed_files)) {
// No files/folders to remove, Exit here
$config_error = sprintf(T_('No "remove" sections have been defined in the file %s.'), '<code>upgrade_policy.conf</code>');
}
if (!empty($config_error)) {
// Display config error
echo '<div class="red">';
echo $config_error;
echo ' ' . T_('No cleanup is being done. You should manually remove the <code>/install</code> folder and check for other unwanted files...');
echo '</div>';
return;
}
foreach ($upgrade_removed_files as $file_path) {
$file_path = $basepath . $file_path;
$log_message = sprintf(T_('Removing %s as stated in upgrade_policy.conf...'), '<code>' . $file_path . '</code>') . ' ';
$success = true;
if (file_exists($file_path)) {
// File exists
if (is_dir($file_path)) {
// Remove folder recursively
if (rmdir_r($file_path)) {
// Success
$log_message .= T_('OK');
} else {
// Failed
$log_message .= T_('Failed') . ': ' . T_('No permissions to delete the folder');
$success = false;
}
} elseif (is_writable($file_path)) {
// Remove file
if (@unlink($file_path)) {
// Success
$log_message .= T_('OK');
} else {
// Failed
$log_message .= T_('Failed') . ': ' . T_('No permissions to delete the file');
$success = false;
}
} else {
// File is not writable
$log_message .= T_('Failed') . ': ' . T_('No permissions to delete the file');
$success = false;
}
} else {
// No file/folder
$log_message .= T_('Failed') . ': ' . T_('No file found');
$success = false;
}
echo $success ? $log_message . '<br />' : '<div class="orange">' . $log_message . '</div>';
evo_flush();
}
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:64,代码来源:_maintenance.funcs.php
示例6: OutputDebug
function OutputDebug($message)
{
$message .= "\n";
if ($this->html_debug) {
$message = str_replace("\n", "<br />\n", HtmlEntities($message));
}
echo $message;
evo_flush();
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:9,代码来源:http.php
示例7: xmlrpcresp
/**
* Contributed by Justin Miller <[email protected]>
* Requires curl to be built into PHP
* NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
* @access private
*/
function &sendPayloadCURL($msg, $server, $port, $timeout = 0, $username = '', $password = '', $authtype = 1, $cert = '', $certpass = '', $cacert = '', $cacertdir = '', $proxyhost = '', $proxyport = 0, $proxyusername = '', $proxypassword = '', $proxyauthtype = 1, $method = 'https', $keepalive = false, $key = '', $keypass = '')
{
if (!function_exists('curl_init')) {
$this->errstr = 'CURL unavailable on this install';
$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_curl'], $GLOBALS['xmlrpcstr']['no_curl']);
return $r;
}
if ($method == 'https') {
if (($info = curl_version()) && (is_string($info) && strpos($info, 'OpenSSL') === null || is_array($info) && !isset($info['ssl_version']))) {
$this->errstr = 'SSL unavailable on this install';
$r = new xmlrpcresp(0, $GLOBALS['xmlrpcerr']['no_ssl'], $GLOBALS['xmlrpcstr']['no_ssl']);
return $r;
}
}
if ($port == 0) {
if ($method == 'http') {
$port = 80;
} else {
$port = 443;
}
}
// Only create the payload if it was not created previously
if (empty($msg->payload)) {
$msg->createPayload($this->request_charset_encoding);
}
// Deflate request body and set appropriate request headers
$payload = $msg->payload;
if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
if ($this->request_compression == 'gzip') {
$a = @gzencode($payload);
if ($a) {
$payload = $a;
$encoding_hdr = 'Content-Encoding: gzip';
}
} else {
$a = @gzcompress($payload);
if ($a) {
$payload = $a;
$encoding_hdr = 'Content-Encoding: deflate';
}
}
} else {
$encoding_hdr = '';
}
if ($this->debug > 1) {
print "<PRE>\n---SENDING---\n" . htmlentities($payload) . "\n---END---\n</PRE>";
// let the client see this now in case http times out...
evo_flush();
}
if (!$keepalive || !$this->xmlrpc_curl_handle) {
$curl = curl_init($method . '://' . $server . ':' . $port . $this->path);
if ($keepalive) {
$this->xmlrpc_curl_handle = $curl;
}
} else {
$curl = $this->xmlrpc_curl_handle;
}
// results into variable
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
if ($this->debug) {
curl_setopt($curl, CURLOPT_VERBOSE, 1);
}
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
// required for XMLRPC: post the data
curl_setopt($curl, CURLOPT_POST, 1);
// the data
curl_setopt($curl, CURLOPT_POSTFIELDS, $payload);
// return the header too
curl_setopt($curl, CURLOPT_HEADER, 1);
// will only work with PHP >= 5.0
// NB: if we set an empty string, CURL will add http header indicating
// ALL methods it is supporting. This is possibly a better option than
// letting the user tell what curl can / cannot do...
if (is_array($this->accepted_compression) && count($this->accepted_compression)) {
//curl_setopt($curl, CURLOPT_ENCODING, implode(',', $this->accepted_compression));
// empty string means 'any supported by CURL' (shall we catch errors in case CURLOPT_SSLKEY undefined ?)
if (count($this->accepted_compression) == 1) {
curl_setopt($curl, CURLOPT_ENCODING, $this->accepted_compression[0]);
} else {
curl_setopt($curl, CURLOPT_ENCODING, '');
}
}
// extra headers
$headers = array('Content-Type: ' . $msg->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
// if no keepalive is wanted, let the server know it in advance
if (!$keepalive) {
$headers[] = 'Connection: close';
}
// request compression header
if ($encoding_hdr) {
$headers[] = $encoding_hdr;
}
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
// timeout is borked
//.........这里部分代码省略.........
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:101,代码来源:_xmlrpc.inc.php
示例8: search_result_block
function search_result_block($params = array())
{
global $Blog, $Session, $debug;
$search_keywords = param('s', 'string', '', true);
// Try to load existing search results from Session:
$search_params = $Session->get('search_params');
$search_result = $Session->get('search_result');
$search_result_loaded = false;
if (empty($search_params) || $search_params['search_keywords'] != $search_keywords || $search_params['search_blog'] != $Blog->ID || $search_result === NULL) {
// We need to perform a new search:
if ($debug) {
echo '<p class="text-muted">Starting a new search...</p>';
}
// Flush first part of the page before starting search, which can be long...
evo_flush();
$search_params = array('search_keywords' => $search_keywords, 'search_blog' => $Blog->ID);
// Perform new search:
$search_result = perform_scored_search($search_keywords);
// Save results into session:
$Session->set('search_params', $search_params);
$Session->set('search_result', $search_result);
$search_result_loaded = true;
} else {
// We found the desired saved search results in the Session:
if ($debug) {
// Display counts
echo '<div class="text-muted">';
echo '<p>We found the desired saved search results in the Session:</p>';
echo '<ul><li>' . sprintf('%d posts', $search_result[0]['nr_of_items']) . '</li>';
echo '<li>' . sprintf('%d comments', $search_result[0]['nr_of_comments']) . '</li>';
echo '<li>' . sprintf('%d chapters', $search_result[0]['nr_of_cats']) . '</li>';
echo '<li>' . sprintf('%d tags', $search_result[0]['nr_of_tags']) . '</li></ul>';
echo '</div>';
}
// Flush first part of the page before starting search, which can be long...
evo_flush();
}
// Make sure we are not missing any display params:
$params = array_merge(array('no_match_message' => '<p class="alert alert-info msg_nothing" style="margin: 2em 0">' . T_('Sorry, we could not find anything matching your request, please try to broaden your search.') . '<p>', 'title_suffix_post' => ' (' . T_('Post') . ')', 'title_suffix_comment' => ' (' . T_('Comment') . ')', 'title_suffix_category' => ' (' . T_('Category') . ')', 'title_suffix_tag' => ' (' . T_('Tag') . ')', 'block_start' => '', 'block_end' => '', 'pagination' => array(), 'use_editor' => false, 'author_format' => 'avatar_name', 'date_format' => locale_datefmt()), $params);
$search_result = $Session->get('search_result');
if (empty($search_result)) {
echo $params['no_match_message'];
return;
}
// Prepare pagination:
$result_count = count($search_result);
$result_per_page = $Blog->get_setting('search_per_page');
if ($result_count > $result_per_page) {
// We will have multiple search result pages:
$current_page = param('page', 'integer', 1);
$total_pages = ceil($result_count / $result_per_page);
if ($current_page > $total_pages) {
$current_page = $total_pages;
}
$page_params = array_merge(array('total' => $result_count, 'current_page' => $current_page, 'total_pages' => $total_pages, 'list_span' => 11), $params['pagination']);
search_page_links($page_params);
} else {
// Only one page of results:
$current_page = 1;
$total_pages = 1;
}
// Set current page indexes:
$from = ($current_page - 1) * $result_per_page;
$to = $current_page < $total_pages ? $from + $result_per_page : $result_count;
// Init caches
$ItemCache =& get_ItemCache();
$CommentCache =& get_CommentCache();
$ChapterCache =& get_ChapterCache();
if (!$search_result_loaded) {
// Search result objects are not loaded into memory yet, load them
// Group required object ids by type:
$required_ids = array();
for ($index = $from; $index < $to; $index++) {
$row = $search_result[$index];
if (isset($required_ids[$row['type']])) {
$required_ids[$row['type']][] = $row['ID'];
} else {
$required_ids[$row['type']] = array($row['ID']);
}
}
// Load each required object into the corresponding cache:
foreach ($required_ids as $type => $object_ids) {
switch ($type) {
case 'item':
$ItemCache->load_list($object_ids);
break;
case 'comment':
$CommentCache->load_list($object_ids);
break;
case 'category':
$ChapterCache->load_list($object_ids);
break;
// TODO: we'll probably load "tag" objects once we support tag-synonyms.
// TODO: we'll probably load "tag" objects once we support tag-synonyms.
default:
// Not handled search result type
break;
}
}
}
//.........这里部分代码省略.........
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_search.funcs.php
示例9: generate_hit_stat
//.........这里部分代码省略.........
// If yes, generate search link and add it to DB
//mt_srand(crc32(microtime()+ $time_shift));
$keywords = 'fake search ' . mt_rand(0, 9);
$links[$rand_link]['link'] = str_replace('$keywords$', urlencode($keywords), $links[$rand_link]['link']);
if (strstr($links[$rand_link]['link'], 's=')) {
$links[$rand_link]['s'] = $keywords;
}
}
if ($cur_seesion['sess_ID'] == -1) {
// This session needs initialization:
$cur_seesion['sess_start_ts'] = $time_shift - 1;
$cur_seesion['sess_lastseen_ts'] = $time_shift;
$DB->query("\n\t\t\t\t\tINSERT INTO T_sessions ( sess_key, sess_start_ts, sess_lastseen_ts, sess_ipaddress, sess_user_ID, sess_device )\n\t\t\t\t\tVALUES (\n\t\t\t\t\t\t'" . $cur_seesion['sess_key'] . "',\n\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_start_ts']) . "',\n\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_lastseen_ts']) . "',\n\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_ipaddress']) . ",\n\t\t\t\t\t\t" . $cur_seesion['sess_user_ID'] . ",\n\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_device']) . "\n\t\t\t\t\t)");
$cur_seesion['sess_ID'] = $DB->insert_id;
$sessions[$rand_i] = $cur_seesion;
$Test_hit = new Hit('', $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $links[$rand_link]);
$Test_hit->log();
} else {
if ($time_shift - $cur_seesion['sess_lastseen_ts'] > 3000 || !empty($cur_seesion['robot'])) {
// This session last updated more than 3000 sec ago. Instead of this session create a new session.
$cur_seesion = array('sess_ID' => -1, 'sess_key' => generate_random_key(32), 'sess_start_ts' => 0, 'sess_lastseen_ts' => 0, 'sess_ipaddress' => generate_random_ip(), 'sess_user_ID' => $users_array[mt_rand(0, $users_count - 1)]['user_ID'], 'sess_device' => $devices[mt_rand(0, $devices_count - 1)], 'pervios_link' => '', 'robot' => '');
$cur_seesion['sess_start_ts'] = $time_shift - 1;
$cur_seesion['sess_lastseen_ts'] = $time_shift;
$r_num = mt_rand(0, 100);
if ($r_num > 40) {
// Create anonymous user and make double insert into hits.
$cur_seesion['sess_user_ID'] = -1;
$DB->query("\n\t\t\t\t\t\t\tINSERT INTO T_sessions ( sess_key, sess_start_ts, sess_lastseen_ts, sess_ipaddress, sess_device )\n\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t'" . $cur_seesion['sess_key'] . "',\n\t\t\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_start_ts']) . "',\n\t\t\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_lastseen_ts']) . "',\n\t\t\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_ipaddress']) . ",\n\t\t\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_device']) . "\n\t\t\t\t\t\t\t)");
if ($r_num >= 80) {
// Create robot hit
$cur_seesion['robot'] = $robots[mt_rand(0, $robots_count)];
}
} else {
$DB->query("\n\t\t\t\t\t\t\tINSERT INTO T_sessions( sess_key, sess_start_ts, sess_lastseen_ts, sess_ipaddress, sess_user_ID, sess_device )\n\t\t\t\t\t\t\tVALUES (\n\t\t\t\t\t\t\t\t'" . $cur_seesion['sess_key'] . "',\n\t\t\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_start_ts']) . "',\n\t\t\t\t\t\t\t\t'" . date('Y-m-d H:i:s', $cur_seesion['sess_lastseen_ts']) . "',\n\t\t\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_ipaddress']) . ",\n\t\t\t\t\t\t\t\t" . $cur_seesion['sess_user_ID'] . ",\n\t\t\t\t\t\t\t\t" . $DB->quote($cur_seesion['sess_device']) . "\n\t\t\t\t\t\t\t)");
}
$cur_seesion['sess_ID'] = $DB->insert_id;
if (mt_rand(0, 100) > 20) {
//$ref_count
$ref_link = $referes[mt_rand(0, $ref_count)];
if (strstr($ref_link, '$keywords$')) {
// check if the current search link is selected randomly.
$keywords = 'fake search ' . mt_rand(0, 9);
$ref_link = str_replace('$keywords$', urlencode($keywords), $ref_link);
}
} else {
$ref_link = '';
}
if ($cur_seesion['sess_user_ID'] == -1) {
if (empty($cur_seesion['robot'])) {
$link = array('link' => '/htsrv/login.php', 'blog_id' => 1);
$Test_hit = new Hit($ref_link, $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $link);
$Test_hit->log();
$link = array('link' => '/htsrv/login.php?redirect_to=fake_stat', 'blog_id' => 1);
$Test_hit = new Hit($baseurlroot, $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'] + 3, 1, $link);
$Test_hit->log();
$cur_seesion['pervios_link'] = $baseurlroot . $link['link'];
} else {
if (mt_rand(0, 100) < 50) {
// robot hit
$Test_hit = new Hit('', $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $links[$rand_link], $cur_seesion['robot']);
} else {
// rss/atom hit
$Test_hit = new Hit('', $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $links[$rand_link], NULL, NULL, 1);
}
$Test_hit->log();
}
} else {
if (mt_rand(0, 100) < 10) {
// Test hit to admin page
$Test_hit = new Hit('', $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $admin_link, NULL, 1);
$Test_hit->log();
$cur_seesion['pervios_link'] = $admin_url;
} else {
$Test_hit = new Hit($ref_link, $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $links[$rand_link]);
$Test_hit->log();
$cur_seesion['pervios_link'] = $baseurlroot . $links[$rand_link]['link'];
}
}
} else {
// Update session
$cur_seesion['sess_lastseen_ts'] = $time_shift;
$Test_hit = new Hit($cur_seesion['pervios_link'], $cur_seesion['sess_ipaddress'], $cur_seesion['sess_ID'], $cur_seesion['sess_lastseen_ts'], 1, $links[$rand_link]);
$Test_hit->log();
$sql = "UPDATE T_sessions SET\n\t\t\t\t\t\t\t\tsess_lastseen_ts = '" . date('Y-m-d H:i:s', $cur_seesion['sess_lastseen_ts']) . "'\n\t\t\t\t\t\t\t\tWHERE sess_ID = {$cur_seesion['sess_ID']}";
$DB->query($sql, 'Update session');
$cur_seesion['pervios_link'] = $baseurlroot . $links[$rand_link]['link'];
$sessions[$rand_i] = $cur_seesion;
}
}
$sessions[$rand_i] = $cur_seesion;
if ($display_process) {
if ($insert_data_count % 100 == 0) {
// Display a process of creating by one dot for 100 hits
echo ' .';
evo_flush();
}
}
}
return $insert_data_count;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_hitlog.funcs.php
示例10: send_all_emails
/**
* Send email newsletter for all users of this campaign
*
* @param boolean
*/
function send_all_emails($display_messages = true)
{
global $DB, $localtimenow, $mail_log_insert_ID;
// Send emails only for users which still don't accept emails
$user_IDs = $this->get_users('wait');
if (empty($user_IDs)) {
// No users, Exit here
return;
}
$DB->begin();
// Update date of sending
$this->set('sent_ts', date('Y-m-d H:i:s', $localtimenow));
$this->dbupdate();
if ($display_messages) {
// We need in this cache when display the messages
$UserCache =& get_UserCache();
}
foreach ($user_IDs as $user_ID) {
$result = $this->send_email($user_ID);
if ($result) {
// Email newsletter was sent for user successfully
if (!empty($mail_log_insert_ID)) {
// ID of last inserted mail log is defined in function mail_log()
$DB->query('UPDATE T_email__campaign_send
SET csnd_emlog_ID = ' . $DB->quote($mail_log_insert_ID) . '
WHERE csnd_camp_ID = ' . $DB->quote($this->ID) . '
AND csnd_user_ID = ' . $DB->quote($user_ID));
// Update arrays where we store which users accepted email and who waiting it now
$this->users['accept'][] = $user_ID;
if (($wait_user_ID_key = array_search($user_ID, $this->users['wait'])) !== false) {
unset($this->users['wait'][$wait_user_ID_key]);
}
}
}
if ($display_messages) {
// Print the messages
$User =& $UserCache->get_by_ID($user_ID, false, false);
if ($result === true) {
// Success
echo sprintf(T_('Email was sent to user: %s'), $User->get_identity_link()) . '<br />';
} else {
// Failed, Email was NOT sent
if (!check_allow_new_email('newsletter_limit', 'last_newsletter', $user_ID)) {
// Newsletter email is limited today for this user
echo '<span class="orange">' . sprintf(T_('User %s has already received max # of newsletters today.'), $User->get_identity_link()) . '</span><br />';
} else {
// Another error
echo '<span class="red">' . sprintf(T_('Email was not sent to user: %s'), $User->get_identity_link()) . '</span><br />';
}
}
evo_flush();
}
}
$DB->commit();
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:60,代码来源:_emailcampaign.class.php
示例11: wpxml_import
/**
* Import WordPress data from XML file into b2evolution database
*/
function wpxml_import()
{
global $DB, $tableprefix;
// Load classes:
load_class('regional/model/_country.class.php', 'Country');
load_class('regional/model/_region.class.php', 'Region');
load_class('regional/model/_subregion.class.php', 'Subregion');
load_class('regional/model/_city.class.php', 'City');
// Set Blog from request blog ID
$wp_blog_ID = param('wp_blog_ID', 'integer', 0);
$BlogCache =& get_BlogCache();
$wp_Blog =& $BlogCache->get_by_ID($wp_blog_ID);
// The import type ( replace | append )
$import_type = param('import_type', 'string', 'replace');
// Should we delete files on 'replace' mode?
$delete_files = param('delete_files', 'integer', 0);
$XML_file_path = get_param('wp_file');
$XML_file_name = basename($XML_file_path);
if (preg_match('/\\.(xml|txt)$/i', $XML_file_name)) {
// XML format
// Check WordPress XML file
if (!wpxml_check_xml_file($XML_file_path)) {
// Errors are in XML file
return;
}
// Use this folder to upload files if they exist in subfolder "/b2evolution_export_files"
$attached_files_path = dirname($XML_file_path);
} else {
if (preg_match('/\\.zip$/i', $XML_file_name)) {
// ZIP format
// Extract ZIP and check WordPress XML file
global $media_path;
$ZIP_folder_path = $media_path . 'import/temp-' . md5(rand());
if (!unpack_archive($XML_file_path, $ZIP_folder_path, true, $XML_file_name)) {
// Errors on unpack ZIP file
return;
}
// Find valid XML file in ZIP package
$ZIP_files_list = scandir($ZIP_folder_path);
$xml_exists_in_zip = false;
foreach ($ZIP_files_list as $ZIP_file) {
if (preg_match('/\\.(xml|txt)$/i', $ZIP_file)) {
// XML file is found in ZIP package
if (wpxml_check_xml_file($ZIP_folder_path . '/' . $ZIP_file)) {
// XML file is valid
$XML_file_path = $ZIP_folder_path . '/' . $ZIP_file;
$xml_exists_in_zip = true;
break;
}
}
}
if (!$xml_exists_in_zip) {
// No XML is detected in ZIP package
echo '<p style="color:red">' . T_('XML file is not detected in your ZIP package.') . '</p>';
// Delete temporary folder that contains the files from extracted ZIP package
rmdir_r($ZIP_folder_path);
return;
}
// Use this folder to upload files, $ZIP_folder_path must be deleted after import
$attached_files_path = $ZIP_folder_path;
} else {
// Unrecognized extension
echo '<p style="color:red">' . sprintf(T_('%s has an unrecognized extension.'), '<b>' . $xml_file['name'] . '</b>') . '</p>';
return;
}
}
// Parse WordPress XML file into array
$xml_data = wpxml_parser($XML_file_path);
$DB->begin();
if ($import_type == 'replace') {
// Remove data from selected blog
// Get existing categories
$SQL = new SQL();
$SQL->SELECT('cat_ID');
$SQL->FROM('T_categories');
$SQL->WHERE('cat_blog_ID = ' . $DB->quote($wp_blog_ID));
$old_categories = $DB->get_col($SQL->get());
if (!empty($old_categories)) {
// Get existing posts
$SQL = new SQL();
$SQL->SELECT('post_ID');
$SQL->FROM('T_items__item');
$SQL->WHERE('post_main_cat_ID IN ( ' . implode(', ', $old_categories) . ' )');
$old_posts = $DB->get_col($SQL->get());
}
echo T_('Removing the comments... ');
evo_flush();
if (!empty($old_posts)) {
$SQL = new SQL();
$SQL->SELECT('comment_ID');
$SQL->FROM('T_comments');
$SQL->WHERE('comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
$old_comments = $DB->get_col($SQL->get());
$DB->query('DELETE FROM T_comments WHERE comment_item_ID IN ( ' . implode(', ', $old_posts) . ' )');
if (!empty($old_comments)) {
$DB->query('DELETE FROM T_comments__votes WHERE cmvt_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
$DB->query('DELETE FROM T_links WHERE link_cmt_ID IN ( ' . implode(', ', $old_comments) . ' )');
//.........这里部分代码省略.........
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:101,代码来源:_wp.funcs.php
示例12: getDirectoryTree
/**
* getDirectoryTree
*
* Returns the complete tree of files and directories in $folder from the
* version $version of the repository. Can also be used to get the info
* for a single file or directory.
*
* @param string $folder Folder to get tree
* @param integer $version Repository version, -1 means current
* @param boolean $recursive Whether to get the tree recursively, or just
* the specified directory/file.
* @param boolean Display the progress dots
*
* @return array List of files and directories.
*/
public function getDirectoryTree($folder = '/', $version = -1, $recursive = true, $display_progress = false)
{
$directoryTree = array();
if (!($arrOutput = $this->getDirectoryFiles($folder, $version))) {
return false;
}
if (!$recursive) {
return $arrOutput[0];
}
$i = 0;
while (count($arrOutput) && is_array($arrOutput)) {
$array = array_shift($arrOutput);
array_push($directoryTree, $array);
if (trim($array['path'], '/') == trim($folder, '/')) {
continue;
}
if ($array['type'] == 'directory') {
if (!($walk = $this->getDirectoryFiles($array['path'], $version))) {
return false;
}
array_shift($walk);
foreach ($walk as $step) {
array_unshift($arrOutput, $step);
}
}
if ($display_progress && $i == 10) {
echo ' .';
evo_flush();
$i = 0;
}
$i++;
}
return $directoryTree;
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:49,代码来源:phpsvnclient.php
示例13: recurse_copy
/**
* Copy directory recursively
* @param string source directory
* @param string destination directory
* @param array excluded directories
*/
function recurse_copy($src, $dest, $root = true)
{
if (is_dir($src)) {
if (!($dir = opendir($src))) {
return false;
}
if (!evo_mkdir($dest)) {
return false;
}
while (false !== ($file = readdir($dir))) {
if ($file != '.' && $file != '..') {
$srcfile = $src . '/' . $file;
if (is_dir($srcfile)) {
if ($root) {
// progressive display of what backup is doing
echo sprintf(T_('Backing up «<strong>%s</strong>» ...'), $srcfile) . '<br/>';
evo_flush();
}
$this->recurse_copy($srcfile, $dest . '/' . $file, false);
} else {
// Copy file
copy($srcfile, $dest . '/' . $file);
}
}
}
closedir($dir);
} else {
copy($src, $dest);
}
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:36,代码来源:_backup.class.php
示例14: db_upgrade_to_utf8_ascii
/**
* Upgrade DB to UTF-8 and fix ASCII fields
*/
function db_upgrade_to_utf8_ascii()
{
global $db_config, $tableprefix, $DB;
echo '<h2 class="page-title">' . T_('Normalizing DB charsets...') . '</h2>';
evo_flush();
// Load db schema to be able to check the original charset definition
load_db_schema(true);
$db_tables = $DB->get_col('SHOW TABLES FROM `' . $db_config['name'] . '` LIKE "' . $tableprefix . '%"');
foreach ($db_tables as $table) {
// Convert all tables charset to utf8
echo sprintf(T_('Normalizing %s...'), $table);
evo_flush();
convert_table_to_utf8_ascii($table);
echo " OK<br />\n";
}
echo T_('Changing default charset of DB...') . '<br />' . "\n";
evo_flush();
$DB->query('ALTER DATABASE `' . $db_config['name'] . '` CHARACTER SET utf8 COLLATE utf8_general_ci');
echo '<p>' . T_('Upgrading done!') . '</p>';
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:23,代码来源:_upgrade.funcs.php
示例15: comment_mass_delete_process
/**
* Delete the comments
*
* @param string Type of deleting:
* 'recycle' - to move into recycle bin
* 'delete' - to delete permanently
* @param string sql query to get deletable comment ids
*/
function comment_mass_delete_process($mass_type, $deletable_comments_query)
{
if ($mass_type != 'recycle' && $mass_type != 'delete') {
// Incorrect action
return;
}
global $DB, $cache_comments_has_replies, $user_post_read_statuses, $cache_postcats;
/**
* Disable log queries because it increases the memory and stops the process with error "Allowed memory size of X bytes exhausted..."
*/
$DB->log_queries = false;
$Form = new Form();
$Form->begin_form('fform');
$Form->begin_fieldset(T_('Mass deleting log'));
echo T_('The comments are deleting...');
evo_flush();
$CommentCache =& get_CommentCache();
$ItemCache =& get_ItemCache();
$ChapterCache =& get_ChapterCache();
// Get the comments by 1000 to avoid an exhausting of memory
$deletable_comment_ids = $DB->get_col($deletable_comments_query . ' LIMIT 1000');
while (!empty($deletable_comment_ids)) {
// Get the first slice of the deletable comment ids list
$ids = array_splice($deletable_comment_ids, 0, 100);
// Make sure the CommentCache is empty
$CommentCache->clear();
// Load deletable comment ids
$CommentCache->load_list($ids);
while (($iterator_Comment =& $CommentCache->get_next()) != NULL) {
// Delete all comments from CommentCache
$iterator_Comment->dbdelete($mass_type == 'delete');
}
// Display progress dot
echo ' .';
evo_flush();
if (empty($deletable_comment_ids)) {
// Clear all caches to save memory
$ItemCache->clear();
$ChapterCache->clear();
$cache_comments_has_replies = array();
$user_post_read_statuses = array();
$cache_postcats = array();
// Get new portion of deletable comments
$deletable_comment_ids = $DB->get_col($deletable_comments_query . ' LIMIT 1000');
}
}
echo ' OK';
$Form->end_form();
// Clear a comment cache
$CommentCache->clear();
}
开发者ID:ldanielz,项目名称:uesp.blog,代码行数:59,代码来源:_comment.funcs.php
示例16: task_begin
/**
* Begin install task.
* This will offer other display methods in the future
*/
function task_begin($title)
{
echo $title . "\n";
evo_flush();
}
开发者ID:Ariflaw,项目名称:b2evolution,代码行数:9,代码来源:_functions_install.php
示例17: antispam_bankruptcy_delete
/**
* Delete ALL comments from selected blogs
*
* @param string Comment status
* @param array Blog IDs
*/
function antispam_bankruptcy_delete($blog_IDs = array(), $comment_status = NULL)
{
global $DB;
if (empty($blog_IDs)) {
// No blogs selected
echo T_('Please select at least one blog.');
return;
}
echo T_('The comments are deleting...');
evo_flush();
$DB->begin();
$items_IDs_SQL = new SQL('Get all posts IDs of selected blogs');
$items_IDs_SQL->SELECT('postcat_post_ID');
$items_IDs_SQL->FROM('T_postcats');
$items_IDs_SQL->FROM_add('INNER JOIN T_categories ON postcat_cat_ID = cat_ID');
$items_IDs_SQL->WHERE('cat_blog_ID IN ( ' . $DB->quote($blog_IDs) . ' )');
$items_IDs = $DB->get_col($items_IDs_SQL->get());
$comments_IDs_SQL = new SQL('Get all comments IDs of selected blogs');
$comments_IDs_SQL->SELECT('comment_ID');
$comments_IDs_SQL->FROM('T_comments');
$comments_IDs_SQL->WHERE('comment_post_ID IN ( '
|
请发表评论