Exemplo n.º 1
0
|			return 'Filtered!';
|		});
|
| Next, attach the filter to a route:
|
|		Route::get('/', array('before' => 'filter', function()
|		{
|			return 'Hello World!';
|		}));
|
*/
Route::filter('before', function () {
    if (@$_SERVER["HTTP_CF_CONNECTING_IP"]) {
        $CF = array('204.93.240.0/24', '204.93.177.0/24', '199.27.128.0/21', '173.245.48.0/20', '103.21.244.0/22', '103.22.200.0/22', '103.31.4.0/22', '141.101.64.0/18', '108.162.192.0/18', '190.93.240.0/20', '188.114.96.0/20', '197.234.240.0/22', '198.41.128.0/17', '162.158.0.0/15');
        foreach ($CF as $range) {
            if (Appsettings::isCloudFlare($range)) {
                $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
                break;
            }
        }
    }
    $dtz = new DateTimeZone(Config::get('application.timezone'));
    $time_in_sofia = new DateTime('now', $dtz);
    $offset = $dtz->getOffset($time_in_sofia) / 3600;
    $offset = $offset . ':00';
    $offset = $offset < 0 ? $offset : "+" . $offset;
    DB::query('SET time_zone = ?', array($offset));
    /*
     *
     * Check if logged in user is banned
     */
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Appsettings the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Appsettings::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }