Example #1
0
 public function __construct()
 {
     $this->now = date("Y/m/d H:i:s");
     $this->ConfigFolder = realpath(__DIR__ . '/../../../config/banks/' . $this->drivername . '/');
     $this->bankConfig = \Config::get('Payby::banks\\' . $this->drivername . '\\config.info');
     \View::addLocation($this->ConfigFolder);
     \View::addNamespace('Payby', $this->ConfigFolder);
 }
Example #2
0
 public function setUp()
 {
     parent::setUp();
     View::addLocation(__DIR__ . '/../views');
     Route::get('user/{id}', ['as' => 'get_user', function ($id) {
         return $id;
     }]);
     Route::get('comment/{id}', ['as' => 'get_comment', function ($id) {
         return $id;
     }]);
     Route::get('post/{id}', ['as' => 'get_post', function ($id) {
         return $id;
     }]);
 }
 public function setUp()
 {
     parent::setUp();
     View::addLocation(__DIR__ . '/fixtures/views');
     $this->controllerName = "AcProjectsController";
     $this->modelName = "AcProject";
     $this->modelAttributes = ['id' => 5, 'name' => 'Test AuthorityController package', 'priority' => 1];
     $this->resourceName = "ac_projects";
     // str_plural(snake_case($this->modelName));
     Route::resource($this->resourceName, $this->controllerName);
     $this->userAttributes = ['id' => 1, 'username' => 'tortue', 'firstname' => 'Tortue', 'lastname' => 'Torche', 'email' => '*****@*****.**', 'password' => Hash::make('tortuetorche'), 'displayname' => 'Tortue Torche'];
     $this->user = $this->getUserWithRole('admin');
     $this->authority = $this->getAuthority($this->user);
     $this->authority->allow('manage', $this->modelName);
 }
Example #4
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $agent = new Agent();
     // Определяем устройство и устанавливаем пути к js контроллерам и видам
     if ($agent->isMobile()) {
         \Config::set('js-controllers.path_controllers', 'dist/main/ng');
         \Config::set('js-controllers.path_js_files', 'dist/main/js');
         \View::addLocation(realpath(base_path('resources/views/mobile')));
     } else {
         \Config::set('js-controllers.path_controllers', 'dist/main/ng');
         \Config::set('js-controllers.path_js_files', 'dist/main/js');
         \View::addLocation(realpath(base_path('resources/views/desktop')));
     }
     return $next($request);
 }
Example #5
0
 function __construct($module)
 {
     if (!session_id()) {
         session_start();
     }
     // set Custom Pagination
     Config::set('view.pagination', 'frontend.partial.pagination');
     //set Theme
     $this->theme = Config::get('frontend.theme');
     // set module
     $this->module = $module;
     // no use layout master when ajax
     if (Request::ajax()) {
         $this->layout = null;
     }
     View::share('assetURL', 'frontend/theme/' . $this->theme . '/assets/');
     // add Location View
     View::addLocation(base_path() . '/frontend/theme/' . $this->theme . '/views/' . $this->module);
     View::addLocation(base_path() . '/frontend/theme/' . $this->theme . '/views');
     // add Lang
     Lang::addNamespace($this->module, base_path() . '/frontend/modules/' . $this->module . '/lang');
 }
 /**
  * @test
  *
  * Note that to complete this test, you must have aws credentials as well as a valid
  * from address in the mail config.
  */
 public function it_retrieves_the_mesage_id_from_ses()
 {
     if (!config('aws.credentials.key') || config('mail.from.address') == null) {
         $this->markTestIncomplete();
         return;
     }
     Config::set('mail.driver', 'ses');
     (new Illuminate\Mail\MailServiceProvider(app()))->register();
     // Must re-register the MailTracker to get the test to work
     $this->app['mailer']->getSwiftMailer()->registerPlugin(new MailTracker());
     $faker = Faker\Factory::create();
     $email = '*****@*****.**';
     $subject = $faker->sentence;
     $name = $faker->firstName . ' ' . $faker->lastName;
     \View::addLocation(__DIR__);
     \Mail::send('email.test', [], function ($message) use($email, $subject, $name) {
         $message->to($email, $name);
         $message->replyTo('*****@*****.**', 'Reply-To Name');
         $message->subject($subject);
         $message->priority(3);
     });
     $sent_email = \jdavidbakr\MailTracker\Model\SentEmail::orderBy('id', 'desc')->first();
     $this->assertEquals(0, preg_match('/swift\\.generated/', $sent_email->message_id));
 }
