Advertisement
Guest User

Untitled

a guest
Mar 17th, 2021
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.38 KB | None | 0 0
  1. <?php
  2. function dumpComments($comments, $view = 'video.comment') {
  3.     $commentList = '';
  4.     $user=\Session::get('User');
  5.     foreach ($comments as $comment) {
  6.  
  7.         $commentList .= view($view)->with('result', $comment)->with('user',$user)->render();
  8.     }
  9.  
  10.     echo $commentList;
  11. }
  12. /**
  13.  * truncate a string after n words
  14.  * @param string $text
  15.  * @param int $limit limit word
  16.  * @return string
  17.  */
  18. function truncate($text, $limit){
  19.     $text = strip_tags($text);
  20.     if (str_word_count($text, 0) > $limit) {
  21.         $words = str_word_count($text, 2);
  22.         $pos = array_keys($words);
  23.         $text = substr($text, 0, $pos[$limit]) . '...';
  24.     }
  25.     return $text;
  26. }
  27.  
  28. function sec2hms ($sec, $padHours = false)
  29.      {
  30.         $hms = "";
  31.         $hours = intval(intval($sec) / 3600);
  32.         if($hours > 0){
  33.           $hms .= ($padHours)? str_pad($hours, 2, "0", STR_PAD_LEFT). ':': $hours. ':';  
  34.         }
  35.         $minutes = intval(($sec / 60) % 60);
  36.         $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
  37.         $seconds = intval($sec % 60);
  38.         $hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
  39.         return $hms;
  40.     }
  41. function convert_time($time="00:00:00"){
  42.   $time_array=explode(':', $time);
  43.   // var_dump($time_array);die;
  44.   $timer=0;
  45.   $hours=$minutes=$seconds=0;
  46.   if(count($time_array)==3){
  47.     // die('dsd')/;
  48.     $hours=intval($time_array[0])*3600;
  49.     $minutes=intval($time_array[1])*60;
  50.     $seconds=intval($time_array[2]);
  51.     return $timer=$hours+$minutes+$seconds;
  52.   }else{
  53.     $minutes=intval($time_array[0])*60;
  54.     $seconds=intval($time_array[1]);
  55.     return $timer=$hours+$minutes+$seconds;
  56.   }
  57. }
  58.  
  59. function get_title_datetime() {
  60.     $date = new Datetime();
  61.     $format = $date->format('l, F dS, Y');
  62.     return "Videos Uploaded On " . $format;
  63. }
  64.  
  65. function getAvailableAppLangArray()
  66. {
  67.   $locales[''] = Lang::get('app.select_your_language');
  68.  
  69.   foreach (Config::get('app.locales') as $key => $value)
  70.   {
  71.     $locales[$key] = $value;
  72.   }
  73.  
  74.   return $locales;
  75. }
  76. function get_categories_list($cat_array){
  77.   $cat=explode(',',$cat_array);
  78.     $cat_list=array();
  79.     for ($i=0; $i <count($cat) ; $i++) {
  80.         $catID=explode("_",$cat[$i]);
  81.         array_push($cat_list,end($catID));
  82.     }
  83.   echo implode(",", $cat_list);
  84. }
  85.  
  86. function get_categories_list_link($cat_array){
  87.   $cat=explode(',',$cat_array);
  88.     $cat_list=array();
  89.     for ($i=0; $i <count($cat) ; $i++) {
  90.         $catID=explode("_",$cat[$i]);
  91.         $cat_name= \App\Models\CategoriesModel::find($catID[0]);
  92.         if($cat_name!=NULL){
  93.           $html='<a class="tag" href="'.URL('categories').'/'.$cat_name->ID.'.'.$cat_name->post_name.'.html">'.$cat_name->title_name.'</a>';
  94.           array_push($cat_list, $html);
  95.         }
  96.        
  97.     }
  98.  
  99.   return  implode(',',$cat_list);
  100.  
  101. }
  102.   function cat_form_array($cat_array){
  103.     $cat_post= explode(',', $cat_array);
  104.     $cat_list=array();
  105.     for ($i=0; $i <count($cat_post) ; $i++) {
  106.         $catID=explode("_", $cat_post[$i]);
  107.         array_push($cat_list, $catID[0]);
  108.     }
  109.     return implode(',',$cat_list);
  110. }
  111. function cat_array($cat_array){
  112.     $cat_post= explode(',', $cat_array);
  113.     $cat_list=array();
  114.     for ($i=0; $i <count($cat_post) ; $i++) {
  115.         $catID=explode("_", $cat_post[$i]);
  116.         array_push($cat_list, $catID[0]);
  117.     }
  118.     return $cat_list;
  119. }
  120. function cat_array_name($cat_array){
  121.     $cat_post= explode(',', $cat_array);
  122.     $cat_list=array();
  123.     for ($i=0; $i <count($cat_post) ; $i++) {
  124.         $catID=explode("_", $cat_post[$i]);
  125.         array_push($cat_list, $catID[1]);
  126.     }
  127.     return implode(',',$cat_list);
  128. }
  129. function get_cat_video_id($id,$video_list){
  130.   $temp=array();
  131.     $tempvideoID=array();
  132.     for ($i=0; $i <count($video_list); $i++) {
  133.       array_push($temp,$video_list[$i]->string_Id."_".$video_list[$i]->cat_id);
  134.     }
  135.     for ($i=0; $i <count($temp) ; $i++) {
  136.       $videoID=explode('_', $temp[$i]);
  137.       $cat_id=$videoID[1];
  138.       $cat_array=explode(',',$cat_id);
  139.       if(in_array($id,$cat_array)){
  140.         array_push($tempvideoID,$videoID[0]);
  141.       }
  142.     }
  143.     return $tempvideoID;
  144. }
  145. function get_video_form_cat($id){
  146.     $video_id=array();
  147.     $get_video_id= \App\Models\VideoCatModel::where('cat_id','=',$id)->get();
  148.     for ($i=0; $i <count($get_video_id) ; $i++) {
  149.         array_push($video_id,$get_video_id[$i]->video_id);
  150.     }
  151.     $video_array=\App\Models\VideoModel::where('status','=',1)
  152.                                         ->whereIn('string_Id',$video_id)
  153.                                         ->take(4)
  154.                                         ->OrderbyRaw('RAND()')
  155.                                         ->get();
  156.     return $video_array;
  157. }
  158. function count_video_in_cat($id){
  159.    $count= \App\Models\VideoCatModel::select('video_cat.video_id')->where('video_cat.cat_id','=',$id)->count();
  160.    if($count==1 or $count==0){
  161.     return $count." Video";
  162.    }else{
  163.     return $count." Videos";
  164.    }
  165. }
  166. function count_video_in_channel($id){
  167.    $count= \App\Models\VideoModel::where('channel_Id','=',$id)->count();
  168.    if($count==1 or $count==0){
  169.     return $count." Video";
  170.    }else{
  171.     return $count." Videos";
  172.    }
  173. }
  174. function get_client_ip() {
  175.          // check for shared internet/ISP IP
  176.     if (!empty($_SERVER['HTTP_CLIENT_IP']) && validate_ip($_SERVER['HTTP_CLIENT_IP'])) {
  177.         return $_SERVER['HTTP_CLIENT_IP'];
  178.     }
  179.  
  180.     // check for IPs passing through proxies
  181.     if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  182.         // check if multiple ips exist in var
  183.         if (strpos($_SERVER['HTTP_X_FORWARDED_FOR'], ',') !== false) {
  184.             $iplist = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
  185.             foreach ($iplist as $ip) {
  186.                 if (validate_ip($ip))
  187.                     return $ip;
  188.             }
  189.         } else {
  190.             if (validate_ip($_SERVER['HTTP_X_FORWARDED_FOR']))
  191.                 return $_SERVER['HTTP_X_FORWARDED_FOR'];
  192.         }
  193.     }
  194.     if (!empty($_SERVER['HTTP_X_FORWARDED']) && validate_ip($_SERVER['HTTP_X_FORWARDED']))
  195.         return $_SERVER['HTTP_X_FORWARDED'];
  196.     if (!empty($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']) && validate_ip($_SERVER['HTTP_X_CLUSTER_CLIENT_IP']))
  197.         return $_SERVER['HTTP_X_CLUSTER_CLIENT_IP'];
  198.     if (!empty($_SERVER['HTTP_FORWARDED_FOR']) && validate_ip($_SERVER['HTTP_FORWARDED_FOR']))
  199.         return $_SERVER['HTTP_FORWARDED_FOR'];
  200.     if (!empty($_SERVER['HTTP_FORWARDED']) && validate_ip($_SERVER['HTTP_FORWARDED']))
  201.         return $_SERVER['HTTP_FORWARDED'];
  202.  
  203.     // return unreliable ip since all else failed
  204.     return $_SERVER['REMOTE_ADDR'];
  205. }
  206. function pornhub_param_url_time_start(){
  207.   $start=date('Y-m-d H:i:s');
  208.   return strtotime($start);
  209. }
  210. function pornhub_param_url_time_end(){
  211.   $end=strtotime('+2 hours',pornhub_param_url_time_start());
  212.   return $end;
  213. }
  214.  
  215. function get_categories(){
  216.   $categories = \App\Models\CategoriesModel::where('status','=',1)->orderby('title_name','asc')->get();
  217.   return $categories;
  218. }
  219.  
  220. function StandardAdHome(){
  221.   $data= \App\Models\StandardAdsModel::get_standard_home();
  222.   return $data;
  223. }
  224. function StandardAdFooter(){
  225.   $data= \App\Models\StandardAdsModel::get_standard_footer();
  226.   return $data;
  227. }
  228. function StandardAdTopRate(){
  229.   $data= \App\Models\StandardAdsModel::get_standard_toprate();
  230.   return $data;
  231. }
  232. function StandardAdMostView(){
  233.   $data= \App\Models\StandardAdsModel::get_standard_mostview();
  234.   return $data;
  235. }
  236. function StandardAdVideo(){
  237.   $data= \App\Models\StandardAdsModel::get_standard_video();
  238.   return $data;
  239. }
  240. function StandardAdPornstar(){
  241.   $data = \App\Models\StandardAdsModel::get_standard_pornstar();
  242.   return $data;
  243. }
  244. function GetVideoConfig(){
  245.   $setting = \App\Models\VideoSettingModel::get_config();
  246.   return $setting;
  247. }
  248. function GetSiteConfig(){
  249.   $setting = \App\Models\OptionModel::get_config();
  250.   return $setting;
  251. }
  252. function GetPlayerAds(){
  253.   $video_ads = \App\Models\VideoAdsModel::get_ads_video();
  254.   return $video_ads;
  255. }
  256. function GetRatingVideo($videoID){
  257.   $rating = \App\Models\RatingModel::get_percent($videoID);
  258.   return $rating;
  259. }
  260. function CheckWatchingVideo(){
  261.   $checkwatching = \App\Models\WatchNowModel::check_watch();
  262.   return $checkwatching;
  263. }
  264. function CheckBanIP(){
  265.   $IPadress = \App\Models\BanIPModel::get_list_ban();
  266.   return $IPadress;
  267. }
  268. function GetPaymentConfig(){
  269.   $config = \App\Models\PaymentConfigModel::get_payment_config();
  270.   return $config;
  271. }
  272. function GetStaticPage($id){
  273.   $staticpage= \App\Models\StaticPageModel::show_link($id);
  274.   return $staticpage;
  275. }
  276. function GetHeaderNews(){
  277.   $sticknews= \App\Models\HeaderModel::get_list_link();
  278.   return $sticknews;
  279. }
  280. function is_404($url) {
  281.     $handle = curl_init($url);
  282.     curl_setopt($handle,  CURLOPT_RETURNTRANSFER, TRUE);
  283.  
  284.     /* Get the HTML or whatever is linked in $url. */
  285.     $response = curl_exec($handle);
  286.  
  287.     /* Check for 404 (file not found). */
  288.     $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
  289.     curl_close($handle);
  290.  
  291.     /* If the document has loaded successfully without any redirection or error */
  292.     if ($httpCode >= 200 && $httpCode < 300) {
  293.         return false;
  294.     } else {
  295.         return true;
  296.     }
  297. }
  298. function CountMessageMember($form){
  299.   $c_message= App\Models\MemberMessageModel::where('frommember','=',$form)->count();
  300.   return $c_message;
  301. }
  302. function GetAllMessage($form){
  303.   $allmessage= \App\Models\MemberMessageModel::select('members.firstname','members.lastname','member_message.*')
  304.                                             ->where('member_message.frommember','=',$form)
  305.                                             //->where('member_message.tomember','=',$frommember)
  306.                                             ->join('members','members.user_id','=','member_message.frommember')
  307.                                             ->get();
  308.     return $allmessage;
  309. }
  310. function GetMemberName($uID){
  311.   $member_name= \App\Models\MemberModel::where('user_ID','=',$uID)->first();
  312.   return $member_name;
  313. }
  314. function CheckUserPayment($userID,$videoID){
  315.   $checkUse= \App\Models\SubsriptionModel::check_user_buy_video($userID,$videoID);
  316.   return $checkUse;
  317. }
  318.  
  319. //get link server http://www.4tube.com/
  320.  
  321. function ResetURLVideo($url,$host){
  322.  
  323.   $call_c= new App\Http\Controllers\admincp\DownloaderController();
  324.  $data= $call_c->get_info_video($url,$host);
  325.   return $data;
  326. }
  327. function GetPath() {
  328.   return "";
  329. }
  330.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement