This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| if (!function_exists('http_response_code')) { | |
| function http_response_code($code = null) | |
| { | |
| static $defaultCode = 200; | |
| if (null != $code) { | |
| switch ($code) { | |
| case 100: $text = 'Continue'; break; // RFC2616 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /* | |
| 参考自: | |
| http://darklaunch.com/2010/09/01/http-status-codes-in-php-http-header-response-code-function | |
| http://snipplr.com/view/68099/ | |
| */ | |
| function HTTPStatus($num) { | |
| $http = array( | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php // got from here https://www.sanwebe.com/2011/02/how-to-detect-ajax-request-using-php | |
| //detect ajax | |
| if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') { | |
| die('Request must come from Ajax!'); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /* Simple spam protection for email addresses using jQuery. | |
| * Well, the protection isn’t jQuery-based, but you get the idea. | |
| * This snippet allows you to slightly ‘obfuscate’ email addresses to make it harder for spambots to harvest them, while still offering a readable address to your visitors. | |
| * E.g. | |
| * <a href="mailto:foo(at)example(dot)com">foo at example dot com</a> | |
| * → | |
| * <a href="mailto:[email protected]">[email protected]</a> | |
| */ | |
| $(function() { | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // декодим Unicode ( \xc3\xa9 ) | |
| $a = array("\xc3\xa9"); | |
| echo "Unicode: ", json_encode($a, JSON_UNESCAPED_UNICODE), "\n"; | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * [CheckMemoryConsumption проверка занимаемой памяти приложением] | |
| * @param string $state [состояние одно из возможных: initial,final,peak] | |
| * @return string | |
| */ | |
| public static function CheckMemoryConsumption($state = 'initial') | |
| { | |
| $memorySizeConsumptionString = ''; | |
| switch ($state){ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Generating Command Line Colors with PHP | |
| * @author Mario Awad | |
| * @link http://softkube.com/blog/generating-command-line-colors-with-php | |
| */ | |
| function colorize($text, $status) { | |
| $out = ""; | |
| switch($status) { | |
| case "SUCCESS": | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| /** | |
| * Get Last Header (no need to follow by redirect manually) | |
| * @param $url | |
| * @return array | |
| */ | |
| function getLastHeaderStatus($url) | |
| { | |
| $result = array(); | |
| $header = get_headers( $url, 1 ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function timespan($time1, $time2 = NULL, $output = 'years,months,weeks,days,hours,minutes,seconds') | |
| { | |
| $output = preg_split('/[^a-z]+/', strtolower((string) $output)); | |
| if (empty($output)) | |
| return FALSE; | |
| extract(array_flip($output), EXTR_SKIP); | |
| $time1 = max(0, (int) $time1); | |
| $time2 = empty($time2) ? time() : max(0, (int) $time2); | |
| $timespan = abs($time1 - $time2); | |
| isset($years) and $timespan -= 31556926 * ($years = (int) floor($timespan / 31556926)); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | public function buildQuery($query) | |
| { | |
| $sql=isset($query['distinct']) && $query['distinct'] ? 'SELECT DISTINCT' : 'SELECT'; | |
| $sql.=' '.(isset($query['select']) ? $query['select'] : '*'); | |
| if(isset($query['from'])) | |
| $sql.="\nFROM ".$query['from']; | |
| else | |
| throw new CDbException(Yii::t('yii','The DB query must contain the "from" portion.')); | |