Example #7
0
 public function adsProcess()
 {
     //Cache::flush();
     $startProcess = microtime(1);
     ignore_user_abort(true);
     $this->layout = null;
     $response = null;
     $responseType = '';
     $expandFields = array();
     $deliveryStatus = '';
     $requestType = Input::get('rt', Delivery::REQUEST_TYPE_AD);
     $flightWebsiteID = Input::get('fpid', 0);
     $zoneID = Input::get('zid', 0);
     $websiteID = Input::get('wid', 0);
     $data = Input::all();
     $trackingModel = new Tracking();
     $deliveryModel = new Delivery();
     $vast = new Advalue\VAST();
     $isOverReport = $data['ovr'] = false;
     //ghi log trước khi xử lý
     $logPreProcess = $trackingModel->logPreProcess($requestType, $data);
     if ($logPreProcess) {
         //kiểm tra referrer
         $hostReferer = $trackingModel->getRequestReferer();
         $responseType = $trackingModel->checkPreProcess($requestType, $hostReferer, $zoneID);
         //pre validate ok
         if (empty($responseType)) {
             $adZone = $deliveryModel->getAdzone($zoneID);
             if (isset($data['type'])) {
                 $data['type'] = strtolower($data['type']);
             }
             if ($zoneID && $websiteID) {
                 if ($adZone && !empty($adZone->site)) {
                     $expandFields['ad_format_id'] = $adZone->ad_format_id;
                     if ($adZone->publisher_site_id == $websiteID) {
                         //kiểm tra referrer đúng với site đã đăng ký
                         // if(1){//test only
                         if (isSameDomain($hostReferer, getWebDomain($adZone->site->url)) || Input::get('ec') == 0 || isLocal()) {
                             $flightWebsites = $deliveryModel->getAvailableAds($adZone->publisher_site_id, $adZone->ad_format_id);
                             // shuffle($flightWebsites);
                             if ($flightWebsites) {
                                 //sort available flights base on priority and retargeting
                                 //TO DO retargeting
                                 $flightWebsites = $deliveryModel->sortAvailableFlightWebsites($flightWebsites);
                                 //lấy ad từ list thỏa điều kiện để trả về
                                 $deliveryInfo = $deliveryModel->getFullFlightInfo($flightWebsites, $adZone->publisher_site_id, $adZone->ad_format_id);
                                 foreach ($flightWebsites as $k => $flightWebsite) {
                                     if (!empty($deliveryInfo['flightDates'][$flightWebsite->flight_id]) && !empty($deliveryInfo['flights'][$flightWebsite->flight_id])) {
                                         $flightDates = $deliveryInfo['flightDates'][$flightWebsite->flight_id];
                                         $flight = $deliveryInfo['flights'][$flightWebsite->flight_id];
                                         $ad = $deliveryInfo['ads'][$flight->ad_id];
                                         $checkFlightDate = $deliveryModel->checkFlightDate($flightDates, $flight);
                                         //flight date ok
                                         if ($checkFlightDate) {
                                             $deliveryStatus = $deliveryModel->deliveryAd($ad, $flightWebsite, $flight, $flightDates);
                                             if ($deliveryStatus == Delivery::DELIVERY_STATUS_OK || $deliveryStatus == Delivery::DELIVERY_STATUS_OVER_REPORT) {
                                                 //pr($flight);
                                                 //trả về ad này
                                                 $serveAd = $ad;
                                                 $data['ad'] = $ad;
                                                 $data['aid'] = $ad->id;
                                                 $data['fpid'] = $flightWebsite->id;
                                                 //over report
                                                 if ($deliveryStatus == Delivery::DELIVERY_STATUS_OVER_REPORT) {
                                                     $data['ovr'] = $isOverReport = true;
                                                 }
                                                 $responseType = Delivery::RESPONSE_TYPE_ADS_SUCCESS;
                                                 // update number show retargeting
                                                 $url = $flight->retargeting_url;
                                                 if ($url != "") {
                                                     $campaign = $deliveryModel->getCampaign($flight->campaign_id);
                                                     $tracking = new Tracking();
                                                     $key = "Retargeting:{$campaign->advertiser_id}:{$tracking->getVisitorId()}";
                                                     $cache = RedisHelper::get($key);
                                                     if (isset($cache->{$url})) {
                                                         $keyNumberTarget = "RetargetingNumber:{$campaign->advertiser_id}:{$flight->id}:{$flight->ad_id}:{$tracking->getVisitorId()}";
                                                         $cacheNumberTarget = RedisHelper::get($keyNumberTarget);
                                                         if ($cacheNumberTarget) {
                                                             RedisHelper::increment($keyNumberTarget);
                                                         } else {
                                                             RedisHelper::set($keyNumberTarget, 1);
                                                         }
                                                     }
                                                 }
                                                 break;
                                             }
                                         }
                                     }
                                 }
                                 //endforeach
                             }
                             //no ads available
                             if ($responseType != Delivery::RESPONSE_TYPE_ADS_SUCCESS) {
                                 $responseType = Delivery::RESPONSE_TYPE_NOT_AVAILABLE;
                             }
                         } else {
                             $responseType = Delivery::RESPONSE_TYPE_REFERRER_NOT_MATCH;
                         }
                     }
                 }
             }
         }
     }
     //invalid ads request
     if (empty($responseType)) {
         $responseType = Delivery::RESPONSE_TYPE_INVALID;
     } elseif ($responseType == Delivery::RESPONSE_TYPE_ADS_SUCCESS) {
         $expandFields = array('flight_id' => $flightWebsite->flight_id, 'ad_format_id' => $adZone->ad_format_id, 'ad_id' => $flight->ad_id, 'campaign_id' => $flight->campaign_id, 'publisher_ad_zone_id' => $adZone->id, 'flight_website_id' => $flightWebsite->id, 'website_id' => $flightWebsite->website_id);
         if ($isOverReport) {
             $expandFields['ovr'] = 1;
         }
         $expandFields['checksum'] = $checksum = $trackingModel->makeChecksumHash($flightWebsite->id, $trackingModel->created_at);
         $eventChecksum = Delivery::RESPONSE_TYPE_ADS_SUCCESS;
         $trackingModel->setChecksumTrackingEvent($checksum, Delivery::RESPONSE_TYPE_ADS_SUCCESS);
         (new RawTrackingSummary())->addSummary('ads_request', $flightWebsite->website_id, $adZone->id, $adZone->ad_format_id, $flightWebsite->flight_id, $flightWebsite->id, $flight->ad_id, $flight->campaign_id);
     }
     //serve Ad
     // if(0){
     if (!empty($serveAd)) {
         View::addLocation(base_path() . '/frontend/theme/default/views/delivery');
         if (isset($data['ec'])) {
             if ($data['ec'] == 1) {
                 $data['checksum'] = $expandFields['checksum'];
                 $this->data['data'] = $data;
                 $data['type'] = $serveAd->ad_view ? $serveAd->ad_view : strtolower($data['type']);
                 if (Input::get('test') == 1) {
                     return View::make($data['type'], $this->data);
                 } else {
                     $response = Response::view($data['type'], $this->data)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 }
             } else {
                 $response = $vast->makeVAST($data['aid'], $data['fpid'], $data['zid'], $expandFields['checksum'], $isOverReport);
             }
         }
     } else {
         //TO DO : return backup ads
         if (!empty($adZone)) {
             $alternateAds = $deliveryModel->getAlternateAds($adZone->id);
             if (isset($adZone) && $alternateAds) {
                 if (isset($data['ec']) && !$data['ec']) {
                     $response = $vast->makeEmptyVast();
                 } else {
                     $this->data['listAlternateAd'] = $alternateAds;
                     $this->data['zid'] = $adZone->id;
                     View::addLocation(base_path() . '/frontend/theme/default/views/delivery');
                     $response = Response::view('rotator', $this->data)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 }
             } else {
                 if (isset($data['ec']) && !$data['ec']) {
                     $response = $vast->makeEmptyVast();
                 }
             }
             (new RawTrackingSummary())->addSummaryRequestEmptyAd($adZone->id, $adZone->ad_format_id, $websiteID);
         }
     }
     //ghi log process
     $trackingModel->logAfterProcess($responseType, $expandFields, $logPreProcess);
     //response to client
     $endProcess = microtime(1);
     pr($deliveryStatus);
     pr($responseType, 1);
     return $response;
 }
