Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php ini_set('display_errors', 1);//ini_set('error_reporting', E_ALL);
- function corl($Ur){$ch = curl_init();curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_VERBOSE, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
- curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0');
- curl_setopt($ch, CURLOPT_URL,$Ur);
- $target_url = curl_exec($ch); curl_close($ch); // تخزين الصفحة في متغير نصي
- return $target_url;}
- // معرفة العناصر المكررة بعد استدعائها في الحلقة
- $f=-1;$inArr= Array();
- function rep($vlu) { global $f,$inArr; // استخدمت قلوبل حتى
- if (in_array($vlu,$inArr)) return true ; // التحقق ادا كان القيمة مكررة ام لا
- else { $inArr[$f++]=$vlu; // ضع القيمة في مصفوفة المقارنة
- return false; }} // ارجاع خطاء ادا القيمة غير مكررة
- $start = microtime( true ) ; function excute() { global $start; $end = microtime( true ) ; $time = number_format( ( $end - $start ), 3 ) ; return $time ; }
- function array_key_filter( $array , $callback) {
- $f = array_filter(array_keys( $array ), $callback);
- return array_intersect_key( $array , array_flip( $f ) ); }
- function video ( $arr ) {
- /* [thumbnail] => https://i.ytimg.com/vi/hZmoMyFXDoI/mqdefault.jpg
- [title] => [MV] BOL4(볼빨간사춘기) _ Some(썸 탈꺼야)
- [title_short] => [MV] BOL4(볼빨간사춘기) _ Some(썸...
- [username] => 1theK (원더케이)
- [profile] => https://www.youtube.com/channel/UCweOkPb1wVVH0Q0Tlj4a5Pw
- [views] => 33511996
- [date] => 28/09/17
- [time] => 00:03:07
- [more] => https://www.youtube.com/watch?v=hZmoMyFXDoI
- [embed_url] => http://www.youtube.com/embed/hZmoMyFXDoI?autoplay=1 */
- //echo '<iframe allowFullScreen="allowFullScreen" src="'. $arr[ 'embed_url' ] .'?ecver=1&iv_load_policy=3&rel=0&showinfo=0&yt:stretch=16:9&autohide=0&color=red&width=560&width=560" width="560" height="315" allowtransparency="true" frameborder="0"></iframe> ' ;
- }
- //j الاسرع لتحميل صفحة parse_url( $domain )['path']
- function sockopen( $domain ) { $contents = NULL ; $i = 0 ;
- $host = parse_url( $domain )['host'] ;
- $url = explode ( $host , $domain )[1] ;
- $fp = @fsockopen( "ssl://$host" , 443 , $errno, $errstr , 3 ) ;
- // echo '<br> fsockopen In '.excute().' Seconds'.'<br/>';
- if( !$fp ) { $contents .= $errstr. ' (' . $errno . ')<br />' ; echo ( $contents ) ; }
- else {
- $out = "GET ". $url." HTTP/1.1\r\n" ;
- $out .= "Host: ".$host."\r\n" ;
- $out .= "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008050509 Firefox/3.0b5\r\n" ;
- //$out .= "Referer: https://www.google.com/\r\n";
- $out .= "Connection: Close\r\n\r\n" ;
- // var_dump ( $out ) ;
- fwrite( $fp , $out ) ; // fwrite fgets exit() ;
- while( !feof( $fp ) ) { // $i++; if ( $i > 2 ) break ;
- $contents .= fread ( $fp , 480 ) ; }
- // $contents = fread ( $fp, 14096 ) ;
- fclose( $fp ) ;
- }
- // echo $i ;
- // return explode ( "Connection: close\r\n\r\n" , $contents )[1] ; // "Connection: close\r\n\r\n"
- return $contents ; // "Connection: close\r\n\r\n"
- }
- function time_elapsed_string( $ptime ) {
- //var_dump(time());
- //var_dump($ptime);
- $etime = time( ) - $ptime;
- //var_dump($etime);
- if ( $etime < 1 ) {
- return '0 seconds';
- }
- $a = array( 12 * 30 * 24 * 60 * 60 => 'year',
- 30 * 24 * 60 * 60 => 'month',
- 24 * 60 * 60 => 'day',
- 60 * 60 => 'hour',
- 60 => 'minute',
- 1 => 'second'
- ) ;
- foreach ( $a as $secs => $str ) {
- $d = $etime / $secs;
- //var_dump($d);
- if ( $d >= 1 ) {
- $r = round( $d );
- return $r . ' ' . $str . ( $r > 1 ? 's' : '' ) . ' ago';
- }
- }
- }
- ///////////////////////////////////////////
- /**
- * @param $timestampl
- * @param $timestamp2
- * @param $time_unit
- * @return bool|float
- */
- function time_difference($timestampl, $timestamp2, $time_unit)
- {
- // determine the difference between two dates
- $timestampl = intval($timestampl);
- $timestamp2 = intval($timestamp2);
- if ($timestampl && $timestamp2)
- {
- $time_lapse = $timestamp2 - $timestampl;
- $seconds_in_unit = array(
- "second" => 1,
- "minute" => 60,
- "hour" => 3600,
- "day" => 86400,
- "week" => 604800,
- );
- if ($seconds_in_unit[$time_unit])
- return round($time_lapse/$seconds_in_unit[$time_unit]);
- }
- return false;
- }
- /**
- * Outputting formatted date-time
- * @param $date_time
- * @return string
- */
- function date_time_out($date_time)
- {
- $current_time = time();
- $time_diff = time_difference($date_time, $current_time, 'minute');
- $date_diff = time_difference($date_time, $current_time, 'day');
- $result = '';
- if ($time_diff < 60) return $time_diff . ' minute' . ($time_diff==1)?'':'es' . ' ago';
- else if ($time_diff >= 60 AND $date_diff == 0) $result.= 'Today';
- else if ($date_diff == 1) $result.= 'Yesterday';
- else $result.= date("Y-m-d", $date_time);
- $result.= ' at '. date('H:i', $date_time);
- return $result;
- }
- /**
- * Outputting text with limited words count
- * @param $text
- * @param $words_count
- * @return string
- */
- function short_text_out($text, $words_count) {
- $arr = explode(' ', $text);
- $count_arr = count($arr);
- $arr = array_slice($arr, 0, $words_count);
- $text = implode(' ', $arr);
- if ($count_arr > $words_count) $text.= '...';
- unset($arr);
- unset($count_arr);
- return strip_tags($text);
- }
- /**
- * Return the youtube video duration
- * @param $youtube_time
- * @return time
- */
- function covtime($youtube_time){
- $start = new DateTime('@0'); // Unix epoch
- $start->add(new DateInterval($youtube_time));
- return $start->format('H:i:s');
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement