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


PHP connection_aborted函数代码示例

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


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

示例1: send_file

function send_file($path)
{
    ob_end_clean();
    if (preg_match(':\\.\\.:', $path)) {
        return FALSE;
    }
    if (!preg_match(':^plotcache/:', $path)) {
        return FALSE;
    }
    if (!is_file($path) or connection_status() != 0) {
        return FALSE;
    }
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Content-Type: application/octet-stream");
    header("Content-Length: " . (string) filesize($path));
    header("Content-Disposition: inline; filename=" . basename($path));
    header("Content-Transfer-Encoding: binary\n");
    if ($file = fopen($path, 'rb')) {
        while (!feof($file) and connection_status() == 0) {
            print fread($file, 1024 * 8);
            flush();
            @ob_flush();
        }
        fclose($file);
    }
    return connection_status() == 0 and !connection_aborted();
}
开发者ID:nsahoo,项目名称:cmssw-1,代码行数:31,代码来源:download.php

示例2: getJson

 function getJson($url)
 {
     //echo urlencode($url)."</br>";
     $code = http_response_code();
     //  Initiate curl
     $ch = curl_init();
     // Disable SSL verification
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     // Will return the response, if false it print the response
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     // Set the url
     curl_setopt($ch, CURLOPT_URL, $url);
     // Execute
     $result = curl_exec($ch);
     if (connection_aborted()) {
         echo "erra bae";
     } elseif (connection_status() == CONNECTION_TIMEOUT) {
         echo "<h1>Error caught, stopped from crashing</h1>";
     } else {
         $this->busted = false;
         //  any normal completion actions
     }
     // Closing
     curl_close($ch);
     return json_decode($result, true);
 }
开发者ID:kelmo2,项目名称:leagueOfLegendsClubSite,代码行数:26,代码来源:championList.php

示例3: css_store_css