Example #8
0
    } else {
        Log::error($exception);
    }
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
View::addLocation(app_path() . '/themes');
View::addLocation(app_path() . '/themes/default');
Example #9
0
<?php

Lang::addNamespace('stream', public_path('plugins/streaming/plugin/lang'));
//register plugin routes
require public_path() . '/plugins/streaming/plugin/routes.php';
//register a filter for links
Route::filter('links', function ($route, $request, $value) {
    if (!is_string($value)) {
        App::Abort(403);
    }
    if (!Helpers::hasAccess("links.{$value}")) {
        return Redirect::to('/');
    }
});
//make sure laravel can find and load plugin views
View::addLocation(public_path('plugins/streaming/plugin/views'));
//override mtdb controllers
App::bind('DashboardController', function () {
    return new StreamingDashboardController();
});
App::bind('SeriesSeasonsController', function () {
    return new StreamingSeriesSeasonsController();
});
App::bind('SeasonsEpisodesController', function () {
    return new StreamingSeasonsEpisodesController();
});
//override other classes
App::bind('Lib\\Repository', function () {
    return new Plugins\Streaming\Plugin\Lib\Repository();
});
App::bind('Lib\\Titles\\TitleRepository', function () {
Example #10
0
        //kd($module->getpath());
    }
}
//add_filter('theme_root',function($theme_root){
//    return __DIR__;
//});
//add_filter('theme_root_uri',function($theme_root_uri = '', $siteurl = '', $stylesheet_or_template = ''){
//    kd($theme_root_uri, $siteurl, $stylesheet_or_template);
//    return content_url();
//});
show_admin_bar(false);
// 上传图片时把绝对地址修改成相对地址(禁用,导致上传文件http错误)
//add_filter('wp_handle_upload', function ($fileInfos){
//    global $blog_id;
//    $path = get_blog_option($blog_id, 'siteurl');
//
//    $fileInfos['url'] = str_replace($path, '', $fileInfos['url']);
//
//    return $fileInfos;
//});
add_action("user_register", function ($user_id) {
    update_user_meta($user_id, 'show_admin_bar_front', false);
    //update_user_meta( $user_id, 'show_admin_bar_admin', 'false' );
}, 10, 1);
if (is_dir(get_template_directory() . '/Resources/views')) {
    View::addLocation(get_template_directory() . '/Resources/views');
    View::addNamespace('tpl', get_template_directory() . '/Resources/views');
}
View::addLocation(get_template_directory());
View::addNamespace('default', get_template_directory());
//kd(get_template_directory());
Example #11
0
 public function __construct($module, $layout)
 {
     if (session_id() == '') {
         @session_start();
     }
     //CUSTOM PAGINATION BACKEND
     Config::set('view.pagination', 'partials.pagination');
     // set section name by segment
     $this->section = Request::segment(2);
     // set folder name of section
     $this->sectionFolder = str_replace("-", "_", $this->section);
     // set user
     $this->user = Sentry::getUser();
     if ($this->user) {
         $this->beforeFilter(function () {
             if (!$this->checkUserSection()) {
                 return $this->logout();
             }
         });
     }
     // set module name
     $this->moduleName = $module;
     // share global module route prefix
     View::share('moduleRoutePrefix', Str::studly($module));
     // set module name by segment
     $this->moduleSegment = Request::segment(3);
     // set folder name of module
     $this->moduleFolder = str_replace("-", "_", $this->moduleName);
     // set url of module
     $this->moduleURL = URL::to('/') . '/' . Config::get('backend.uri') . '/' . $this->section . '/' . $this->moduleSegment . '/';
     // set theme
     $this->theme = Config::get('backend.theme');
     // set asset url
     $this->assetURL = url() . '/backend/theme/' . $this->theme . '/assets/';
     // set view path for autoload
     View::addLocation(base_path() . '/backend/theme/' . $this->theme . '/views/' . $this->sectionFolder . '/' . $this->moduleFolder);
     View::addLocation(base_path() . '/backend/theme/' . $this->theme . '/views/' . $this->sectionFolder);
     View::addLocation(base_path() . '/backend/theme/' . $this->theme . '/views/general');
     View::addLocation(base_path() . '/backend/theme/' . $this->theme . '/views');
     // set asset url for all view
     View::share('assetURL', $this->assetURL);
     // Set lang namespace
     Lang::addNamespace("backend", base_path() . '/backend/lang');
     Lang::addNamespace($this->moduleSegment, base_path() . '/backend/modules/' . $this->moduleFolder . '/lang');
     // no use layout master when ajax
     if (Request::ajax()) {
         $this->layout = null;
     } else {
         $this->layout = View::make($layout);
     }
 }
