public function actionSetFingerprintBad() { if (empty($_POST)) { $this->redirect(Yii::app()->request->urlReferrer); } $fb = new FingerprintBan(); $fb->attributes = $_POST['FingerprintBan']; if (isset($_POST['delete'])) { $cnt = FingerprintBan::model()->deleteAllByAttributes(array('type' => $fb->type, 'value' => $fb->value)); if ($cnt) { Yii::app()->user->setFlash('success', Yii::t('test', 'Удалена {n} запись| Удалено {n} записи | Удалено {n} записей', $cnt)); } else { Yii::app()->user->setFlash('error', "Подходящих записей не найдено"); } $this->redirect(Yii::app()->request->urlReferrer); } $fb->time_start = time(); if (isset($_POST['ban'])) { $fb->status_bad = Anketa::BAD_STATUS_BAN; } else { if (isset($_POST['clone'])) { $fb->status_bad = Anketa::BAD_STATUS_CLONE; } else { die('NO VALID STATUS'); } } if ($fb->save()) { $txt = $fb->status_bad == Anketa::BAD_STATUS_BAN ? ' Бан ' : ' Клон '; $txt .= $fb->isNewRecord ? ' добавлен ' : ' обновлен '; Yii::app()->user->setFlash('success', $txt); } else { $txt = ''; foreach ($fb->getErrors() as $error) { $txt .= print_r($error, true) . '<br>'; } Yii::app()->user->setFlash('error', $txt); } $this->redirect(Yii::app()->request->urlReferrer); }
/** * 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 FingerprintBan the loaded model * @throws CHttpException */ public function loadModel($id) { $model = FingerprintBan::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
if ($etag) { $ids = explode(':',$etag); if ($etagClones = Anketa::model()->findAllByPk($ids)) { echo "<h3>100% клоны (Etag):</h3>"; foreach ($etagClones as $zombie) { if ($zombie->id == $model->id) continue; echo CHtml::link($zombie->name.", {$zombie->age}, {$zombie->city}",$zombie->link,array('target'=>'_blank')); echo ($zombie->isBad() ? " / ".Anketa::$bad_statuses[$zombie->status_bad] : ''); echo " | "; } echo '<br/><br/>'; } } ?> <h3>Подозрения (ip):</h3> <table style="width:660px;"> <?php foreach ($iparray as $ipdata) { $zombie = $zombies[$ipdata['id']]; $class = $zombie->id != $model->id ? 'red':''; echo "<tr><td><span ><a class='$class' target='_blank' href='http://www.nic.ru/whois/?query={$ipdata['ip']}'>{$ipdata['ip']}</span></td>"; echo "<td nowrap='nowrap'>".FingerprintBan::drawForm(array('id_anketa'=>$zombie->id,'type'=>FingerprintBan::TYPE_IP,'value'=>$ipdata['ip']))."</td>"; echo "<td>".CHtml::link($zombie->name.", {$zombie->age}, {$zombie->city}",$zombie->link,array('target'=>'_blank'))."</td>"; echo CHtml::tag('td',array(),$zombie->contact_count.' cnt'); echo CHtml::tag('td',array(),CHtml::link('переписка','/cp/message/list/'.$zombie->id,array('target'=>'_blank'))); echo CHtml::tag('td',array(),CHtml::link('IP','/cp/anketa/zombie/'.$zombie->id,array('target'=>'_blank'))); echo CHtml::tag('td',array('class'=>'red'),$zombie->isdeleted?'удалён':''); echo "</tr>"; } ?> </table> <?php $this->renderPartial('_fingerprints', compact('model')); ?>
public function checkClone() { if ($this->getAccountType() == Anketa::ACCOUNT_PREMIUM) { return; } // премиум(?) if ($this->status_bad) { return; } // уже клон/бан или снятый клон/бан static $wasHere = 0; if ($this->id == Yii::app()->user->id) { Yii::log($this->id . ' fp=' . Yii::app()->user->getState('AnketaFingerprint') . ' | ' . $_SERVER['REQUEST_URI'], CLogger::LEVEL_INFO, 'checkClone'); } $status_bad = self::BAD_STATUS_NONE; foreach ($this->findClones() as $clone) { /** @var $clone Anketa */ if ($this->first_visit <= $clone->first_visit) { // если анкета зарегистрирована раньше клона continue; } if ($clone->status_bad == self::BAD_STATUS_BAN) { $status_bad = self::BAD_STATUS_BAN; } else { $status_bad = self::BAD_STATUS_CLONE; } Yii::log('bad_status ' . $status_bad . ' ' . $this->id . ' <- ' . $clone->id, CLogger::LEVEL_INFO, 'ban'); } if ($status_bad == self::BAD_STATUS_NONE) { if ($this->findEtagClones()) { foreach ($this->findEtagClones() as $clone) { /** @var $clone Anketa */ if ($this->first_visit <= $clone->first_visit) { // если анкета зарегистрирована раньше клона continue; } if ($clone->status_bad == self::BAD_STATUS_BAN) { $status_bad = self::BAD_STATUS_BAN; } else { $status_bad = self::BAD_STATUS_CLONE; } Yii::log('bad_status ' . $status_bad . ' ' . $this->id . ' <- Etag ' . $clone->id, CLogger::LEVEL_INFO, 'ban'); } } } if ($status_bad == self::BAD_STATUS_NONE) { if ($this->id == Yii::app()->user->id) { $attributes = array(); $attributes[] = array('type' => FingerprintBan::TYPE_IP, 'value' => $_SERVER['REMOTE_ADDR']); if (Yii::app()->user->getState('FingerprintChecked', 0) === false) { $wasHere++; } if ($fp = Yii::app()->user->getState('AnketaFingerprint')) { if ($fp = AnketaFingerprint::model()->findByPk($fp)) { // бан по fingerprints foreach (FingerprintBan::$types as $k => $v) { $attributes[] = array('type' => $v, 'value' => md5($fp->{$k})); } } } foreach ($attributes as $k => $v) { if ($fb = FingerprintBan::model()->findByAttributes($v)) { $status_bad = $fb->status_bad; break; } } if ($status_bad != self::BAD_STATUS_NONE) { Yii::log('bad_status ' . $status_bad . ' ' . $this->id . ' <- ' . FingerprintBan::$typesText[$fb->type] . ' ' . $fb->value . ' ', CLogger::LEVEL_INFO, 'ban'); } if ($fp || !$wasHere) { Yii::app()->user->setState('FingerprintChecked', 1); } else { Yii::app()->user->setState('FingerprintChecked', false); } } } // За клонов до введения оплаты не блокируем. if ($status_bad == self::BAD_STATUS_CLONE) { $status_bad = self::BAD_STATUS_NONE; } // авторазбан при входе if ($status_bad != self::BAD_STATUS_NONE) { if ($this->totalPaid > 0) { $status_bad = self::BAD_STATUS_PAID; } } $this->setBad($status_bad); if ($status_bad & 1) { $this->trialReset(); } }
<h2><?php echo $attribute; ?> </h2> <?php $prints = array(); $i = 1; foreach ($model->fingerprints as $fingerprint) { if (!in_array($fingerprint->{$attribute}, $prints)) { $prints[] = $fingerprint->{$attribute}; if (in_array($fingerprint->{$attribute}, array('No Flash or Java fonts detected', 'undefined', 'undefined (via Flash)', '(via Flash)'))) { echo "<p class='red'>{$i} Нет</p>"; $i++; continue; } echo $_SERVER['REMOTE_ADDR'] != '89.169.186.440' ? FingerprintBan::drawForm(array('id_anketa' => $model->id, 'type' => FingerprintBan::$types[$attribute], 'value' => md5($fingerprint->{$attribute}))) : '', "<p><b>{$i} ", mb_substr($fingerprint->{$attribute}, 0, 100000, 'utf-8'), " </b></p>"; $i++; if (!($fingerprints = AnketaFingerprint::model()->findAllByAttributes(array($attribute . '_md5' => $fingerprint->{$attribute . '_md5'}), array('condition' => 'id_anketa <> ' . $model->id, 'limit' => 21)))) { //'id_anketa'=>'<>'.$model->id continue; } if (count($fingerprints) > 20) { echo "Больше 20 <span class='pointer blue toggle_sibling'> Показать/скрыть </span> <div style='display:none'>"; } else { echo "<div>"; } echo "<table>"; foreach ($fingerprints as $fpclone) { $zombie = $fpclone->anketa; // echo CHtml::link($zombie->name.", {$zombie->age}, {$zombie->city}",$zombie->link,array('target'=>'_blank')) ; // echo "<tr><td><span ><a class='$class' target='_blank' href='http://www.nic.ru/whois/?query={$ipdata['ip']}'>{$ipdata['ip']}</span></td>";