/**
 * 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;
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:47,代码来源:csslib.php

示例4: send_file

function send_file($name)
{
    $path = $name;
    $path_info = pathinfo($path);
    $basename = $path_info['basename'];
    if (!is_file($path) or connection_status() != 0) {
        return false;
    }
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    header("Expires: " . gmdate("D, d M Y H:i:s", mktime(date("H") + 2, date("i"), date("s"), date("m"), date("d"), date("Y"))) . " GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Content-Type: application/octet-stream");
    header("Content-Length: " . (string) filesize($path));
    header("Content-Disposition: inline; filename={$basename}");
    header("Content-Transfer-Encoding: binary\n");
    if ($file = fopen($path, 'rb')) {
        while (!feof($file) and connection_status() == 0) {
            print fread($file, 1024 * 8);
            flush();
        }
        fclose($file);
    }
    return connection_status() == 0 and !connection_aborted();
}
开发者ID:MusicalAPP,项目名称:gfk-api-spotify-itunes,代码行数:26,代码来源:spotifydwn.php

示例5: __construct

 public function __construct()
 {
     $this->Connect();
     if (connection_aborted() == TRUE) {
         //@mssql_close($this->Connect);
     }
 }
开发者ID:neilor,项目名称:effectweb-v1.8.5,代码行数:7,代码来源:CTM_MSSQL.class.php

示例6: send_file

function send_file($path)
{
    session_write_close();
    ob_end_clean();
    if (!is_file($path) || connection_status() != 0) {
        return false;
    }
    //to prevent long file from getting cut off from    //max_execution_time
    set_time_limit(0);
    $name = basename($path);
    //filenames in IE containing dots will screw up the
    //filename unless we add this
    if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
        $name = preg_replace('/\\./', '%2e', $name, substr_count($name, '.') - 1);
        //required, or it might try to send the serving    //document instead of the file
        $name = str_replace(array("\"", "<", ">", "?", ":"), array('%22', '%3c', '%3e', '%3f', '_'), $name);
    } else {
        $name = str_replace(array("\"", ":"), array("'", "_"), $name);
    }
    header("Cache-Control: ");
    header("Pragma: ");
    header("Content-Type: application/octet-stream");
    header("Content-Length: " . (string) filesize($path));
    header('Content-Disposition: attachment; filename="' . $name . '"');
    header("Content-Transfer-Encoding: binary\n");
    if ($file = fopen($path, 'rb')) {
        while (!feof($file) && connection_status() == 0) {
            print fread($file, 1024 * 8);
            flush();
        }
        fclose($file);
    }
    return connection_status() == 0 and !connection_aborted();
}
开发者ID:anboto,项目名称:xtreamer-web-sdk,代码行数:34,代码来源:downloadfiles.php

示例7: zipify

function zipify($Dir, $ExhibitName) {
	chdir($Dir);
		
	$filename = '../../tmp/'.$ExhibitName.'.zip';

	echo 'real filename: '.realpath($filename);

	if(size_dir('.') > disk_free_space('.'))
		die('Error: not enough free space to zip');
			
	ignore_user_abort(true);
	
	$command='zip -r '.escapeshellarg($filename).' .';
	exec($command);
			
	if(connection_aborted()) {
		unlink($filename);
		die();
	}
	else {
		header('Content-Description: File Transfer');
	   header('Content-Type: application/zip');
	   header('Content-Disposition: attachment; filename='.urlencode($ExhibitName).'.zip');
	   header('Content-Transfer-Encoding: binary');
	   header('Expires: 0');
	   header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
	   header('Pragma: public');
	   header('Content-Length: ' . filesize($filename));
	   ob_clean();
	   flush();
	   readfile($filename);
		unlink($filename);
	   exit;
	}
}
开发者ID:slambert,项目名称:Add-Art-Image-Cropper,代码行数:35,代码来源:dlaszip.php

示例8: send

 /**
 		Transmit file to HTTP client; Return file size if successful,
 		FALSE otherwise
 		@return int|FALSE
 		@param $file string
 		@param $mime string
 		@param $kbps int
 	**/
 function send($file, $mime = NULL, $kbps = 0)
 {
     if (!is_file($file)) {
         return FALSE;
     }
     if (PHP_SAPI != 'cli') {
         header('Content-Type: ' . $mime ?: $this->mime($file));
         if ($mime == 'application/octet-stream') {
             header('Content-Disposition: attachment; ' . 'filename=' . basename($file));
         }
         header('Accept-Ranges: bytes');
         header('Content-Length: ' . ($size = filesize($file)));
         header('X-Powered-By: ' . Base::instance()->get('PACKAGE'));
     }
     $ctr = 0;
     $handle = fopen($file, 'rb');
     $start = microtime(TRUE);
     while (!feof($handle) && ($info = stream_get_meta_data($handle)) && !$info['timed_out'] && !connection_aborted()) {
         if ($kbps) {
             // Throttle output
             $ctr++;
             if ($ctr / $kbps > ($elapsed = microtime(TRUE) - $start)) {
                 usleep(1000000.0 * ($ctr / $kbps - $elapsed));
             }
         }
         // Send 1KiB and reset timer
         echo fread($handle, 1024);
     }
     fclose($handle);
     return $size;
 }
开发者ID:adentes-org,项目名称:preums,代码行数:39,代码来源:web.php

示例9: jok

 function jok($str)
 {
     if ($this->transObj) {
         $this->transObj->query(connection_aborted() ? 'ROLLBACK' : 'COMMIT');
     }
     $cli = HTML_FlexyFramework::get()->cli;
     if ($cli) {
         echo "OK: " . $str . "\n";
         exit;
     }
     require_once 'Services/JSON.php';
     $json = new Services_JSON();
     $retHTML = isset($_SERVER['CONTENT_TYPE']) && preg_match('#multipart/form-data#i', $_SERVER['CONTENT_TYPE']);
     if ($retHTML) {
         if (isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] == 'NO') {
             $retHTML = false;
         }
     } else {
         $retHTML = isset($_REQUEST['returnHTML']) && $_REQUEST['returnHTML'] != 'NO';
     }
     if ($retHTML) {
         header('Content-type: text/html');
         echo "<HTML><HEAD></HEAD><BODY>";
         // encode html characters so they can be read..
         echo str_replace(array('<', '>'), array('\\u003c', '\\u003e'), $json->encodeUnsafe(array('success' => true, 'data' => $str)));
         echo "</BODY></HTML>";
         exit;
     }
     echo $json->encode(array('success' => true, 'data' => $str));
     exit;
 }
开发者ID:roojs,项目名称:Pman.Core,代码行数:31,代码来源:RooJsonOutputTrait.php

示例10: SPEWCLEANUP