Example #12
0
<?php

/**
 * Cutlass includes
 *
 * The $cutlass_includes array determines the code library included in your theme.
 * Add or remove files to the array as needed. Supports child theme overrides.
 *
 * Please note that missing files will produce a fatal error.
 */
$cutlass_includes = array('utils.php', 'init.php', 'config.php', 'activation.php', 'titles.php', 'wp_bootstrap_navwalker.php', 'gallery.php', 'comments.php', 'scripts.php', 'extras.php');
///if (defined('TEMPLATEPATH')) {
View::addLocation(__DIR__ . '/Resources/views');
View::addNamespace('tpl', __DIR__ . '/Resources/views');
//}
foreach ($cutlass_includes as $file) {
    if (!($filepath = locate_template("Entities/{$file}"))) {
        trigger_error(sprintf(__('Error locating %s for inclusion', 'cutlass'), $file), E_USER_ERROR);
    }
    require_once $filepath;
}
unset($file, $filepath);
Example #13
0
<?php

View::share('currentuser', Auth::user());
Asset::push('js', 'application');
Asset::push('css', 'application');
if (Session::has('errors')) {
    foreach (Session::get('errors')->all() as $message) {
        Log::error($message);
    }
}
View::addLocation(app_path() . '/base/views');
 public function boot()
 {
     \View::addLocation(__DIR__ . '/../Views');
     // Bring in the routes
     require __DIR__ . '/../routes.php';
 }
Example #15
0
    Log::error($exception);
});
/*
|--------------------------------------------------------------------------
| Maintenance Mode Handler
|--------------------------------------------------------------------------
|
| The "down" Artisan command gives you the ability to put an application
| into maintenance mode. Here, you will define what is displayed back
| to the user if maintenance mode is in effect for the application.
|
*/
App::down(function () {
    return Response::make("Be right back!", 503);
});
/*
|--------------------------------------------------------------------------
| Require The Filters File
|--------------------------------------------------------------------------
|
| Next we will load the filters file for the application. This gives us
| a nice separate location to store our route and application filter
| definitions instead of putting them all in the main routes file.
|
*/
require app_path() . '/filters.php';
View::addLocation(DIRNAME(app_path()) . '/src/views');
require app_path() . '/helpers/Validate.php';
require app_path() . '/helpers/General.php';
// require app_path() . '/helpers/Images.php';
// require app_path() . '/helpers/scss.inc.php';
Example #16
0
<?php

