<?php use App\Helpers\ElasticSearch as elastic; use App\Http\Controllers\AjaxController; use App\Models\Rajneeti\Follower; use App\Models\SpiderCMS\Banner; use App\Models\SpiderCMS\Category; use App\Models\SpiderCMS\ContentPriority; use App\Models\SpiderCMS\Location; use App\Models\SpiderCMS\Menus; use App\Models\SpiderCMS\Page; use App\Models\SpiderCMS\Section; use App\Models\SpiderCMS\Seo; use App\Models\SpiderCMS\Slug; use App\Models\SpiderCMS\Story; use App\Models\SpiderCMS\StoryAnalytics; use App\Models\SpiderCMS\User; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Redis; use Illuminate\Support\Str; use Jenssegers\Date\Date; use Lullabot\AMP\AMP; use predictionio\EngineClient; use App\Http\Controllers\WidgetController as SSO; use App\Models\Rajneeti\UserProfile; //use Lullabot\AMP\Validate\Scope; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //$elastic = false; // Breadcrumbs function home_bread_crumb(){ return ['slug' => '', 'title' => 'Hindi News', 'title_hn' => ' 9 ?  & @ 8 . >  > 0']; } function getRequestType() { $requestFormat = 'normal'; $is_ajax = Illuminate\Support\Facades\Request::ajax(); if ($is_ajax) $requestFormat = "ajax"; return $requestFormat; } /* function hindi_date($value) { Date::setLocale('hi'); //dd($value); $obj = new Carbon; $date = $obj->parse($value); //$value->toDateTime(); //dd( $d); $date = $date->format('Y-m-d H:i:s'); //dd($date); $cdate = new Date($date); $formatedDate = $cdate->format('j F Y'); //$formatedDate = $cdate->format('l, j F Y'); //$formatedDate = str_replace('  A 0 B 5 > 0', '  A 0 A 5 > 0', $formatedDate); //$date1 = $date = new Date('2000-01-31'); //dd($formatedDate); return $formatedDate; }*/ function hindi_date($value) { Date::setLocale('hi'); $formatedDate = date('j F Y', strtotime($value)); return $formatedDate; } function hindi_date_day($value) { Date::setLocale('hi'); $obj = new Carbon; $date = $obj->parse($value); //$value->toDateTime(); $date = $date->format('Y-m-d H:i:s'); $cdate = new Date($date); $formatedDate = $cdate->format(' l, j F Y'); return $formatedDate; } function hindi_date_time($value) { Date::setLocale('hi'); $obj = new Carbon; $date = $obj->parse($value); //$value->toDateTime(); $date = $date->format('Y-m-d H:i:s'); $cdate = new Date($date); $formatedDate = $cdate->format(' H:i l, j F Y'); return $formatedDate; } function hindi_date_without_day($value) { Date::setLocale('hi'); $obj = new Carbon; $date = $obj->parse($value); //$value->toDateTime(); $date = $date->format('Y-m-d H:i:s'); $cdate = new Date($date); $formatedDate = $cdate->format('j F Y H:i'); return $formatedDate; } function get_class_name_for_view($index, $chunk_number) { $class = ['fst left', 'left', 'right hide']; if ($index < 0 || $chunk_number < 1) { return false; } $index++; $result = $index % $chunk_number; return $result ? $class[--$result] : $class[--$chunk_number]; } /** * @author Awanish Singh <awanish.singh@auw.co.in> * @param type $array * @return type returns only array of id for wherein ids */ function getIdsArray($array) { $ids_arr = array(); //dd(count($array)); if (is_array($array)) { foreach ($array as $item) { //dd($item); $ids_arr[] = $item['_id']; } //$category_ids_str = rtrim($category_ids_str, ","); } return $ids_arr; } function getStoryIdsArray($array) { $ids_arr = array(); //dd(count($array)); if (is_array($array)) { foreach ($array as $item) { //dd($item); $ids_arr[] = $item['story_id']; } //$category_ids_str = rtrim($category_ids_str, ","); } return $ids_arr; } function checkLogin() { if (!empty($_COOKIE['ssoId'])) { return true; } else { return false; } } function popolateMenu($menu_slug = null, $count = 50) { $menu_item_list = array(); if ( empty( $menu_slug ) ) { return $menu_item_list; } // $menu_list = Menus::getMenuList(); $menu_list = Menus::getMenusBySlug($menu_slug); if (!empty($menu_list)) { $menu_item_list = isset($menu_list['items']) ? $menu_list['items'] : null; if (count($menu_item_list) >= $count) { $menu_item_list = array_slice($menu_item_list, 0, $count); } } $items = []; if (isset($menu_item_list) && is_array($menu_item_list)) { foreach ($menu_item_list as $item) { if (isset($item['status']) && $item['status'] == 'enable') { $items[] = $item; } } } //foreach ($menu_list as $item) { //$menu_item_list = getItemListByMenusId($menu_list[0]['_id']); //} return $items; } //function getTrendingNow() { // // $trending_item_list = array(); // $trending_list = Menus::getMenusBySlug('trending-now'); // //dd($trending_list); // if (!empty($trending_list)) { // $trending_item_list = isset($trending_list['items']) ? $trending_list['items'] : null; // if (count($trending_item_list) > 5) { // $trending_item_list = array_slice($trending_item_list, 0, 5); // } // } // return $trending_item_list; //} //function getFirkeeStories() { // // $firkee_item_list = array(); // $firkee_list = Menus::getMenusBySlug('home-firkee-stories'); // //dd($trending_list); // if (!empty($firkee_list)) { // $firkee_item_list = isset($firkee_list['items']) ? $firkee_list['items'] : null; // if (count($firkee_item_list) > 2) { // $firkee_item_list = array_slice($firkee_item_list, 0, 2); // } // } // return $firkee_item_list; //} function getItemListByMenusId($menu_id) { $menu_item = Menus::getItemListByMenusId($menu_id); return $menu_item['items']; } function getLiveTvCountDown(Request $request, $menu_slug = 'live-tv-next-show') { $options['time'] = $request->input('time', null); // only for skip cache each second $menu_item = Menus::getMenusBySlug($menu_slug, false, $options); $menu_item = is_object($menu_item) ? $menu_item->toArray() : $menu_item; $return = ''; foreach ($menu_item['items'] as $item) { if (strtotime($item['link']) > time()) { $return = []; $return['titles'] = $item['titles']; $return['deadline'] = strtotime($item['link']); $return['start'] = time(); break; } } return $return; } function getMostViewedStory($menu_id) { $mv_stories = ''; return $mv_stories; } function getContentPriorityStoriesBySectionId($id, $count = 40, $options = [], $memcache_time = true,$is_premium=false) { $result = array(); //dd($options); $memcache = getMemcacheKey(func_get_args(), __METHOD__, $memcache_time); if (isset($memcache['data']) && !empty($memcache['data'])) { //dd('memcache'); //return $memcache['data']; return is_array($memcache['data']) ? collect($memcache['data']) : $memcache['data']; } $priority_stories = ContentPriority::getCPListBySectionId($id); // if($id=='56ab24c81126f4773e8b4567') $story_ids=[]; if(!empty($priority_stories[0]) && isset($priority_stories[0]['created_at']) && strtotime("+".config('env.SECTION_CONTENT_PRIORITY_TIME')." minutes",strtotime($priority_stories[0]['created_at'])) > strtotime("now")){ $story_ids = getStoryIdsArray($priority_stories); } //$priority_stories_count = count($story_ids); $stories = array(); $extra_stories = array(); foreach ($story_ids as $story_id) { $story_detail = Story::getStoryById($story_id, 'publish'); if (!empty($story_detail)) { $stories[] = Story::getStoryById($story_id, 'publish'); } } //dd(collect($stories)->toArray()); $priority_stories_count = count($stories); $notIn = []; $stories = collect($stories); if (!isset($options['is_muted']) || (isset($options['is_muted']) && $options['is_muted'] == false)) { if ($priority_stories_count < $count) { $extra_stories_count = $count - $priority_stories_count; $not_in_array = is_object($stories) ? $stories->toArray() : $notIn; if($is_premium===true){ $option['is_premium']=true; } $notIn = is_array($not_in_array) ? array_column($not_in_array, 'slug') : false; //dd($options); $notIn = $notIn ? ['slug' => $notIn] : false; if (isset($options['location_slug'])) { $option['not_in'] = $notIn; //this remove currently not need in excludes videos //$option['excludes'] = ['type' => 'video']; $cat_slug = isset($options['cat_slug']) ? $options['cat_slug'] : null; $loc_slug = isset($options['location_slug']) ? $options['location_slug'] : null; $location_id = isset($options['location_id']) ? $options['location_id'] : null; $story_type = isset($options['story_type']) ? $options['story_type'] : null; if (!empty($location_id)) { //dd($location_id); $extra_stories = Story::getStoryListByLocationId($cat_slug, $location_id, $story_type, 0, $extra_stories_count, 'updated_at', 'DESC', $option); } else { $extra_stories = Story::getStoryListByLocationSlug($cat_slug, $loc_slug, $story_type, 0, $extra_stories_count, 'updated_at', 'DESC', $option); } //dd($extra_stories); } else { if (isset($options['type']) && !empty($options['type'])) { $extra_stories = getStoriesBySectionId($id, $extra_stories_count, $notIn, $options['type'],$is_premium); } else { $extra_stories = getStoriesBySectionId($id, $extra_stories_count, $notIn,null,$is_premium); } } //dd($extra_stories->toArray()); } $result = $stories->merge($extra_stories); } else { $result = $stories; } $result = $result->slice(0, $count); // if($id=='56ab24c81126f4773e8b4567') // dd($result); if (is_object($result)) { $result->toArray(); } if (isset($memcache['key']) && !empty($result)) { putDataMemcached($memcache['key'], $result); } return is_array($result) ? collect($result) : $result; } function getStoriesBySectionId($section_id, $count = 10, $notIn = [], $type = null,$is_premium = false) { $memcache = getMemcacheKey(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } $story_result = []; $section_details = Section::getSectionById($section_id); $section_details = is_object($section_details)?$section_details->toArray():$section_details; $categories=$search =$cat=$options= []; if(!empty($section_details[0])){ $categories = !empty($section_details[0]['categories'])?$section_details[0]['categories']:[]; $cat = getIdsArray($categories); $type = !empty($section_details[0]['story_type'])?$section_details[0]['story_type']:$type; } //fetch child category form parent if(count($cat) == 1) { $tmp_cat_ids=Category::getCategoriesByParentId($cat[0]); if(count($tmp_cat_ids)>1){ $cat=[$cat[0]]; // include parent id $cat=array_merge($cat,array_column($tmp_cat_ids,'_id')); } } //if multiple categories then use (in query) for performance if(count($cat) > 1) { $search['cats_in'] = $cat; }elseif(!empty($cat[0])){ $search['cat'] = $cat[0]; } if(!empty($type)){ $options['type'] = $type; } if($is_premium===true){ $options['is_premium']=true; } $story_result = Story::storyList($sort_by = 'updated_at', $sort_dir = 'desc', $search, 'publish', $notIn, $options)->take($count)->get(); if (isset($memcache['key']) && !empty($story_result)) { putDataMemcached($memcache['key'], $story_result); } return $story_result; } function getBreakingNewsBySlug($slug) { $breaking_news_list = Section::getSectionListBySlug($slug); return $breaking_news_list; } /** * * @param type $url related path of image uri such as 2015/12/12/.... * @param type $size in which image required such as 590x330 * @return string image full url */ /* old function.. function getImageUrl($url, $size, $optional = false, $skip_old_image_check=false) { $return = '/default_500.png'; /// bypass $url is valid url then no need to parse it if (!filter_var($url, FILTER_VALIDATE_URL) === false) { return $url; } // code used for reutrn default city image if image not found if (empty($url) && !empty($optional)) { $url = $optional; } /// end city code if (empty($url)) { $url = $return; } $url = str_replace("http://img.amarujala.com", "", $url); //when new migration completed it should remove $imgSizes = ['950x440' => '_landscape_', '990x572' => '_landscape_', '590x330' => '_landscape_', '336x200' => '_landscape_', '250x250' => '_square_', '150x150' => '_square_', '50x50' => '_thumb_', '900x800' => '_landscape_', '990x460' => '_landscape_', '108x108' => '_square_', '500x500' => '_square_', '590x274' => '_landscape_', '337x156' => '_landscape_', 'original' => '_','portrait'=>'_portrait_']; $new_image_sizes = ['750x506'=>'_','360x243'=>'_','262x177'=>'_','110x74'=>'_']; // code for manage old images if (array_key_exists(strtolower($size), $imgSizes)) { $uriData = array_reverse(explode('/', $url)); if (count($uriData) >= 3) { $ugc= (strpos($url, '/ugc/')=== false)?false:true; if ($ugc==true ||(!$skip_old_image_check && strtotime(config('env.DATE_OLD_IMG')) > strtotime($uriData[3] . '-' . $uriData[2] . '-' . $uriData[1]))) { $return = config('env.CACHE_IMAGE_PATH') . $size . $url; } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); if ($size == 'original') { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev($url), 1)); } if ($size == 'portrait') { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev(str_replace('_','_portrait_',$url)), 1)); } } } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); } }elseif(array_key_exists(strtolower($size), $new_image_sizes)) { $uriData = array_reverse(explode('/', $url)); if(count($uriData) >= 3) { if(!$skip_old_image_check && strtotime(config('env.DATE_OLD_CROP_IMG','2017-12-26')) > strtotime($uriData[3] . '-' . $uriData[2] . '-' . $uriData[1])){ $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev($url), 1)); } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); } } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); } } else { $return = config('env.CACHE_IMAGE_PATH') . $size . '/default_500.png'; } return $return; } */ function getImageUrl($url, $size, $optional = false, $skip_old_image_check = false) { if(!$url && str_contains(url()->current(), 'kavya') ){ $return = ""; if($size == '500x500'){ $return = '/2021/02/16/500x500_602b9e6974c84.jpg'; }else if($size == '250x250'){ $return = '/2021/02/16/250x250_602b9b3663447.jpg'; }else if($size == '360x243'){ $return = '/2021/02/16/360x243_602b9e9073c88.jpg'; }else if($size == 'original'){ $return = '/2021/02/16/250x250_602b9b3663447.jpg'; }else{ $explodeSize = explode('x',$size); return rtrim(config('env.IMAGE_URL'),'/').'/cdn-cgi/image/width='.$explodeSize[0].',height='.$explodeSize[0].'/assets/images/2021/02/16/500x500_602b9e6974c84.jpg'; } if($return){ return config('env.CACHE_IMAGE_PATH_STATIC').$return; } }else{ $return = '/default_500.png'; } /// bypass $url is valid url then no need to parse it if (!filter_var($url, FILTER_VALIDATE_URL) === false) { return $url; } // code used for reutrn default city image if image not found if (empty($url) && !empty($optional)) { $url = $optional; } /// end city code if (empty($url)) { $url = $return; } $url = str_replace("http://img.amarujala.com", "", $url); //when new migration completed it should remove $imgSizes = ['950x440' => '_landscape_', '990x572' => '_landscape_', '590x330' => '_landscape_', '336x200' => '_landscape_', '250x250' => '_square_', '150x150' => '_square_', '50x50' => '_thumb_', '900x800' => '_landscape_', '990x460' => '_landscape_', '108x108' => '_square_', '500x500' => '_square_', '590x274' => '_landscape_', '337x156' => '_landscape_', 'original' => '_', 'portrait' => '_portrait_']; $new_image_sizes = ['750x506' => '_', '360x243' => '_', '262x177' => '_', '110x74' => '_', '300x300' => 'square','1x1'=>'square']; // Array to map old images to new images, because we stopped cropping old sizes $old_to_new = [ '990x460' => '750x506', '590x274' => '360x243', '337x156' => '360x243','108x108'=>'150x150','50x50'=>'150x150', '92x65'=>'110x74','167x124'=>'110x74','500x750'=>'500x500','320x480'=>'300x300']; // code for manage old images if (array_key_exists(strtolower($size), $imgSizes)) { $uriData = array_reverse(explode('/', $url)); $uriData_year = isset($uriData[3]) ? $uriData[3] : null; $uriData_month = isset($uriData[2]) ? $uriData[2] : null; $uriData_date = isset($uriData[1]) ? $uriData[1] : null; if (count($uriData) >= 3) { $ugc = (strpos($url, '/ugc/') === false) ? false : true; if ($ugc == true || (!$skip_old_image_check && strtotime(config('env.DATE_OLD_IMG')) > strtotime($uriData_year . '-' . $uriData_month . '-' . $uriData_date))) { $return = config('env.CACHE_IMAGE_PATH') . $size . $url; } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); if ($size == 'original') { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev($url), 1)); } if ($size == 'portrait') { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev(str_replace('_', '_portrait_', $url)), 1)); } if(array_key_exists(strtolower($size), $old_to_new)) { $return = str_replace($size, $old_to_new[$size], $return); } } } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); if(array_key_exists(strtolower($size), $old_to_new)) { $return = str_replace($size, $old_to_new[$size], $return); } } } elseif (array_key_exists(strtolower($size), $new_image_sizes)) { $uriData = array_reverse(explode('/', $url)); $uriData_year = isset($uriData[3]) ? $uriData[3] : null; $uriData_month = isset($uriData[2]) ? $uriData[2] : null; $uriData_date = isset($uriData[1]) ? $uriData[1] : null; if (count($uriData) >= 3) { if (!$skip_old_image_check && strtotime(config('env.DATE_OLD_CROP_IMG', '2017-12-26')) > strtotime($uriData_year . '-' . $uriData_month . '-' . $uriData_date)) { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/'), strrev($url), 1)); } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); } } else { $return = config('env.CACHE_IMAGE_PATH_STATIC') . strrev(preg_replace(strrev("//\/"), strrev('/' . $size . '/'), strrev($url), 1)); } } else { $return = config('env.CACHE_IMAGE_PATH') . $size . '/default_500.png'; } return $return; } function getCdnCgiImage($url, $size) { if(empty($url)){ return $url; } $size = strtolower($size); $size_array = explode('x', $size); $weight = !empty($size_array[0]) ? $size_array[0] : ''; $height = !empty($size_array[1]) ? $size_array[1] : ''; $image_url = str_replace('/assets/images/','/cdn-cgi/image/width='.$weight.',height='.$height.',fit=cover,f=auto/assets/images/', $url); return $image_url; } function getUserImage($url) { $default = "//sso.amarujala.com/images/photo.jpg"; if (isset($url) && !empty($url)) { return $url; } else { return $default; } } function shiftArray($array, $count = 0) { if ($count > 0) { if (is_array($array)) { while ($count--) { array_shift($array); } } } return $array; } function curlSSORequest($url, $post = null, $is_raw = false) { $memcache = getMemcacheKey(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } $result = array(); if ($is_raw) { //$post = http_build_query($post); } $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:application/json', 'clientkey:' . config('env.SSO_CLIENT_KEY'),'secret: ' . config("env.SSO_Secret_key"))); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); $response = curl_exec($ch); curl_close($ch); $response1 = json_decode($response, true); if (isset($response1['status']) && $response1['status'] == 'true') { $result = $response1; } else { \Illuminate\Support\Facades\Log::info("curlRequestURl " . $url); $result = array(); } if (isset($memcache['key']) && !empty($result)) { putDataMemcached($memcache['key'], $result); } return $result; } /** * * @param type $url * @param type $post this parameter will be null for get request * @return type */ function makeSSORequest($url, $post = null, $auth = false,$myjyotish_property = false) { $memcache = getMemcacheKey(func_get_args(), __METHOD__,true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } if(!empty($myjyotish_property) && $myjyotish_property == true){ $sso_property_id = config('env.MYJYOTISH_SSO_PROPERTY_ID'); }else{ $sso_property_id = config('env.SSO_PROPERTY_ID'); } $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept:application/json', 'clientkey:' . config('env.SSO_CLIENT_ID'), 'propertykey:' . $sso_property_id)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if (!empty($auth)) { curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: ' . $auth]); } curl_setopt($ch, CURLOPT_TIMEOUT, 2); // curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); if ($post !== null) { curl_setopt($ch, CURLOPT_POSTFIELDS, $post); } $response = curl_exec($ch); if ($response !== false) { $result = json_decode($response, true); } else { \Illuminate\Support\Facades\Log::info("curlRequest " . curl_error($ch) . " curlRequestURl " . $url); $result = array(); } curl_close($ch); if (isset($memcache['key']) && !empty($result)) { putDataMemcached($memcache['key'], $result); } return $result; } function getParamString($param) { $str_array = []; foreach ($param as $key => $value) { $str_array[] = $key . "=" . $value; } $string = "?" . implode('&', $str_array); return $string; } function curlRequest($url, $post = null, $cache = true) { $result = array(); $memcache = getMemcacheKey(func_get_args(), __METHOD__, $cache); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 2); curl_setopt($ch, CURLOPT_ENCODING, 'gzip'); if (!empty($post)) { curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); } $response = curl_exec($ch); if ($response !== false) { $result = json_decode($response, true); if (isset($memcache['key']) && !empty($result)) { putDataMemcached($memcache['key'], $result); } } else { \Illuminate\Support\Facades\Log::info("curlRequest " . curl_error($ch) . " curlRequestURl " . $url); $result = array(); } curl_close($ch); return $result; } function ssoDataValue($story) { $sso_attr = array(); $sso_attr["_id"] = isset($story["_id"]) ? $story["_id"] : ''; $sso_attr["slug"] = isset($story["slug"]) ? $story["slug"] : ''; $sso_attr["type"] = isset($story["type"]) ? $story["type"] : 'story'; $sso_attr["status"] = isset($story["status"]) ? $story["status"] : 'publish'; $sso_attr["title_hn"] = isset($story["title_hn"]) ? $story["title_hn"] : $story["title"]; //$sso_attr["emoticon"] = $story["emoticon"]; if (isset($story["category"]["title"]) && !empty($story["category"]["title"])) { $sso_attr["category"]["title"] = $story["category"]["title"]; } if (isset($story["category"]["title_hn"])) { $sso_attr["category"]["title_hn"] = $story["category"]["title_hn"]; } if (isset($story["category"]["slug"])) { $sso_attr["category"]["slug"] = $story["category"]["slug"]; } $sso_data = json_encode($sso_attr, true); return $sso_data; $sso_data = json_encode($story, true); return $sso_data; } function ssoDataValueV1($story) { $sso_attr = array(); $sso_attr["_id"] = isset($story["_id"]) ? $story["_id"] : ''; $sso_attr["slug"] = isset($story["slug"]) ? $story["slug"] : ''; $sso_attr["type"] = isset($story["type"]) ? $story["type"] : 'story'; $sso_attr["status"] = isset($story["status"]) ? $story["status"] : 'publish'; $sso_attr["title_hn"] = isset($story["title_hn"]) ? $story["title_hn"] : $story["title"]; //$sso_attr["emoticon"] = $story["emoticon"]; if (isset($story["category"]["title"]) && !empty($story["category"]["title"])) { $sso_attr["category"]["title"] = $story["category"]["title"]; } if (isset($story["category"]["title_hn"])) { $sso_attr["category"]["title_hn"] = $story["category"]["title_hn"]; } if (isset($story["category"]["slug"])) { $sso_attr["category"]["slug"] = $story["category"]["slug"]; } $sso_data = json_encode($sso_attr,JSON_UNESCAPED_UNICODE); return $sso_data; } function slugData($story) { $slug_array = null; $sso_data = json_encode($story, true); //dd($sso_data); return $sso_data; } function getMetaTag(Request $request, $slug, $story = null) { $meta_list = array(); $memcache = getMemcacheKeyV1(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } if (empty($slug)) { return null; } $meta_title = $amphtml_url = null; $meta_description = null; $meta_keywords = null; $twitter_title = null; $twitter_image = null; $og_description = null; $twitter_description = null; $google_image = null; $json_image = null; //use this image in amp & json schema $json_image_1600x900=null; //use this image in amp & json schema $google_desc = null; $story_type = null; $article_id = null; $story_created_date = null; $story_publish_date = null; $story_section_name = null; $slug_meta_list = array(); $slugParts = array(); $footer_title = null; $twitter_player = null; $og_title = null; $og_title_seo = null; $og_image = null; $og_type = null; $video_duration=0; $page_detail = []; $amp_page = array(); $request_uri = $request->server('REQUEST_URI'); $clean_request_uri = strtok($request_uri, '?'); $secure_url = $request->secure() ? 'https://' : 'https://'; //$site_link = $secure_url . $request->server('HTTP_HOST'); $replace_texts = ['/jio', '/amp']; foreach ($replace_texts as $replace_text) { if ($clean_request_uri == $replace_text) { $clean_request_uri = str_replace($replace_text, '/', $clean_request_uri); $request_uri = str_replace($replace_text, '/', $request_uri); } else { $clean_request_uri = str_replace($replace_text . '/', '/', $clean_request_uri); $request_uri = str_replace($replace_text . '/', '/', $request_uri); } } $site_link = $secure_url . 'www.amarujala.com'; $canonical_url = 'https://www.amarujala.com' . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $link_next_previous_url = $site_link . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $alternate_url = $site_link . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $og_url = $canonical_url; //$site_link . $request_uri;//$request->server('REQUEST_URI'); $twitter_url = $canonical_url; //$site_link . $request_uri;//$request->server('REQUEST_URI'); ////////////////////////////////////////////////////////// if (strpos($slug, '/') !== false) { //dd($slug); $slugParts = explode("/", rtrim($slug, '/')); $slug = $slugParts[count($slugParts) - 1]; } $slug_meta_list = Slug::getSlugBySlug($slug); $amp_page = Slug::getSlugBySlug($slug.'-amp'); /* for direct access to photo-gallery slide access */ $currentPageNo = $request->has('pageId') && is_numeric(trim($request->input('pageId'))) ? (int) trim($request->input('pageId')) : 1; /* close */ if (isset($story) && isset($story['type']) && !empty($story['type'])) { //dd($story); $cat_title = isset($story['category']['title']) ? $story['category']['title'] : ''; $cat_title_array = explode(" ", rtrim($cat_title, '')); $cat_title_first_part = isset($cat_title_array[0]) ? $cat_title_array[0] : null; $cat_title_hindi = isset($story['category']['title_hn']) ? $story['category']['title_hn'] : ''; $cat_title_hindi_array = explode(" ", rtrim($cat_title_hindi, '')); $cat_title_hindi_first_part = isset($cat_title_hindi_array[0]) ? $cat_title_hindi_array[0] : null; $category_slug = isset($story['category']['slug']) ? $story['category']['slug'] : ''; $parent_cat_id = isset($story['category']['parent_id']) ? $story['category']['parent_id'] : null; $location_slug = isset($story['geo_scope'][0]['slug']) ? $story['geo_scope'][0]['slug'] : null; $location_type = isset($story['geo_scope'][0]['type']) ? $story['geo_scope'][0]['type'] : null; $parent_loc_id = isset($story['geo_scope'][0]['parent_id']) ? $story['geo_scope'][0]['parent_id'] : null; $parent_cat_title = null; //20200202 Mayank Gupta updated below code due to error $created_by = ''; $page_detail['author_type'] = ''; if (isset($story['source']) && !empty($story['source'])) { $created_by = 'Amar Ujala Digital Team'; $page_detail['author_type'] = 'Organization'; } else if (isset($story['author_details']) && !empty($story['author_details'])) { $created_by = isset($story['author_details']) && !empty($story['author_details']) ? (isset($story['author_details']['firstname_hn']) && !empty($story['author_details']['firstname_hn']) ? $story['author_details']['firstname_hn'] : ucfirst($story['author_details']['firstname'])) . ' ' . (isset($story['author_details']['lastname_hn']) && !empty($story['author_details']['lastname_hn']) ? $story['author_details']['lastname_hn'] : ucfirst($story['author_details']['lastname'])) : $created_by; $page_detail['author_type'] = 'Person'; } $page_detail['story_title'] = isset($story['title_hn']) ? $story['title_hn'] : null; $footer_title = $cat_title . " News in Hindi by Amar Ujala Digital team. Visit our Homepage for more News in Hindi. " . $cat_title . " Samachar, " . $cat_title . " Hindi Samachar, Online " . $cat_title . " Samachar."; $page_detail['author_name'] = $created_by; $page_detail['analytics']['id'] = isset($story['_id']) ? $story['_id'] : null; $page_detail['id'] = isset($story['_id']) ? $story['_id'] : null; //$page_detail['partner'] = isset($story['partners']['title']) && !empty($story['partners']['title']) ? $story['partners']['title'] : 'Digital'; $page_detail['content_partner'] = isset($story['partners']['title']) && !empty($story['partners']['title']) ? $story['partners']['title'] : 'Digital'; $story_writer_detail = User::getUserById(isset($story['created_by']) ? $story['created_by'] : $story['updated_by']); $story_writer = isset($story_writer_detail) && !empty($story_writer_detail) ? (isset($story_writer_detail['firstname']) && !empty($story_writer_detail['firstname']) ? $story_writer_detail['firstname'] : ucfirst($story_writer_detail['firstname'])) . ' ' . (isset($story_writer_detail['lastname']) && !empty($story_writer_detail['lastname']) ? $story_writer_detail['lastname'] : ucfirst($story_writer_detail['lastname'])) : $created_by; if(!empty($story_writer)){ $page_detail['story_writer'] = $story_writer; } $page_detail['analytics']['type'] = 'story'; if (!empty($parent_cat_id)) { $category_list = Category::getCategoryById($parent_cat_id, true); $page_detail['category'] = isset($category_list['slug']) ? $category_list['slug'] : null; $page_detail['sub_category'] = $category_slug; $parent_cat_title = isset($category_list['title']) ? $category_list['title'] : $story['category']['title']; if (isset($story['is_premium']) && $story['is_premium'] == false) { $page_detail['analytics']['user_source'] = $page_detail['category']; } } else { $page_detail['category'] = $category_slug; if (isset($story['is_premium']) && $story['is_premium'] == false) { $page_detail['analytics']['user_source'] = $category_slug; } } if (!empty($parent_loc_id)) { $location = Location::getLocationById($parent_loc_id); $page_detail[isset($location['type'])?$location['type'] :'city'] = ($location && isset($location['slug'])) ? $location['slug'] : null; $page_detail[$location_type] = isset($location_slug) ? $location_slug : null; if (isset($story['is_premium']) && $story['is_premium'] == false) { $page_detail['analytics']['user_source'] = ($location && isset($location['slug'])) ? $location['slug'] : null; } } else { $page_detail[$location_type] = isset($location_slug) ? $location_slug : null; if (isset($story['is_premium']) && $story['is_premium'] == false) { $page_detail['analytics']['user_source'] = isset($location_slug) ? $location_slug : null; } } //notification title if ($category_slug != "city-and-states" && $category_slug != "crime") { $category_list = Category::getCategoryBySlug($category_slug, true); $page_detail['notification_title'] = isset($category_list['message']) ? $category_list['message'] : null; if (empty($page_detail['notification_title']) && !empty($parent_cat_id)) { $category_list = Category::getCategoryById($parent_cat_id, true); $page_detail['notification_title'] = isset($category_list['message']) ? $category_list['message'] : null; } }elseif (empty($page_detail['notification_title'])) { $location = Location::getLocationBySlug($location_slug); $page_detail['notification_title'] = isset($location['message']) ? $location['message'] : null; if (empty($page_detail['notification_title']) && !empty($parent_loc_id)) { $location = Location::getLocationById($parent_loc_id); $page_detail['notification_title'] = isset($location['message']) ? $location['message'] : null; } } if(!empty($story['is_premium']) && $story['is_premium'] == true){ //ga(site_ga_data[ga_data]['name'] + '.set', 'contentGroup1', 'premiumstories'); $page_detail["cg1"]="premiumstories"; }elseif(!empty($story["type"]) && !empty($story["custom_attribute"]) && !empty($story["custom_attribute_value"]) && $story["type"] == 'feature-story' && $story["custom_attribute"] == "live_text" && strtolower($story["custom_attribute_value"]) == "timeline"){ //ga(site_ga_data[ga_data]['name'] + '.set', 'contentGroup1', 'timeline'); /* GA Content Grouping tags */ $page_detail["cg1"]="timeline"; }else{ //ga(site_ga_data[ga_data]['name'] + '.set', 'contentGroup1', 'allstories'); /* GA Content Grouping tags */ $page_detail["cg1"]="allstories"; } if(!empty($story["type"])){ $page_detail["cg2"]=$story["type"]; } if(!empty($story["newspro_city"][0])){ $page_detail["cg2"]="newspro"; } if(!empty($story["partners"]["title"]) && strtolower($story["partners"]["title"])=="ugc"){ $page_detail["cg2"]="ugc"; } if(!empty($category_list['slug'])){ if($category_list['slug']=="city-and-states"){ $page_detail["cg3"]=!empty($location_slug)?$location_slug:null; }else{ $page_detail["cg3"]=$category_list['slug']; } } if(!empty($page_detail['content_partner']) && trim($page_detail['content_partner']) =='Print' && !empty($story['created_by'])) { $limitNewsProStory = array( '58f721f14f1c1b3874472e1e', '58f7232d4f1c1beb02472e6e', '58f722524f1c1b0b52471aa2', '58f723a44f1c1ba346472119', '58f724544f1c1b1b74472eb8', '58f724b44f1c1b0b52471aae', '58f725064f1c1b0b52471ab3', '58f7262f4f1c1bb44647240f' ); if (in_array($story['created_by'], $limitNewsProStory)) { $page_detail["cg4"]="Tagger"; if(!empty($story["newspro_city"][0])){ $page_detail["cg2"]="newspro-tagger"; } } } $og_type = 'article'; $story_meta_keyword = isset($story['meta']['keyword']) && !empty($story['meta']['keyword']) ? $story['meta']['keyword'] . ',' : implode(',', $story['tags']); $exp_keyword = explode(',', $story_meta_keyword); $story_meta_keyword = implode(', ', $exp_keyword); //comment for 35 words //$story_meta_description = isset($story['meta']['description']) && !empty($story['meta']['description'])?$story['meta']['description']:(str_replace("\r\n",' ',$story['synopsis'])); $story_meta_description = isset($story['meta']['description']) && !empty($story['meta']['description']) ? $story['meta']['description'] : null; if (empty($story_meta_description)) { $story_desc_for_desc = isset($story['description']) ? strip_tags(str_replace("\r\n", ' ', $story['description'])) : ''; $story_meta_description = implode(' ', array_slice(explode(' ', $story_desc_for_desc), 0, 34)); } //comment for 35 words $page_detail['template'] = $story['type']; $page_detail['keywords'] = $exp_keyword; $page_detail['tags'] = isset($story['tags']) ? $story['tags'] : []; if(!empty($parent_cat_id)){ $parent_categories =Category::getCategoryById($parent_cat_id, true); $page_detail['tags'] = getAppendTags($story,$parent_categories); } //use for dfp advt if(!empty($page_detail['tags'])){ $tags_list= array_filter($page_detail['tags']); foreach($tags_list as $key=>$tag_slug){ $page_detail["tags_slug".$key] = strtolower(str_replace(" ","-",$tag_slug)); } } //use for dfp advt $title = null; /* if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ //entertainment case if (!empty($story['title_hn']) && $story['title_hn']) { $title = cleanSpecialString($story['title_hn']); } }else{ */ if ($story['title'] == cleanSpecialString($story['title_hn'])) { $title = $story['title']; } else { $title = $story['title'] . ' - ' . cleanSpecialString($story['title_hn']); //$title = cleanSpecialString($story['title_hn']) . ' - ' . $story['title']; } // } $og_title_seo = !empty($story["title_seo"]) ? cleanSpecialString($story["title_seo"]) : (!empty($story['title_hn']) ? cleanSpecialString($story['title_hn']) :'') ; if (($category_slug == 'city-and-states' || $category_slug == 'crime') && isset($story['geo_scope'][0]) && !empty($story['geo_scope'][0])) { $cat_title = isset($story['geo_scope'][0]['title']) ? $story['geo_scope'][0]['title'] : null; $cat_title_hindi = isset($story['geo_scope'][0]['title_hn']) ? $story['geo_scope'][0]['title_hn'] : null; } $exception_category = ['india-news', 'cricket-news', 'auto-news', 'bizarre-news', 'useful-news', 'news-headlines']; if (isset($story['is_premium']) && $story['is_premium'] == true) { $page_detail['analytics']['user_source'] = 'premium wall'; } //code for article description part club for NewsArticle schema.org if(!empty($story) && !empty($story['parts']) && count($story['parts'])>1){ $schema_story_desc = array_column($story['parts'], 'description'); $schema_story_parts_description = array_map(function($v){ return trim(strip_tags(str_replace("\r\n", ' ', $v))); }, $schema_story_desc); $schema_story_description = implode(' ', $schema_story_parts_description); }else{ $schema_story_description = !empty($story["description"])? strip_tags(str_replace("\r\n", ' ', $story['description'])):''; } //code for article description part club for NewsArticle schema.org switch ($story['type']) { case 'story': case 'feature-story': case 'live': $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $alternate_url = $amphtml_url; $meta_title = $title . ' - Amar Ujala Hindi News Live'; // if(in_array("kavya",[isset($page_detail["category"]) && !empty($page_detail["category"])?$page_detail["category"]:''])){ // $meta_title = $title . ' - Amar Ujala Kavya'; // } /* if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ //entertainment case $meta_title = $title ." - ". ucfirst($page_detail["category"]).' News: Amar Ujala'; } */ if (isset($page_detail['category']) && $page_detail['category'] == 'city-and-states') { $meta_city_name = !empty($page_detail["city"]) ? $page_detail["city"]." news":''; //$meta_title = (!empty($story['title_hn'])?cleanSpecialString($story['title_hn']):'').(!empty($meta_city_name)? " - ".$meta_city_name:''); $meta_title = $meta_title; $meta_keywords = $story_meta_keyword . $cat_title . ' News in Hindi, Latest ' . $cat_title . ' News in Hindi, ' . $cat_title . ' Hindi Samachar'; //$meta_description = $cat_title . ' News in Hindi: ' . $story['title'] . ', ' . $story_meta_description . ' - amarujala.com'; //$meta_description = (!empty($meta_city_name)?$meta_city_name." - ":'').$story_meta_description; $meta_description = $story_meta_description; } elseif (isset($page_detail['category']) && $page_detail['category'] == 'crime') { $meta_title = $meta_title; $meta_keywords = $story_meta_keyword . $cat_title . ' Crime News in Hindi, Latest ' . $cat_title . ' Crime News in Hindi'; //$meta_description = $cat_title . ' News: ' . $story_meta_description . ', ' . $story['title'] . ' - amarujala.com'; $meta_description = $story_meta_description; } elseif (isset($page_detail['category']) && $page_detail['category'] == 'kavya') { $meta_title = $title . ' - Amar Ujala Kavya'; //comment for 12 words // if (!empty($story_meta_description)) { // $meta_description = implode(' ', array_slice(explode(' ', $story_meta_description), 0, 12)); // } //$meta_description = $meta_description . ". Read more hindi poetry, hindi shayari, hindi kavita on amar ujala kavya."; //comment for 12 words $exp_keyword_split = ""; if (isset($exp_keyword) && !empty($exp_keyword) && (!isset($story["ugc"]) || (isset($story["ugc"]) && $story["ugc"] != 1))) { $exp_keyword_split = implode(', ', array_slice($exp_keyword, 0, 3)); $meta_description = $story_meta_description . ". Read more about " . $exp_keyword_split . " on amar ujala kavya."; } else { $meta_description = $story_meta_description . ". Read more hindi poetry, hindi shayari, hindi kavita on amar ujala kavya."; } if (empty($story_meta_keyword)) { $meta_keywords = "hindi shayari, poetry in hindi, shayari in hindi, hindi poetry, 9 ?  & @ 6 > / 0 @, 9 ?  & @  5 ? $ >"; } else { $meta_keywords = rtrim($story_meta_keyword, ", "); } } else { $meta_title = $meta_title; //$category_name_check = !empty($page_detail["category"])? $page_detail["category"]:''; //$category_name_add_in_title = addHindiNewsTitle($category_name_check); //$meta_title = (!empty($story['title_hn'])?cleanSpecialString($story['title_hn']):'').(!empty($category_name_add_in_title) ? " - " .$category_name_add_in_title : ""); //$meta_description = $story['title'] . ', '.$story_meta_description.' - amarujala.com'; //if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ $meta_description = $story_meta_description; //}else{ //$meta_description = (!empty($category_name_add_in_title) ? $category_name_add_in_title ." - " : "").$story_meta_description; //} if ($parent_cat_title == null) { $keyword = null; } else { if (in_array($page_detail['category'], $exception_category)) { $keyword = $parent_cat_title . ' in Hindi, '; } else { $keyword = $parent_cat_title . ' News in Hindi, '; } } if (in_array($category_slug, $exception_category)) { //$meta_keywords = $story_meta_keyword . $keyword . $cat_title . ' in Hindi, Latest '. $cat_title.' Updates'; $meta_keywords = $story_meta_keyword . $cat_title . ' in Hindi, Latest ' . $cat_title . ' Updates'; } else { $meta_keywords = $story_meta_keyword . $keyword . $cat_title . ' News in Hindi, ' . $cat_title . ' Hindi News'; } } break; case 'photo-gallery': $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $alternate_url = $amphtml_url; $add_keywords_in_description = array_slice($exp_keyword, 0, 3); $add_keywords_in_description = implode(', ', $add_keywords_in_description); if (isset($story["created_at"]) && $story["created_at"] >= "2018-03-06") { $meta_description = trim($story_meta_description) . " Read latest hindi news ( $ >  > 9 ? ( M & @ 8 . >  > 0) on " . $add_keywords_in_description . " - #1 9 ? ( M & @ ( M / B  < website."; /* if (isset($page_detail['category']) && $page_detail['category'] == 'city-and-states') { $meta_city_name = !empty($page_detail["city"]) ? $page_detail["city"]." news":''; $meta_description = (!empty($meta_city_name)?$meta_city_name." - ":''). trim($story_meta_description); }else{ $category_name_check = !empty($page_detail["category"])? $page_detail["category"]:''; $category_name_add_in_title = addHindiNewsTitle($category_name_check); if($category_name_check == "entertainment"){ $meta_description = trim($story_meta_description) . " Read latest hindi news ( $ >  > 9 ? ( M & @ 8 . >  > 0) on " . $add_keywords_in_description . " - #1 9 ? ( M & @ ( M / B  < website."; }else{ $meta_description = (!empty($category_name_add_in_title) ? $category_name_add_in_title ." - " : ""). trim($story_meta_description); } } */ } else { $meta_description = trim($story_meta_description); } if (isset($currentPageNo) && !empty($currentPageNo) && $currentPageNo > 1) { if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ //entertainment case $meta_title = $title . ' , Slide ' . $currentPageNo . " - ". ucfirst($page_detail["category"]).' News: Amar Ujala'; }else{ $meta_title = $title . ' , Slide ' . $currentPageNo . ' - Amar Ujala Hindi News Live'; /* if (isset($page_detail['category']) && $page_detail['category'] == 'city-and-states') { $meta_city_name = !empty($page_detail["city"]) ? $page_detail["city"] . " news" : ''; $meta_title = (!empty($story['title_hn']) ? cleanSpecialString($story['title_hn']) : '') . (!empty($meta_city_name) ? " - " . $meta_city_name : ''); } else { $category_name_check = !empty($page_detail["category"]) ? $page_detail["category"] : ''; $category_name_add_in_title = addHindiNewsTitle($category_name_check); $meta_title = (!empty($story['title_hn']) ? cleanSpecialString($story['title_hn']) : '') . (!empty($category_name_add_in_title) ? " - " . $category_name_add_in_title : ""); } */ } if (isset($story["created_at"]) && $story["created_at"] < "2018-03-06") { $meta_description = $story['title'] . ', ' . 'Slide' . ' ' . $currentPageNo . ' ' . $story_meta_description . ' - amarujala.com'; } $meta_keywords = $story_meta_keyword . $cat_title . ' Photos, Latest ' . $cat_title . ' Photographs, ' . $cat_title . ' Images, Latest ' . $cat_title . ' photos'; } else { if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ //entertainment case $meta_title = $title ." - ". ucfirst($page_detail["category"]).' News: Amar Ujala'; }else{ $meta_title = $title . ' - Amar Ujala Hindi News Live'; /* if (isset($page_detail['category']) && $page_detail['category'] == 'city-and-states') { $meta_city_name = !empty($page_detail["city"]) ? $page_detail["city"] . " news" : ''; $meta_title = (!empty($story['title_hn']) ? cleanSpecialString($story['title_hn']) : '') . (!empty($meta_city_name) ? " - " . $meta_city_name : ''); } else { $category_name_check = !empty($page_detail["category"]) ? $page_detail["category"] : ''; $category_name_add_in_title = addHindiNewsTitle($category_name_check); $meta_title = (!empty($story['title_hn']) ? cleanSpecialString($story['title_hn']) : '') . (!empty($category_name_add_in_title) ? " - " . $category_name_add_in_title : ""); } */ } //$meta_description = $story['title'] . ', ' . $story_meta_description . '- amarujala.com'; //$meta_description = $story_meta_description ." Get latest hindi news on ". $add_keywords_in_description ." at amarujala.com."; //$meta_keywords = $story_meta_keyword . $cat_title . ' Photos, Latest ' . $cat_title . ' Photographs, ' . $cat_title . ' Images, Latest ' . $cat_title . ' photos'; $meta_keywords = isset($story_meta_keyword) && !empty($story_meta_keyword) ? rtrim($story_meta_keyword, ", ") : $cat_title . ' news in hindi, Latest ' . $cat_title . ' news in hindi, ' . $cat_title . ' hindi samachar'; } break; case 'video': $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $twitter_player = $secure_url . 'www.youtube.com/embed/' . $story['youtube_id']; if(!empty($page_detail["category"]) && $page_detail["category"] == "entertainment"){ //entertainment case $meta_title = $title ." - ". ucfirst($page_detail["category"]).' News: Amar Ujala'; }else{ //$category_name_check = !empty($page_detail["category"])? $page_detail["category"]:''; //$category_name_add_in_title = addHindiNewsTitle($category_name_check); //$meta_title = (!empty($story['title_hn'])?cleanSpecialString($story['title_hn']):'') ." - ". $category_name_add_in_title; $meta_title = $title . '- Amar Ujala Hindi News Live'; } //$meta_description = $story['title'] .': '. $story_meta_description; $meta_description = $story_meta_description; $meta_keywords = $story_meta_keyword; $video_duration = isset($story['video_duration']) && !empty($story['video_duration']) ? timeToIso8601Duration($story['video_duration']) :'PT0M35S'; if (empty($story_meta_keyword)) { if ($category_slug == 'crime') { $meta_keywords = $cat_title . ' Crime Video, Latest ' . $cat_title . ' Crime News Video, ' . $cat_title . ' Crime Video Clips, ' . $cat_title . ' Crime Hindi Video, Online ' . $cat_title . ' Crime News, ' . $cat_title_hindi . '  M 0 >  . ( M / B [ 5 @ ! ? / K'; } else { if (in_array($category_slug, $exception_category)) { if ($category_slug == 'india-news') { $cat_title_hindi = '   ! ? / > ( M / B ['; } else { $cat_title_hindi = $cat_title_hindi; } $meta_keywords = $cat_title . ' Video, Online ' . $cat_title . ' Video, ' . $cat_title . ' Video Clips, ' . $cat_title . ' Hindi Video, Online ' . $cat_title . ' , ' . $cat_title_hindi . ' 5 @ ! ? / K'; } else { if ($category_slug == 'viral-videos' || $category_slug == 'funny-videos') { $cat_title = $cat_title_first_part; $cat_title_hindi = $cat_title_hindi_first_part; if (!empty($location_type) && $location_type == 'city') { $cat_title = (isset($story['geo_scope'][0]['title']) ? $story['geo_scope'][0]['title'] : null) . ' ' . $cat_title_first_part; $cat_title_hindi = (isset($story['geo_scope'][0]['title_hn']) ? $story['geo_scope'][0]['title_hn'] : null) . ' ' . $cat_title_hindi_first_part; } } else { $cat_title = $cat_title; $cat_title_hindi = $cat_title_hindi; } $meta_keywords = $cat_title . ' News Video, Online ' . $cat_title . ' News Video, ' . $cat_title . ' News Video Clips, ' . $cat_title . ' Hindi News Video, Online ' . $cat_title . ' News, ' . $cat_title_hindi . ' ( M / B [ 5 @ ! ? / K'; } } } break; case 'wiki': if(!empty($story['sub_story_type']) && ($story['sub_story_type']=="movie-review" || $story['sub_story_type']=="job")){ $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $alternate_url = $amphtml_url; $meta_title = $title . ' - Amar Ujala Hindi News Live'; $meta_title = $title ." - ". ucfirst($page_detail["category"]).' News: Amar Ujala'; $meta_title = $meta_title; $meta_description = $story_meta_description; $keyword = $parent_cat_title . ' News in Hindi, '; $meta_keywords = $story_meta_keyword . $keyword . $cat_title . ' News in Hindi, ' . $cat_title . ' Hindi News'; }else{ $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $meta_title = $story['title'] . ' Profile: Height, Age, Affairs, Biography | Amar Ujala'; $meta_description = $story['title'] . ' Profile: Checkout ' . $story['title'] . ' Height, Weight, Age, Biography, Affairs, Photos, Videos, Favorite things, interesting facts in hindi and More at amar ujala'; $meta_keywords = $story['title'] . ' Biography,' . $story['title'] . ' Profile,' . $story['title'] . ' Bio data,' . $story['title'] . ' videos, ' . $story['title'] . ' Photos, ' . $story['title'] . ' Awards, ' . $story['title'] . ' Age, ' . $story['title'] . ' News,' . $story['title'] . ' profile in hindi, famous personalities'; } break; case 'web-stories': //$meta_title = (!empty($story['title_seo'])?$story['title_seo'] :$story['title_hn']). ' | '.$story['category']['title'].' Web Stories'; $meta_title = (!empty($story['title_seo'])?$story['title_seo'] :$story['title_hn']); $meta_description = $story_meta_description; $meta_keywords = $story_meta_keyword; break; case 'podcast': $meta_title = (!empty($story['title_seo'])?$story['title_seo'] :$story['title_hn']). ' | '.$story['category']['title'].' Podcast'; $meta_description = $story_meta_description; $meta_keywords = $story_meta_keyword; break; default: $meta_title = $title . ', ' . $cat_title . ' News in Hindi - Amar Ujala'; //$meta_description = $story_meta_description . ', Read all ' . $cat_title . ' Latest and Breaking News in Hindi at Amar Ujala'; $meta_description = $story_meta_description; $meta_keywords = $cat_title . ' News in Hindi, ' . $cat_title . ' News in Hindi, Latest Hindi News , ' . $story_meta_keyword . ' Latest Hindi News, ' . $cat_title . ' Samachar in hindi, online hindi news, hindi newspaper, live hindi news'; } //rules to be updated from CMS if (isset($slug_meta_list['meta']) && count($slug_meta_list['meta']) > 0) { if (isset($currentPageNo) && (int) $currentPageNo > 1) { if (!empty($slug_meta_list['meta']['title'])) $meta_title = $slug_meta_list['meta']['title'] . ', ' . 'Slide' . ' ' . $currentPageNo; if (!empty($slug_meta_list['meta']['description'])) $meta_description = $slug_meta_list['meta']['description'] . ', ' . 'Slide' . ' ' . $currentPageNo; if (!empty($slug_meta_list['meta']['keyword'])) $meta_keywords = $slug_meta_list['meta']['keyword']; }else { if (!empty($slug_meta_list['meta']['title'])) $meta_title = $slug_meta_list['meta']['title']; if (!empty($slug_meta_list['meta']['description'])) $meta_description = $slug_meta_list['meta']['description']; if (!empty($slug_meta_list['meta']['keyword'])) $meta_keywords = $slug_meta_list['meta']['keyword']; } } if (isset($slug_meta_list['og']) && count($slug_meta_list['og']) > 0) { if (!empty($slug_meta_list['og']['title'])) { $og_title = $slug_meta_list['og']['title']; $twitter_title = $slug_meta_list['og']['title']; $og_title_seo = $slug_meta_list['og']['title']; } if (!empty($slug_meta_list['og']['description'])) { $og_description = $slug_meta_list['og']['description']; $twitter_description = $slug_meta_list['og']['description']; } if (!empty($slug_meta_list['og']['keyword'])) { $og_keywords = $slug_meta_list['og']['keyword']; } if (!empty($slug_meta_list['og']['url'])) { $og_url = $slug_meta_list['og']['url']; } if (!empty($slug_meta_list['og']['image'])) { //$og_image = getImageUrl($slug_meta_list['og']['image'], '990x460'); $og_image = getImageUrl($slug_meta_list['og']['image'], '750x506'); $twitter_image = $og_image; $google_image = getImageUrl($slug_meta_list['og']['image'], '500x500'); $json_image = getImageUrl($slug_meta_list['og']['image'], 'original'); $json_image_1600x900 = getCdnCgiImage(getImageUrl( str_replace(' ', '%20', $slug_meta_list['og']['image']),'750x506'),'1600x900'); } } //newspro meta if(isset($story["newpro_md5"]) && !empty($story["newpro_md5"])){ $englishTitle = isset($story['geo_scope'][0]['title']) && !empty($story['geo_scope'][0]['title']) ? $story['geo_scope'][0]['title'] : null; $hindiTitle = isset($story['geo_scope'][0]['title_hn']) && !empty($story['geo_scope'][0]['title_hn']) ? $story['geo_scope'][0]['title_hn'] : null; $geoScopeEngTitle = !empty($englishTitle)?$englishTitle.' News':''; $geoScopeTitle = !empty($englishTitle)?$englishTitle.' News Today in Hindi':''; $geoScopeTitle_ = !empty($englishTitle)?$englishTitle.' News Today':''; $geoScope_ = !empty($englishTitle)?$englishTitle.' News in Hindi':''; $geoHindiTitle = !empty($hindiTitle)?$hindiTitle.' 8 . >  > 0':''; $geoHindiTitle_ = !empty($hindiTitle)?$hindiTitle.' ( M / B  <':''; $meta_title = $title." - ". $geoScopeEngTitle; $storyMetaDescription = isset($story['meta']['description']) && !empty($story['meta']['description']) ? $story['meta']['description'] : null; if (empty($storyMetaDescription)) { $storyDescForDesc = isset($story['description']) ? strip_tags(str_replace("\r\n", ' ', $story['description'])) : ''; $storyMetaDescription = implode(' ', array_slice(explode(' ', $storyDescForDesc), 0, 20)); } $meta_description = "Read Latest ".$geoScopeTitle." - ".$storyMetaDescription; $meta_keywords = $geoScopeEngTitle.", ".$geoScopeTitle_.", ". $geoScope_.", " .$geoHindiTitle .", ". $geoHindiTitle_ ; if(!empty($story_meta_keyword)) { $meta_keywords .= ",".$story_meta_keyword; $keywordTemp = array_unique(explode(",",$meta_keywords)); foreach($keywordTemp as $key =>$word){ $keywordTemp[$key] = trim($word); } $meta_keywords = implode(", ",$keywordTemp); $meta_keywords = trim($meta_keywords); } } //default rules if (isset($page_detail['category']) && $page_detail['category'] == 'kavya') { $og_title = cleanSpecialString($story['title_hn']);// . '- Amarujala Kavya'; $twitter_title = cleanSpecialString($story['title_hn']);// . '- Amarujala Kavya'; } else { $og_title = cleanSpecialString($story['title_hn']);// . '- Amarujala'; $twitter_title = cleanSpecialString($story['title_hn']);// . '- Amarujala'; } //$og_image = getImageUrl($story['image'], '990x460'); if (isset($story['ugc']) && $story['ugc'] == '1') { if(isset($story['image']) && empty($story['image'])){ if (isset($page_detail['category']) && $page_detail['category'] == 'kavya') { $og_image= config('env.CACHE_IMAGE_PATH_STATIC').'/2019/07/17/kavya-og-image_5d2f23a2001c8.jpg'; //if ugc story image is black }else{ $og_image= ""; } }else{ $og_image = getImageUrl($story['image'], 'original'); } }else { $og_image = getImageUrl($story['image'], '750x506'); } $twitter_image = $og_image; $google_image = getImageUrl($story['image'], '500x500'); $json_image = getImageUrl($story['image'], 'original'); $json_image_1600x900 = getCdnCgiImage(getImageUrl( str_replace(' ', '%20', $story['image']),'750x506'),'1600x900'); //$og_description = $story['description']; $og_description = isset($story['synopsis'])?$story['synopsis']:$story['description']; $google_desc = $og_description; $twitter_description = $og_description; $story_type = isset($story['type']) ? $story['type'] : ''; //$story_created_date = isset($story['created_at']) ? date('D, d M Y h:i A T', strtotime($story['created_at'])) : date('D, d M Y h:i A T'); //$story_publish_date = isset($story['updated_at']) ? date('D, d M Y h:i A T', strtotime($story['updated_at'])) : date('D, d M Y h:i A T'); //$story_created_date = isset($story['created_at']) ? date('c', strtotime($story['created_at'].'-6 hours 30 min')) : date('D, d M Y h:i A T'); //$story_publish_date = isset($story['updated_at']) ? date('c', strtotime($story['updated_at'].'-6 hours 30 min')) : date('D, d M Y h:i A T'); $story_created_date = isset($story['created_at']) ? date('c', strtotime($story['created_at'])) : date('D, d M Y h:i A T'); $story_publish_date = isset($story['updated_at']) ? date('c', strtotime($story['updated_at'])) : date('D, d M Y h:i A T'); $story_section_name = isset($story['category']['title']) ? $story['category']['title'] : null; } else { $page_array = ['video', 'search', 'tags', 'livetv', 'live-tv', 'poll', 'election', 'budget', 'home', 'photo-gallery', 'city-and-states']; if (in_array($slug, $page_array)) { $page_detail['template'] = 'page'; $page_detail['page'] = $slug; } $city_crime_page = false; if (isset($slug_meta_list['type'])) { $tagName = str_replace('-', ' ', $slug); //meta for category type if ($slug_meta_list['type'] == 'category' || $slug == 'city-and-states' ) {// || (!empty($amp_page) && $amp_page['status'] == "enable") ---uncomment this if needed $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); if($slug == 'cricket-scorecards'){ $amphtml_url = ''; // remove AMP meta from cricket scorecard category page } $temp = Category::getCategoryBySlug($slug); $parent_cat_id = isset($temp['parent_id']) ? $temp['parent_id'] : null; $page_detail['analytics']['id'] = isset($temp['_id']) ? $temp['_id'] : null; if (!empty($parent_cat_id)) { $category_list = Category::getCategoryById($parent_cat_id, true); $page_detail['category'] = isset($category_list['slug']) ? $category_list['slug'] : null; $page_detail['sub_category'] = $slug; $page_detail['template'] = 'sub_category'; $page_detail['analytics']['user_source'] = isset($category_list['slug']) ? $category_list['slug'] : null; $page_detail['analytics']['type'] = 'category'; $page_detail["cg1"]="category"; $page_detail["cg2"]=!empty($category_list['slug']) ? $category_list['slug'] : null; $page_detail["cg3"]="category"; } else { $page_detail['category'] = $slug; $page_detail['template'] = 'category'; $page_detail['analytics']['user_source'] = $slug; $page_detail['analytics']['type'] = 'category'; $page_detail["cg1"]="category"; $page_detail["cg2"]=$slug; $page_detail["cg3"]="category"; } //notification title $page_detail['notification_title'] = isset($temp['message']) ? $temp['message'] : null; if (empty($page_detail['notification_title']) && !empty($parent_cat_id)){ $category_list = Category::getCategoryById($parent_cat_id, true); $page_detail['notification_title'] = isset($category_list['message']) ? $category_list['message'] : null; } $tagName = ($temp && isset($temp['title'])) ? $temp['title'] : ''; $cat_title_hn = ($temp && isset($temp['title_hn'])) ? $temp['title_hn'] : ''; $meta_title = $tagName . ' Breaking and Latest News in Hindi - Amarujala.com'; //meta for category of video type if (!empty($story) && $story == 'video') { $amphtml_url = ''; // remove AMp meta from video listing page $city_crime_page = true; $meta_title = $tagName . ' News Video: Watch ' . $tagName . ' News Video Clips in Hindi - Amarujala Videos'; $meta_description = $tagName . ' Hindi News Video: Watch latest ' . $tagName . ' hindi news in video clips online at Amarujala. 5 @ ! ? / K . G  & G  ? / G 8 , 8 G $ >  < > $ 0 @ ( ' . $cat_title_hn . ' 9 ?  & @ 8 . >  > 0'; $meta_keywords = $tagName . ' News Video, Watch ' . $tagName . ' News Video, ' . $tagName . ' News Video Clips, ' . $tagName . ' Hindi News Video, Watch ' . $tagName . ' News, ' . $cat_title_hn . ' ( M / B [ 5 @ ! ? / K'; $video_category_meta = Config::get('global_config.video_category_meta'); if (isset($slug) && !empty($slug)) { $video_category_meta = isset($video_category_meta[$slug]) ? $video_category_meta[$slug] : null; } if (isset($video_category_meta) && !empty($video_category_meta)) { $meta_title = isset($video_category_meta['meta_title']) ? $video_category_meta['meta_title'] : null; $meta_description = isset($video_category_meta['meta_description']) ? $video_category_meta['meta_description'] : null; $meta_keywords = isset($video_category_meta['meta_keywords']) ? $video_category_meta['meta_keywords'] : null; } } } //meta for location type else if (isset($slug_meta_list['type']) && $slug_meta_list['type'] == 'location') { $amphtml_url = $site_link . "/amp" . $clean_request_uri; //strtok($request->server('REQUEST_URI'), '?'); $location_info = Location::getLocationBySlug($slug); $parent_loc_id = isset($location_info['parent_id']) ? $location_info['parent_id'] : null; $page_detail['template'] = isset($location_info['type']) ? $location_info['type'] : $slug_meta_list['type']; $cat_title_hn = isset($location_info['title_hn']) ? $location_info['title_hn'] : null; $tagName = isset($location_info['title']) ? $location_info['title'] : null; $page_detail['analytics']['id'] = isset($location_info['_id']) ? $location_info['_id'] : null; if (!empty($parent_loc_id)) { $location = Location::getLocationById($parent_loc_id); $page_detail[$location['type']] = isset($location['slug']) ? $location['slug'] : null; $page_detail[$location_info['type']] = isset($slug) ? $slug : null; $page_detail['analytics']['user_source'] = isset($location['slug']) ? $location['slug'] : null; $page_detail['analytics']['type'] = 'location'; $page_detail["cg1"]="location"; $page_detail["cg2"]=!empty($location_info['type']) ? $location_info['type'] : $slug_meta_list['type']; $page_detail["cg3"]=!empty($slug) ? $slug : null; } else { $page_detail[$location_info['type']] = isset($slug) ? $slug : null; $page_detail['analytics']['user_source'] = isset($slug) ? $slug : null; $page_detail['analytics']['type'] = 'location'; $page_detail["cg1"]="location"; $page_detail["cg2"]=!empty($location_info['type']) ? $location_info['type'] : $slug_meta_list['type']; $page_detail["cg3"]=!empty($slug) ? $slug : null; } //notification title $page_detail['notification_title'] = isset($location_info['message']) ? $location_info['message'] : null; if(empty($page_detail['notification_title']) && !empty($parent_loc_id) ) { $location = Location::getLocationById($parent_loc_id); $page_detail['notification_title'] = isset($location['message']) ? $location['message'] : null; } $meta_title = 'Breaking and Latest ' . $tagName . ' News in Hindi - Amarujala.com'; if (!empty($page_detail['template']) && $page_detail['template'] == 'city') { if (empty($meta_keywords)) { $meta_keywords = $tagName . ' news, ' . $tagName . ' news in hindi, ' . $tagName . ' local news, ' . $tagName . ' breaking news, ' . $tagName . ' hindi news, ' . $tagName . ' news today, ' . $tagName . ' live news, ' . $cat_title_hn . ' ( M / B [, ' . $cat_title_hn . ' 9 ?  & @ 8 . >  > 0, ' . $cat_title_hn . ' 8 . >  > 0, 9 ?  & @ . G  ' . $cat_title_hn . ' 8 . >  > 0 '; } } //meta for location type of crime category if (isset($story) && $story == 'crime') { $city_crime_page = true; $meta_title = $tagName . ' Crime News: Latest Crime News in Hindi, ' . $cat_title_hn . '  M 0 >  . ( M / B  - Amar Ujala Hindi News'; $meta_description = 'Find all latest ' . $tagName . ' Crime news headlines and top stories in Hindi. Get breaking ' . $cat_title_hn . '  M 0 >  . ( M / B [ videos, pictures online at Amarujala.com'; $meta_keywords = $tagName . ' Crime news, ' . $cat_title_hn . '  M 0 >  . ( M / B [, latest ' . $tagName . ' crime news, ' . $tagName . ' crime news in hindi, today ' . $tagName . ' crime news, ' . $tagName . ' crime headlines, ' . $tagName . ' crime hindi news headlines, ' . $tagName . ' latest crime news headlines'; } //meta for location of video type if (!empty($story) && $story == 'video') { $amphtml_url = ''; // remove AMP meta from video listing page $city_crime_page = true; $meta_title = $tagName . ' News Video: Watch ' . $tagName . ' News Video Clips in Hindi - Amarujala Videos'; $meta_description = $tagName . ' Hindi News Video: Watch latest ' . $tagName . ' hindi news in video clips online at Amarujala. 5 @ ! ? / K . G  & G  ? / G 8 , 8 G $ >  < > $ 0 @ ( ' . $cat_title_hn . ' 9 ?  & @ 8 . >  > 0'; $meta_keywords = $tagName . ' News Video, Watch ' . $tagName . ' News Video, ' . $tagName . ' News Video Clips, ' . $tagName . ' Hindi News Video, Watch ' . $tagName . ' News, ' . $cat_title_hn . ' ( M / B [ 5 @ ! ? / K'; } } //meta for page type else if (isset($slug_meta_list['type']) && $slug_meta_list['type'] == 'page') { $temp_page = Page::getPageBySlug($slug); $cat_title_hn = isset($temp_page['title_hn']) ? $temp_page['title_hn'] : ''; $page_detail['template'] = 'page'; $page_detail['page'] = $slug; if (isset($temp_page['meta']) && count($temp_page['meta']) > 0) { if (isset($temp_page['meta']['title']) && !empty($temp_page['meta']['title'])) { $meta_title = $temp_page['meta']['title']; } if (isset($temp_page['meta']['description']) && !empty($temp_page['meta']['description'])) { $meta_description = $temp_page['meta']['description']; } if (isset($temp_page['meta']['keyword']) && !empty($temp_page['meta']['keyword'])) { $meta_keywords = $temp_page['meta']['keyword']; } } $page_detail['analytics']['user_source'] = $slug; $page_detail['analytics']['type'] = $slug_meta_list['type']; $page_detail['analytics']['id'] = isset($temp_page['_id']) ? $temp_page['_id'] : null; if (!empty($slug)) { switch ($slug) { case 'home': $page_detail["cg1"] = "homepage"; $page_detail["cg2"] = "category"; $page_detail["cg3"] = "homepage"; break; case 'web-stories': $page_detail["cg1"] = $slug; $page_detail["cg2"] = "category"; $page_detail["cg3"] = $slug; break; case 'podcast': $page_detail["cg1"] = $slug; $page_detail["cg2"] = "category"; $page_detail["cg3"] = $slug; break; case 'video': $page_detail["cg1"] = $slug; $page_detail["cg2"] = "category"; $page_detail["cg3"] = $slug; break; case 'photo-gallery': $page_detail["cg1"] = $slug; $page_detail["cg2"] = "category"; $page_detail["cg3"] = $slug; break; } } } //default rules for all above listed types if (empty($meta_title)) { $meta_title = $tagName . ' ' . 'hindi news, ' . $tagName . ' News in Hindi - Amarujala.com'; } if (empty($meta_description)) { $meta_description = 'Read breaking and latest ' . $tagName . ' News in Hindi in India\'s No. 1 Leading Hindi Newspaper Amar Ujala covering ' . $tagName . ' samachar in Hindi, election news, crime news, education news and more'; } if (empty($meta_keywords)) { $meta_keywords = $tagName . ' News in hindi, news in hindi, ' . $tagName . ' news, latest ' . $tagName . ' news, breaking ' . $tagName . ' news, ' . $tagName . ' Samachar, samachar in hindi , Online Hindi News, Hindi Newspaper, live hindi News,hindi news'; } if (empty($cat_title_hn)) { $cat_title_hn = $tagName; } $og_title = $cat_title_hn . '  @ 8 , 8 G $ > [ >  , 0'; $twitter_title = $og_title; $og_description = ' 9 ?  & @ . G  * >   ' . $cat_title_hn . ' 8 G 8 . M ,  ' ? $ 8 - @ 8 . >  > 0  . 0  > 2 > * 0 - - > 0 $  >   M 0 # @ 8 . >  > 0 * $ M 0'; $twitter_description = $og_description; $og_title_seo = $og_title; //rules to be updated from CMS for above listed types if (isset($slug_meta_list['og']) && count($slug_meta_list['og']) > 0 && !$city_crime_page) { if (isset($slug_meta_list['og']['title']) && !empty($slug_meta_list['og']['title'])) { $og_title = $slug_meta_list['og']['title']; $twitter_title = $slug_meta_list['og']['title']; $og_title_seo = $slug_meta_list['og']['title']; } if (isset($slug_meta_list['og']['description']) && !empty($slug_meta_list['og']['description'])) { $og_description = $slug_meta_list['og']['description']; $twitter_description = $slug_meta_list['og']['description']; } if (isset($slug_meta_list['og']['keyword']) && !empty($slug_meta_list['og']['keyword'])) { $og_keywords = $slug_meta_list['og']['keyword']; } if (isset($slug_meta_list['og']['url']) && !empty($slug_meta_list['og']['url'])) { $og_url = $slug_meta_list['og']['url']; } if (isset($slug_meta_list['og']['image']) && !empty($slug_meta_list['og']['image'])) { //$og_image = getImageUrl($slug_meta_list['og']['image'], '990x460'); $og_image = getImageUrl($slug_meta_list['og']['image'], '750x506'); $twitter_image = $og_image; $google_image = getImageUrl($slug_meta_list['og']['image'], '500x500'); $json_image = getImageUrl($slug_meta_list['og']['image'], 'original'); $json_image_1600x900 = getCdnCgiImage(getImageUrl( str_replace(' ', '%20', $slug_meta_list['og']['image']),'750x506'),'1600x900'); } } if (isset($slug_meta_list['meta']) && count($slug_meta_list['meta']) > 0 && !$city_crime_page) { if (isset($slug_meta_list['meta']['title']) && !empty($slug_meta_list['meta']['title'])) { $meta_title = $slug_meta_list['meta']['title']; } if (isset($slug_meta_list['meta']['description']) && !empty($slug_meta_list['meta']['description'])) { $meta_description = $slug_meta_list['meta']['description']; } if (isset($slug_meta_list['meta']['keyword']) && !empty($slug_meta_list['meta']['keyword'])) { $exp_cat_keyword = explode(",", $slug_meta_list['meta']['keyword']); $meta_keywords = implode(", ", $exp_cat_keyword); //$meta_keywords = $slug_meta_list['meta']['keyword']; } //meta for landing category/location page of photo-gallery if (isset($slugParts[0]) && $slugParts[0] == "photo-gallery") { $meta_title = $tagName . " Photo Gallery News in Hindi, " . $tagName . " + K  K  H 2 0 @,  . G   H 2 0 @ Hindi News - Amar Ujala"; $meta_description = $tagName . " photo gallery, ( + K  K  H 2 0 @ ( M / B [ ) in Hindi: Read latest " . $tagName . " image gallery news in hindi, picture gallery news in hindi from all across the world at amarujala.com."; $meta_keywords = $tagName . " photo gallery, " . $tagName . " photo gallery samachar, " . $tagName . " photo gallery hindi news, " . $tagName . " photo gallery news today, " . $tagName . " + K  K  H 2 0 @, " . $tagName . "  . G   H 2 0 @"; } //meta for landing category/location page of web-stories if (isset($slugParts[0]) && $slugParts[0] == "web-stories") { $meta_title = $tagName." Web Stories - Amarujala.com"; $meta_description = "Find here the latest ". $tagName ." amp web stories at Amarujala.com."; $meta_keywords = $tagName . " web stories, " . $tagName . " amp stories, ". $tagName ." google amp web stories, ". $tagName ." amp web stories"; $og_title = $meta_title; $twitter_title = $og_title; $og_description = $meta_description; $twitter_description = $og_description; $amphtml_url = ''; $og_title_seo = $og_title; } //meta for landing category/location page of podcast if (isset($slugParts[0]) && $slugParts[0] == "podcast") { $meta_title = "Podcasts " . $tagName . " News: Listen Online ". $tagName ." Audio News in Hindi, ".$cat_title_hn."  ! ? / K ( M / B ["; $meta_description = $tagName ." Audio News in Hindi - Listen online breaking ". $tagName ." podcast news, latest ". $tagName ." audio news ( ".$cat_title_hn."  ! ? / K ( M / B [) updates today on Amar Ujala Podcasts."; $meta_keywords = $tagName ." hindi podcasts, ".$tagName ." news podcasts, ".$tagName ." audio news in hindi, ".$tagName ." audio news today, ".$tagName ." audio news updates, ".$cat_title_hn."  ! ? / K ( M / B ["; $og_title = $meta_title; $twitter_title = $og_title; $og_description = $meta_description; $twitter_description = $og_description; $amphtml_url = ''; $og_title_seo = $og_title; } } if (isset($slug) && strpos($slug, "quotes")!==false) { $meta_title = $tagName." in Hindi"; $meta_description = $tagName." in Hindi"; $meta_keywords = $tagName.", ".$tagName." in Hindi"; $og_title = $meta_title; $twitter_title = $og_title; $og_description = $meta_description; $twitter_description = $og_description; $amphtml_url = ''; $og_title_seo = $og_title; } if (isset($slug) && strpos($slug, "jokes")!=false) { $meta_title = "Jokes in Hindi, 9 ? ( M & @  A   A 2 G"; $meta_description = "Best collection of Funny jokes in Hindi, Chutkule in Hindi and Jokes of the Day"; $meta_keywords = "hindi jokes, jokes in hindi, funny jokes in hindi, hindi chutkule, husband wife jokes, teacher student jokes, short jokes, one liner jokes, majedar chutkule, love jokes, comedy jokes, hilarious jokes"; $og_title = "Jokes in Hindi, 9 ? ( M & @  A   A 2 G"; $twitter_title = "Jokes in Hindi, 9 ? ( M & @  A   A 2 G"; $og_description = "Best collection of Funny jokes in Hindi, Chutkule in Hindi"; $twitter_description = "Best collection of Funny jokes in Hindi, Chutkule in Hindi"; $amphtml_url = ''; $og_title_seo = $og_title; } //meta for homepage if ($tagName == 'home') { $tagName = ''; $og_title = "  , * >   8 , 8 G ( ? 7 M *  M 7, 5 ? 6 M 5 8 ( @ /  0 $ G   , 0 G , 8 ? 0 M +  . 0  > 2 > ! I   I . * 0 d"; $twitter_title = $og_title; $og_description = ' 9 ?  & @ . G  * >   & G 6, 5 ? & G 6,  G 2, 0 >  ( @ $ ?,  M 0 >  .,   K . K , >  2  0  M / K $ ? 7 8 G 8 . M ,  ' ? $ 8 - @  , 0 G   . 0  > 2 > * 0'; $twitter_description = $og_description; $og_title_seo = $og_title; } if (empty($footer_title)) { $footer_title = 'Stay updated with the Latest and Breaking ' . $tagName . ' news in India with Amarujala.com. Read latest and daily news updates on Crime, Business, National, Local, International, Sports, Automobile, Entertainment, Lifestyle, Jobs, Astrology, Spirituality News in Hindi' . $tagName . ' Samachar, ' . $tagName . ' Hindi Samachar, Online ' . $tagName . ' Samachar.'; } } //default meta rules where type is empty else { $search_meta = explode('/', $canonical_url); if (in_array("topic", $search_meta) || in_array("search", $search_meta)) { $tag_name = str_replace("-", " ", $slug); $meta_title = $tag_name . ': Latest Photos, Videos, News in Hindi - Amar Ujala'; $meta_description = $tag_name . ' latest and breaking news in hindi: explore more photos, videos and hindi news about ' . $tag_name . ' online at Amarujala.'; $meta_keywords = $tag_name . ', ' . $tag_name . ' in Hindi, breaking news, news in hindi, hindi news'; } else { $tag_name = str_replace("-", " ", $slug); $meta_title = $tag_name . ' Hindi News, ' . $tag_name . ' News in Hindi - Amarujala.com'; $meta_description = 'Best Website to read breaking and latest ' . $tag_name . ' News in Hindi, Amar Ujala'; $meta_keywords = $tag_name . ' News in hindi, news in hindi, ' . $tag_name . ' news, latest ' . $tag_name . ' news, breaking ' . $tag_name . ' news, hindi news'; } } } if (!empty($twitter_description) && strlen($twitter_description) > 299) { $pos1 = strpos($twitter_description, ' ', 300); if ($pos1 != false) { $twitter_description = substr($twitter_description, 0, $pos1); } } if (!empty($og_description) && strlen($og_description) > 299) { $pos1 = strpos($og_description, ' ', 300); if ($pos1 != false) { $og_description = substr($og_description, 0, $pos1); } } ///// code for remove live score amp pages if (strpos($amphtml_url, '/live-cricket-score/') !== false || strpos($amphtml_url, '/basic-details') !== false || strpos($amphtml_url, '/required-details') !== false) { $amphtml_url = ''; } //add for DFP android targetion $page_detail["request_client"]= app('request')->input('client','web'); if(!empty($story["author_details"]["author_id"])){ $page_detail["author"]= $story["author_details"]["author_id"]; } $page_detail["refresh"]= "false"; //amphtml_url set blank if astrology $exp_amp_url = !empty($amphtml_url) ? explode("/", $amphtml_url):[]; if(!empty($exp_amp_url) && in_array("astrology",$exp_amp_url)){ $amphtml_url=''; } //close block amphtml_url set blank if astrology $meta_list = array( 'meta_title' => htmlspecialchars_decode(cleanSpecialString($meta_title), ENT_QUOTES), 'meta_description' => htmlspecialchars_decode(cleanSpecialString($meta_description), ENT_QUOTES), 'meta_keywords' => htmlspecialchars_decode(cleanSpecialString($meta_keywords), ENT_QUOTES), 'canonical_url' => $canonical_url, 'link_next_previous_url' => $link_next_previous_url, 'alternate_url' => $alternate_url, 'amphtml_url' => $amphtml_url, 'og_title' => cleanSpecialString($og_title), 'og_url' => $og_url, 'og_type' => $og_type, 'og_description' => htmlspecialchars_decode(cleanSpecialString($og_description), ENT_QUOTES), 'og_image' => $og_image, 'google_image' => $google_image, 'twitter_url' => $twitter_url, 'twitter_title' => cleanSpecialString($twitter_title), 'twitter_description' => htmlspecialchars_decode(cleanSpecialString($twitter_description), ENT_QUOTES), 'google_desc' => cleanSpecialString($google_desc), 'twitter_image' => $twitter_image, 'story_type' => $story_type, 'article_id' => $article_id, 'story_created_date' => $story_created_date, 'story_publish_date' => $story_publish_date, 'story_section_name' => $story_section_name, 'footer_title' => cleanSpecialString($footer_title), 'page_detail' => $page_detail, 'twitter_player' => $twitter_player, 'video_duration'=>$video_duration, 'json_image'=>$json_image, 'json_image_1600x900'=>$json_image_1600x900, 'amp_page'=>$amp_page, 'schema_story_description'=> !empty($schema_story_description) ? str_replace('\\','',$schema_story_description) : '', 'og_title_seo'=>$og_title_seo ); if (isset($memcache['key']) && !empty($meta_list)) { putDataMemcachedV1($memcache['key'], $meta_list); } return $meta_list; } /** * * @param type $request This is REQUEST object or string * @description this return key and data both */ function getMemcacheKey($args, $method, $get = false) { if (config('env.MODEL_MEMCACHED') != 1) { return false; } if (Illuminate\Support\Facades\Request::has('cache_clear')) { $get = false; } $key = [$method . config('env.MEMCACHED_PREFIX')]; foreach ($args as $dd) { if (!is_object($dd)) { $key[] = $dd; } } $data['key'] = md5(json_encode($key)); $data['data'] = []; if ($get) { $data['data'] = Cache::store('redis_model')->get($data['key'], false); if (isset($data['data']['data']) && !empty($data['data']['data'])) { if ($data['data']['collect'] == 1) { $data['data'] = collect($data['data']['data']); } else { $data['data'] = $data['data']['data']; } } else { $data['data'] = null; } } return $data; } /** * * @param type $key memcached key * @param type $value this may be any data type */ function putDataMemcached($key, $value, $expire = null) { if (empty($expire)) { $expire = config('env.MEMCACHED_TIME', 5); } if (is_object($value) && !empty($value)) { $result['collect'] = 1; $result['data'] = $value->toArray(); } else { $result['collect'] = 0; $result['data'] = $value; } if ($key && !empty($result)) { Cache::store('redis_model')->put($key, $result, $expire); } } function getRelatedStoriesByType($data, $type, $take = 5, $skip = 0) { $elastic1 = new elastic(); $res = $res1 = $res2 = $res3 = $res4 = $res5 = $return = $tag_related_list = array(); $related_location = isset($data['geo_scope'][0]['slug']) ? $data['geo_scope'][0]['slug'] : null; $related_tag = isset($data['tags']) ? $data['tags'] : null; $related_cat = isset($data['category']['slug']) ? $data['category']['slug'] : null; $related_list = isset($data['related_news']) ? $data['related_news'] : null; $stories = array(); $story_get_src = null; //get stories by related stories ids if (count($related_list) > 0) { $stories = Story::getStoryByIds($related_list); if (!empty($stories)) { $res1 = getStoriesByType($stories, $type); } } if (count($res1) < $take) { $extra_story_count = $take - count($res1); $res1 = is_array($res1) ? collect($res1) : $res1; //get stories by tag if (count($related_tag) > 0) { $options['is_flag'] = true; //$tag_related_list = $elastic1->searchByFieldsByArray('auw', 'story', ['tags' => $related_tag], 0, $extra_story_count, 'updated_at', 'desc', 'publish', $options)['data']; $tag_related_list = $elastic1->searchByNestedFields('auw', 'story', ['tags' => $related_tag[0]], 0, $extra_story_count, 'updated_at', 'desc', $options); $tag_related_list = $tag_related_list['data']; if (!empty($tag_related_list)) { $res2 = getStoriesByType($tag_related_list, $type); } if (is_object($res1)) { $res1 = $res1->merge($res2); } } if (count($res1) < $take) { $extra_story_count = $take - count($res1); //get stories by category slug $exception_category = Category::$exception_category; if ($type == 'video') {//for video story always look for parent cat slug $category_list = Category::getCategoryBySlug($related_cat, true); $parent_id = isset($category_list['parent_id']) ? $category_list['parent_id'] : null; if (empty($category_list['parent_id'])) { $parent_id = $category_list['_id']; } $category_list = Category::getCategoryById($parent_id); $parent_slug = isset($category_list['slug']) ? $category_list['slug'] : null; $related_category_news = Story::getStoryListByCategorySlug($parent_slug, null, $type, $skip, $extra_story_count); } elseif (in_array($related_cat, $exception_category)) { $related_category_news = Story::getStoryListByCategorySlug($related_cat, null, $type, $skip, $extra_story_count); } else { $category_list = Category::getCategoryBySlug($related_cat, true); $parent_id = isset($category_list['parent_id']) ? $category_list['parent_id'] : null; if ($parent_id == 0) { $parent_id = $category_list['_id']; } else { $parent_id = null; } //$parent_id $related_category_news = Story::getStoryListByCategorySlug($related_cat, $parent_id, $type, $skip, $extra_story_count); if (empty($related_category_news)) { $related_category_news = Story::getStoryListByLocationSlug(null, $related_location, $type, $skip, $extra_story_count); } } $related_category_news = is_object($related_category_news) ? $related_category_news->toArray() : $related_category_news; if (is_object($res1)) { $res1 = $res1->merge($related_category_news); } } } ////get recent news if no news found in the same category if (count($res1) < $take) { $extra_story_count = $take - count($res1); $related_type = Story::getTopNewsByType($type, null, $skip, $extra_story_count); if (is_object($res1)) { $res1 = $res1->merge($related_type); } } $res1 = is_object($res1) ? $res1->toArray() : $res1; $count_related_story = count($res1); if ($count_related_story > $take) { $res1 = array_slice($res1, 0, $take); } $return['data'] = $res1; return $return; } function getStoriesByType($stories, $type) { $storyDt = []; $photoDt = []; $videoDt = []; foreach ($stories as $item) { if (isset($item['type'])) { switch ($item['type']) { case 'story': case 'feature-story': case 'live': $storyDt[] = $item; break; case 'photo-gallery': $photoDt[] = $item; break; case 'video': $videoDt[] = $item; break; } } } $return = array(); if ($type == 'video') { return $return = $videoDt; } elseif ($type == 'photo-gallery') { return $return = $photoDt; } else { return $return = $storyDt; } } /** * Removing al special char */ function cleanString($string = '') { $except = ['*', '&', '%', '/', '[', ']', ';', '\'', '~', '^', '}', '{', '<', '#', '$', ')', '(', ':']; return str_replace($except, '', $string); // return $string; //echo $string=iconv("UTF-8","UTF-8//IGNORE",$string); //$string = preg_replace('/[^A-Za-z0-9 - 3 - \ ]/', '', $string); // Removes special chars. //return preg_replace('/ +/', ' ', $string); // Replaces multiple hyphens with single one. } function clientPropertyDetails($options = false) { if (empty($options['client_id']) || empty($options['property_id'])) { $data['client_id'] = config('env.CLIENT_ID', 0); $data['property_id'] = config('env.PROPERTY_ID', 0); } else { $data['client_id'] = $options['client_id']; $data['property_id'] = $options['property_id']; } return $data; } function getImageFilePath($folder_name = 'spider_form_amc16') { $folder_name = custom_slug($folder_name); $img_path = public_path('assets/dyn_form/' . $folder_name . '/') . date('Y') . '/' . date('m') . '/' . date('d') . '/'; if (!is_dir($img_path)) { mkdir($img_path, 0777, true); } return $img_path; } function createDirecory($path) { //$folder_name = custom_slug($folder_name); $dir = public_path($path); if (!is_dir($dir)) { mkdir($dir, 0755, true); } chmod($dir, 0755); return $dir; } //this remove html attribute function strip_attribute_tags($html_text) { // $html_text = preg_replace('/<br style[^>]*>/', ' ', $html_text); // $html_text = preg_replace('/<p style[^>]*>/', ' ', $html_text); // $html_text = preg_replace('/<strong style[^>]*>/', ' ', $html_text); // return $html_text; $html = preg_replace("/<([a-z][a-z0-9]*)[^>]*?(\/?)>/i", '<$1$2>', $html_text); return $html; } //this romove html attribute /** * * @param type $name banner name * @return type banner details on the basis of name * @method pagepusher_advt */ function pagepusher_advt($name = 'pagepusher',$options = []) { $pagePusher = Banner::getBannerByName($name, false,$options); return $pagePusher; } /** * * @param type $name banner name * @return type banner details on the basis of name * @method */ function getBannerByBannerSlug($slug = '') { return Banner::getBannerBySlug($slug, false); } /** * @param type $slug * @return type * @description return all story which are navigated in provided section */ function getStoryBySectionSlug($slug = '', $count = 4) { $news_list = []; if (!empty($slug)) { $section_data = Section::getSectionBySlug($slug); if (isset($section_data['_id'])) { $news_list = getContentPriorityStoriesBySectionId($section_data['_id'], $count); } } return $news_list; } /* Get News Flash data form the section st */ function getRecommendedNews($id) { $news_recommendation_section = Section::getSectionBySlug('news-recommendation'); $newsList = array(); $exclude_article = array(); $news_flash_data = array(); if (count($news_recommendation_section) > 0) { $newsList = getContentPriorityStoriesBySectionId($news_recommendation_section['_id'], 10); $newsList = is_object($newsList) ? $newsList->toArray() : $newsList; } $exclude_article = Story::getStoryById($id); if (is_array($newsList) && count($newsList) > 0) { if ($newsList[0]['slug'] === $exclude_article['slug']) { shuffle($newsList); return $newsList[0]; } else { shuffle($newsList); return $newsList[0]; } } } /* Get News Flash data form the section Cl */ /* story breadcrumbs list st */ function getBreadCrumbList($story_details, $page = []) { $bread_crumb = []; //$home = ['slug' => '', 'title' => 'Home', 'title_hn' => ' 9 K .']; $home = home_bread_crumb(); array_push($bread_crumb, $home); if (!empty($page)) { array_push($bread_crumb, $page); } $bread_crumb_category = ['crime', 'campus', 'bashindey']; $bread_crumb_scope = ['national', 'international']; $geo_scope_slug = isset($story_details['geo_scope'][0]['slug']) ? $story_details['geo_scope'][0]['slug'] : null; if (!empty($geo_scope_slug) && !in_array($geo_scope_slug, $bread_crumb_scope)) { if (isset($story_details['geo_scope'][0]['_id']) && isset($story_details['geo_scope'][0]['parent_id']) && !empty($story_details['geo_scope'][0]['parent_id']) && ($story_details['geo_scope'][0]['parent_id']!=$story_details['geo_scope'][0]['_id'])) { $location = Location::getLocationById($story_details['geo_scope'][0]['parent_id']); $parent_title_seo = isset($location['title_seo']) ? $location['title_seo'] : null; if (!empty($parent_title_seo)) { $parent_title = $parent_title_seo; } else { $parent_title = isset($location['title']) ? $location['title'] : null; } $parent_title_hn = isset($location['title_hn']) ? $location['title_hn'] : null; $loc_slug = isset($location['full_slug']) ? $location['full_slug'] : null; $parent_loc = ['title' => $parent_title, 'title_hn' => $parent_title_hn, 'slug' => $loc_slug]; array_push($bread_crumb, $parent_loc); $current_loc_title_seo = isset($story_details['geo_scope'][0]['title_seo']) ? $story_details['geo_scope'][0]['title_seo'] : null; if (!empty($current_loc_title_seo)) { $current_loc_title = $current_loc_title_seo; } else { $current_loc_title = isset($story_details['geo_scope'][0]['title']) ? $story_details['geo_scope'][0]['title'] : null; } $current_loc_title_hn = isset($story_details['geo_scope'][0]['title_hn']) ? $story_details['geo_scope'][0]['title_hn'] : null; $current_loc_slug = isset($story_details['geo_scope'][0]['full_slug']) ? $story_details['geo_scope'][0]['full_slug'] : null; $current_loc = ['title' => $current_loc_title, 'title_hn' => $current_loc_title_hn, 'slug' => $current_loc_slug]; array_push($bread_crumb, $current_loc); } else { $current_loc_title_seo = isset($story_details['geo_scope'][0]['title_seo']) ? $story_details['geo_scope'][0]['title_seo'] : null; if (!empty($current_loc_title_seo)) { $current_loc_title = $current_loc_title_seo; } else { $current_loc_title = isset($story_details['geo_scope'][0]['title']) ? $story_details['geo_scope'][0]['title'] : null; } $current_loc_title_hn = isset($story_details['geo_scope'][0]['title_hn']) ? $story_details['geo_scope'][0]['title_hn'] : null; $current_loc_slug = isset($story_details['geo_scope'][0]['full_slug']) ? $story_details['geo_scope'][0]['full_slug'] : null; $current_loc = ['title' => $current_loc_title, 'title_hn' => $current_loc_title_hn, 'slug' => $current_loc_slug]; array_push($bread_crumb, $current_loc); } } else { if (isset($story_details['category']['parent_id']) && !empty($story_details['category']['parent_id']) && isset($story_details['category']['_id']) && ($story_details['category']['parent_id']!=$story_details['category']['_id']) ) { $bread_category = Category::getCategoryById($story_details['category']['parent_id']); $parent_title_seo = isset($bread_category['title_seo']) ? $bread_category['title_seo'] : null; if (!empty($parent_title_seo)) { $parent_title = $parent_title_seo; } else { $parent_title = isset($bread_category['title']) ? $bread_category['title'] : null; } $parent_title_hn = isset($bread_category['title_hn']) ? $bread_category['title_hn'] : null; $cat_slug = isset($bread_category['full_slug']) ? $bread_category['full_slug'] : null; $parent_cat = ['title' => $parent_title, 'title_hn' => $parent_title_hn, 'slug' => $cat_slug]; array_push($bread_crumb, $parent_cat); $current_cat_title_seo = isset($story_details['category']['title_seo']) ? $story_details['category']['title_seo'] : null; if (!empty($current_cat_title_seo)) { $current_cat_title = $current_cat_title_seo; } else { $current_cat_title = isset($story_details['category']['title']) ? $story_details['category']['title'] : null; } $current_cat_title_hn = isset($story_details['category']['title_hn']) ? $story_details['category']['title_hn'] : null; $current_cat_slug = isset($story_details['category']['full_slug']) ? $story_details['category']['full_slug'] : null; $current_cat = ['title' => $current_cat_title, 'title_hn' => $current_cat_title_hn, 'slug' => $current_cat_slug]; array_push($bread_crumb, $current_cat); } else { $current_cat_title_seo = isset($story_details['category']['title_seo']) ? $story_details['category']['title_seo'] : null; if (!empty($current_cat_title_seo)) { $current_cat_title = $current_cat_title_seo; } else { $current_cat_title = isset($story_details['category']['title']) ? $story_details['category']['title'] : null; } $current_cat_title_hn = isset($story_details['category']['title_hn']) ? $story_details['category']['title_hn'] : null; $current_cat_slug = isset($story_details['category']['full_slug']) ? $story_details['category']['full_slug'] : null; $current_cat = ['title' => $current_cat_title, 'title_hn' => $current_cat_title_hn, 'slug' => $current_cat_slug]; array_push($bread_crumb, $current_cat); } } $current_section = array(); if(!empty($story_details['podcast_show'])){ $show_section_details = getSectionBySlug($story_details['podcast_show']); $cat_full_slug = isset($show_section_details['categories']) && count($show_section_details['categories'])>0 ? $show_section_details['categories'][0]['full_slug'].'/':""; $current_section = ['title' => $show_section_details['title'], 'title_hn' => $show_section_details['title_hn'], 'slug' => 'podcast/'.$cat_full_slug.$show_section_details['slug']]; array_push($bread_crumb, $current_section); } $story_title_hn = isset($story_details['title_hn']) ? $story_details['title_hn'] : null; $story_title = !empty($story_details['title']) ? $story_details['title'] : $story_title_hn; $story_slug = isset($story_details['full_slug']) ? $story_details['full_slug'] : null; $story_type = isset($story_details['type']) ? $story_details['type'] : null; $bread_story = ['slug' => $story_slug, 'title' => $story_title, 'title_hn' => $story_title_hn, 'type' => $story_type]; array_push($bread_crumb, $bread_story); return $bread_crumb; } /* story breadcrumbs list cl */ /* Location breadcrumbs list st */ function getLocationBreadCrumbList($location = []) { $bread_crumb = []; //$home = ['slug' => '', 'title' => 'Home', 'title_hn' => ' 9 K .']; // $home = ['slug' => '', 'title' => 'Home', 'title_hn' => ' 9 K .']; // Updated on 21st Jan 2022 with respect to trello card // https://trello.com/c/Lp54eZYj/2871-replace-home-with-hindi-news-across-website-in-breadcrumb-path $home = home_bread_crumb(); array_push($bread_crumb, $home); if (isset($location['_id']) && isset($location['parent_id']) && !empty($location['parent_id']) && $location['parent_id']!= $location['_id']) { $parent_location = Location::getLocationById($location['parent_id']); if (empty($parent_location)) { $parent_location = Category::getCategoryById($location['parent_id']); } $parent_title_seo = isset($parent_location['title_seo']) ? $parent_location['title_seo'] : null; if (!empty($parent_title_seo)) { $parent_title = $parent_title_seo; } else { $parent_title = isset($parent_location['title']) ? $parent_location['title'] : null; } $parent_title_hn = isset($parent_location['title_hn']) ? $parent_location['title_hn'] : null; $loc_slug = isset($parent_location['full_slug']) ? $parent_location['full_slug'] : null; $parent_loc = ['title' => $parent_title, 'title_hn' => $parent_title_hn, 'slug' => $loc_slug]; array_push($bread_crumb, $parent_loc); $current_loc_title_seo = isset($location['title_seo']) ? $location['title_seo'] : null; if (!empty($current_loc_title_seo)) { $current_loc_title = $current_loc_title_seo; } else { $current_loc_title = isset($location['title']) ? $location['title'] : null; } $current_loc_title_hn = isset($location['title_hn']) ? $location['title_hn'] : null; $current_loc_slug = isset($location['full_slug']) ? $location['full_slug'] : null; $current_loc = ['title' => $current_loc_title, 'title_hn' => $current_loc_title_hn, 'slug' => $current_loc_slug]; array_push($bread_crumb, $current_loc); } else { $current_loc_title_seo = isset($location['title_seo']) ? $location['title_seo'] : null; if (!empty($current_loc_title_seo)) { $current_loc_title = $current_loc_title_seo; } else { $current_loc_title = isset($location['title']) ? $location['title'] : null; } $current_loc_title_hn = isset($location['title_hn']) ? $location['title_hn'] : null; $current_loc_slug = isset($location['full_slug']) ? $location['full_slug'] : null; $current_loc = ['title' => $current_loc_title, 'title_hn' => $current_loc_title_hn, 'slug' => $current_loc_slug]; array_push($bread_crumb, $current_loc); } return $bread_crumb; } /* story breadcrumbs list cl */ function getSectionBySlug($slug = null) { $section_detail = []; if (!empty($slug)) { $section_detail = Section::getSectionBySlug($slug); } return $section_detail; } function mini_score_card($matchName = null) { $match_toss_details = ""; $match_time = ""; $batting_team_tinitial = ""; $total_runs = ""; $total_wickets = ""; $total_overs = ""; $matchid = ""; $match_short_slug = ""; $match_tinitial = []; $match_title = ""; $curl_url = config('env.CRIC_API_URL', 'https://www.amarujala.com/cricket/mini-scorecards'); $curl_result = curlRequest($curl_url, null, false); if (!empty($curl_result)) { foreach ($curl_result["microscorecard_data_items"] as $key => $val) { $match_tinitial = array(strtolower($val["batting_team_tinitial"]), strtolower($val["bowling_team_tinitial"])); if (in_array(strtolower($matchName), $match_tinitial)) { $match_title_short_slug = explode("-", isset($val["match_title_short"]) ? $val["match_title_short"] : ''); $match_time = isset($val["match_time"]) ? $val["match_time"] : ''; $match_toss_details = isset($val["match_toss_details"]) ? strtolower($val["match_toss_details"]) : ''; $batting_team_tinitial = isset($val["batting_team_tinitial"]) ? $val["batting_team_tinitial"] : ''; $total_runs = isset($val["total_runs"]) ? $val["total_runs"] : ''; $total_wickets = isset($val["total_wickets"]) ? $val["total_wickets"] : ''; $total_overs = isset($val["total_overs"]) ? $val["total_overs"] : ''; $matchid = isset($val["matchid"]) ? $val["matchid"] : ''; $match_short_slug = isset($match_title_short_slug[1]) ? $match_title_short_slug[1] : ''; $match_title = isset($val['match_title']) ? $val['match_title'] : ''; } else { if ($key == 0) { $match_title_short_slug = explode("-", isset($val["match_title_short"]) ? $val["match_title_short"] : ''); $match_time = isset($val["match_time"]) ? $val["match_time"] : ''; $match_toss_details = isset($val["match_toss_details"]) ? strtolower($val["match_toss_details"]) : ''; $batting_team_tinitial = isset($val["batting_team_tinitial"]) ? $val["batting_team_tinitial"] : ''; $total_runs = isset($val["total_runs"]) ? $val["total_runs"] : ''; $total_wickets = isset($val["total_wickets"]) ? $val["total_wickets"] : ''; $total_overs = isset($val["total_overs"]) ? $val["total_overs"] : ''; $matchid = isset($val["matchid"]) ? $val["matchid"] : ''; $match_short_slug = isset($match_title_short_slug[1]) ? $match_title_short_slug[1] : ''; $match_title = isset($val['match_title']) ? $val['match_title'] : ''; } } } } $data = [ 'match_toss_details' => $match_toss_details, 'match_time' => $match_time, 'batting_team_tinitial' => $batting_team_tinitial, 'total_runs' => $total_runs, 'total_wickets' => $total_wickets, 'total_overs' => $total_overs, 'matchid' => $matchid, 'match_short_slug' => $match_short_slug, 'match_title' => $match_title ]; $return = $data; return $return; } function getSectionTitleUrl($title_str, $url_str) { $result = []; $title_arr = explode('##', $title_str); $url_arr = explode(',', $url_str); foreach ($title_arr as $key => $title) { $data['title'] = $title; $data['url'] = isset($url_arr[$key]) ? $url_arr[$key] : '#'; $result[] = $data; } return $result; } /** * * @param type $story_details * @param type $url is urldecode($request->path()) and $story_details is story or category data which contain slug and full slug */ function validateSlug($story_details, $url) { if ((isset($story_details["slug"]) && !empty(custom_slug($story_details["slug"]))) && isset($story_details["full_slug"]) && ltrim($story_details["full_slug"], '/') != urldecode($url)) { return true; } else { return false; } } /** * * @param type $user_id user id entity id * @param type $number number of record default 6 * @return type stoty list */ function getRecommendedStories($search, $user_id, $number = 6) { $return = []; $engineClient = new EngineClient(config('env.ENGINE_URL', 'http://engine.amarujala.com/'), 5, 5); $query['num'] = $number; $query['blacklistItems'] = [$user_id]; $query['currentDate'] = date(DATE_ISO8601, strtotime("- 12 hours")); $query = array_merge($search, $query); $response = $engineClient->sendQuery($query); if (isset($response['itemScores']) && count($response['itemScores']) == 0) { $query['currentDate'] = date(DATE_ISO8601, strtotime("- 72 hours")); $response = $engineClient->sendQuery($query); } if (isset($response['itemScores']) && count($response['itemScores']) > 0) { $response = array_column($response['itemScores'], 'item'); if (count($response) > 0) { //$response=['57e09a944f1c1b8341a8233b','573397014f1c1bb54d919acc','5733980c4f1c1b3741919fb0','57e06f004f1c1b223aa839f5','57e068c04f1c1bde40a824bb']; $return = Story::getStoryByIds($response); } } return $return; } function fullScheduleByDate($menu_list = []) { $return = []; if (!empty($menu_list)) { if (is_array($menu_list)) { foreach ($menu_list as $item) { $key = strtotime(date('Y-m-d', strtotime($item['link']))); $return[$key][] = $item; } } } asort($return); return $return; } function generateUrl($scheme, $uri) { if ($scheme == 'https') { $url = secure_url($uri); } else { $url = url($uri); } return $url; } function location_dd($list) { $return = []; if (count($list) > 0) { foreach ($list as $value) { $return[$value['slug']] = $value['name_hn']; } return $return; } } function setMaxMinPage($page_no = 1) { $max_page_no = config('env.MAX_ALLOW_PAGE', 100); if ($page_no < 0) { $page_no = 1; } elseif ($page_no >= $max_page_no) { $page_no = $max_page_no; } return $page_no; } function getHotNews($count = 40) { $hot_news = []; $hot_news = StoryAnalytics::getTrandingStory([], '12hours', 0, $count, [], 'created_at'); return $hot_news; } function getTimeAgo($story_date) { $seconds = time() - (strtotime($story_date)); $days = floor($seconds / 86400); if ($days > 0) { return $days . ' d'; } $seconds %= 86400; $hours = floor($seconds / 3600); if ($hours > 0) { return $hours . ' hr'; } $seconds %= 3600; $minutes = floor($seconds / 60); if ($minutes > 0) { return $minutes . ' min'; } $seconds %= 60; if ($seconds > 0) { return $seconds . ' s'; } } function getSlugInfoBySlug($slug) { $slug_info = null; if (isset($slug) && !empty($slug)) { $slugParts = explode("/", rtrim($slug, '/')); $slugLastPart = $slugParts[count($slugParts) - 1]; $slug_details = Slug::getSlugBySlug($slugLastPart); $slug_info = isset($slug_details) ? $slug_details : null; } return $slug_info; } function getBannerBySlug($page_slug = null, $type = null, $city_slug = null,$banner_category=null) { $page_slug = $page_slug . "-banner-top"; $city_slug = $city_slug . "-banner-top"; $top_promotional_banner = []; $page_banner_value = []; $pagePusher =[]; $page_name_pusher=[]; $page_banner_value = Banner::getBannerBySlug($city_slug); if (empty($page_banner_value)) { $page_banner_value = Banner::getBannerBySlug($page_slug); } $page_banner_val = isset($page_banner_value["page_name"]) ? strtolower($page_banner_value["page_name"]) : ''; $page_banner_value_arr = (explode(",", $page_banner_val)); if (isset($page_banner_value_arr) && (in_array($city_slug, $page_banner_value_arr))) { $top_promotional_banner = $page_banner_value; } elseif (isset($page_banner_value_arr) && (in_array($type, $page_banner_value_arr))) { $top_promotional_banner = $page_banner_value; } else { //$top_promotional_banner = pagepusher_advt('home-promotional-banner-top'); //if(trim($type)=="page"){ $pagePusher = Banner::getBannerBySlug($banner_category.'-banner-top'); //} if(empty($pagePusher)){ $pagePusher = pagepusher_advt('home-promotional-banner-top'); } if(isset($pagePusher['page_name'])){ $page_name_pusher = (explode(",", strtolower($pagePusher['page_name']))); } if(isset($pagePusher['page_name']) && strtolower($pagePusher['page_name'])=="all"){ $top_promotional_banner = $pagePusher; //pagepusher_advt('home-promotional-banner-top'); }else{ if(isset($banner_category) && (in_array($banner_category, $page_name_pusher))){ $top_promotional_banner = $pagePusher; //pagepusher_advt('home-promotional-banner-top'); } } // print_r($top_promotional_banner); // dd($banner_category); } return $top_promotional_banner; } function validateDate($date, $format = 'Y-m-d H:i:s') { $d = DateTime::createFromFormat($format, $date); return $d && $d->format($format) == $date; } function date_in_hour_format($value) { $obj = new Carbon; $formatedDate = $obj->parse($value)->diffForHumans(); return $formatedDate; } function numberHumanFormat($number) { $return = (int) $number; if ((int) $number > 1000) { $return = round(($number / 1000), 1) . "K"; } return $return; } function getRequestHeader($header_name = null) { $header = null; if (empty($header_name)) { $header = app('request')->header(); } else { $header = app('request')->header(strtolower($header_name)); } return $header; } function convert_menu_to_category($menu_array) { $sub_menu_item_list = array(); if (!empty($menu_array) && count($menu_array) > 0) { $sub_menu_item_list = $menu_array; foreach ($sub_menu_item_list as $key => $item) { $explode_slug = explode("/", $item["link"]); $slug = isset($explode_slug) ? $explode_slug[count($explode_slug) - 1] : null; $sub_menu_item_list[$key]['title'] = $item["titles"]; $sub_menu_item_list[$key]['title_hn'] = $item["titles"]; $sub_menu_item_list[$key]['full_slug'] = $item["link"]; if (isset($item['type']) && $item['type'] != 'new-tab') { $sub_menu_item_list[$key]['link'] = null; } $sub_menu_item_list[$key]['slug'] = $slug; } } return $sub_menu_item_list; } // clean &zwnj; from string function cleanSpecialString($str) { return $text = preg_replace('/[\x{200B}-\x{200D}]/u', '', $str); } function commonCurl($url, $value, $http_header = false, $request_type = "GET",$timeout=5) { $ch = curl_init(); //GET or POST request method curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request_type); //set url to fetch data curl_setopt($ch, CURLOPT_URL, $url); //TRUE to return the transfer as a string of the return value curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); //maximum number of seconds to allow cURL functions to execute. curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); if (!empty($http_header)) { //curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json")); //An array of HTTP header fields curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header); } if (!empty($value)) { if (is_array($value)) { //if array is set in $value, it will be parsed in query string. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($value)); } else { //if json data is set in $value curl_setopt($ch, CURLOPT_POSTFIELDS, $value); } } $results = curl_exec($ch); if ($results == false) { Log::info("commonCurl() curlRequest " . curl_error($ch) . " curlRequestURl " . $url); } curl_close($ch); return $results; } function custom_str_slug($search_text = null) { if (empty($search_text)) { return ''; } $search_text = cleanSpecialString($search_text); $search_text = !empty($search_text) ? strtolower(trim($search_text)) : ''; // preg replace used instead of str replace to // handle multiple white spaces $search_text = preg_replace('/\s+/', '-', $search_text); return $search_text; } function human_to_seconds($time) { if (empty($time)) { return 0; } $return_time = 0; $time_array = explode(':', $time); $count = count($time_array); if ($count > 0) { for ($i = 0; $i < $count; $i++) { $return_time += (int) $time_array[$count - $i - 1] * (pow(60, $i)); } } return $return_time; } /* * Check for availability of multiple fields in an array * function will return value of only one field in sequence order * * @param1 : the array in which fields are to be checked * @param2 : array of field names in order of priority * or single field name with param3 passed * @param3 : optional field name, $param1[$param3] will be returned when $param1[$param2] is not available */ function getAlternateFields($data = null, $field1 = null, $field2 = null) { if (empty($data) || empty($field1)) { return ''; } if (is_array($field1)) { foreach ($field1 as $field_name) { if (isset($data[$field_name]) && !empty($data[$field_name])) { return cleanSpecialString($data[$field_name]); } } return ''; } else { if (isset($data[$field1]) && !empty($data[$field1])) { return cleanSpecialString($data[$field1]); } if (!empty($field2) && isset($data[$field2]) && !empty($data[$field2])) { return cleanSpecialString($data[$field2]); } return ''; } } function fixture($tournamentid) { $match_data = Cache::get('ipl_fixture', false); if (!$match_data) { //$json = "/var/www/AU/cricket/crid/livescore/fixtures.json"; $json = "https://api.amarujala.com/crid/livescore/fixtures_v1.json"; $match_data = file_get_contents($json); $match_data = json_decode($match_data, true); Cache::put('ipl_fixture', $match_data, 1); } $arr_count = 0; $ipl_matchs = []; foreach ($match_data as $key => $match_val) { if ($match_val['tournamentid'] == $tournamentid) { $str_mtime = strtotime($match_val['mdate']); //$curent_mdate_start = strtotime(date('y-m-d')." 00:00"); //$curent_mdate_end = strtotime(date('y-m-d')." 23:59"); //if($str_mtime >=$curent_mdate_start){ $m_name = explode("-", $match_val['mname']); $m_city_val = explode(",", $match_val['mvenue']); $m_city = $m_city_val[count($m_city_val) - 1]; $ipl_matchs[$arr_count] = $match_val; $m_name_last = array_pop($m_name); $ipl_matchs[$arr_count]['m_number'] = isset($m_name) ? implode('-', $m_name) : ''; $ipl_matchs[$arr_count]['m_name'] = isset($m_name_last) ? $m_name_last : ''; $ipl_matchs[$arr_count]['city'] = isset($m_city) ? $m_city : ''; $ipl_matchs[$arr_count]['month'] = date("F", $str_mtime); $ipl_matchs[$arr_count]['day'] = date("d", $str_mtime); $ipl_matchs[$arr_count]['match_date'] = date("d-m-Y", $str_mtime); $ipl_matchs[$arr_count]["m_name_split"] = explode(" v ", $ipl_matchs[$arr_count]['m_name']); $arr_count++; // } } } return $ipl_matchs; } function schedule_match_result($matchid) { /* schedule match result */ $matchs = []; //$res_json = "https://api.amarujala.com/crid/livescore/results.json"; $res_json = "/var/www/AU/cricket/crid/livescore/results.json"; $match_result_data = file_get_contents($res_json); $match_result_data = json_decode($match_result_data, true); foreach ($match_result_data as $match_val) { if ($match_val["matchid"] == $matchid) { $matchs["winstatus"] = $match_val["winstatus"]; } } return $matchs; } function remove_specific_tags($html, $tags, $with_content = false) { $existing_tags = getAllTagNames($html); $allowable_tags = '<' . implode('><', array_diff($existing_tags, $tags)) . '>'; return $with_content ? strip_tags_content($html, $tags) : strip_tags($html, $allowable_tags); } function strip_tags_content($text, $tags = [], $invert = false) { // print_r($tags); if (is_array($tags)) { foreach ($tags as $tag) { $text = preg_replace("/<\s?" . $tag . ".*?>.*?<\s?\/" . $tag . "\s?>/ism", "", $text); //dd("/<".$tag."(.)*>(.)*<\/".$tag.">$/im"); } } else { $text = preg_replace("/<\s?" . $tags . ".*?>.*?<\s?\/" . $tags . "\s?>/ism", "", $text); } //echo "text=".$text; return $text; } function getAllTagNames($html) { $tags = array(); $part = explode("<", $html); foreach ($part as $tag) { $chunk = explode(" ", $tag); if (empty($chunk[0]) || $chunk[0][0] == "/") continue; $tag = trim($chunk[0], " >"); if (!in_array($tag, $tags)) $tags[] = $tag; } return $tags; } function mini_score_card_v1($matchName = null) { $match_toss_details = ""; $match_time = ""; $batting_team_tinitial = ""; $total_runs = ""; $total_wickets = ""; $total_overs = ""; $matchid = ""; $match_short_slug = ""; $match_tinitial = []; $match_title = ""; $bowler_runs = ""; $res_json = 'https://api.amarujala.com/crid/livescore/Full_Miniscorecard.json'; $match_result_data = file_get_contents($res_json); $match_result_data = json_decode($match_result_data, true); /* $time = '13:59'; if (date('H:i') > date('H:i', strtotime($time))) { */ $condition = $match_result_data['dat_profile_data']['miniscorecard_data'][0]['tab_ls'][0]['tab_ls_items']; /* }else{ $condition = $match_result_data['dat_profile_data']['miniscorecard_data'][0]['tab_rs'][0]['tab_rs_items'] ; } */ if (!empty($match_result_data) && !empty($condition)) { foreach ($condition as $key => $val) { $match_tinitial = array(strtolower($val["batting_team"][0]['tinitial']), strtolower($val["bowling_team"][0]['tinitial'])); if (in_array(strtolower($matchName), $match_tinitial)) { $match_time = isset($val["mdate"]) ? $val["mdate"] : ''; $match_status = isset($val["mstatus"]) ? strtolower($val["mstatus"]) : ''; $batting_team_tinitial = isset($val["batting_team"][0]['tinitial']) ? $val["batting_team"][0]['tinitial'] : ''; $matchid = isset($val["matchid"]) ? $val["matchid"] : ''; $match_short_slug = isset($val["batting_team"][0]['tinitial']) && isset($val["bowling_team"][0]['tinitial']) ? $val["batting_team"][0]['tinitial'] . ' V ' . $val["bowling_team"][0]['tinitial'] : ''; $match_title = isset($val['mname']) ? $val['mname'] : ''; $batsman = isset($val['batsman'][0]['name_lang']) ? $val['batsman'][0]['name_lang'] : ''; $off_batsman = isset($val['off_batsman'][0]['name_lang']) ? $val['off_batsman'][0]['name_lang'] : ''; $batsman_runs = isset($val['batsman'][0]['runs']) ? $val['batsman'][0]['runs'] : ''; $off_batsman_runs = isset($val['off_batsman'][0]['runs']) ? $val['off_batsman'][0]['runs'] : ''; $batsman_balls = isset($val['batsman'][0]['balls']) ? $val['batsman'][0]['balls'] : ''; $off_batsman_balls = isset($val['off_batsman'][0]['balls']) ? $val['off_batsman'][0]['balls'] : ''; $match_text = isset($val['mstatustext']) ? $val['mstatustext'] : ''; if (isset($val["innnings_data"]) && !empty($val["innnings_data"])) { foreach ($val["innnings_data"][0]['innnings_data_items'] as $index => $items) { if (isset($items['istatus']) && strtolower($items['istatus']) == "ip" && $items['innningno'] == 1) { $total_runs = isset($items['runs']) ? $items['runs'] : 0; $total_wickets = isset($items["wickets"]) ? $items["wickets"] : 0; $total_overs = isset($items["overs"]) ? $items["overs"] : 0; $bowler_runs = 0; } else { $total_runs = isset($items['runs']) ? $items['runs'] : 0; $total_wickets = isset($items["wickets"]) ? $items["wickets"] : 0; $total_overs = isset($items["overs"]) ? $items["overs"] : 0; $bowler_runs = isset($val["innnings_data"][0]['innnings_data_items'][0]['runs']) ? $val["innnings_data"][0]['innnings_data_items'][0]['runs'] + 1 : 0; } } } } else { if ($key == 0) { $match_time = isset($val["mdate"]) ? $val["mdate"] : ''; $match_status = isset($val["mstatus"]) ? strtolower($val["mstatus"]) : ''; $batting_team_tinitial = isset($val["batting_team"][0]['tinitial']) ? $val["batting_team"][0]['tinitial'] : ''; $matchid = isset($val["matchid"]) ? $val["matchid"] : ''; /* if (date('H:i') > date('H:i', strtotime($time))) { $matchid = $matchid; }else{ $matchid = $matchid-1; } */ $match_short_slug = isset($val["batting_team"][0]['tinitial']) && isset($val["bowling_team"][0]['tinitial']) ? $val["batting_team"][0]['tinitial'] . ' V ' . $val["bowling_team"][0]['tinitial'] : ''; $match_title = isset($val['mname']) ? $val['mname'] : ''; $batsman = isset($val['batsman'][0]['name_lang']) ? $val['batsman'][0]['name_lang'] : ''; $off_batsman = isset($val['off_batsman'][0]['name_lang']) ? $val['off_batsman'][0]['name_lang'] : ''; $batsman_runs = isset($val['batsman'][0]['runs']) ? $val['batsman'][0]['runs'] : ''; $off_batsman_runs = isset($val['off_batsman'][0]['runs']) ? $val['off_batsman'][0]['runs'] : ''; $batsman_balls = isset($val['batsman'][0]['balls']) ? $val['batsman'][0]['balls'] : ''; $off_batsman_balls = isset($val['off_batsman'][0]['balls']) ? $val['off_batsman'][0]['balls'] : ''; $match_text = isset($val['mstatustext']) ? $val['mstatustext'] : ''; if (isset($val["innnings_data"]) && !empty($val["innnings_data"])) { foreach ($val["innnings_data"][0]['innnings_data_items'] as $index => $items) { if (isset($items['istatus']) && strtolower($items['istatus']) == "ip" && $items['innningno'] == 1) { $total_runs = isset($items['runs']) ? $items['runs'] : 0; $total_wickets = isset($items["wickets"]) ? $items["wickets"] : 0; $total_overs = isset($items["overs"]) ? $items["overs"] : 0; $bowler_runs = 0; } else { $total_runs = isset($items['runs']) ? $items['runs'] : 0; $total_wickets = isset($items["wickets"]) ? $items["wickets"] : 0; $total_overs = isset($items["overs"]) ? $items["overs"] : 0; $bowler_runs = isset($val["innnings_data"][0]['innnings_data_items'][0]['runs']) ? $val["innnings_data"][0]['innnings_data_items'][0]['runs'] + 1 : 0; } } } } } } } $data = [ 'match_status' => $match_status, 'match_time' => $match_time, 'batting_team_tinitial' => $batting_team_tinitial, 'total_runs' => $total_runs, 'total_wickets' => $total_wickets, 'total_overs' => $total_overs, 'matchid' => $matchid, 'match_short_slug' => $match_short_slug, 'match_title' => $match_title, 'batsman' => $batsman, 'off_batsman' => $off_batsman, 'batsman_runs' => $batsman_runs, 'off_batsman_runs' => $off_batsman_runs, 'batsman_balls' => $batsman_balls, 'off_batsman_balls' => $off_batsman_balls, 'match_text' => $match_text, 'bowler_runs' => $bowler_runs ]; $return = $data; return $return; } function miniScorecardV2($match_name = null) { $match_result_data = $completed_match_data = []; $live_match_key = 'livematch_es'; //check match data available in redis then return result from redis if(Redis::exists($live_match_key)){ $livematch_es= Redis::get($live_match_key); //Log::info('get data from Redis- key=='.$live_match_key.PHP_EOL.'data'.$livematch_es); $match_result_data = json_decode($livematch_es,true); }else{ $live_scorcard_json = config('env.API_URL') . 'crid/livescore/livematch_es'; $match_result_data = json_decode(commonCurl($live_scorcard_json,null),true); $match_result_data=isset($match_result_data['data']) && !empty($match_result_data['data'])?$match_result_data['data']:[]; } if(empty($match_result_data)){ $live_scorcard_json = config('env.API_URL') . 'crid/livescore/livematch_es.json'; $match_result_data = json_decode(commonCurl($live_scorcard_json,null),true); } if (isset($match_result_data) && count($match_result_data) > 0) { if (array_key_exists($match_name, $match_result_data)) { $match_result_data = isset($match_result_data[$match_name]['status']) && $match_result_data[$match_name]['status'] == 3 ? $match_result_data[$match_name] : getCompletedMatchData($match_name, $match_result_data); } else { $match_result_data = getCompletedMatchData($match_name, $match_result_data); } $players_details = isset($match_result_data['players']) ? $match_result_data['players'] : ''; $batsman_details = isset($match_result_data['batsmen']) ? $match_result_data['batsmen'] : ''; if (!empty($players_details) && !empty($batsman_details)) { foreach ($players_details as $pvalue) { if (isset($batsman_details[0]) && isset($batsman_details[0]['batsman_id']) && $pvalue['pid'] == $batsman_details[0]['batsman_id']) { $batsman_name = isset($pvalue['title']) ? $pvalue['title'] : ''; } if (isset($batsman_details[1]) && isset($batsman_details[1]['batsman_id']) && $pvalue['pid'] == $batsman_details[1]['batsman_id']) { $off_batsman_name = isset($pvalue['title']) ? $pvalue['title'] : ''; } } } } $data = [ 'batsman_name' => isset($batsman_name) ? $batsman_name : '', 'off_batsman_name' => isset($off_batsman_name) ? $off_batsman_name : '', 'match_result_data' => $match_result_data ]; return $data; } /* purpose - to display completed match data on home page cricket mini-scorecard widget */ function getCompletedMatchData($match_id = null, $match_result_data = []) { if(!empty($match_id)){ $live_match_key = $match_id; //check match data available in redis then return result from redis if(Redis::exists($live_match_key)){ $livematch_es= Redis::get($live_match_key); //Log::info('get data from Redis- key=='.$live_match_key.PHP_EOL.'data'.$livematch_es); $match_result_data = json_decode($livematch_es,true); }else{ $live_scorcard_json =config('env.API_URL').'crid/full-scorecard/'.$match_id; $match_result_data=json_decode(commonCurl($live_scorcard_json,null),true); $match_result_data=isset($match_result_data['data']) && !empty($match_result_data['data'])?$match_result_data['data']:[]; } if(empty($match_result_data)){ $live_scorcard_json = config('env.API_URL') . 'crid/full-scorecard/' . $match_id. '.json'; // if(remoteFileExists($live_scorcard_json)){ $match_result_data=json_decode(commonCurl($live_scorcard_json,null),true); //isset($match_result_data['message'])&&$match_result_data['message']=="data not found"?abort(404):[]; // } } if(!empty($match_result_data) && count($match_result_data) >0){ $match_result_data = isset($match_result_data['response']) && !empty($match_result_data['response']) ? $match_result_data['response'] : []; } }else{ $match_result_data = isset($match_result_data) && count($match_result_data) > 0 ? array_splice($match_result_data, 0, 1) : []; $match_result_data = isset($match_result_data[0]) ? $match_result_data[0] : []; } //change status =2 for completed match $match_result_data['status'] = 2; return $match_result_data; } function remoteFileExists($url) { $curl = curl_init($url); //don't fetch the actual page, you only want to check the connection is ok curl_setopt($curl, CURLOPT_NOBODY, true); //do request $result = curl_exec($curl); $ret = false; //if request did not fail if ($result !== false) { //if request was ok, check response code $statusCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($statusCode == 200) { $ret = true; } } curl_close($curl); return $ret; } /* Function to get ICC Ranking Details st */ function getICCRankingData() { $url = config('env.API_URL') . 'crid/icc-ranking/iccranking.json'; $iccranking_data = $iccranking_json = $iccranking = $ranks_data = []; $iccgroup = ["teams" => "Teams", "batsmen" => "Batsmen", "bowlers" => "Bowlers", "all-rounders" => "All Rounders"]; $iccformat = ["odis" => "Odi", "tests" => "Test", "t20s" => "T20"]; // if (remoteFileExists($url)) { $iccranking_json = commonCurl($url,null); $iccranking_data = json_decode($iccranking_json, true); if (!empty($iccranking_data) && count($iccranking_data) > 0) { $ranks_data = isset($iccranking_data['response']['ranks']) ? $iccranking_data['response']['ranks'] : []; } // } $data = [ 'iccgroup' => $iccgroup, 'iccformat' => $iccformat, 'ranks_data' => $ranks_data, 'group_data' => isset($ranks_data['teams']) ? $ranks_data['teams'] : [], 'group' => 'teams' ]; return $data; } /* Function to get ICC Ranking Details cl */ /* convert html in to Amp format */ function convertToAmpHtml($html = "", $flag = false, $story_date=false) { $return = $html; if (!empty($html)) { //if story date after 1 jan 2017 then call AMP module --> $match_story_date =strtotime("2018-01-01 00:00:01"); if($story_date > $match_story_date){ $flag = true; } //removed linking and other embed, comment below line and uncomment below this $return = strip_tags(html_entity_decode($html), "<br>"); if ($flag) { try { $amp = new AMP(); $amp->loadHtml($html); $return = $amp->convertToAmpHtml(); } catch (\Throwable $e) { Log::error("amp story conversion error " . url()->current()); } } } return $return; } /** * """ * If Category contains a menu ( mongoid as string ) * then fetch that menu and return it as submenu * otherwise use subcategory as submenus * """ * * @returns : array of submenu based on Category * @param type $category : array with category details from DB */ function getSubMenuByCategory($category = []) { if (empty($category) || (!isset($category['_id']) && !isset($category['parent_id']) )) { return []; } $submenu = []; if (isset($category['menu']) && !empty($category['menu'])) { $submenu = Menus::getMenusById($category['menu']); $submenu = mapSubMenuToCategory($submenu); } else { $category_id = isset($category['parent_id']) && $category['parent_id'] != "0" ? $category['parent_id'] : (isset($category['_id']) ? $category['_id'] : null); $submenu = Category::getCategoriesByParentId($category_id, ['status' => 'enable']); } return $submenu; } /** * """ * Data stored in menu has different indexes from category * This function maps useful data from menu to give * same indexes * """ * @param type $sub * @return type array (assoc) */ function mapSubMenuToCategory($sub = []) { if (empty($sub)) { return []; } $data = []; $items = isset($sub['items']) ? $sub['items'] : []; if (count($items) > 0) { foreach ($items as $sub_menu_key => $sub_menu_value) { if( !empty($sub_menu_value['status']) && $sub_menu_value['status']=="enable"){ $data[$sub_menu_key]['sub_menu_type'] = 'menu'; $link = array_filter(explode('/', $sub_menu_value['link'])); $data[$sub_menu_key]['title_hn'] = isset($sub_menu_value['titles']) ? $sub_menu_value['titles'] : ''; $data[$sub_menu_key]['titles'] = isset($sub_menu_value['titles']) ? $sub_menu_value['titles'] : ''; $data[$sub_menu_key]['full_slug'] = isset($sub_menu_value['link']) ? $sub_menu_value['link'] : ''; $data[$sub_menu_key]['title'] = isset($sub_menu_value['title']) ? $sub_menu_value['title'] : ''; $data[$sub_menu_key]['others'] = isset($sub_menu_value['others']) ? $sub_menu_value['others'] : ''; $data[$sub_menu_key]['status'] = isset($sub_menu_value['status']) ? $sub_menu_value['status'] : 'enable'; if(!empty($link) && isset($link[1]) && !empty($link[1]) && ($link[1] == 'video' || $link[1] == 'photo-gallery')){ $data[$sub_menu_key]['slug'] = $sub_menu_value['link']; }else{ $data[$sub_menu_key]['slug'] = !empty($link) ? end($link) : ''; } $data[$sub_menu_key]['link'] = isset($sub_menu_value['link']) ? $sub_menu_value['link'] : ''; $data[$sub_menu_key]['type'] = isset($sub_menu_value['type']) ? $sub_menu_value['type'] : 'same-page'; }} $data =array_values($data); } return $data; } /* * this function return subcategory slug along with category slug * * @return array * */ function getSubcategoryByParentSlug() { $sucategory_data = []; $for_you_excluded_category = ['entertainment', 'lifestyle', 'fashion', 'cricket', 'sports']; $sucategory_data = Category::getCategoriesByParentSlugs($for_you_excluded_category); return $sucategory_data; } /* * this function return 'PT01H12M21S' duration for VideoObject Schema.org */ function timeToIso8601Duration($duration) { $return = $duration; $time = explode(':', $duration); if (count($time) == 2) { $return = 'PT' . trim($time[0]) . 'M' . trim($time[1]) . 'S'; } elseif (count($time) == 3) { $return = 'PT' . trim($time[0]) . 'H' . trim($time[1]) . 'M' . trim($time[2]) . 'S'; } return $return; } /* * Convert seconds to formated time */ function getFormattedDuration($seconds) { if (empty($seconds)) { return null; } if (strpos($seconds, ':')) { return $seconds; } $t = round($seconds); return sprintf('%02d:%02d', ($t / 60 % 60), $t % 60); } /** * * @param \DateTime $lastStoryUpdatedAt * @param type $type story type * @param string $cat category slug * @param type $params its may be array of where AND clause * @param type $take limit * @param type $status publish or draft * @param type $comparision this can be "<" or ">" * @param type $dir asc or desc * @param type $options * @param type $geo_scope location slug * @return type array of story * @description get next prev story from elasticsearch * @author Arun kumar yadav arun.yadav@auw.co.in */ function getNextPrevStory($lastStoryUpdatedAt = null, $type = null, $cat = null, $params = null, $take = 1, $status = 'publish', $comparision = '<', $dir = 'DESC', $options = [], $geo_scope = null) { $elasticObj = new elastic(); $take = (int) $take; $result = array(); $where = []; $options = ['status' => 'publish']; if (!empty($lastStoryUpdatedAt)) { if (!empty($cat)) { $where['category.slug'] = $cat; } if (!empty($type)) { $where['type'] = $type; } if (!empty($geo_scope) && $cat == 'city-and-states') { $where['geo_scope.slug'] = $geo_scope; } if (!empty($lastStoryUpdatedAt)) { // $options['from'] = '1971-01-01 00:00:00'; if($dir!="ASC"){ $options['from'] = date('Y-m-d 00:00:00',strtotime("- 6 months",strtotime($lastStoryUpdatedAt))); $options['to'] = date('Y-m-d H:i:s', strtotime($lastStoryUpdatedAt)); }else{ $options['to'] = date('Y-m-d 00:00:00',strtotime("+ 6 months",strtotime($lastStoryUpdatedAt))); $options['from'] = date('Y-m-d H:i:s', strtotime($lastStoryUpdatedAt)); } } if (!empty($params) && isset($params['not_in']['slug'])) { $where['slug'] = $params['not_in']['slug']; } $result = $elasticObj->searchByNestedFields('auw', 'story', $where, 1, $take, 'updated_at', $dir, $options); } //// fall back get data from mongo if (isset($result['data']) && !empty($result['data'])) { $return = $result['data']; } else { $return = Story::getNextPrevStory($lastStoryUpdatedAt, $type, $cat, $params , $take, $status , $comparision , $dir, $options, $geo_scope); } return $return; } function getTopMenu($slug,$type) { $memcache = getMemcacheKey(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } $state_lead_section_list = [ 0 => ['section_slug' => 'uttar-pradesh-lead-section', 'slug' => 'uttar-pradesh', 'title_hn' => ' $ M $ 0 * M 0 & G 6', 'title' => 'Uttar Pradesh'], 1 => ['section_slug' => 'delhi-lead-section', 'slug' => 'delhi', 'title_hn' => ' & ? 2 M 2 @', 'title' => 'Delhi'], 2 => ['section_slug' => 'uttarakhand-lead-section', 'slug' => 'uttarakhand', 'title_hn' => ' $ M $ 0 >   !', 'title' => 'Uttarakhand'], 3 => ['section_slug' => 'himachal-pradesh-lead-section', 'slug' => 'himachal-pradesh', 'title_hn' => ' 9 ? . >  2 * M 0 & G 6', 'title' => 'Himachal Pradesh'], 4 => ['section_slug' => 'jammu-and-kashmir-lead-section', 'slug' => 'jammu-and-kashmir', 'title_hn' => '  . M . B  0  6 M . @ 0', 'title' => 'Jammu And Kashmir'], 5 => ['section_slug' => 'punjab-lead-section', 'slug' => 'punjab', 'title_hn' => ' *   > ,', 'title' => 'Punjab'], 6 => ['section_slug' => 'haryana-lead-section', 'slug' => 'haryana', 'title_hn' => ' 9 0 ? / > # >', 'title' => 'Haryana'], 7 => ['section_slug' => 'rajasthan-lead-section', 'slug' => 'rajasthan', 'title_hn' => ' 0 >  8 M % > (', 'title' => 'Rajasthan'], 8 => ['section_slug' => 'bihar-lead-section', 'slug' => 'bihar', 'title_hn' => ' , ? 9 > 0', 'title' => 'Bihar'], 9 => ['section_slug' => 'chhattisgarh-lead-section', 'slug' => 'chhattisgarh', 'title_hn' => '  $ M $ @ 8  ]', 'title' => 'Chhattisgarh'], 10 => ['section_slug' => 'jharkhand-lead-section', 'slug' => 'jharkhand', 'title_hn' => '  > 0  # M !', 'title' => 'Jharkhand'], 11 => ['section_slug' => 'madhya-pradesh-lead-section', 'slug' => 'madhya-pradesh', 'title_hn' => ' . ' M / * M 0 & G 6', 'title' => 'Madhya Pradesh'], ]; $type=isset($type)?$type:''; $slug=isset($slug)?$slug:''; $parent=[]; $sub_menu=[]; if(empty($slug) || empty($type)){ return []; } switch ($type) { case 'category': $category_list = Category::getCategoryBySlug($slug, true); if (empty($category_list['parent_id']) || $category_list['parent_id'] == $category_list['_id']) { $sub_menu = getSubMenuByCategory($category_list);//Category::getCategoriesByParentId($category_list['_id']); $parent = $category_list; } else { $sub_menu = getSubMenuByCategory($category_list);//Category::getCategoriesByParentId($category_list['parent_id'], ['status' => 'enable']); $parent = Category::getCategoryById($category_list['parent_id']); } break; case 'location': $location = Location::getLocationBySlug($slug); $parent = $location; if ($slug == 'city-and-states') { foreach ($state_lead_section_list as $key => $state_list) { $sub_menu[$key]['slug'] = $state_list['slug']; $sub_menu[$key]['full_slug'] = $state_list['slug']; $sub_menu[$key]['title_hn'] = $state_list['title_hn']; $sub_menu[$key]['title'] = $state_list['title']; } } else { if (!empty($location) && $location['status'] == 'enable') { $parent_id = isset($location['parent_id']) && $location['parent_id']!="0" ? $location['parent_id'] : (isset($location["_id"]) && !empty($location["_id"])?$location["_id"]:null); $location_id = isset($location['_id']) ? $location['_id'] : null; if(!empty($parent_id)){ $parent = Location::getLocationById($parent_id); } switch ($location['type']) { case 'city': $sub_menu = getCitiesMenuByLocation($location); //Location::getCityListByStateId($parent_id, 'title_hn', 'ASC', 'enable'); break; case 'hyper': $sub_menu = getCitiesMenuByLocation($location); //Location::getCityListByHyperId($location_id, 'title_hn', 'ASC', 'enable'); break; case 'state': case 'international': case 'national': $sub_menu = getCitiesMenuByLocation($location); //Location::getCityListByStateId($location_id, 'title_hn', 'ASC', 'enable'); break; default: $sub_menu = getCitiesMenuByLocation($location);//Location::getCityListByStateId($parent_id, 'title_hn', 'ASC', 'enable'); break; } } //return $city_menu; } break; case 'photo-gallery': $photo_gallery_menu = popolateMenu('photogallery-menu'); if (!empty($photo_gallery_menu)) { $sub_menu = convert_menu_to_category($photo_gallery_menu); } $parent = ['full_slug'=>'/photo-gallery','slug'=>'photo-gallery','title'=>'Photo Gallery','title_hn'=>' + K  K']; break; case 'video': $video_menu = popolateMenu('live-tv-categorymenu'); if (!empty($video_menu)) { $sub_menu = convert_menu_to_category($video_menu); } $parent = ['full_slug'=>'/video','slug'=>'video','title'=>' 5 @ ! ? / K','title_hn'=>' 5 @ ! ? / K']; break; case 'special-stories': $special_stories_menu = popolateMenu('special-stories-menu'); if (!empty($special_stories_menu)) { $sub_menu = convert_menu_to_category($special_stories_menu); } $parent = ['full_slug'=>'/special-stories','slug'=>'special-stories','title'=>'Special Stories','title_hn'=>' 5 ? 6 G 7']; break; case 'election': $sub_menu = popolateMenu('election-menu'); $parent = ['full_slug'=>'/election','slug'=>'election','title'=>'Election','title_hn'=>'  A ( > 5']; break; default: break; } //if sub_menu is not available then call default menu if((isset($sub_menu) && empty($sub_menu)) || (count($sub_menu)<=1 && $type=='category')){ $sub_menu = popolateMenu('amarujala-main-menu'); } foreach($sub_menu as $key=>$value){ //we are require full_slug,slug,title_hn fields in menu . so we are add if not available fields //some full url having '/' & some is without '/' so we are remove '/' from full_slug and '/' call in blade if(isset($value["full_slug"])){ $sub_menu[$key]["full_slug"]=isset($value["full_slug"])?ltrim($value["full_slug"],"/"):''; } if(!isset($value["full_slug"])){ $sub_menu[$key]["full_slug"]=isset($value["link"])?ltrim($value["link"],"/"):''; } if(!isset($value["slug"])){ $sub_menu[$key]["slug"]=isset($value["link"])?ltrim($value["link"],"/"):''; } if(!isset($value["title_hn"])){ $sub_menu[$key]["title_hn"]=isset($value["titles"])?$value["titles"]:''; } } $sub_menu_unset = []; //we set selected value in first position if(isset($sub_menu) && !empty($sub_menu)){ foreach($sub_menu as $key=>$value){ if(isset($value["slug"]) && $value["slug"] == $slug){ $sub_menu_unset[] = $value; unset($sub_menu[$key]); break; } } $sub_menu = array_merge($sub_menu_unset,$sub_menu); } //if child menu available in parent then remove form child foreach($sub_menu as $key=>$value){ if(isset($value["slug"]) && isset($parent["slug"]) && $value["slug"] == $parent["slug"]){ unset($sub_menu[$key]); break; } } $parent['sub_menu']=$sub_menu; $parent['selected']=$slug; if (isset($memcache['key']) && !empty($parent)) { putDataMemcached($memcache['key'], $parent,15); } return $parent; } /** * """ * If Location contains a menu ( mongoid as string ) * then fetch that menu and return it as submenu * otherwise use states cities as submenus * """ * * @returns : array of submenu based on Location * @param type $Location : array with location details from DB */ function getCitiesMenuByLocation($location = []) { $city_menu = []; if(isset($location['slug']) && $location['slug']=='city-and-states'){ $city_menu = Menus::getMenusBySlug('states-list'); $city_menu = mapSubCitiesToLocation($city_menu); return $city_menu; }elseif (empty($location) || (!isset($location['_id']) && !isset($location['parent_id']) )) { return []; } if (isset($location['menu']) && !empty($location['menu'])) { $city_menu = Menus::getMenusById($location['menu']); $city_menu = mapSubCitiesToLocation($city_menu); }else { $location_id = isset($location['parent_id']) && $location['parent_id'] != "0" ? $location['parent_id'] : (isset($location['_id']) ? $location['_id'] : null); $type=isset($location['type'])?$location['type']:null; switch($type){ case 'city': case 'state': $city_menu = Location::getCityListByStateId($location_id,'title_hn', 'ASC', 'enable'); break; case 'hyper': $city_menu = Location::getCityListByHyperId(isset($location['_id'])?$location['_id']:null,'title_hn','ASC', 'enable'); break; default: break; } } return $city_menu; } /** * """ * Data stored in menu has different indexes from Location * This function maps useful data from menu to give * same indexes * """ * @param type $sub * @return type array (assoc) */ function mapSubCitiesToLocation($sub = []) { if (empty($sub)) { return []; } $data = []; $items = isset($sub['items']) ? $sub['items'] : []; if (count($items) > 0) { foreach ($items as $sub_menu_key => $sub_menu_value) { if( !empty($sub_menu_value['status']) && $sub_menu_value['status']=="enable"){ $data[$sub_menu_key]['sub_menu_type'] = 'menu'; $link = array_filter(explode('/', $sub_menu_value['link'])); $data[$sub_menu_key]['title_hn'] = isset($sub_menu_value['titles']) ? $sub_menu_value['titles'] : ''; $data[$sub_menu_key]['full_slug'] = isset($sub_menu_value['link']) ? $sub_menu_value['link'] : '';//!empty($link) ? end($link) : '' $data[$sub_menu_key]['title'] = isset($sub_menu_value['others']) ? $sub_menu_value['others'] : ''; $data[$sub_menu_key]['status'] = isset($sub_menu_value['status']) ? $sub_menu_value['status'] : 'enable'; $data[$sub_menu_key]['slug'] = !empty($link) ? end($link) : ''; $data[$sub_menu_key]['link'] = isset($sub_menu_value['link']) ? $sub_menu_value['link'] : ''; $data[$sub_menu_key]['type'] = isset($sub_menu_value['type']) ? $sub_menu_value['type'] : ''; $data[$sub_menu_key]['others'] = isset($sub_menu_value['others']) ? $sub_menu_value['others'] : ''; $data[$sub_menu_key]['label'] = isset($sub_menu_value['label']) ? $sub_menu_value['label'] : ''; }} $data =array_values($data); } return $data; } function popolateMenuDetail($menu_slug = null,$options=[]) { $menu_item_list = array(); if (empty($menu_slug)) { return $menu_item_list; } $menu_item_list = Menus::getMenusBySlug($menu_slug,false,$options); return $menu_item_list; } //////////////////////////election RAJNETI these methods are used from rajneeti models so can't implements with auw utilities///////////////////////////// /////////////////////////////////////////////////////////////////////// if ( !function_exists('getFullImageUrl')) { /** * Get full image path/url * * @param string $image * @param string $size small, medium, large, original * * @return null|string */ function getFullImageUrl($image = '', $size='') { if( !$image ) { return null; } $size_array = [ 'small', 'large', 'medium']; $image = str_replace('//userimg.amarujala.com/uploads/', '', $image); if( in_array($size, $size_array) ) { $url =config('env.IMAGE_SSO_URL','//userimg.amarujala.com/uploads')."/".$size."/".$image; if( is_url_exist('http:'.$url) ) { return $url ; } } return config('env.IMAGE_SSO_URL','//userimg.amarujala.com')."/".$image; } } if ( !function_exists('getClientId')) { /** * Get some functionality * * @var string some variable * @return string some return value **/ function getClientId() { return config('env.SSO_CLIENT_ID'); } } if ( !function_exists('getPropertyId')) { /** * Get some functionality * * @var string some variable * @return string some return value **/ function getPropertyId() { return config('env.SSO_PROPERTY_ID'); } } ////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////// End Rajneti utilities /////////////////////////////// /** * @param Request $request * send sms to user require param is sender id,message template and 10 digit mobile number, * call url is ajax/send-sms by post */ function sendSms($send = null, $msg=null, $mobile=null) { if(empty($send) && empty($msg) && empty($mobile)){ return false; } $url_sms = 'http://103.247.98.91/API/SendMsg.aspx'; $fields = array( 'uname' => '20142918', 'pass' => 'uj856hz', 'send' => $send, 'dest' => $mobile, 'msg' => $msg ); $postvars = ''; $sep = ''; foreach ($fields as $key => $value) { $postvars.= $sep . urlencode($key) . '=' . urlencode($value); $sep = '&'; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url_sms); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $flag = curl_exec($ch); curl_close($ch); return $flag; } function sendSmsV1($send = null, $msg=null, $mobile=null,$request_type="GET") { if(empty($send) || empty($msg) || empty($mobile)){ return false; } $fields = array( 'username' => config('env.SMS_API_USERNAME'), 'password' => config('env.SMS_API_PASSWORD'), 'sender' => config('env.SMS_API_SENDERID',$send), 'sendto' => $mobile, 'message' => $msg ); $url_sms = config('env.SMS_API_URL').'?'. http_build_query($fields); $flag = commonCurl($url_sms, null, false, $request_type); return $flag; } function custom_slug($title, $separator = '-') { // Convert all dashes/underscores into separator $flip = $separator == '-' ? '_' : '-'; // Replace & with the word 'and' //$title = str_replace('&', $separator.'and'.$separator, $title); //Allow on few character sets in slug -- including english $title = detectRanges($title); $title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title); // Remove all characters that are not the separator, letters, numbers, or whitespace. //$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title)); // Replace all separator characters and whitespace by a single separator $title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title); //$title = preg_replace('/[^\x20-\x7E]/u', '', $title); $title = trim($title, $separator); return $title; } function entityToUTF8( $number ) { $number = (int) $number; if( $number < 0 ) return false; # Replace ASCII characters if( $number < 128 ) return chr( $number ); # Replace illegal Windows characters if( $number < 160 ) { switch( $number ) { case 128: $conversion = 8364; break; case 129: $conversion = 160; break; case 130: $conversion = 8218; break; case 131: $conversion = 402; break; case 132: $conversion = 8222; break; case 133: $conversion = 8230; break; case 134: $conversion = 8224; break; case 135: $conversion = 8225; break; case 136: $conversion = 710; break; case 137: $conversion = 8240; break; case 138: $conversion = 352; break; case 139: $conversion = 8249; break; case 140: $conversion = 338; break; case 141: $conversion = 160; break; case 142: $conversion = 381; break; case 143: $conversion = 160; break; case 144: $conversion = 160; break; case 145: $conversion = 8216; break; case 146: $conversion = 8217; break; case 147: $conversion = 8220; break; case 148: $conversion = 8221; break; case 149: $conversion = 8226; break; case 150: $conversion = 8211; break; case 151: $conversion = 8212; break; case 152: $conversion = 732; break; case 153: $conversion = 8482; break; case 154: $conversion = 353; break; case 155: $conversion = 8250; break; case 156: $conversion = 339; break; case 157: $conversion = 160; break; case 158: $conversion = 382; break; case 159: $conversion = 376; break; } return $conversion; } if ( $number < 2048 ) return chr( ($number >> 6 ) + 192 ) . chr( ( $number & 63 ) + 128 ); if ( $number < 65536 ) return chr( ( $number >> 12 ) + 224 ) . chr( ( ( $number >> 6 ) & 63 ) + 128 ) . chr( ( $number & 63 ) + 128 ); if ( $number < 2097152 ) return chr( ( $number >> 18 ) + 240 ) . chr( ( ( $number >> 12 ) & 63 ) + 128 ) . chr( ( ( $number >> 6 ) & 63 ) + 128 ) . chr( ( $number & 63 ) + 128 ); return false; } function MBStrToHexes( $str ) { $str = mb_convert_encoding( $str, 'UCS-4BE' ); $hexs = array(); for( $i = 0; $i < mb_strlen( $str, 'UCS-4BE' ); $i++ ) { $s2 = mb_substr( $str, $i, 1, 'UCS-4BE' ); $val = unpack( 'N', $s2 ); $hexs[] = str_pad( dechex( $val[1] ), 4, 0, STR_PAD_LEFT ); } return( $hexs ); } function detectRanges( $str ) { $hexes = MBStrToHexes( $str ); $slug = ''; foreach( $hexes as $hex ) { if( ( $hex >= 'a8e0' ) && ( $hex <= 'a8ff' ) ) { //echo entityToUTF8( hexdec($hex) ) . ' - Extended Devanagari<br />'; $slug .= entityToUTF8( hexdec($hex) ); } elseif ( ( $hex >= '0900' ) && ( $hex <= '097f' ) ){ //echo entityToUTF8( hexdec($hex) ) . ' - Devanagari<br />'; $slug .= entityToUTF8( hexdec($hex) ); } elseif( ( $hex == '0020' ) || ( $hex == '002d' ) ) { //echo entityToUTF8( hexdec($hex) ) . ' - Space or Dash<br />'; $slug .= entityToUTF8( hexdec($hex) ); } elseif( ( $hex >= '0030' ) && ( $hex <= '0039' ) ) { //echo entityToUTF8( hexdec($hex) ) . ' - Numbers<br />'; $slug .= entityToUTF8( hexdec($hex) ); } elseif( ( $hex >= '0041' ) && ( $hex <= '005a' ) ) { //echo entityToUTF8( hexdec($hex) ) . ' - English Uppercase<br />'; $slug .= entityToUTF8( hexdec($hex) ); } elseif( ( $hex >= '0061' ) && ( $hex <= '007a' ) ) { //echo entityToUTF8( hexdec($hex) ) . ' - English Lowercase<br />'; $slug .= entityToUTF8( hexdec($hex) ); } else { //echo $hex . " " . entityToUTF8( $hex ) . ' - Some Other Range<br />'; //return ''; } } return $slug; } /* * send mail to user * @param subject,email,template,attachment */ function sendMail($subject,$email,$template=null,$attachment=null) { $data = ['subject'=>$subject,'email'=>$email,'template'=>$template,'attachment'=>$attachment]; Mail::send('emails.'.$data["template"], [], function($message) use($data){ $message->to($data["email"])->subject($data["subject"]); if(!empty($data["attachment"])){ $message->attach($data["attachment"]); } }); } /** * This function used to Display Competition Scheedule time which is in GMT. So, we have converted it into IST * @param type $time * @return time in IST Format * */ function convertGMTtoIST($time){ $dt = new DateTime($time."GMT"); $tz = new DateTimeZone('Asia/Kolkata'); // or whatever zone you're after $dt->setTimezone($tz); $convertDate = date('F jS, Y H:i:s', strtotime($dt->format('Y-m-d H:i:s'))); return $convertDate; } /** * @param type $path * @param type $intervention * @param type $size * @return original size image in particular size * */ function getAssetsFullPath( $path = false, $intervention = false, $size='150x150' ) { if( $intervention ) { return str_replace( 'assets/images/', "image/$size/", $path ); } return $path; } /** * @param type $options * @param type $count * @return stories list on the basis of given params * */ function getPremiumStories( $options = [] ,$skip = 0,$count = 19,$slug = null) { $stories_list = array(); $memcache = getMemcacheKey(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } $category_list = Category::getCategoryBySlug($slug, true); $cat = isset($category_list['_id']) ? $category_list['_id'] : null; $options['is_preimum'] = true; if($slug == "special-stories"){ $stories_list = Story::storyList('updated_at', 'desc',[], 'publish', [], $options)->skip($skip)->take($count)->get(); }else{ $stories_list = Story::getStoryListByCategorySlug($slug,$cat,null,$skip,$count,'updated_at', 'desc', $options); } if (is_object($stories_list)) { $stories_list = $stories_list->toArray(); } if (isset($memcache['key']) && !empty($stories_list)) { putDataMemcached($memcache['key'], $stories_list); } return $stories_list; } //this is use for spotlight data fetch by trending process & in last story sort by updated_at desc function getSpotlightNewsByTranding($request,$slug=null){ $spotlight_news =[]; $ajax_get_fatafat_khabar= new AjaxController(); $spotlight_news_data=$ajax_get_fatafat_khabar->getFatafatKhabar($request); if($slug != null && !empty($slug) && !empty($spotlight_news_data)){ // For non-repetition of the current story in spotlight section foreach ($spotlight_news_data as $item) { if (!empty($item['slug']) && $item['slug'] != $slug) { $item['updated_at'] = !empty($item['updated_AT']) ? $item['updated_AT'] : $item['updated_at']; // overwrite value '1 Hr' formate in updated_at date & time $item['full_slug'] = !empty($item['full_slug']) ? $item['full_slug'] : ''; // append src in full slug $spotlight_news[] = $item; } } $spotlight_news = collect(array_slice($spotlight_news,0,10)); $spotlight_news_collect = $spotlight_news->sortByDesc('updated_at'); $spotlight_news = $spotlight_news_collect->toArray(); } return $spotlight_news; } /** * convert milisecond to formated time * @param type $milliseconds * @return type */ function formatMilliseconds($milliseconds) { if($milliseconds){ $time = $milliseconds / 1000; $days = floor($time / (24*60*60)); $hours = floor(($time - ($days*24*60*60)) / (60*60)); $minutes = floor(($time - ($days*24*60*60)-($hours*60*60)) / 60); $seconds = ($time - ($days*24*60*60) - ($hours*60*60) - ($minutes*60)) % 60; return sprintf('%02d:%02d',$minutes,$seconds); } } function substrwords($text, $maxchar, $end='...') { if (strlen($text) > $maxchar || $text == '') { $words = preg_split('/\s/', $text); $output = ''; $i = 0; while (1) { $words_len = isset($words[$i]) ? strlen($words[$i]):0; $length = strlen($output)+ $words_len ; if ($length > $maxchar) { break; } else { $words_str = isset($words[$i]) ? $words[$i]:''; $output .= " " . $words_str; ++$i; } } $output .= $end; } else { $output = $text; } return $output; } /* call it => array_sort_by_column($array, 'test',SORT_DESC); @description array_sort_by_column for sort multiple array on the basis of particular column @param $arr two-d array @param $col column name for sort @param $dir sort order SORT_ASC or SORT_DESC */ function array_sort_by_column(&$arr, $col, $dir = SORT_DESC) { $sort_col = array(); foreach ($arr as $key=> $row) { $sort_col[$key] = $row[$col]; } array_multisort($sort_col, $dir, $arr); } /** * below three function used for google assistant feed * @param type $path * @return type */ function getDurationOfAudioInMs($path) { $time = getDurationOfAudioFile($path); if(!empty($time)){ list($hms, $milli) = explode('.', $time); list($hours, $minutes, $seconds) = explode(':', $hms); $totalSeconds = ($hours * 3600) + ($minutes * 60) + $seconds; return $totalSeconds; } } /** * * @param string $path * @return string */ function getDurationOfAudioFile($path) { $cmd = "ffmpeg -i " . escapeshellarg($path) . " 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//"; return shell_exec($cmd); } /** * * @param type $file_path * @return type */ function getAudioFileSize($file_path){ $ch = curl_init($file_path); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_NOBODY, TRUE); $data = curl_exec($ch); $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); return $size; } function getAppendTags($story=[],$parent_categories=[]){ //append category, sub category & location in tags $append_tags = []; $append_unique_tags = []; if (!empty($parent_categories)) { $append_tags[] = !empty($parent_categories["title"]) ? strtolower($parent_categories["title"]) :''; } if (!empty($story["categories"])) { foreach ($story["categories"] as $category) { $append_tags[] = !empty($category["title"]) ? strtolower($category["title"]) :''; } } if (!empty($story["geo_scope"])) { foreach ($story["geo_scope"] as $geo) { $append_tags[] = !empty($geo["title"]) ? strtolower($geo["title"]) :''; } } if (!empty($append_tags)) { $append_unique_tags = array_merge($append_tags, $story["tags"]); $append_unique_tags = array_filter($append_unique_tags); $append_unique_tags = array_unique($append_unique_tags); } return array_values($append_unique_tags); //append category, sub category & location in tags } function checkIframe($string){ if(Str::contains($string,'iframe')){ return true; } return false; } /* * strip selected tags by id or classname */ function strip_selected_tags_by_id_or_class($array_of_id_or_class, $text) { $name = implode('|', $array_of_id_or_class); $regex = '#<(\w+)\s[^>]*(class|id)\s*=\s*[\'"](' . $name . ')[\'"][^>]*>.*</\\1>#isU'; return(preg_replace($regex, '', $text)); } /* * explode title by Special Character */ function explodeTitleBySpecialCharacter($specialCharacter,$storyTitle) { $title['title_first'] = ''; $title['title_second'] = $storyTitle; if(Str::contains($storyTitle,$specialCharacter)){ $name = explode($specialCharacter, $storyTitle); if(!empty($name)){ $title['title_first'] = !empty($name[0])?$name[0].$specialCharacter:''; $title['title_second'] = !empty($name[1])?$name[1]:''; } } return $title; } function kavyaDeskUser(){ return User::getUserBySlug('kavyadesk'); } function cleankavyaStoryDescription($description){ $storyDescription = rtrim($description,"<br>"); $storyDescription = rtrim($storyDescription,"<br/>"); $storyDescription = rtrim($storyDescription,"<br.../"); $storyDescription = rtrim($storyDescription,"<br .../"); return $storyDescription; } function cleanAMPIframe($description){ $ampStoryDescription = str_replace('<iframe','<amp-iframe sandbox="allow-scripts allow-same-origin allow-popups"',$description); $ampStoryDescription = str_replace('</iframe','</amp-iframe',$ampStoryDescription); $ampStoryDescription = str_replace('allowfullscreen="true"','',$ampStoryDescription); $ampStoryDescription = str_replace('allowTransparency="true"','',$ampStoryDescription); $ampStoryDescription = str_replace('allowFullScreen="true"','',$ampStoryDescription); $ampStoryDescription = str_replace('style="border:none;overflow:hidden"','',$ampStoryDescription); return $ampStoryDescription; } function isMobileDevice() { if(isset($_SERVER["HTTP_USER_AGENT"]) && !empty($_SERVER["HTTP_USER_AGENT"]) ){ return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo |fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i" , $_SERVER["HTTP_USER_AGENT"]); } return false; } function getPopularPoetsV1() { $user_data = array(); $user_data = User::getUGCDataListV1('today_views', 'desc', 9); $user_data = is_object($user_data) ? $user_data->toArray() : $user_data; return $user_data; } if(!function_exists('is_valid_mongo_id')){ function is_valid_mongo_id($id){ return strlen($id) === 24 && strspn($id,'0123456789ABCDEFabcdef') === 24; } } function cleanUserImageUrl($url){ $url = str_replace('com//','com/',$url); $url = str_replace('spiderimg.itstrendingnow.com','spiderimg.amarujala.com',$url); $url = str_replace('spiderimg.amarujala.com','userimg.amarujala.com',$url); return $url; } function checkResourceExists($url){ stream_context_set_default( array( 'http' => array( 'method' => 'HEAD' ) ) ); $url = str_replace('https:','',$url); $url = str_replace('http:','',$url); $headers = get_headers('https:'.$url); return $headers; } function kavyaFeedArticleUrl($url,$recommended){ return $url; /** * remove src tag from url */ // if($recommended){ // return $url.'?src=rcmd'; // } // return $url; } /** * * @param type $request This is REQUEST object or string * @description this return key and data both */ function getMemcacheKeyV1($args, $method, $get = false) { if (config('env.MODEL_MEMCACHED') != 1) { return false; } if (Illuminate\Support\Facades\Request::has('cache_clear_long_duration')) { $get = false; } $key = [$method . config('env.MEMCACHED_PREFIX')]; if(!empty(Illuminate\Support\Facades\Request::server('REQUEST_URI'))){ $key[] = Illuminate\Support\Facades\Request::server('REQUEST_URI'); } foreach ($args as $dd) { if (!is_object($dd)) { $key[] = $dd; } } $data['key'] = md5(json_encode($key)); $data['data'] = []; if ($get) { $data['data'] = Cache::store('redis_model')->get($data['key'], false); if (isset($data['data']['data']) && !empty($data['data']['data'])) { if ($data['data']['collect'] == 1) { $data['data'] = collect($data['data']['data']); } else { $data['data'] = $data['data']['data']; } } else { $data['data'] = null; } } return $data; } /** * * @param type $key memcached key * @param type $value this may be any data type */ function putDataMemcachedV1($key, $value, $expire = null) { if (empty($expire)) { $expire = config('env.MEMCACHED_TIME_FOR_LONG_DURATION', 240); } if (is_object($value) && !empty($value)) { $result['collect'] = 1; $result['data'] = $value->toArray(); } else { $result['collect'] = 0; $result['data'] = $value; } if ($key && !empty($result)) { Cache::store('redis_model')->put($key, $result, $expire); } } function filterBlankMovieReview($items){ return array_filter($items,function($item){ if($item['name'] != ""){ return $item; } }); } function addHindiNewsTitle($category_slug){ $category_name_add_in_title = ''; if (!empty($category_slug)) { $explode_category_name = explode("-", $category_slug); $exploded_category_last_value = $explode_category_name[count($explode_category_name) - 1]; if ($exploded_category_last_value == "news") { $category_name_add_in_title = str_replace("-", " ", $category_slug) . " in hindi"; } else { $category_name_add_in_title = str_replace("-", " ", $category_slug) . " news in hindi"; } } return $category_name_add_in_title; } function getUserProfileInfo() { $data = array(); $user_id = $_COOKIE['_raidu'] ?? null; $memcache = getMemcacheKey(func_get_args(), __METHOD__, true); if (isset($memcache['data']) && !empty($memcache['data'])) { return $memcache['data']; } if(!is_null($user_id)) { $user_info = UserProfile::findOrFail($user_id); if(!empty($user_info)){ $user_info = $user_info->toArray(); $data = array('defaultName' => ($user_info['first_name'] ?? '' . $user_info['last_name'] ?? ''), 'defaultEmail' => $user_info['emails'][0]['email'] ?? '', 'defaultMobile' => $user_info['phone']['national_number'] ?? ''); } } if (isset($memcache['key']) && !empty($data)) { putDataMemcached($memcache['key'], $data); } return $data; } function getTopViewsDailmotionVideos($count = 50) { $dm_mv_videos = []; $dm_mv=[]; $dm_mv_video_fetch = StoryAnalytics::getTrandingStory(['type' => 'video'], '24hours', 0, $count, [], 'created_at'); foreach($dm_mv_video_fetch as $video){ if(!empty($video["youtube_id"]) && !empty($video["video_type"]) && $video["video_type"]=="dailymotion"){ $dm_mv_videos[] = $video; } } $dm_mv_rand = rand(0,count($dm_mv_videos)); $dm_mv = isset($dm_mv_videos[$dm_mv_rand])?$dm_mv_videos[$dm_mv_rand]:[]; $dm = ''; if(isset($dm_mv["youtube_id"])) { $dm = '<div id="dailymotionEndofStory" class="dm-player" playerId="x8w60" videoId="'.$dm_mv["youtube_id"].'" mute="true" lazyload="true"> </div>'; $dm .= '<script>'; $dm .= 'const dailymotionScript=document.createElement("script");'; $dm .= 'dailymotionScript.src="https://srvr.dmvs-apac.com/v2/dm-ce.min.js";'; $dm .= 'document.getElementById("dailymotionEndofStory").appendChild(dailymotionScript);'; $dm .= 'eval(dailymotionScript);'; $dm .= '</script>'; $dm .= '<style> div#dailymotion-pip-small-viewport {height:100px!important; width:178px!important; bottom:initial!important; left:initial!important; right:10px!important; top:100px!important;} .dailymotion-pip-controls.dailymotion-pip-collapsed.dailymotion-pip-controls-hidden { opacity:initial!important;} button.dailymotion-pip-button-close { top:-10px!important; left:-10px!important;} button.dailymotion-pip-button-expandcollapse , button.dailymotion-pip-button-back-to-player, button.dailymotion-pip-button-prev, button.dailymotion-pip-button-playback, button.dailymotion-pip-button-next, button.dailymotion-pip-button-volume{ opacity: 0!important;} </style>'; } return $dm; } function getHomeStoryTags(){ $top_section = getSectionBySlug('live-news'); $top_story_list = getContentPriorityStoriesBySectionId($top_section['_id'], 20); $result = topSubNavTags($top_story_list); return $result; } function topSubNavTags($top_story_list){ $result = []; $tmp = []; foreach($top_story_list as $story){ $title_tags = explode(':', !empty($story['title_hn'])?$story['title_hn']:''); if(count($title_tags) >=2){ $title = trim($title_tags[0]); if(!in_array($title, $tmp)){ $tmp[] = $title; $result[] = ['title' => $title, 'full_slug' => !empty($story['full_slug'])?$story['full_slug']:'']; } } } $result = count($result)>10?array_splice($result, 0, 10):$result; return $result; } function dailmotionForVideos($player, $autoplay=false) { if(empty($player)) return ''; if(empty($player['youtube_id'])) return ''; $dm = '<div class="dailymotionPlayerV2 dm-player " owners="amarujala" showOutsidePlaylist="bottom" lazyload="false" '; if($autoplay==false) { $dm .= ' mute="true" '; } if ( (strpos($player['youtube_id'], 'videoId') !== false) || (strpos($player['youtube_id'], 'playlistId') !== false) || (strpos($player['youtube_id'], 'playerId') !== false) ) { $dm .= $player['youtube_id']; } else { $dm .= ' videoId="'.$player['youtube_id'].'" '; } $dm .= ' cpeid="603898e961af77d77620d44c" syndication="276207"'; $dm .= ' sparams="Video_Section"></div>'; $dm .= '<script src="https://srvr.dmvs-apac.com/v2/dm-ce.min.js"></script>'; $dm .= '<style> div#dailymotion-pip-small-viewport {height:100px!important; width:178px!important; bottom:initial!important; left:initial!important; right:10px!important; top:100px!important;} .dailymotion-pip-controls.dailymotion-pip-collapsed.dailymotion-pip-controls-hidden { opacity:initial!important;} button.dailymotion-pip-button-close { top:-10px!important; left:-10px!important;} button.dailymotion-pip-button-expandcollapse , button.dailymotion-pip-button-back-to-player, button.dailymotion-pip-button-prev, button.dailymotion-pip-button-playback, button.dailymotion-pip-button-next, button.dailymotion-pip-button-volume{ opacity: 0!important;} </style>'; return $dm; } function dailmotionForVideosAMP($player, $autoplay=false) { if(empty($player)) return ''; if(empty($player['youtube_id'])) return ''; $dm = '<amp-video-iframe layout="responsive" width="560" height="315" '; $dm .= ' data-param-owners="amarujala" src="/dailymotion/player.htm" '; if($autoplay==false) { $dm .= ' data-param-mute="true" '; } if ( (strpos($player['youtube_id'], 'videoId') !== false) || (strpos($player['youtube_id'], 'playlistId') !== false) || (strpos($player['youtube_id'], 'playerId') !== false) ) { $txt = $player['youtube_id']; $txt = str_replace("videoId","data-param-videoid",$txt); $txt = str_replace("playlistId","data-param-playlistid",$txt); $txt = str_replace("playerId","data-param-playerid",$txt); $dm .= $txt; } else { $dm .= ' data-param-videoid="'.$player['youtube_id'].'" '; } $dm .= ' data-param-syndication="276207" autoplay></amp-video-iframe>'; return $dm; } function justBaatMetaHuman($story, $video=[], $dailymotionPlayer=[],$videoPromotion=[], $divId="") { if(empty($story)) { return null; } if(!empty($video['video_type'])) { return null; } if( isset($dailymotionPlayer['status']) && $dailymotionPlayer['status']=="enable" && isset($dailymotionPlayer["widget_code"]) ) { return null; } if (isset($videoPromotion['status']) && $videoPromotion['status']=="enable" && isset($videoPromotion["widget_code"]) && isset($videoPromotion['section_description']) && $videoPromotion['section_description'] == "dailymotion" ) { return null; } // Shimla -> 58f729884f1c1b1b74472f1b and Lucknow -> 58f7285f4f1c1ba346472226 $limitNewsProStory = array( '58f7285f4f1c1ba346472226', '58f729884f1c1b1b74472f1b'); if (!in_array($story->created_by, $limitNewsProStory)) { return null; } $justbaatAppId = "8b4f7ae5-eee6-452b-937e-69dce0a6692d"; $justbaatSecret = "ac3c99f74026237841f287efebce2fddc3fa4694d85763018263d928381955be"; $justbaatPartnerId = "AMAR_UJALA"; $html ='<div style="width: 500px; margin-top: auto; margin-left: auto; margin-right: auto" id="jb-podcast-container"></div>'; $html .='<script> (function (w, d, s, o, f, js, fjs) { w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments); }; (js = d.createElement(s)), (fjs = d.getElementsByTagName(s)[0]); js.id = o; js.src = f; js.async = 1; fjs.parentNode.insertBefore(js, fjs); })(window, document, \'script\', \'jbWidget\', \'https://widget.justbaat.com/jb-widget.min.js\'); jbWidget(\'init\', { appId: "'.$justbaatAppId.'", secret: "'.$justbaatSecret.'", partner_id: "'.$justbaatPartnerId.'", render: [ { wid: "podcast-list-template-1", tgtEl: "jb-podcast-container", uiConfig: { width: "100%" }, widgetConfig: { // packageId: "", } } ] }); </script>'; echo "<pre>"; echo $html; echo "</pre>"; //return $html; } 🧨 Call to undefined function App\Models\SpiderCMS\getMemcacheKey()