function SPEWCLEANUP()
{
    global $fp;
    if (!$fp || !connection_aborted()) {
        exit;
    }
    pclose($fp);
    exit;
}
开发者ID:mahyuddin,项目名称:emulab-stable,代码行数:9,代码来源:spewevents.php

示例11: can_gzip

function can_gzip(){ 
    global $HTTP_ACCEPT_ENCODING;    
    if (headers_sent() || connection_aborted()){ 
        return 0; 
    } 
    if (strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false) return "x-gzip"; 
    if (strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false) return "gzip"; 
    return 0; 
} 
开发者ID:BackupTheBerlios,项目名称:datenstore,代码行数:9,代码来源:gzencode.php

示例12: indexAction

 /**
  * undocumented function
  *
  * @return  void
  * @author  Neil Brayfield
  **/
 public function indexAction()
 {
     // Get the file path from the request
     $filename = $this->dispatcher->getParam('file');
     // Find the file extension
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     // Remove the extension from the filename
     $filename = substr($filename, 0, -(strlen($ext) + 1));
     if ($filename = $this->fs->findFile('public', $filename, $ext, false)) {
         // Check if the browser sent an "if-none-match: <etag>" header or the if-modfied-since header,
         // and tell if the file hasn't changed
         $mtime = filemtime($filename);
         $etag = md5($mtime);
         $modified_since = $this->request->getHeader('if-modified-since');
         $non_match = $this->request->getHeader('if-none-match');
         if ($non_match === $etag || $modified_since != "" && strtotime($modified_since) >= $mtime) {
             // Throw 304 not modified cache header
             throw new HTTP304();
         }
         $this->response->setEtag($etag);
         // Set the proper headers to allow caching
         $this->response->setHeader('Content-Type', $this->file->mimeByExt($ext));
         $this->response->setHeader('Last-Modified', date('r', $mtime));
         $this->response->sendHeaders();
         while (ob_get_level()) {
             // Flush all output buffers
             ob_end_flush();
         }
         $start = 0;
         $end = filesize($filename);
         // Open the file for reading
         $file = fopen($filename, 'rb');
         // Send data in 16kb blocks
         $block = 1024 * 16;
         fseek($file, $start);
         while (!feof($file) && ($pos = ftell($file)) <= $end) {
             if (connection_aborted()) {
                 break;
             }
             if ($pos + $block > $end) {
                 // Don't read past the buffer.
                 $block = $end - $pos + 1;
             }
             // Output a block of the file
             echo fread($file, $block);
             // Send the data now
             flush();
         }
         // Close the file
         fclose($file);
         exit;
     } else {
         // Return a 404 status
         throw new HTTP404();
     }
 }
开发者ID:braf,项目名称:phalcana-core,代码行数:62,代码来源:PublicController.php

示例13: write

 function write($string = '', $verbosity_status = PROCESS_LEVEL_NOTICE)
 {
     if (!connection_aborted() && $this->current_process) {
         $values['session_id'] = $this->session_id;
         $values['status'] = $verbosity_status;
         $values['name'] = $this->current_process;
         $values['message'] = $string;
         $values['time'] = time();
         $this->db->sql_insert('sys_progress', $values);
     }
 }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:11,代码来源:progress.class.php

示例14: get_conversations