/*
|--------------------------------------------------------------------------
| Register The Laravel Class Loader
|--------------------------------------------------------------------------
|
| In addition to using Composer, you may use the Laravel class loader to
| load your controllers and models. This is useful for keeping all of
| your classes in the "global" namespace without Composer updating.
|
*/
ClassLoader::addDirectories(array(app_path() . '/commands', app_path() . '/controllers', app_path() . '/models', app_path() . '/database/seeds'));
View::addLocation(app('path') . '/MVC/views');
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
|
| Here you may handle any errors that occur in your application, including
Example #17
0
ClassLoader::addDirectories(File::directories(app_path() . '/plugins'));
/*
|--------------------------------------------------------------------------
| Theme functions
|--------------------------------------------------------------------------
|
| Built on top of Laravel is our custom theme functions, we need to make
| sure they're all loaded so there's no errors
|
*/
$functions = array('metadata', 'theme', 'page');
foreach ($functions as $function) {
    require app_path() . '/functions/' . $function . '.php';
}
View::addNamespace('theme', 'public/themes/' . Metadata::item('theme', 'default'));
View::addLocation(get_theme_path('layouts'));
/*
|--------------------------------------------------------------------------
| Application Error Logger
|--------------------------------------------------------------------------
|
| Here we will configure the error logger setup for the application which
| is built on top of the wonderful Monolog library. By default we will
| build a basic log file setup which creates a single file for logs.
|
*/
Log::useFiles(storage_path() . '/logs/laravel.log');
/*
|--------------------------------------------------------------------------
| Application Error Handler
|--------------------------------------------------------------------------
Example #18
0
            return Redirect::to('wardrobe');
        });
    });
});
Route::group(Config::get('core::routes.admin_group_rules'), function () use($wardrobeControllers) {
    Route::get('/', array('uses' => $wardrobeControllers . 'AdminController@index', 'as' => 'wardrobe.admin.index'));
    Route::get('logout', array('uses' => $wardrobeControllers . 'LoginController@destroy', 'as' => 'wardrobe.admin.logout'));
    Route::get('login', array('uses' => $wardrobeControllers . 'LoginController@create', 'as' => 'wardrobe.admin.login'));
    Route::post('login', array('uses' => $wardrobeControllers . 'LoginController@store'));
    Route::get('login/remind', array('uses' => $wardrobeControllers . 'LoginController@remindForm', 'as' => 'wardrobe.admin.remindForm'));
    Route::post('login/remind', array('uses' => $wardrobeControllers . 'LoginController@remindSend'));
});
Route::group(Config::get('core::routes.api_group_rules'), function () use($wardrobeControllers) {
    Route::get('/', array('as' => 'wardrobe.api.index'));
    Route::resource('post', $wardrobeControllers . 'Api\\PostController');
    Route::resource('tag', $wardrobeControllers . 'Api\\TagController');
    Route::resource('user', $wardrobeControllers . 'Api\\UserController');
    Route::controller('dropzone', $wardrobeControllers . 'Api\\DropzoneController');
});
if (Config::get('core::wardrobe.handles_404')) {
    App::missing(function ($exception) {
        View::addLocation(public_path() . '/' . Config::get('core::wardrobe.theme_dir'));
        return Response::view(theme_view('404'), array(), 404);
    });
}
/**
 * Allows themes complete control to over ride routes or add new ones.
 */
if (file_exists($theme_routes = public_path() . '/' . Config::get('core::wardrobe.theme_dir') . '/' . Config::get('core::wardrobe.theme') . '/routes.php')) {
    include $theme_routes;
}
 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     View::addLocation(realpath(addon_path(addon_name(), 'resources/views')));
     $this->setupPublishFiles();
 }
Example #20
0
 public function getDefaultView($title = "api doc")
 {
     $view_path = realpath(base_path("vendor/hurongsheng/laravel-route-doc/lib"));
     \View::addLocation($view_path);
     return view('route_doc', ['api_doc' => $this->getDoc(), 'title' => $title]);
 }
