diff --git a/backend/commands/CronController.php b/backend/commands/CronController.php index 595e0e0d2..ec5204bd7 100644 --- a/backend/commands/CronController.php +++ b/backend/commands/CronController.php @@ -275,13 +275,16 @@ public function actionInstances($pfonly=false) $dc->pull(); $dc->spin(); } - if(($val->team_allowed===true && $val->player->teamPlayer && $val->player->teamPlayer->approved===1) || \Yii::$app->sys->team_visible_instances===true) + if(($val->team_allowed===true || \Yii::$app->sys->team_visible_instances===true) && $val->player->teamPlayer ) { - foreach($val->player->teamPlayer->team->teamPlayers as $teamPlayer) + if($val->player->teamPlayer->approved===1) { - if($teamPlayer->player->last->vpn_local_address!==null && $teamPlayer->approved===1) + foreach($val->player->teamPlayer->team->teamPlayers as $teamPlayer) { - $ips[]=long2ip($teamPlayer->player->last->vpn_local_address); + if($teamPlayer->player->last->vpn_local_address!==null && $teamPlayer->approved===1) + { + $ips[]=long2ip($teamPlayer->player->last->vpn_local_address); + } } } } diff --git a/backend/commands/PlayerController.php b/backend/commands/PlayerController.php index a73c85981..15987c496 100644 --- a/backend/commands/PlayerController.php +++ b/backend/commands/PlayerController.php @@ -464,4 +464,65 @@ private function getErrorRows($model) return $errorows; } + /** + * Fetch identification files from frontend + * @param string $filter Filter players by all, active and inactive + * @param string $scheme Default scheme to use + */ + public function actionFetchIdentification($filter='inactive',$scheme='https') + { + $filters=['all', 'active', 'inactive']; + if(!in_array($filter, $filters)) + { + throw new ConsoleException(Yii::t('app', 'Filter accepts values: {values}', ['values' => implode(',', $filters)])); + } + + $players=Player::find(); + switch($filter) { + case 'active': + $players->where(['active' => 1]); + break; + + case 'inactive': + $players->where(['active' => 0]); + break; + + } + $formats=['.pdf','.png','.jpg','.jpeg','.docx']; + foreach ($players->all() as $player){ + $baseDir=\Yii::getAlias('@app/web/identificationFiles/'); + echo "processing ",$player->username; + $format=null; + + foreach ($formats as $f) + { + $format=null; + $skip=false; + if(file_exists($baseDir.$player->profile->id.$f)) + { + echo " found local file,"; + $skip=true; + break; + } + $ch = curl_init("$scheme://".Yii::$app->sys->offense_domain.'/identificationFiles/'.$player->profile->id.$f); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_NOBODY, true); + curl_setopt($ch, CURLOPT_HEADER, true); + + curl_exec($ch); + $status = curl_getinfo($ch,CURLINFO_HTTP_CODE); + if ($status===200) + { + $format=$f; + break; + } + } + if($format!==null && $skip!==true) { + echo " => grabbing ",$baseDir .$player->profile->id.$format,"\n"; + file_put_contents($baseDir .$player->profile->id.$format, fopen("$scheme://".Yii::$app->sys->offense_domain.'/identificationFiles/'.$player->profile->id.$format, 'r')); + } + else if ($skip===true) { echo " skipping\n";} + else{ echo " no identification found\n";} + } + } } diff --git a/backend/modules/frontend/models/PlayerAR.php b/backend/modules/frontend/models/PlayerAR.php index 6705e8f52..dd794f6b0 100644 --- a/backend/modules/frontend/models/PlayerAR.php +++ b/backend/modules/frontend/models/PlayerAR.php @@ -109,7 +109,7 @@ public function rules() [['auth_key'], 'string', 'max' => 32], [['type'], 'default', 'value' => 'offense'], [['status'], 'default', 'value' => self::STATUS_ACTIVE], - [['activkey'], 'default', 'value' => Yii::$app->security->generateRandomString().'-'.time(), 'on' => 'create'], + [['activkey'], 'default', 'value' => '', 'on' => 'create'], [['verification_token'], 'default', 'value' => str_replace('_','-',Yii::$app->security->generateRandomString().'-'.time()), 'on' => 'create'], [['username', 'fullname', 'email', 'new_password', 'activkey'], 'string', 'max' => 255], [['username'], 'unique'], diff --git a/backend/modules/frontend/views/player/index.php b/backend/modules/frontend/views/player/index.php index e61a2f699..0a771305f 100644 --- a/backend/modules/frontend/views/player/index.php +++ b/backend/modules/frontend/views/player/index.php @@ -65,6 +65,29 @@ } ], ['class' => 'app\components\columns\ProfileColumn', 'idkey' => 'profile.id', 'attribute' => 'username', 'field' => 'username'], + [ + 'attribute'=>'affiliation', + 'visible' => Yii::$app->sys->players_require_approval, + 'format'=>'html', + 'value'=>function($model){ + if($model->active==1) return Html::encode($model->affiliation); + $formats=['.pdf','.png','.jpg','.jpeg','.docx']; + $format=null; + $baseDir=\Yii::getAlias('@app/web/identificationFiles/'); + foreach ($formats as $f) + { + if(file_exists($baseDir.$model->profile->id.$f)) + { + $format=$f; + break; + } + } + if($format!==null) + return Html::a($model->affiliation,'/identificationFiles/'.$model->profile->id.$format,['width' => '50px']); + else + return Html::encode($model->affiliation); + }, + ], 'email:email', [ 'attribute' => 'vpn_local_address', diff --git a/backend/widgets/BooleanTransform.php b/backend/widgets/BooleanTransform.php index c47232d5e..21504bfce 100644 --- a/backend/widgets/BooleanTransform.php +++ b/backend/widgets/BooleanTransform.php @@ -11,7 +11,7 @@ class BooleanTransform * @param mixed $val * @return string */ - function toCheck($val) + public static function toCheck($val) { if($val===true || $val===1 || $val==='1') { @@ -25,7 +25,7 @@ function toCheck($val) * @param mixed $val * @return string */ - function toOnOff($val) + public static function toOnOff($val) { if($val===true || $val===1 || $val==='1') {