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


PHP MainWP_Utility::endSession方法代码示例

本文整理汇总了PHP中MainWP_Utility::endSession方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_Utility::endSession方法的具体用法?PHP MainWP_Utility::endSession怎么用?PHP MainWP_Utility::endSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainWP_Utility的用法示例。


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

示例1: syncSite

 public static function syncSite()
 {
     $website = null;
     if (isset($_POST['wp_id'])) {
         $website = MainWP_DB::Instance()->getWebsiteById($_POST['wp_id']);
     }
     if ($website == null) {
         die(json_encode(array('error' => 'Invalid Request')));
     }
     $maxRequestsInThirtySeconds = get_option('mainwp_maximumRequests');
     MainWP_Utility::endSession();
     $semLock = '103218';
     //SNSyncLock
     //        $identifier = null;
     //        if ($maxRequestsInThirtySeconds != false || $maxRequestsInThirtySeconds != 0)
     //        {
     //            //Lock
     //            $identifier = MainWP_Utility::getLockIdentifier($semLock);
     //            MainWP_Utility::lock($identifier);
     //
     //            $req = MainWP_DB::Instance()->getRequestsSince(30 / $maxRequestsInThirtySeconds);
     //            MainWP_Utility::endSession();
     //
     //            while ($req >= 1)
     //            {
     //                MainWP_Utility::release($identifier);
     //                //Unlock
     //                sleep(2);
     //
     //                //Lock
     //                MainWP_Utility::lock($identifier);
     //                $req = MainWP_DB::Instance()->getRequestsSince(30 / $maxRequestsInThirtySeconds);
     //                MainWP_Utility::endSession();
     //            }
     //        }
     MainWP_DB::Instance()->updateWebsiteSyncValues($website->id, array('dtsSyncStart' => time()));
     MainWP_Utility::endSession();
     //Unlock
     //        MainWP_Utility::release($identifier);
     if (MainWP_Sync::syncSite($website)) {
         die(json_encode(array('result' => 'SUCCESS')));
     }
     $website = MainWP_DB::Instance()->getWebsiteById($website->id);
     die(json_encode(array('error' => $website->sync_errors)));
 }
开发者ID:senlin,项目名称:mainwp,代码行数:45,代码来源:widget-mainwp-right-now.php

示例2: mainwp_createbackup_getfilesize

 function mainwp_createbackup_getfilesize()
 {
     $this->secure_request('mainwp_createbackup_getfilesize');
     try {
         if (!isset($_POST['siteId'])) {
             throw new Exception(__('No site given', 'mainwp'));
         }
         $siteId = $_POST['siteId'];
         $fileName = $_POST['fileName'];
         $fileNameUID = $_POST['fileNameUID'];
         $type = $_POST['type'];
         $website = MainWP_DB::Instance()->getWebsiteById($siteId);
         if (!$website) {
             throw new Exception(__('No site given', 'mainwp'));
         }
         MainWP_Utility::endSession();
         //Send request to the childsite!
         $result = MainWP_Utility::fetchUrlAuthed($website, 'createBackupPoll', array('fileName' => $fileName, 'fileNameUID' => $fileNameUID, 'type' => $type));
         if (!isset($result['size'])) {
             throw new Exception(__('Invalid response', 'mainwp'));
         }
         if (MainWP_Utility::ctype_digit($result['size'])) {
             $output = array('size' => $result['size']);
         } else {
             $output = array();
         }
     } catch (Exception $e) {
         $output = array('error' => $e->getMessage());
     }
     die(json_encode($output));
 }
开发者ID:jexmex,项目名称:mainwp,代码行数:31,代码来源:class-mainwp-post-handler.php