Example #21
0
    // return '';
    // pr( Cache::get('Report:Schedule') );
    $tracking = new RawTrackingSummary();
    if ($rows = $tracking->reportScheduleDaily()) {
        // $cacheKey = "Report:Schedule";
        // Cache::forget($cacheKey);
        pr($rows);
        echo "Report Success";
    } else {
        echo "No Report Complete";
    }
    die;
});
Route::group(array('prefix' => 'demo'), function () {
    View::addLocation(base_path() . '/backend/theme/default/views/demo');
    View::addLocation(base_path() . '/frontend/theme/default/views/home');
    Route::get('jwplayer6/vast', function () {
        return View::make('demoJWplayer6');
    });
    Route::get('jwplayer5/vast', function () {
        return View::make('demoJWplayer5');
    });
    Route::get('tvc', 'HomeController@demoTVC');
    Route::get('run-vast-support', 'HomeController@demoVast');
    Route::get('run-popup', 'HomeController@demoPopup');
    Route::get('balloon', 'HomeController@demoBalloon');
    Route::get('pause-vast', 'HomeController@demoPauseVast');
    Route::get('sidekicknew', 'HomeController@demoSidekick');
});
Route::get('remonth', function () {
    set_time_limit(0);
Example #22
0
 public function adsProcess()
 {
     $startProcess = microtime(1);
     $this->layout = null;
     $response = null;
     $responseType = '';
     $expandFields = array();
     $deliveryStatus = '';
     $requestType = Input::get('rt', Delivery::REQUEST_TYPE_AD);
     $flightWebsiteID = Input::get('fpid', '');
     $zoneID = Input::get('zid', 0);
     $websiteID = Input::get('wid', 0);
     $platform = Input::get('plf', '');
     $tag = Input::get('tag', '');
     $data = Input::all();
     $trackingModel = new Tracking();
     $deliveryModel = new Delivery();
     $isOverReport = $data['ovr'] = false;
     $showBanner = showBanner();
     if ($showBanner !== FALSE) {
         $flightWebsiteID = $showBanner;
     }
     //$uuid = $trackingModel->getVisitorId();
     //ghi log ad request
     (new RawTrackingAdRequest())->addAdRequest($websiteID, $zoneID);
     // if($continueProcess){
     //check pre process
     $hostReferer = $trackingModel->getRequestReferer();
     $responseType = $trackingModel->checkPreProcess($requestType, $hostReferer, $zoneID);
     //pre validate ok
     if (empty($responseType)) {
         //read redis 1
         $data['ref'] = $hostReferer;
         $adZone = $deliveryModel->getAdzone($zoneID);
         if ($adZone && !empty($adZone->site)) {
             $expandFields['ad_format_id'] = $adZone->ad_format_id;
             if ($adZone->publisher_site_id == $websiteID) {
                 //kiểm tra referrer đúng với site đã đăng ký
                 // if(1){//test only
                 $publisherSite = $deliveryModel->getPublisherSite($adZone->publisher_site_id);
                 pr($publisherSite);
                 $domainCheck = isset($publisherSite->domain_checking) ? $publisherSite->domain_checking : 1;
                 if (!$domainCheck || isSameDomain($hostReferer, getWebDomain($adZone->site->url)) || isLocal()) {
                     //    if ($platform == '') {
                     //     $platform = $deliveryModel->getPlatform();
                     // }
                     $platform = '';
                     //read redis 1
                     $flightWebsites = $deliveryModel->getAvailableAds($adZone->publisher_site_id, $adZone->ad_format_id, $flightWebsiteID, $platform);
                     if ($flightWebsites) {
                         //lấy ad từ list thỏa điều kiện để trả về
                         $deliveryInfo = $deliveryModel->getFullFlightInfo($flightWebsites, $adZone->publisher_site_id, $adZone->ad_format_id);
                         //random array flight website, priority flight audience
                         $flightWebsites = $deliveryModel->sortAvailableFlightWebsites($flightWebsites, $deliveryInfo);
                         pr($flightWebsites);
                         pr($deliveryInfo);
                         $redis = new RedisBaseModel(env('REDIS_HOST', '127.0.0.1'), env('REDIS_PORT_6', '6379'), false);
                         foreach ($flightWebsites as $k => $flightWebsite) {
                             if (!empty($flightWebsite) && !empty($deliveryInfo['flightDates'][$flightWebsite->flight_id]) && !empty($deliveryInfo['flights'][$flightWebsite->flight_id])) {
                                 $flightDates = $deliveryInfo['flightDates'][$flightWebsite->flight_id];
                                 $flight = $deliveryInfo['flights'][$flightWebsite->flight_id];
                                 $ad = $deliveryInfo['ads'][$flight->ad_id];
                                 if ($deliveryModel->checkPlatform($ad) === TRUE || isLocal()) {
                                     $checkFlightDate = $deliveryModel->checkFlightDate($flightDates, $flight);
                                     //flight date ok
                                     if ($checkFlightDate) {
                                         $deliveryStatus = $deliveryModel->deliveryAd($ad, $flightWebsite, $flight, $flightDates);
                                         if ($deliveryStatus == Delivery::DELIVERY_STATUS_OK || $deliveryStatus == Delivery::DELIVERY_STATUS_OVER_REPORT) {
                                             if (empty($data['ec']) && !empty($ad->vast_include) && !empty($ad->video_wrapper_tag)) {
                                                 $xmlVastTag = $this->getVastAdTagUri($ad->id, $this->replaceParam($ad->video_wrapper_tag));
                                                 if (empty($xmlVastTag)) {
                                                     continue;
                                                 }
                                             }
                                             if (!empty($flight->filter)) {
                                                 if (!$deliveryModel->checkTag($flight->filter, urldecode($tag))) {
                                                     $deliveryStatus = Delivery::TAG_TYPE_INVALID;
                                                     continue;
                                                 }
                                             }
                                             //Check retargeting
                                             if (!empty($flight->audience)) {
                                                 $check = false;
                                                 $audience = json_decode($flight->audience, true);
                                                 if (!empty($audience['audience_id'])) {
                                                     if (isset($_COOKIE["yoAu_{$audience['audience_id']}"]) && !empty($_COOKIE["uuid"])) {
                                                         if ($_COOKIE["yoAu_{$audience['audience_id']}"] === '1' || substr($_COOKIE["yoAu_{$audience['audience_id']}"], 0, 2) === '1.') {
                                                             $check = true;
                                                         }
                                                     }
                                                     if ($audience['operator'] === 'not in') {
                                                         $check = !$check;
                                                     }
                                                 }
                                                 if ($check === false) {
                                                     $deliveryStatus = Delivery::RESPONSE_TYPE_AUDIENCE_LIMIT;
                                                     continue;
                                                 }
                                             }
                                             //trả về ad này
                                             pr($flightWebsite);
                                             $serveAd = $ad;
                                             $data['ad'] = $ad;
                                             $data['aid'] = $ad->id;
                                             $data['fpid'] = $flightWebsite->id;
                                             $data['flight'] = $flight;
                                             //over report
                                             if ($deliveryStatus == Delivery::DELIVERY_STATUS_OVER_REPORT) {
                                                 $data['ovr'] = $isOverReport = true;
                                             }
                                             $responseType = Delivery::RESPONSE_TYPE_ADS_SUCCESS;
                                             break;
                                         }
                                     } else {
                                         $deliveryStatus = Delivery::RESPONSE_TYPE_FLIGHTDATE_NOT_AVAILABLE;
                                     }
                                 } else {
                                     $deliveryStatus = Delivery::PLATFORM_TYPE_INVALID;
                                 }
                             }
                         }
                         //endforeach
                     }
                     //no ads available
                     if ($responseType != Delivery::RESPONSE_TYPE_ADS_SUCCESS) {
                         $responseType = Delivery::RESPONSE_TYPE_NOT_AVAILABLE;
                     }
                 } else {
                     $responseType = Delivery::RESPONSE_TYPE_REFERRER_NOT_MATCH;
                 }
             }
         }
     }
     // }
     //invalid ads request
     $bLogAdsSuccess = false;
     if (empty($responseType)) {
         $responseType = Delivery::RESPONSE_TYPE_INVALID;
     } elseif ($responseType == Delivery::RESPONSE_TYPE_ADS_SUCCESS) {
         $bLogAdsSuccess = true;
         $expandFields = array('flight_id' => $flightWebsite->flight_id, 'ad_format_id' => $adZone->ad_format_id, 'ad_id' => $flight->ad_id, 'campaign_id' => $flight->campaign_id, 'publisher_ad_zone_id' => $adZone->id, 'flight_website_id' => $flightWebsite->id, 'website_id' => $flightWebsite->website_id, 'publisher_base_cost' => $flightWebsite->publisher_base_cost);
         if ($isOverReport) {
             $expandFields['ovr'] = 1;
         }
         $expandFields['checksum'] = $checksum = $trackingModel->makeChecksumHash($flightWebsite->id);
         $eventChecksum = Delivery::RESPONSE_TYPE_ADS_SUCCESS;
         $trackingModel->setChecksumTrackingEvent($checksum, Delivery::RESPONSE_TYPE_ADS_SUCCESS);
     }
     $data['url_track_ga'] = $deliveryModel->getUrlTrack3rd($data);
     //serve Ad
     // if(0){
     if (!empty($serveAd)) {
         \View::addLocation(base_path() . '/resources/views/delivery');
         if (isset($data['ec'])) {
             if ($data['ec'] == 1) {
                 $data['checksum'] = $expandFields['checksum'];
                 $data['element_id'] = isset($adZone->element_id) ? $adZone->element_id : '';
                 $data['category_name'] = '';
                 $adFormat = $deliveryModel->getAdFormat($data['ad']->ad_format_id);
                 if (empty($data['flight']->category_id)) {
                     $campaign = $deliveryModel->getCampaign($data['flight']->campaign_id);
                     if (!empty($campaign)) {
                         $category = $deliveryModel->getCategory($campaign->category_id);
                         $data['category_name'] = isset($category->name) ? str_replace(' ', '_', strtolower($category->name)) : '';
                     }
                 } else {
                     $category = $deliveryModel->getCategory($data['flight']->category_id);
                     if (!empty($category)) {
                         $data['category_name'] = isset($category->name) ? str_replace(' ', '_', strtolower($category->name)) : '';
                     }
                 }
                 $data['flight_name'] = isset($data['flight']->name) ? str_replace(' ', '_', $data['flight']->name) : '';
                 $data['ad_format'] = isset($adFormat->name) ? str_replace(' ', '_', $adFormat->name) : '';
                 $data['publisher_domain'] = $hostReferer;
                 $data['rd'] = str_random(40);
                 $this->data['data'] = $data;
                 $data['type'] = $serveAd->ad_view ? $serveAd->ad_view : strtolower($data['type']);
                 if (Input::get('test') == 1) {
                     return response(\View::make($data['type'], $this->data), 200)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 } else {
                     $response = response(\View::make($data['type'], $this->data), 200)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 }
             } else {
                 $response = (new VAST())->makeVAST($data['aid'], $data['fpid'], $data['zid'], $expandFields['checksum'], $isOverReport);
             }
         }
     } else {
         //TO DO : return backup ads
         if (!empty($adZone)) {
             $adZone->alternateAds = !empty($adZone->alternateAds) ? $adZone->alternateAds : $deliveryModel->getAlternateAds($adZone->id);
             if (isset($adZone) && !empty($adZone->alternateAds)) {
                 if (isset($data['ec']) && !$data['ec']) {
                     // TO DO : return backup vast
                     shuffle($adZone->alternateAds);
                     $firstBackup = array_shift($adZone->alternateAds);
                     $response = (new VAST())->makeBackupVast($adZone->id, $firstBackup->code);
                 } else {
                     $this->data['listAlternateAd'] = $adZone->alternateAds;
                     $this->data['zid'] = $adZone->id;
                     $this->data['data']['url_track_ga'] = $data['url_track_ga'];
                     \View::addLocation(base_path() . '/resources/views/delivery');
                     $response = response(\View::make('rotator', $this->data), 200)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 }
             } else {
                 if (isset($data['ec']) && !$data['ec']) {
                     $response = (new VAST())->makeEmptyVast();
                 } else {
                     $this->data['data']['url_track_ga'] = $data['url_track_ga'];
                     \View::addLocation(base_path() . '/resources/views/delivery');
                     $response = response(\View::make('url_track_ga', $this->data), 200)->header('Content-Type', 'text/javascript; charset=UTF-8');
                 }
             }
             (new RawTrackingSummary())->addSummaryRequestEmptyAd($adZone->id, $adZone->ad_format_id, $websiteID, $isOverReport);
         }
     }
     //ghi log ad success
     if ($bLogAdsSuccess) {
         (new RawTrackingSummary())->addSummary('ads_request', $flightWebsite->website_id, $adZone->id, $adZone->ad_format_id, $flightWebsite->flight_id, $flightWebsite->id, $flight->ad_id, $flight->campaign_id, $flightWebsite->publisher_base_cost, $isOverReport);
     }
     //response to client
     $endProcess = microtime(1);
     pr("Times: " . ($endProcess - $startProcess));
     pr($deliveryStatus);
     pr($responseType, 1);
     return $response;
 }
Example #23
0
    $uploads['basedir'] = ROOT . '/data/uploads/media';
    $uploads['path'] = $uploads['basedir'] . $uploads['subdir'];
    if ($upload_url_path) {
        $uploads['baseurl'] = $upload_url_path;
        $uploads['url'] = $uploads['baseurl'] . $uploads['subdir'];
    }
    return $uploads;
});
//解决上传文件名中文乱码问题
add_filter('sanitize_file_name', function ($filename) {
    $ext = pathinfo($filename, PATHINFO_EXTENSION);
    $newname = date('YmdHis') . floor(microtime() * 1000) . substr(md5($filename), 16) . ($ext ? ".{$ext}" : '');
    return $newname;
}, 10);
show_admin_bar(false);
/**
 * @see http://zmingcx.com/wordpress-4-2-edition-problem.html
 */
