| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace coderius\hitCounter\components\deviceDetect; | 
| 4 | 4 | |
| 5 | -interface IDeviceDetect{ | |
| 5 | +interface IDeviceDetect { | |
| 6 | 6 | |
| 7 | 7 | public function getOs(); | 
| 8 | 8 | |
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | use DeviceDetector\Parser\Device\DeviceParserAbstract; | 
| 11 | 11 | use yii\base\Component; | 
| 12 | 12 | |
| 13 | -class DeviceDetector extends  Component implements IDeviceDetect{ | |
| 13 | +class DeviceDetector extends  Component implements IDeviceDetect { | |
| 14 | 14 | |
| 15 | 15 | private $detector; | 
| 16 | 16 | |
| @@ -8,7 +8,7 @@ discard block | ||
| 8 | 8 | use yii\base\Model; | 
| 9 | 9 | use coderius\hitCounter\Module; | 
| 10 | 10 | |
| 11 | -class HitCounterModel extends Model{ | |
| 11 | +class HitCounterModel extends Model { | |
| 12 | 12 | // const SCENARIO_CREATE = 'create'; | 
| 13 | 13 | // const SCENARIO_UPDATE = 'update'; | 
| 14 | 14 | |
| @@ -62,12 +62,12 @@ discard block | ||
| 62 | 62 | return [ | 
| 63 | 63 | [['counter_id'], 'required'], | 
| 64 | 64 | [['js_cookei_enabled', 'js_java_enabled', 'js_timezone_offset', 'js_screen_width', 'js_screen_height', 'js_color_depth', 'js_history_length', 'js_is_toutch_device', 'js_processor_ram', 'serv_auth_user_id', 'serv_is_proxy_or_vpn', 'serv_port'], 'integer'], | 
| 65 | - [['serv_cookies','js_current_url', 'js_referer_url','serv_referer_url','serv_user_agent'], 'string'], | |
| 66 | - [['counter_id', 'js_timezone', 'js_connection', 'js_browser_language', 'serv_server_name', 'serv_os', 'serv_client', 'serv_device', 'serv_brand', 'serv_model', 'serv_bot', 'serv_host_by_ip'], 'string', 'max' => 255], | |
| 65 | + [['serv_cookies', 'js_current_url', 'js_referer_url', 'serv_referer_url', 'serv_user_agent'], 'string'], | |
| 66 | + [['counter_id', 'js_timezone', 'js_connection', 'js_browser_language', 'serv_server_name', 'serv_os', 'serv_client', 'serv_device', 'serv_brand', 'serv_model', 'serv_bot', 'serv_host_by_ip'], 'string', 'max' => 255], | |
| 67 | 67 | [['cookie_mark'], 'string', 'max' => 32], | 
| 68 | 68 | [['serv_ip'], 'string', 'max' => 20], | 
| 69 | 69 | [['serv_auth_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => Module::getInstance()->userIdentityClass, 'targetAttribute' => ['serv_auth_user_id' => 'id']], | 
| 70 | - [['cookie_mark', 'js_current_url', 'serv_ip', 'js_timezone_offset','js_timezone', 'js_connection','js_referer_url','js_screen_width','js_screen_height','js_color_depth','js_browser_language','js_history_length','js_processor_ram','serv_user_agent','serv_referer_url','serv_server_name','serv_auth_user_id','serv_port','serv_cookies','serv_os','serv_client','serv_device','serv_brand','serv_model','serv_bot','serv_host_by_ip'], 'default', 'value' => null], | |
| 70 | + [['cookie_mark', 'js_current_url', 'serv_ip', 'js_timezone_offset', 'js_timezone', 'js_connection', 'js_referer_url', 'js_screen_width', 'js_screen_height', 'js_color_depth', 'js_browser_language', 'js_history_length', 'js_processor_ram', 'serv_user_agent', 'serv_referer_url', 'serv_server_name', 'serv_auth_user_id', 'serv_port', 'serv_cookies', 'serv_os', 'serv_client', 'serv_device', 'serv_brand', 'serv_model', 'serv_bot', 'serv_host_by_ip'], 'default', 'value' => null], | |
| 71 | 71 | ]; | 
| 72 | 72 | } | 
| 73 | 73 | |
| @@ -77,7 +77,7 @@ | ||
| 77 | 77 | |
| 78 | 78 | return $data; | 
| 79 | 79 |          }else{ | 
| 80 | -           throw new BadRequestHttpException('required get param "i" cannot be empty.');  | |
| 80 | +            throw new BadRequestHttpException('required get param "i" cannot be empty.');  | |
| 81 | 81 | } | 
| 82 | 82 | |
| 83 | 83 | } | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 | $data['js_processor_ram'] = ArrayHelper::getValue($array, 'ram'); | 
| 77 | 77 | |
| 78 | 78 | return $data; | 
| 79 | -        }else{ | |
| 79 | +        } else{ | |
| 80 | 80 |             throw new BadRequestHttpException('required get param "i" cannot be empty.');  | 
| 81 | 81 | } | 
| 82 | 82 | |
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 | |
| 126 | 126 |          if ($request->cookies->has($name)){ | 
| 127 | 127 | return $request->cookies->getValue($name); | 
| 128 | -        }else{ | |
| 128 | +        } else{ | |
| 129 | 129 | $str = Yii::$app->getSecurity()->generateRandomString(); | 
| 130 | 130 | |
| 131 | 131 | // add to HTTP | 
| @@ -20,14 +20,14 @@ discard block | ||
| 20 | 20 | use yii\web\BadRequestHttpException; | 
| 21 | 21 | |
| 22 | 22 | |
| 23 | -class HitCounterService extends Component{ | |
| 23 | +class HitCounterService extends Component { | |
| 24 | 24 | |
| 25 | 25 | use RequestTrait; | 
| 26 | 26 | |
| 27 | 27 | private $deviceDetector; | 
| 28 | 28 | private $repoHitCounter; | 
| 29 | 29 | |
| 30 | - public function __construct(IDeviceDetect $dd, HitCounterRepository $hcr, $config = []) | |
| 30 | + public function __construct(IDeviceDetect $dd, HitCounterRepository $hcr, $config = []) | |
| 31 | 31 |      { | 
| 32 | 32 | $this->deviceDetector = $dd; | 
| 33 | 33 | $this->repoHitCounter = $hcr; | 
| @@ -37,7 +37,7 @@ discard block | ||
| 37 | 37 | |
| 38 | 38 | public function create(HitCounterModel $model, string $entityClass = HitCounter::class): HitCounter | 
| 39 | 39 |      { | 
| 40 | - $dto = (new HitCounterModelDtoAssembler())->writeDto($model);//dto | |
| 40 | + $dto = (new HitCounterModelDtoAssembler())->writeDto($model); //dto | |
| 41 | 41 | $hit = (new HitCounterDtoAssembler($entityClass))->readDto($dto); | 
| 42 | 42 | |
| 43 | 43 | $this->repoHitCounter->save($hit); | 
| @@ -57,7 +57,7 @@ discard block | ||
| 57 | 57 | $array = $request->get(); | 
| 58 | 58 | $data = []; | 
| 59 | 59 | |
| 60 | -        if(isset($array['i'])){ | |
| 60 | +        if (isset($array['i'])) { | |
| 61 | 61 | $data['counter_id'] = $array['i']; | 
| 62 | 62 | $data['js_cookei_enabled'] = ArrayHelper::getValue($array, 'c', 0); | 
| 63 | 63 | $data['js_java_enabled'] = ArrayHelper::getValue($array, 'j', 0); | 
| @@ -69,13 +69,13 @@ discard block | ||
| 69 | 69 | $data['js_screen_width'] = ArrayHelper::getValue($array, 'w'); | 
| 70 | 70 | $data['js_screen_height'] = ArrayHelper::getValue($array, 'h'); | 
| 71 | 71 | $data['js_color_depth'] = ArrayHelper::getValue($array, 'd'); | 
| 72 | - $data['js_browser_language']= ArrayHelper::getValue($array, 'lg'); | |
| 72 | + $data['js_browser_language'] = ArrayHelper::getValue($array, 'lg'); | |
| 73 | 73 | $data['js_history_length'] = ArrayHelper::getValue($array, 'hl'); | 
| 74 | - $data['js_is_toutch_device']= ArrayHelper::getValue($array, 'td', 0); | |
| 74 | + $data['js_is_toutch_device'] = ArrayHelper::getValue($array, 'td', 0); | |
| 75 | 75 | $data['js_processor_ram'] = ArrayHelper::getValue($array, 'ram'); | 
| 76 | 76 | |
| 77 | 77 | return $data; | 
| 78 | -        }else{ | |
| 78 | +        }else { | |
| 79 | 79 |             throw new BadRequestHttpException('required get param "i" cannot be empty.');  | 
| 80 | 80 | } | 
| 81 | 81 | |
| @@ -122,9 +122,9 @@ discard block | ||
| 122 | 122 | |
| 123 | 123 | $name = static::defaultNameCookieMark(); | 
| 124 | 124 | |
| 125 | -        if ($request->cookies->has($name)){ | |
| 125 | +        if ($request->cookies->has($name)) { | |
| 126 | 126 | return $request->cookies->getValue($name); | 
| 127 | -        }else{ | |
| 127 | +        }else { | |
| 128 | 128 | $str = Yii::$app->getSecurity()->generateRandomString(); | 
| 129 | 129 | |
| 130 | 130 | // add to HTTP | 
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | * Class HitCounterModelAssembler | 
| 10 | 10 | */ | 
| 11 | 11 | |
| 12 | -final class HitCounterModelDtoAssembler{ | |
| 12 | +final class HitCounterModelDtoAssembler { | |
| 13 | 13 | |
| 14 | 14 | /** | 
| 15 | 15 | * Return model with attributes loaded by dto | 
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace coderius\hitCounter\traits; | 
| 4 | 4 | |
| 5 | -trait RequestTrait{ | |
| 5 | +trait RequestTrait { | |
| 6 | 6 | |
| 7 | 7 |      public function isProxyVisit() { | 
| 8 | 8 |          if (@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) { | 
| @@ -39,7 +39,7 @@ discard block | ||
| 39 | 39 | ?> | 
| 40 | 40 | |
| 41 | 41 | <?php //Speed profiling ?> | 
| 42 | -<?php if(YII_DEBUG): ?> | |
| 42 | +<?php if (YII_DEBUG): ?> | |
| 43 | 43 |  <script language="javascript" type="text/javascript">console.time('hitCounter-' + '<?= $counterId; ?>')</script> | 
| 44 | 44 | <?php endif; ?> | 
| 45 | 45 | |
| @@ -95,6 +95,6 @@ discard block | ||
| 95 | 95 | //--></script> | 
| 96 | 96 | |
| 97 | 97 | <?php //Speed profiling ?> | 
| 98 | -<?php if(YII_DEBUG): ?> | |
| 98 | +<?php if (YII_DEBUG): ?> | |
| 99 | 99 |  <script language="javascript" type="text/javascript">console.timeEnd('hitCounter-' + '<?= $counterId; ?>');</script> | 
| 100 | 100 | <?php endif; ?> | 
| @@ -186,7 +186,9 @@ | ||
| 186 | 186 |      { | 
| 187 | 187 | $defOpts = []; | 
| 188 | 188 | $defOpts['target'] = '_blank'; | 
| 189 | - if($this->counterOptions['type'] === self::COUNTER_VIEW_INVISIBLE) $defOpts['style'] = 'position:absolute; left:-9999px;'; | |
| 189 | +        if($this->counterOptions['type'] === self::COUNTER_VIEW_INVISIBLE) { | |
| 190 | + $defOpts['style'] = 'position:absolute; left:-9999px;'; | |
| 191 | + } | |
| 190 | 192 | $this->clientLinkOptions = array_merge($defOpts, $this->clientLinkOptions); | 
| 191 | 193 | |
| 192 | 194 | } | 
| @@ -89,7 +89,7 @@ discard block | ||
| 89 | 89 |      { | 
| 90 | 90 | parent::init(); | 
| 91 | 91 | |
| 92 | -        if(null === $this->counterId){ | |
| 92 | +        if (null === $this->counterId) { | |
| 93 | 93 | $this->counterId = $this->getId(); | 
| 94 | 94 | } | 
| 95 | 95 | |
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 |      { | 
| 192 | 192 | $defOpts = []; | 
| 193 | 193 | $defOpts['target'] = '_blank'; | 
| 194 | - if($this->counterOptions['type'] === self::COUNTER_VIEW_INVISIBLE) $defOpts['style'] = 'position:absolute; left:-9999px;'; | |
| 194 | + if ($this->counterOptions['type'] === self::COUNTER_VIEW_INVISIBLE) $defOpts['style'] = 'position:absolute; left:-9999px;'; | |
| 195 | 195 | $this->clientLinkOptions = array_merge($defOpts, $this->clientLinkOptions); | 
| 196 | 196 | |
| 197 | 197 | } | 
| @@ -23,7 +23,7 @@ | ||
| 23 | 23 | $this->addDependencies(); | 
| 24 | 24 | } | 
| 25 | 25 | |
| 26 | -    private function addDependencies(){ | |
| 26 | +    private function addDependencies() { | |
| 27 | 27 | $container = \Yii::$container; | 
| 28 | 28 | |
| 29 | 29 | $container->set( |