示例3: performUpload

 public static function performUpload()
 {
     MainWP_Utility::endSession();
     //Fetch info..
     $post_data = array('url' => json_encode(explode('||', $_POST['urls'])), 'type' => $_POST['type']);
     if ($_POST['activatePlugin'] == 'true') {
         $post_data['activatePlugin'] = 'yes';
     }
     if ($_POST['overwrite'] == 'true') {
         $post_data['overwrite'] = true;
     }
     $output = new stdClass();
     $output->ok = array();
     $output->errors = array();
     $websites = array(MainWP_DB::Instance()->getWebsiteById($_POST['siteId']));
     MainWP_Utility::fetchUrlsAuthed($websites, 'installplugintheme', $post_data, array(MainWP_Install_Bulk::getClassName(), 'InstallPluginTheme_handler'), $output);
     die(json_encode($output));
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:18,代码来源:page-mainwp-install-bulk.php

示例4: _fetchUrl

 static function _fetchUrl(&$website, $url, $postdata, $checkConstraints = false, $pForceFetch = false, $verifyCertificate = null, $http_user = null, $http_pass = null, $sslVersion = 0)
 {
     //$agent = 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)';
     $agent = 'Mozilla/5.0 (compatible; MainWP/' . MainWP_System::$version . '; +http://mainwp.com)';
     if (!$pForceFetch) {
         //todo: RS:
         //check if offline
     }
     $identifier = null;
     if ($checkConstraints) {
         $semLock = '103218';
         //SNSyncLock
         //Lock
         $identifier = MainWP_Utility::getLockIdentifier($semLock);
         //Check the delays
         //In MS
         $minimumDelay = get_option('mainwp_minimumDelay') === false ? 200 : get_option('mainwp_minimumDelay');
         if ($minimumDelay > 0) {
             $minimumDelay = $minimumDelay / 1000;
         }
         $minimumIPDelay = get_option('mainwp_minimumIPDelay') === false ? 1000 : get_option('mainwp_minimumIPDelay');
         if ($minimumIPDelay > 0) {
             $minimumIPDelay = $minimumIPDelay / 1000;
         }
         MainWP_Utility::endSession();
         $delay = true;
         while ($delay) {
             MainWP_Utility::lock($identifier);
             if ($minimumDelay > 0) {
                 //Check last request overall
                 $lastRequest = MainWP_DB::Instance()->getLastRequestTimestamp();
                 if ($lastRequest > microtime(true) - $minimumDelay) {
                     //Delay!
                     MainWP_Utility::release($identifier);
                     usleep(($minimumDelay - (microtime(true) - $lastRequest)) * 1000 * 1000);
                     continue;
                 }
             }
             if ($minimumIPDelay > 0 && $website != null) {
                 //Get ip of this site url
                 $ip = MainWP_DB::Instance()->getWPIp($website->id);
                 if ($ip != null && $ip != '') {
                     //Check last request for this site
                     $lastRequest = MainWP_DB::Instance()->getLastRequestTimestamp($ip);
                     //Check last request for this subnet?
                     if ($lastRequest > microtime(true) - $minimumIPDelay) {
                         //Delay!
                         MainWP_Utility::release($identifier);
                         usleep(($minimumIPDelay - (microtime(true) - $lastRequest)) * 1000 * 1000);
                         continue;
                     }
                 }
             }
             $delay = false;
         }
         //Check the simultaneous requests
         $maximumRequests = get_option('mainwp_maximumRequests') === false ? 4 : get_option('mainwp_maximumRequests');
         $maximumIPRequests = get_option('mainwp_maximumIPRequests') === false ? 1 : get_option('mainwp_maximumIPRequests');
         $first = true;
         $delay = true;
         while ($delay) {
             if (!$first) {
                 MainWP_Utility::lock($identifier);
             } else {
                 $first = false;
             }
             //Clean old open requests (may have timed out or something..)
             MainWP_DB::Instance()->closeOpenRequests();
             if ($maximumRequests > 0) {
                 $nrOfOpenRequests = MainWP_DB::Instance()->getNrOfOpenRequests();
                 if ($nrOfOpenRequests >= $maximumRequests) {
                     //Delay!
                     MainWP_Utility::release($identifier);
                     //Wait 200ms
                     usleep(200000);
                     continue;
                 }
             }
             if ($maximumIPRequests > 0 && $website != null) {
                 //Get ip of this site url
                 $ip = MainWP_DB::Instance()->getWPIp($website->id);
                 if ($ip != null && $ip != '') {
                     $nrOfOpenRequests = MainWP_DB::Instance()->getNrOfOpenRequests($ip);
                     if ($nrOfOpenRequests >= $maximumIPRequests) {
                         //Delay!
                         MainWP_Utility::release($identifier);
                         //Wait 200ms
                         usleep(200000);
                         continue;
                     }
                 }
             }
             $delay = false;
         }
     }
     if ($website != null) {
         //Log the start of this request!
         MainWP_DB::Instance()->insertOrUpdateRequestLog($website->id, null, microtime(true), null);
     }
     if ($identifier != null) {
//.........这里部分代码省略.........
开发者ID:reeslo,项目名称:mainwp,代码行数:101,代码来源:class-mainwp-utility.php

示例5: backup

 public static function backup($pSiteId, $pType, $pSubfolder, $pExclude, $excludebackup, $excludecache, $excludenonwp, $excludezip, $pFilename = null, $pFileNameUID = '', $pArchiveFormat = false, $pMaximumFileDescriptorsOverride = false, $pMaximumFileDescriptorsAuto = false, $pMaximumFileDescriptors = false, $pLoadFilesBeforeZip = false, $pid = false, $append = false)
 {
     if (trim($pFilename) == '') {
         $pFilename = null;
     }
     $backup_result = array();
     //Creating a backup
     $website = MainWP_DB::Instance()->getWebsiteById($pSiteId);
     $subfolder = str_replace('%sitename%', MainWP_Utility::sanitize($website->name), $pSubfolder);
     $subfolder = str_replace('%url%', MainWP_Utility::sanitize(MainWP_Utility::getNiceURL($website->url)), $subfolder);
     $subfolder = str_replace('%type%', $pType, $subfolder);
     $subfolder = str_replace('%date%', MainWP_Utility::date('Ymd'), $subfolder);
     $subfolder = str_replace('%task%', '', $subfolder);
     $subfolder = str_replace('%', '', $subfolder);
     $subfolder = MainWP_Utility::removePreSlashSpaces($subfolder);
     $subfolder = MainWP_Utility::normalize_filename($subfolder);
     if (!MainWP_Utility::can_edit_website($website)) {
         throw new MainWP_Exception('You are not allowed to backup this site');
     }
     $websiteCleanUrl = $website->url;
     if (substr($websiteCleanUrl, -1) == '/') {
         $websiteCleanUrl = substr($websiteCleanUrl, 0, -1);
     }
     $websiteCleanUrl = str_replace(array('http://', 'https://', '/'), array('', '', '-'), $websiteCleanUrl);
     //Normal flow: use website & fallback to global
     if ($pMaximumFileDescriptorsOverride == false) {
         if ($website->maximumFileDescriptorsOverride == 1) {
             $maximumFileDescriptorsAuto = $website->maximumFileDescriptorsAuto == 1;
             $maximumFileDescriptors = $website->maximumFileDescriptors;
         } else {
             $maximumFileDescriptorsAuto = get_option('mainwp_maximumFileDescriptorsAuto');
             $maximumFileDescriptors = get_option('mainwp_maximumFileDescriptors');
             $maximumFileDescriptors = $maximumFileDescriptors === false ? 150 : $maximumFileDescriptors;
         }
     } else {
         if ($pArchiveFormat != 'global' && $pMaximumFileDescriptorsOverride == 1) {
             $maximumFileDescriptorsAuto = $pMaximumFileDescriptorsAuto == 1;
             $maximumFileDescriptors = $pMaximumFileDescriptors;
         } else {
             $maximumFileDescriptorsAuto = get_option('mainwp_maximumFileDescriptorsAuto');
             $maximumFileDescriptors = get_option('mainwp_maximumFileDescriptors');
             $maximumFileDescriptors = $maximumFileDescriptors === false ? 150 : $maximumFileDescriptors;
         }
     }
     $file = str_replace(array('%sitename%', '%url%', '%date%', '%time%', '%type%'), array(MainWP_Utility::sanitize($website->name), $websiteCleanUrl, MainWP_Utility::date('m-d-Y'), MainWP_Utility::date('G\\hi\\ms\\s'), $pType), $pFilename);
     $file = str_replace('%', '', $file);
     $file = MainWP_Utility::normalize_filename($file);
     //Normal flow: check site settings & fallback to global
     if ($pLoadFilesBeforeZip == false) {
         $loadFilesBeforeZip = $website->loadFilesBeforeZip;
         if ($loadFilesBeforeZip == 1) {
             $loadFilesBeforeZip = get_option('mainwp_options_loadFilesBeforeZip');
             $loadFilesBeforeZip = $loadFilesBeforeZip == 1 || $loadFilesBeforeZip === false;
         } else {
             $loadFilesBeforeZip = $loadFilesBeforeZip == 2;
         }
     } else {
         if ($pArchiveFormat == 'global' || $pLoadFilesBeforeZip == 1) {
             $loadFilesBeforeZip = get_option('mainwp_options_loadFilesBeforeZip');
             $loadFilesBeforeZip = $loadFilesBeforeZip == 1 || $loadFilesBeforeZip === false;
         } else {
             $loadFilesBeforeZip = $pLoadFilesBeforeZip == 2;
         }
     }
     //Nomral flow: check site settings & fallback to global
     if ($pArchiveFormat == false) {
         $archiveFormat = MainWP_Utility::getCurrentArchiveExtension($website);
     } else {
         if ($pArchiveFormat == 'global') {
             $archiveFormat = MainWP_Utility::getCurrentArchiveExtension();
         } else {
             $archiveFormat = $pArchiveFormat;
         }
     }
     MainWP_Utility::endSession();
     $information = MainWP_Utility::fetchUrlAuthed($website, 'backup', array('type' => $pType, 'exclude' => $pExclude, 'excludebackup' => $excludebackup, 'excludecache' => $excludecache, 'excludenonwp' => $excludenonwp, 'excludezip' => $excludezip, 'ext' => $archiveFormat, 'file_descriptors_auto' => $maximumFileDescriptorsAuto, 'file_descriptors' => $maximumFileDescriptors, 'loadFilesBeforeZip' => $loadFilesBeforeZip, MainWP_Utility::getFileParameter($website) => $file, 'fileUID' => $pFileNameUID, 'pid' => $pid, 'append' => $append ? 1 : 0), false, false, false);
     do_action('mainwp_managesite_backup', $website, array('type' => $pType), $information);
     if (isset($information['error'])) {
         throw new MainWP_Exception($information['error']);
     } else {
         if ($pType == 'db' && !$information['db']) {
             throw new MainWP_Exception('Database backup failed.');
         } else {
             if ($pType == 'full' && !$information['full']) {
                 throw new MainWP_Exception('Full backup failed.');
             } else {
                 if (isset($information['db'])) {
                     if ($information['db'] != false) {
                         $backup_result['url'] = $information['db'];
                         $backup_result['type'] = 'db';
                     } else {
                         if ($information['full'] != false) {
                             $backup_result['url'] = $information['full'];
                             $backup_result['type'] = 'full';
                         }
                     }
                     if (isset($information['size'])) {
                         $backup_result['size'] = $information['size'];
                     }
                     $backup_result['subfolder'] = $subfolder;
//.........这里部分代码省略.........
开发者ID:reeslo,项目名称:mainwp,代码行数:101,代码来源:page-mainwp-manage-sites.php

示例6: syncSite

 public static function syncSite(&$pWebsite = null, $pForceFetch = false, $pAllowDisconnect = true)
 {
     if ($pWebsite == null) {
         return false;
     }
     $userExtension = MainWP_DB::Instance()->getUserExtensionByUserId($pWebsite->userid);
     if ($userExtension == null) {
         return false;
     }
     MainWP_Utility::endSession();
     try {
         $pluginDir = $pWebsite->pluginDir;
         if ($pluginDir == '') {
             $pluginDir = $userExtension->pluginDir;
         }
         $cloneEnabled = apply_filters('mainwp_clone_enabled', false);
         $cloneSites = array();
         if ($cloneEnabled) {
             $disallowedCloneSites = get_option('mainwp_clone_disallowedsites');
             if ($disallowedCloneSites === false) {
                 $disallowedCloneSites = array();
             }
             $websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser());
             if ($websites) {
                 while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
                     if (in_array($website->id, $disallowedCloneSites)) {
                         continue;
                     }
                     if ($website->id == $pWebsite->id) {
                         continue;
                     }
                     $cloneSites[$website->id] = array('name' => $website->name, 'url' => $website->url, 'extauth' => $website->extauth, 'size' => $website->totalsize);
                 }
                 @MainWP_DB::free_result($websites);
             }
         }
         $pluginConflicts = get_option('mainwp_pluginConflicts');
         if ($pluginConflicts !== false) {
             $pluginConflicts = array_keys($pluginConflicts);
         }
         $themeConflicts = get_option('mainwp_themeConflicts');
         if ($themeConflicts !== false) {
             $themeConflicts = array_keys($themeConflicts);
         }
         $othersData = apply_filters('mainwp-sync-others-data', array(), $pWebsite);
         $information = MainWP_Utility::fetchUrlAuthed($pWebsite, 'stats', array('optimize' => get_option('mainwp_optimize') == 1 ? 1 : 0, 'heatMap' => MainWP_Extensions::isExtensionAvailable('mainwp-heatmap-extension') ? $userExtension->heatMap : 0, 'pluginDir' => $pluginDir, 'cloneSites' => !$cloneEnabled ? 0 : urlencode(json_encode($cloneSites)), 'pluginConflicts' => json_encode($pluginConflicts), 'themeConflicts' => json_encode($themeConflicts), 'othersData' => json_encode($othersData), 'server' => get_admin_url(), 'numberdaysOutdatePluginTheme' => get_option('mainwp_numberdays_Outdate_Plugin_Theme', 365)), true, $pForceFetch);
         $return = self::syncInformationArray($pWebsite, $information, '', 1, false, $pAllowDisconnect);
         return $return;
     } catch (MainWP_Exception $e) {
         $sync_errors = '';
         $offline_check_result = 1;
         if ($e->getMessage() == 'HTTPERROR') {
             $sync_errors = __('HTTP error', 'mainwp') . ($e->getMessageExtra() != null ? ' - ' . $e->getMessageExtra() : '');
             $offline_check_result = -1;
         } else {
             if ($e->getMessage() == 'NOMAINWP') {
                 $sync_errors = __('MainWP not detected', 'mainwp');
                 $offline_check_result = 1;
             }
         }
         return self::syncInformationArray($pWebsite, $information, $sync_errors, $offline_check_result, true, $pAllowDisconnect);
     }
 }
开发者ID:reeslo,项目名称:mainwp,代码行数:63,代码来源:class-mainwp-sync.php


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