function init_smilies()
{
    global $wpsmiliestrans;
    $wpsmiliestrans = array(':mrgreen:' => 'icon_mrgreen.gif', ':neutral:' => 'icon_neutral.gif', ':twisted:' => 'icon_twisted.gif', ':arrow:' => 'icon_arrow.gif', ':shock:' => 'icon_eek.gif', ':smile:' => 'icon_smile.gif', ':???:' => 'icon_confused.gif', ':cool:' => 'icon_cool.gif', ':evil:' => 'icon_evil.gif', ':grin:' => 'icon_biggrin.gif', ':idea:' => 'icon_idea.gif', ':oops:' => 'icon_redface.gif', ':razz:' => 'icon_razz.gif', ':roll:' => 'icon_rolleyes.gif', ':wink:' => 'icon_wink.gif', ':cry:' => 'icon_cry.gif', ':eek:' => 'icon_surprised.gif', ':lol:' => 'icon_lol.gif', ':mad:' => 'icon_mad.gif', ':sad:' => 'icon_sad.gif', '8-)' => 'icon_cool.gif', '8-O' => 'icon_eek.gif', ':-(' => 'icon_sad.gif', ':-)' => 'icon_smile.gif', ':-?' => 'icon_confused.gif', ':-D' => 'icon_biggrin.gif', ':-P' => 'icon_razz.gif', ':-o' => 'icon_surprised.gif', ':-x' => 'icon_mad.gif', ':-|' => 'icon_neutral.gif', ';-)' => 'icon_wink.gif', '8O' => 'icon_eek.gif', ':(' => 'icon_sad.gif', ':)' => 'icon_smile.gif', ':?' => 'icon_confused.gif', ':D' => 'icon_biggrin.gif', ':P' => 'icon_razz.gif', ':o' => 'icon_surprised.gif', ':x' => 'icon_mad.gif', ':|' => 'icon_neutral.gif', ';)' => 'icon_wink.gif', ':!:' => 'icon_exclaim.gif', ':?:' => 'icon_question.gif');
}
add_action('init', 'init_smilies', 5);
//require __DIR__.'/extra/remove-category-parents.php';
/** @type \YCMS\Modules\Module $module */
foreach (\Modules::all() as $module) {
    \register_theme_directory(dirname($module->getPath()));
}
View::addLocation(realpath(get_template_directory() . '/Resources/views') ?: get_template_directory());
 public function setUp()
 {
     parent::setUp();
     View::addLocation(dirname(__DIR__) . '/fixtures/views');
 }
 function saveCodeSingleFlight($pid = 0, $wid = 0, $zid = 0, $fwid = 0)
 {
     $adZoneModel = new PublisherAdZoneBaseModel();
     $item = $adZoneModel->where('id', $zid)->first();
     if ($item) {
         View::addLocation(base_path() . '/backend/theme/' . $this->theme . '/views/partials');
         $view = "code" . $item->adFormat->code_view;
         //$view = Config::get("ad_format_code.$item->ad_format_id");
         $data['wid'] = $item->publisher_site_id;
         $data['zid'] = $zid;
         $data['pid'] = $pid;
         $data['fwid'] = $fwid;
         $data['el_id'] = $item->element_id;
         $data['width'] = $item->width;
         $data['height'] = $item->height;
         $contents = View::make($view . 'Save', $data);
         $response = Response::make($contents, '200');
         $response->header('Content-Description', 'File Transfer');
         $response->header('Content-Type', 'application/octet-stream');
         $response->header('Content-Disposition', "attachment; filename={$item->site->name}_{$item->adFormat->name}_{$fwid}.txt");
         $response->header('Content-Transfer-Encoding', 'binary');
         $response->header('Expires', '0');
         $response->header('Cache-Control', 'must-revalidate');
         $response->header('Pragma', 'public');
         return $response;
     }
 }