function get_conversations($dao, $user_id, $latest_pulled, $latest_seen_by_u2)
{
    global $user;
    global $INITIAL_CONVO_SIZE;
    $this_conversation = "((user_id1=\"{$user->user_id}\" AND user_id2=\"{$user_id}\") OR \n\t\t \t\t\t\t\t   (user_id2=\"{$user->user_id}\" AND user_id1=\"{$user_id}\"))";
    $properties = array("msg_id", "user_id1", "user_id2", "user_name", "msg_content", "msg_seen");
    //Select all messages that have not been pulled by this client
    // AND all messages that have been seen by the other user, but this has not yet been observed
    // by this client.
    if ($latest_pulled != -1) {
        $query = "SELECT " . implode(",", $properties) . " FROM\n\t\t\t\t\t\tchat_msg JOIN user ON user.user_id=user_id1 \n\t\t\t\t\t\tWHERE {$this_conversation}\n\t\t\t\t\t\t\tAND ((msg_id > {$latest_seen_by_u2} AND msg_seen AND user_id2=\"{$user_id}\")\n\t\t\t\t\t\t\t      OR (msg_id > {$latest_pulled}))\n\t\t\t\t\t\tORDER BY msg_id ASC;";
    } else {
        $query = "(SELECT " . implode(",", $properties) . " FROM\n\t\t\t\t\t\tchat_msg JOIN user ON user.user_id=user_id1 \n\t\t\t \t\t\tWHERE {$this_conversation}\n\t\t\t \t\t\tORDER BY msg_id DESC LIMIT {$INITIAL_CONVO_SIZE}) ORDER BY msg_id ASC;";
    }
    $dao->myquery($query);
    $messages = $dao->fetch_all_obj_part($properties);
    if (connection_aborted()) {
        echo "Connection aborted";
    }
    $conversations = array();
    //When a request for a specific user is made, include conversation info
    // even if there aren't any messages.
    if ($user_id != "-1") {
        $user2 = DataObject::select_one($dao, "user", array("user_id", "user_name", "user_picture"), array("user_id" => $user_id));
        $conversation = new stdClass();
        $conversation->messages = array();
        $conversation->user_name = $user2->user_name;
        $conversation->user_picture = $user2->user_picture;
        $conversation->user_id = $user_id;
        $conversations[$user_id] = $conversation;
    }
    foreach ($messages as $message) {
        $dao->myquery("UPDATE chat_msg SET msg_seen=1 WHERE msg_id=\"{$message->msg_id}\" AND user_id2=\"{$user->user_id}\";");
        if ($message->user_id2 != $user->user_id) {
            $convo_id = $message->user_id2;
        } else {
            $convo_id = $message->user_id1;
        }
        if (!array_key_exists($convo_id, $conversations)) {
            $user2 = DataObject::select_one($dao, "user", array("user_id", "user_name", "user_picture"), array("user_id" => $convo_id));
            $conversation = new stdClass();
            $conversation->messages = array();
            $conversation->user_name = $user2->user_name;
            $conversation->user_id = $convo_id;
            $conversation->user_picture = $user2->user_picture;
            $conversations[$convo_id] = $conversation;
        } else {
            $conversation = $conversations[$convo_id];
        }
        $conversation->messages[$message->msg_id] = $message;
    }
    return $conversations;
}
开发者ID:ThisIsGJ,项目名称:unify,代码行数:53,代码来源:get.php

示例15: css_store_css

/**
 * 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 array $cssfiles The CSS files to store.
 */
function css_store_css(theme_config $theme, $csspath, array $cssfiles)
{
    global $CFG;
    if (!empty($CFG->enablecssoptimiser)) {
        // This is an experimental feature introduced in Moodle 2.3
        // The CSS optimiser organises the CSS in order to reduce the overall number
        // of rules and styles being sent to the client. It does this by collating
        // the CSS before it is cached removing excess styles and rules and stripping
        // out any extraneous content such as comments and empty rules.
        $optimiser = new css_optimiser();
        $css = '';
        foreach ($cssfiles as $file) {
            $css .= file_get_contents($file) . "\n";
        }
        $css = $theme->post_process($css);
        $css = $optimiser->process($css);
        // If cssoptimisestats is set then stats from the optimisation are collected
        // and output at the beginning of the CSS
        if (!empty($CFG->cssoptimiserstats)) {
            $css = $optimiser->output_stats_css() . $css;
        }
    } else {
        // This is the default behaviour.
        // The cssoptimise setting was introduced in Moodle 2.3 and will hopefully
        // in the future be changed from an experimental setting to the default.
        // The css_minify_css will method will use the Minify library remove
        // comments, additional whitespace and other minor measures to reduce the
        // the overall CSS being sent.
        // However it has the distinct disadvantage of having to minify the CSS
        // before running the post process functions. Potentially things may break
        // here if theme designers try to push things with CSS post processing.
        $css = $theme->post_process(css_minify_css($cssfiles));
    }
    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);
    if ($fp = fopen($csspath . '.tmp', 'xb')) {
        fwrite($fp, $css);
        fclose($fp);
        rename($csspath . '.tmp', $csspath);
        @chmod($csspath, $CFG->filepermissions);
        @unlink($csspath . '.tmp');
        // just in case anything fails
    }
    ignore_user_abort(false);
    if (connection_aborted()) {
        die;
    }
}
开发者ID:nicusX,项目名称:moodle,代码行数:62,代码来源:csslib.php


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