Пример #1
1
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                			    |
|--------------------------------------------------------------------------|
|   Licence Info: GPL			                                    |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V5					    |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless, Autotron, whocares, Swizzles.					    |
|--------------------------------------------------------------------------|
 _   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    //== Delete inactive user accounts
    $secs = 350 * 86400;
    $dt = TIME_NOW - $secs;
    $maxclass = UC_STAFF;
    sql_query("SELECT FROM users WHERE parked='no' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
    //== Delete parked user accounts
    $secs = 675 * 86400;
    // change the time to fit your needs
    $dt = TIME_NOW - $secs;
    $maxclass = UC_STAFF;
    sql_query("SELECT FROM users WHERE parked='yes' AND status='confirmed' AND class < {$maxclass} AND last_access < {$dt}");
    if ($queries > 0) {
        write_log("Inactive Clean -------------------- Inactive Clean Complete using {$queries} queries--------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
 function DeleteLyrics3()
 {
     // Initialize getID3 engine
     $getID3 = new getID3();
     $ThisFileInfo = $getID3->analyze($this->filename);
     if (isset($ThisFileInfo['lyrics3']['tag_offset_start']) && isset($ThisFileInfo['lyrics3']['tag_offset_end'])) {
         if (is_readable($this->filename) && is_writable($this->filename) && is_file($this->filename) && ($fp = fopen($this->filename, 'a+b'))) {
             flock($fp, LOCK_EX);
             $oldignoreuserabort = ignore_user_abort(true);
             fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_end'], SEEK_SET);
             $DataAfterLyrics3 = '';
             if ($ThisFileInfo['filesize'] > $ThisFileInfo['lyrics3']['tag_offset_end']) {
                 $DataAfterLyrics3 = fread($fp, $ThisFileInfo['filesize'] - $ThisFileInfo['lyrics3']['tag_offset_end']);
             }
             ftruncate($fp, $ThisFileInfo['lyrics3']['tag_offset_start']);
             if (!empty($DataAfterLyrics3)) {
                 fseek($fp, $ThisFileInfo['lyrics3']['tag_offset_start'], SEEK_SET);
                 fwrite($fp, $DataAfterLyrics3, strlen($DataAfterLyrics3));
             }
             flock($fp, LOCK_UN);
             fclose($fp);
             ignore_user_abort($oldignoreuserabort);
             return true;
         } else {
             $this->errors[] = 'Cannot fopen(' . $this->filename . ', "a+b")';
             return false;
         }
     }
     // no Lyrics3 present
     return true;
 }
Пример #3
1
/**
 * Stores CSS in a file at the given path.
 *
 * This function either succeeds or throws an exception.
 *
 * @param theme_config $theme The theme that the CSS belongs to.
 * @param string $csspath The path to store the CSS at.
 * @param string $csscontent the complete CSS in one string
 * @param bool $chunk If set to true these files will be chunked to ensure
 *      that no one file contains more than 4095 selectors.
 * @param string $chunkurl If the CSS is be chunked then we need to know the URL
 *      to use for the chunked files.
 */
function css_store_css(theme_config $theme, $csspath, $csscontent, $chunk = false, $chunkurl = null)
{
    global $CFG;
    clearstatcache();
    if (!file_exists(dirname($csspath))) {
        @mkdir(dirname($csspath), $CFG->directorypermissions, true);
    }
    // Prevent serving of incomplete file from concurrent request,
    // the rename() should be more atomic than fwrite().
    ignore_user_abort(true);
    // First up write out the single file for all those using decent browsers.
    css_write_file($csspath, $csscontent);
    if ($chunk) {
        // If we need to chunk the CSS for browsers that are sub-par.
        $css = css_chunk_by_selector_count($csscontent, $chunkurl);
        $files = count($css);
        $count = 1;
        foreach ($css as $content) {
            if ($count === $files) {
                // If there is more than one file and this IS the last file.
                $filename = preg_replace('#\\.css$#', '.0.css', $csspath);
            } else {
                // If there is more than one file and this is not the last file.
                $filename = preg_replace('#\\.css$#', '.' . $count . '.css', $csspath);
            }
            $count++;
            css_write_file($filename, $content);
        }
    }
    ignore_user_abort(false);
    if (connection_aborted()) {
        die;
    }
}
Пример #4
0
 public function acyqueueHelper()
 {
     $this->config = acymailing_config();
     $this->subClass = acymailing_get('class.subscriber');
     $this->listsubClass = acymailing_get('class.listsub');
     $this->listsubClass->checkAccess = false;
     $this->listsubClass->sendNotif = false;
     $this->listsubClass->sendConf = false;
     $this->send_limit = (int) $this->config->get('queue_nbmail', 40);
     acymailing_increasePerf();
     @ini_set('default_socket_timeout', 10);
     @ignore_user_abort(true);
     $timelimit = intval(ini_get('max_execution_time'));
     if (empty($timelimit)) {
         $timelimit = 600;
     }
     $calculatedTimeout = $this->config->get('max_execution_time');
     if (!empty($calculatedTimeout) && $calculatedTimeout < $timelimit) {
         $timelimit = $calculatedTimeout;
     }
     if (!empty($timelimit)) {
         $this->stoptime = time() + $timelimit - 4;
     }
     $this->db = JFactory::getDBO();
 }
Пример #5
0
/**
 * Upgrades vendor permissions
 *
 * @since 2.2
 * @return void
 */
function fes_22_upgrade_vendor_permissions()
{
    $fes_version = get_option('fes_db_version', '2.1');
    if (version_compare($fes_version, '2.2', '>=')) {
        return;
    }
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $offset = $step == 1 ? 0 : $step * 100;
    $users = new WP_User_Query(array('fields' => 'ID', 'number' => 100, 'offset' => $offset));
    $users = $users->results;
    if ($users && count($users) > 0) {
        foreach ($users as $user => $id) {
            if (user_can($id, 'fes_is_vendor') && !user_can($id, 'fes_is_admin') && !user_can($id, 'administrator') && !user_can($id, 'editor')) {
                $user = new WP_User($id);
                $user->add_role('frontend_vendor');
            }
        }
        // Keys found so upgrade them
        $step++;
        $redirect = add_query_arg(array('page' => 'fes-upgrades', 'edd_upgrade' => 'upgrade_vendor_permissions', 'step' => $step), admin_url('index.php'));
        wp_redirect($redirect);
        exit;
    } else {
        // No more keys found, update the DB version and finish up
        update_option('fes_db_version', fes_plugin_version);
        wp_redirect(admin_url('admin.php?page=fes-about'));
        exit;
    }
}
Пример #6
0
 /**
  * Add (export) several products to Google Content
  *
  * @return \Magento\Framework\Controller\ResultInterface
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function execute()
 {
     $flag = $this->_getFlag();
     if ($flag->isLocked()) {
         return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     }
     session_write_close();
     ignore_user_abort(true);
     set_time_limit(0);
     $storeId = $this->_getStore()->getId();
     $productIds = $this->getRequest()->getParam('product', null);
     try {
         $flag->lock();
         $this->_objectManager->create('Magento\\GoogleShopping\\Model\\MassOperations')->setFlag($flag)->addProducts($productIds, $storeId);
     } catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
         // Google requires CAPTCHA for login
         $this->messageManager->addError(__($e->getMessage()));
         $flag->unlock();
         return $this->_redirectToCaptcha($e);
     } catch (\Exception $e) {
         $flag->unlock();
         $this->notifier->addMajor(__('Something went wrong while adding products to the Google shopping account.'), $e->getMessage());
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
     }
     $flag->unlock();
     return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_RAW);
 }
 public function init()
 {
     if (file_exists($this->sock)) {
         $this->log->error("Sock file already exists, concurrent process cannot be started");
         exit;
     }
     $this->log->info('Streamer initialization');
     // connection keep-alive, in other case browser will close it when receive last frame
     header('Connection: keep-alive');
     // disable caches
     header('Cache-Control: no-cache');
     header('Cache-Control: private');
     header('Pragma: no-cache');
     // x-mixed-replace to stream JPEG images
     header('Content-type: multipart/x-mixed-replace; boundary=' . self::$BOUNDARY);
     // set unlimited so PHP doesn't timeout during a long stream
     set_time_limit(0);
     // ignore user abort script
     ignore_user_abort(true);
     @apache_setenv('no-gzip', 1);
     // disable apache gzip compression
     @ini_set('zlib.output_compression', 0);
     // disable PHP zlib compression
     @ini_set('implicit_flush', 1);
     // flush all current buffers
     $k = ob_get_level();
     for ($i = 0; $i < $k; $i++) {
         ob_end_flush();
     }
     register_shutdown_function(array($this, 'shutdown'));
     fclose(fopen($this->sock, 'w'));
     $this->initialized = true;
 }
Пример #8
0
 /**
  *
  */
 function WYSIJA_help_queue()
 {
     $this->config = WYSIJA::get('config', 'model');
     $this->subClass = WYSIJA::get('user', 'model');
     //acymailing_get('class.sub');
     $this->listsubClass = WYSIJA::get('user_list', 'model');
     //acymailing_get('class.listsub');
     $this->listsubClass->checkAccess = false;
     $this->listsubClass->sendNotif = false;
     $this->listsubClass->sendConf = false;
     $is_multisite = is_multisite();
     //$is_multisite=true;//PROD comment that line
     // get the right sending limit based on the setup we are on,
     // if we are on a multisite we need to see which sending method is used to determine that
     if ($is_multisite && $this->config->getValue('sending_method') == 'network') {
         $this->send_limit = (int) $this->config->getValue('ms_sending_emails_number');
     } else {
         $this->send_limit = (int) $this->config->getValue('sending_emails_number');
     }
     if (isset($_REQUEST['totalsend'])) {
         $this->send_limit = (int) $_REQUEST['totalsend'] - $_REQUEST['alreadysent'];
     }
     @ini_set('max_execution_time', 0);
     @ini_set('default_socket_timeout', 10);
     @ignore_user_abort(true);
     //we set a stoppage time to avoid broken process
     $time_limit = ini_get('max_execution_time');
     if (!empty($time_limit)) {
         $this->stoptime = time() + $time_limit - 4;
     }
 }
Пример #9
0
 function Display($pView = null, $pData = array())
 {
     ignore_user_abort(true);
     $Model = $this->GetModel();
     $Model->Retrieve();
     while ($Model->Fetch()) {
         $Task = $Model->Get('Task');
         $Tasks[$Task] = strtotime($Model->Get('Updated'));
     }
     // Run the janitor every minute.
     // TODO: Make this configurable.
     if (!$this->_IsPast($Tasks['Janitorial'], 1)) {
         return true;
     }
     $Model->Set('Updated', NOW());
     $Model->Save(array('Task' => 'Janitorial'));
     // Process the newsfeed every FIVE minutes.
     // TODO: Make this configurable.
     if ($this->_IsPast($Tasks['ProcessNewsfeed'], 5)) {
         $this->Talk('Newsfeed', 'ProcessQueue');
         $Model->Set('Updated', NOW());
         $Model->Save(array('Task' => 'ProcessNewsfeed'));
     }
     // Update the node network every 24 hours.
     // TODO: Make this configurable.
     if ($this->_IsPast($Tasks['UpdateNodeNetwork'], 1440)) {
         $this->GetSys('Event')->Trigger('Update', 'Node', 'Network');
         $Model->Set('Updated', NOW());
         $Model->Save(array('Task' => 'UpdateNodeNetwork'));
     }
     return true;
 }
Пример #10
0
 public function __construct()
 {
     // Enforce time limit, ignore aborts
     set_time_limit(2);
     ignore_user_abort();
     // Load constants
     require_once 'system/core/constants.php';
     // Set error reporting (debuging mode)
     if (debug) {
         error_reporting(E_ALL ^ E_DEPRECATED);
     }
     // Load security
     require_once 'system/core/security.php';
     // Load dependencies
     require_once 'system/core/dependencies.php';
     // Session handling
     date_default_timezone_set(local_timezone);
     session_start();
     // Initialize the stack (stack routing)
     Stack::Push((isset($_REQUEST[route_key]) and trim($_REQUEST[route_key]) != '') ? $_REQUEST[route_key] : route_home);
     // Initialize buffering
     ob_start();
     // Cycle the processes stack, run all the processors sucessively until the stack is empty.
     while (Stack::Ahead() > 0) {
         // Pre-init / re-init 'found' flag (in case the stack had multiple items)
         $found = false;
         // Catch anything that might happen
         try {
             foreach (route_repos as $rep => $types) {
                 if (!is_array($types)) {
                     $types = array($types);
                 }
                 foreach ($types as $t) {
                     $p = $rep . Stack::Top() . $t;
                     if (is_file($p)) {
                         $found = true;
                         // Update the output sequencer
                         Output::Path(Stack::Path());
                         if (!(include $p)) {
                             throw new SystemException(sprintf(err_include500, Stack::Top()));
                         }
                         break 2;
                     }
                 }
             }
             if (!$found) {
                 throw new SystemException(sprintf(err_include404, Stack::Top()));
             }
             // Processor completed; pop the stack
             Stack::Pop();
         } catch (Exception $e) {
             throw new SystemException($e);
         }
     }
     $this->buffer = ob_get_contents();
     ob_end_clean();
     // Pass the buffer to the output handler for final render
     Output::Flush($this->buffer);
     exit(1);
 }
Пример #11
0
function docleanup($data)
{
    global $INSTALLER09, $queries;
    set_time_limit(1200);
    ignore_user_abort(1);
    $sql = sql_query("SHOW TABLE STATUS FROM {$INSTALLER09['mysql_db']}");
    $oht = '';
    while ($row = mysqli_fetch_assoc($sql)) {
        if ($row['Data_free'] > 100) {
            $oht .= $row['Data_free'] . ',';
        }
    }
    $oht = rtrim($oht, ',');
    if ($oht != '') {
        $sql = sql_query("OPTIMIZE TABLE {$oht}");
    }
    if ($queries > 0) {
        write_log("Auto-optimizedb--------------------Auto Optimization Complete using {$queries} queries --------------------");
    }
    if ($oht != '') {
        $data['clean_desc'] = "MySQLCleanup optimized {$oht} table(s)";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
Пример #12
0
 /**
  *    执行
  *
  *    @author    Garbin
  *    @param    none
  *    @return    void
  */
 function execute()
 {
     //此处的锁定机制可能存在冲突问题
     /* 被锁定 */
     if ($this->is_lock()) {
         return;
     }
     /* 在运行结束前锁定 */
     @set_time_limit(1800);
     //半个小时
     @ignore_user_abort(true);
     //忽略用户退出
     $this->lock();
     $this->_init_tasks();
     /* 获取到期的任务列表 */
     $due_tasks = $this->get_due_tasks();
     /* 没有到期的任务 */
     if (empty($due_tasks)) {
         $this->unlock();
         return;
     }
     /* 执行任务 */
     $this->run_task($due_tasks);
     /* 更新任务列表 */
     $this->update_tasks($due_tasks);
     /* 解锁 */
     $this->unlock();
 }
Пример #13
0
 function start_send_wechat()
 {
     session_write_close();
     ignore_user_abort(true);
     set_time_limit(0);
     $this->_global("send_wechat_running", true);
     $timemap = $this->_global("send_wechat_timemap");
     $diff = time() - $timemap;
     if ($diff > 3) {
         while (true) {
             $flag = $this->_global("send_wechat_running");
             if (empty($flag)) {
                 exit;
             }
             sleep(1);
             $this->_global("send_wechat_timemap", time());
             $where = array();
             $where['westatus'] = array('eq', 1);
             $data = D("PushView")->where($where)->find();
             //$test=dump($data,false);
             //$this->wechat_test($test);
             $where['id'] = $data['id'];
             if ($data) {
                 M("Push")->delete($data['id']);
                 //$this->wechat_test($test);
                 $this->send_wechat($data['info'], $data['openid']);
             }
         }
     } else {
         dump("Y1");
     }
 }
Пример #14
0
/**
 * Upgrades all commission records to use a taxonomy for tracking the status of the commission
 *
 * @since 2.8
 * @return void
 */
function eddcr_upgrade_post_meta()
{
    if (!current_user_can('manage_shop_settings')) {
        return;
    }
    define('EDDCR_DOING_UPGRADES', true);
    ignore_user_abort(true);
    if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) {
        set_time_limit(0);
    }
    $step = isset($_GET['step']) ? absint($_GET['step']) : 1;
    $args = array('posts_per_page' => 20, 'paged' => $step, 'status' => 'any', 'order' => 'ASC', 'post_type' => 'any', 'fields' => 'ids', 'meta_key' => '_edd_cr_restricted_to');
    $items = get_posts($args);
    if ($items) {
        // items found so upgrade them
        foreach ($items as $post_id) {
            $restricted_to = get_post_meta($post_id, '_edd_cr_restricted_to', true);
            $price_id = get_post_meta($post_id, '_edd_cr_restricted_to_variable', true);
            $args = array();
            $args[] = array('download' => $restricted_to, 'price_id' => $price_id);
            update_post_meta($post_id, '_edd_cr_restricted_to', $args);
            add_post_meta($restricted_to, '_edd_cr_protected_post', $post_id);
        }
        $step++;
        $redirect = add_query_arg(array('page' => 'edd-upgrades', 'edd-upgrade' => 'upgrade_cr_post_meta', 'step' => $step), admin_url('index.php'));
        wp_safe_redirect($redirect);
        exit;
    } else {
        // No more items found, finish up
        update_option('eddcr_version', EDD_CONTENT_RESTRICTION_VER);
        delete_option('edd_doing_upgrade');
        wp_redirect(admin_url());
        exit;
    }
}
Пример #15
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $flag = $this->_getFlag();
     if ($flag->isLocked()) {
         return;
     }
     session_write_close();
     ignore_user_abort(true);
     set_time_limit(0);
     $itemIds = $this->getRequest()->getParam('item');
     try {
         $flag->lock();
         $operation = $this->operation;
         $this->_objectManager->create('Magento\\GoogleShopping\\Model\\MassOperations')->setFlag($flag)->{$operation}($itemIds);
     } catch (\Zend_Gdata_App_CaptchaRequiredException $e) {
         // Google requires CAPTCHA for login
         $this->messageManager->addError(__($e->getMessage()));
         $flag->unlock();
         $this->_redirectToCaptcha($e);
         return;
     } catch (\Exception $e) {
         $flag->unlock();
         $this->notifier->addMajor(__('An error has occurred while deleting products from google shopping account.'), __('One or more products were not deleted from google shopping account. Refer to the log file for details.'));
         $this->_objectManager->get('Psr\\Log\\LoggerInterface')->critical($e);
         return;
     }
     $flag->unlock();
 }
 /**
  * Export your settings
  * @author Julien Maury
  * @return bool|void
  */
 public function export_settings()
 {
     if (empty($_POST['export_facetwp']) || empty($_POST['action']) || 'export_facetwp_settings' !== $_POST['action']) {
         return;
     }
     if (!current_user_can('manage_options')) {
         return;
     }
     if (!wp_verify_nonce($_POST['export_facetwp_nonce'], 'export_facetwp_nonce')) {
         return;
     }
     $items = $_POST['export_facetwp'];
     if (!empty($items)) {
         foreach ($items as $item) {
             if ('facet' == substr($item, 0, 5)) {
                 $item_name = substr($item, 6);
                 $output['facets'][] = FacetWP::instance()->helper->get_facet_by_name($item_name);
             } elseif ('template' == substr($item, 0, 8)) {
                 $item_name = substr($item, 9);
                 $output['templates'][] = FacetWP::instance()->helper->get_template_by_name($item_name);
             }
         }
     }
     ignore_user_abort(true);
     nocache_headers();
     header('Content-Type: application/json; charset=utf-8');
     header('Content-Disposition: attachment; filename=facetwp-settings-export-' . strtotime('now') . '.json');
     header('Expires: 0');
     echo json_encode($output);
     exit;
 }
Пример #17
0
 public function request($arg)
 {
     if (!isset($_GET['cronpass']) || $this->password != $_GET['cronpass']) {
         return 403;
     }
     if (($fh = @fopen($this->lockpath . 'cron.lok', 'w')) && flock($fh, LOCK_EX | LOCK_NB)) {
         try {
             set_time_limit(300);
             if (litepublisher::$debug) {
                 ignore_user_abort(true);
             } else {
                 litepublisher::$urlmap->close_connection();
             }
             if (ob_get_level()) {
                 ob_end_flush();
             }
             flush();
             $this->sendexceptions();
             $this->log("started loop");
             $this->execute();
         } catch (Exception $e) {
             litepublisher::$options->handexception($e);
         }
         flock($fh, LOCK_UN);
         fclose($fh);
         @chmod($this->lockpath . 'cron.lok', 0666);
         $this->log("finished loop");
         return 'Ok';
     }
     return 'locked';
 }
Пример #18
0
/**
|--------------------------------------------------------------------------|
|   https://github.com/Bigjoos/                			    |
|--------------------------------------------------------------------------|
|   Licence Info: GPL			                                    |
|--------------------------------------------------------------------------|
|   Copyright (C) 2010 U-232 V5					    |
|--------------------------------------------------------------------------|
|   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.   |
|--------------------------------------------------------------------------|
|   Project Leaders: Mindless, Autotron, whocares, Swizzles.					    |
|--------------------------------------------------------------------------|
 _   _   _   _   _     _   _   _   _   _   _     _   _   _   _
/ \ / \ / \ / \ / \   / \ / \ / \ / \ / \ / \   / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/ \_/ \_/   \_/ \_/ \_/ \_/
*/
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //=== Clean silver
    $res = sql_query("SELECT id, silver FROM torrents WHERE silver > 1 AND silver < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    $Silver_buffer = array();
    if (mysqli_num_rows($res) > 0) {
        while ($arr = mysqli_fetch_assoc($res)) {
            $Silver_buffer[] = '(' . $arr['id'] . ', \'0\')';
            $mc1->begin_transaction('torrent_details_' . $arr['id']);
            $mc1->update_row(false, array('silver' => 0));
            $mc1->commit_transaction($INSTALLER09['expires']['torrent_details']);
        }
        $count = count($Silver_buffer);
        if ($count > 0) {
            sql_query("INSERT INTO torrents (id, silver) VALUES " . implode(', ', $Silver_buffer) . " ON DUPLICATE key UPDATE silver=values(silver)") or sqlerr(__FILE__, __LINE__);
            write_log("Cleanup - Removed Silver from " . $count . " torrents");
        }
        unset($Silver_buffer, $count);
    }
    //==End
    if ($queries > 0) {
        write_log("Free clean-------------------- Silver Torrents cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
Пример #19
0
 public static function run($cronid = 0)
 {
     global $_G;
     $cron = $cronid ? C::t('common_cron')->fetch($cronid) : C::t('common_cron')->fetch_nextrun(TIMESTAMP);
     $processname = 'DZ_CRON_' . (empty($cron) ? 'CHECKER' : $cron['cronid']);
     if ($cronid && !empty($cron)) {
         discuz_process::unlock($processname);
     }
     if (discuz_process::islocked($processname, 600)) {
         return false;
     }
     if ($cron) {
         $cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']);
         $cronfile = DISCUZ_ROOT . './source/include/cron/' . $cron['filename'];
         $cron['minute'] = explode("\t", $cron['minute']);
         self::setnextime($cron);
         @set_time_limit(1000);
         @ignore_user_abort(TRUE);
         if (!@(include $cronfile)) {
             return false;
         }
     }
     self::nextcron();
     discuz_process::unlock($processname);
     return true;
 }
Пример #20
0
 public function process($loadReferencedRecords = array())
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $this->deleteCancelFile();
     $filter = $this->grid->getFilter();
     $filter->setLimit(0);
     $ids = array();
     foreach (ActiveRecordModel::getFieldValues($this->grid->getModelClass(), $filter, array('ID'), ActiveRecordModel::LOAD_REFERENCES) as $row) {
         $ids[] = $row['ID'];
     }
     $totalCount = count($ids);
     $progress = 0;
     $response = new JSONResponse(array('act' => $this->request->get('act')), 'success', $this->completionMessage);
     ActiveRecord::beginTransaction();
     $chunkSize = count($ids) / self::MASS_ACTION_CHUNK_SIZE > 5 ? self::MASS_ACTION_CHUNK_SIZE : ceil(count($ids) / 5);
     foreach (array_chunk($ids, $chunkSize) as $chunk) {
         $response->flush('|' . base64_encode(json_encode(array('total' => $totalCount, 'progress' => $progress, 'pid' => $this->pid))));
         $this->processSet(ActiveRecordModel::getRecordSet($this->grid->getModelClass(), new ARSelectFilter(new INCond(new ARFieldHandle($this->grid->getModelClass(), 'ID'), $chunk)), $loadReferencedRecords));
         $progress += count($chunk);
     }
     ActiveRecord::commit();
     $response->flush('|');
     return $response;
 }
Пример #21
0
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    sql_query("UPDATE `freeslots` SET `addedup` = 0 WHERE `addedup` != 0 AND `addedup` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `freeslots` SET `addedfree` = 0 WHERE `addedfree` != 0 AND `addedfree` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("DELETE FROM `freeslots` WHERE `addedup` = 0 AND `addedfree` = 0") or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `free_switch` = 0 WHERE `free_switch` > 1 AND `free_switch` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `torrents` SET `free` = 0 WHERE `free` > 1 AND `free` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `downloadpos` = 1 WHERE `downloadpos` > 1 AND `downloadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `uploadpos` = 1 WHERE `uploadpos` > 1 AND `uploadpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `chatpost` = 1 WHERE `chatpost` > 1 AND `chatpost` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `avatarpos` = 1 WHERE `avatarpos` > 1 AND `avatarpos` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `immunity` = 0 WHERE `immunity` > 1 AND `immunity` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `warned` = 0 WHERE `warned` > 1 AND `warned` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `pirate` = 0 WHERE `pirate` > 1 AND `pirate` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    sql_query("UPDATE `users` SET `king` = 0 WHERE `king` > 1 AND `king` < " . TIME_NOW) or sqlerr(__FILE__, __LINE__);
    if ($queries > 0) {
        write_log("User Clean -------------------- User Clean Complete using {$queries} queries--------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
Пример #22
0
 /**
  * Implementation Create Backup functionality for Filesystem
  *
  * @throws \Magento\Framework\Exception\LocalizedException
  * @return boolean
  */
 public function create()
 {
     set_time_limit(0);
     ignore_user_abort(true);
     $this->_lastOperationSucceed = false;
     $this->_checkBackupsDir();
     $fsHelper = new \Magento\Framework\Backup\Filesystem\Helper();
     $filesInfo = $fsHelper->getInfo($this->getRootDir(), \Magento\Framework\Backup\Filesystem\Helper::INFO_READABLE | \Magento\Framework\Backup\Filesystem\Helper::INFO_SIZE, $this->getIgnorePaths());
     if (!$filesInfo['readable']) {
         throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(new \Magento\Framework\Phrase('Not enough permissions to read files for backup'));
     }
     $this->validateAvailableDiscSpace($this->getBackupsDir(), $filesInfo['size']);
     $tarTmpPath = $this->_getTarTmpPath();
     $tarPacker = new \Magento\Framework\Backup\Archive\Tar();
     $tarPacker->setSkipFiles($this->getIgnorePaths())->pack($this->getRootDir(), $tarTmpPath, true);
     if (!is_file($tarTmpPath) || filesize($tarTmpPath) == 0) {
         throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Failed to create backup'));
     }
     $backupPath = $this->getBackupPath();
     $gzPacker = new \Magento\Framework\Archive\Gz();
     $gzPacker->pack($tarTmpPath, $backupPath);
     if (!is_file($backupPath) || filesize($backupPath) == 0) {
         throw new \Magento\Framework\Exception\LocalizedException(new \Magento\Framework\Phrase('Failed to create backup'));
     }
     @unlink($tarTmpPath);
     $this->_lastOperationSucceed = true;
     return $this->_lastOperationSucceed;
 }
Пример #23
0
 function run($cronid = 0)
 {
     global $_G;
     $timestamp = TIMESTAMP;
     $cron = DB::fetch_first("SELECT * FROM " . DB::table('common_cron') . "\n\t\t\t\tWHERE " . ($cronid ? "cronid='{$cronid}'" : "available>'0' AND nextrun<='{$timestamp}'") . "\n\t\t\t\tORDER BY nextrun LIMIT 1");
     $processname = 'DZ_CRON_' . (empty($cron) ? 'CHECKER' : $cron['cronid']);
     if ($cronid && !empty($cron)) {
         discuz_process::unlock($processname);
     }
     if (discuz_process::islocked($processname, 600)) {
         return false;
     }
     if ($cron) {
         $cron['filename'] = str_replace(array('..', '/', '\\'), '', $cron['filename']);
         $cronfile = DISCUZ_ROOT . './source/include/cron/' . $cron['filename'];
         $cron['minute'] = explode("\t", $cron['minute']);
         discuz_cron::setnextime($cron);
         @set_time_limit(1000);
         @ignore_user_abort(TRUE);
         if (!@(include $cronfile)) {
             return false;
         }
     }
     discuz_cron::nextcron();
     discuz_process::unlock($processname);
     return true;
 }
Пример #24
0
 /**
  * Execute command in background.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function execAction(Request $request)
 {
     ignore_user_abort(true);
     set_time_limit(0);
     $this->get('anime_db.command')->execute($request->get('command'), 0);
     return new Response();
 }
Пример #25
0
/**
 *   https://github.com/Bigjoos/
 *   Licence Info: GPL
 *   Copyright (C) 2010 U-232 v.3
 *   A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon.
 *   Project Leaders: Mindless, putyn.
 *
 */
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(0);
    ignore_user_abort(1);
    //=== delete from now viewing after 15 minutes
    sql_query('DELETE FROM now_viewing WHERE added < ' . (TIME_NOW - 900));
    //=== fix any messed up counts
    $forums = sql_query('SELECT f.id, count( DISTINCT t.id ) AS topics, count(p.id) AS posts
                          FROM forums f
                          LEFT JOIN topics t ON f.id = t.forum_id
                          LEFT JOIN posts p ON t.id = p.topic_id
                          GROUP BY f.id');
    while ($forum = mysqli_fetch_assoc($forums)) {
        $forum['posts'] = $forum['topics'] > 0 ? $forum['posts'] : 0;
        sql_query('update forums set post_count = ' . sqlesc($forum['posts']) . ', topic_count = ' . sqlesc($forum['topics']) . ' where id=' . sqlesc($forum['id']));
    }
    if ($queries > 0) {
        write_log("Forum clean-------------------- Forum cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
Пример #26
0
 function run()
 {
     // Make sure that the output is sent to the browser before
     // loading libraries and connecting to the db
     flush();
     $aConf = $GLOBALS['_MAX']['CONF'];
     // Set longer time out, and ignore user abort
     if (!ini_get('safe_mode')) {
         @set_time_limit($aConf['maintenance']['timeLimitScripts']);
         @ignore_user_abort(true);
     }
     if (!defined('OA_VERSION')) {
         // If the code is executed inside delivery, the constants
         // need to be initialized
         require_once MAX_PATH . '/constants.php';
         setupConstants();
     }
     $oLock =& OA_DB_AdvisoryLock::factory();
     if ($oLock->get(OA_DB_ADVISORYLOCK_MAINTENANCE)) {
         OA::debug('Running Automatic Maintenance Task', PEAR_LOG_INFO);
         OA_Preferences::loadAdminAccountPreferences();
         require_once LIB_PATH . '/Maintenance.php';
         $oMaint = new OX_Maintenance();
         $oMaint->run();
         $oLock->release();
         OA::debug('Automatic Maintenance Task Completed', PEAR_LOG_INFO);
     } else {
         OA::debug('Automatic Maintenance Task not run: could not acquire lock', PEAR_LOG_INFO);
     }
 }
 /**
  * Create a sync object/request
  *
  * @param string $object Type of object to sync -- [ post | comment | option ]
  * @param int $id Unique identifier
  * @param array $settings
  */
 function register($object, $id = false, array $settings = null)
 {
     // Since we've registered something for sync, hook it up to execute on shutdown if we haven't already
     if (!$this->sync) {
         ignore_user_abort(true);
         add_action('shutdown', array($this, 'sync'), 9);
         // Right before async XML-RPC
     }
     $defaults = array('on_behalf_of' => array());
     $settings = wp_parse_args($settings, $defaults);
     if (!isset($this->sync[$object])) {
         $this->sync[$object] = array();
     }
     // Store the settings for this object
     if (!isset($this->sync[$object][$id])) {
         // Easy: store the current settings
         $this->sync[$object][$id] = $settings;
     } else {
         // Not as easy:  we have to manually merge the settings from previous runs for this object with the settings for this run
         $this->sync[$object][$id]['on_behalf_of'] = array_unique(array_merge($this->sync[$object][$id]['on_behalf_of'], $settings['on_behalf_of']));
     }
     $delete_prefix = 'delete_';
     if (0 === strpos($object, $delete_prefix)) {
         $unset_object = substr($object, strlen($delete_prefix));
     } else {
         $unset_object = "{$delete_prefix}{$object}";
     }
     // Ensure post ... delete_post yields a delete operation
     // Ensure delete_post ... post yields a sync post operation
     // Ensure update_option() ... delete_option() ends up as a delete
     // Ensure delete_option() ... update_option() ends up as an update
     // Etc.
     unset($this->sync[$unset_object][$id]);
     return true;
 }
function docleanup($data)
{
    global $INSTALLER09, $queries, $mc1;
    set_time_limit(1200);
    ignore_user_abort(1);
    //== delete torrents - ????
    $days = 30;
    $dt = TIME_NOW - $days * 86400;
    sql_query("UPDATE torrents SET flags='1' WHERE added < {$dt} AND seeders='0' AND leechers='0'") or sqlerr(__FILE__, __LINE__);
    $res = sql_query("SELECT id, name FROM torrents WHERE mtime < {$dt} AND seeders='0' AND leechers='0' AND flags='1'") or sqlerr(__FILE__, __LINE__);
    while ($arr = mysqli_fetch_assoc($res)) {
        sql_query("DELETE files.*, comments.*, thankyou.*, thanks.*, thumbsup.*, bookmarks.*, coins.*, rating.*, xbt_files_users.* FROM xbt_files_users\n                                 LEFT JOIN files ON files.torrent = xbt_files_users.fid\n                                 LEFT JOIN comments ON comments.torrent = xbt_files_users.fid\n                                 LEFT JOIN thankyou ON thankyou.torid = xbt_files_users.fid\n                                 LEFT JOIN thanks ON thanks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN bookmarks ON bookmarks.torrentid = xbt_files_users.fid\n                                 LEFT JOIN coins ON coins.torrentid = xbt_files_users.fid\n                                 LEFT JOIN rating ON rating.torrent = xbt_files_users.fid\n                                 LEFT JOIN thumbsup ON thumbsup.torrentid = xbt_files_users.fid\n                                 WHERE xbt_files_users.fid =" . sqlesc($arr['id'])) or sqlerr(__FILE__, __LINE__);
        @unlink("{$INSTALLER09['torrent_dir']}/{$arr['id']}.torrent");
        write_log("Torrent " . (int) $arr['id'] . " (" . htmlsafechars($arr['name']) . ") was deleted by system (older than {$days} days and no seeders)");
    }
    if ($queries > 0) {
        write_log("Delete Old Torrents XBT Clean -------------------- Delete Old XBT Torrents cleanup Complete using {$queries} queries --------------------");
    }
    if (false !== mysqli_affected_rows($GLOBALS["___mysqli_ston"])) {
        $data['clean_desc'] = mysqli_affected_rows($GLOBALS["___mysqli_ston"]) . " items deleted/updated";
    }
    if ($data['clean_log']) {
        cleanup_log($data);
    }
}
Пример #29
0
 /**
  * Data export action
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction()
 {
     // Export time execution depends on entities exported
     ignore_user_abort(false);
     set_time_limit(0);
     return $this->createStreamedResponse()->send();
 }
Пример #30
-1
 public function run()
 {
     ignore_user_abort(false);
     ob_implicit_flush(1);
     ini_set('implicit_flush', true);
     cachemgr::init(false);
     if (strpos(strtolower(PHP_OS), 'win') === 0) {
         if (function_exists('mb_internal_encoding')) {
             mb_internal_encoding('UTF-8');
             mb_http_output('GBK');
             ob_start('mb_output_handler', 2);
         } elseif (function_exists('iconv_set_encoding')) {
             iconv_set_encoding('internal_encoding', 'UTF-8');
             iconv_set_encoding('output_encoding', 'GBK');
             ob_start('ob_iconv_handler', 2);
         }
     }
     if (isset($_SERVER['argv'][1])) {
         $args = array_shift($_SERVER['argv']);
         $rst = $this->exec_command(implode(' ', $_SERVER['argv']));
         if ($rst === false) {
             exit(-1);
         }
     } else {
         $this->interactive();
     }
 }