1
0
Fork 0
mirror of https://github.com/janickiy/yii2-nomer synced 2025-03-09 15:39:59 +00:00

add files to project

This commit is contained in:
janickiy 2020-02-05 06:34:26 +03:00
commit 5cac498444
3729 changed files with 836998 additions and 0 deletions

50
models/ApplePayment.php Normal file
View file

@ -0,0 +1,50 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "apple_payments".
*
* @property integer $id
* @property string $tm
* @property string $sum
* @property string $amount
* @property string $refund
*/
class ApplePayment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'apple_payments';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm'], 'safe'],
[['sum', 'amount', 'refund'], 'number'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'tm' => 'Tm',
'sum' => 'Sum',
'amount' => 'Amount',
'refund' => 'Refund',
];
}
}

View file

@ -0,0 +1,95 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "apple_subscribe_events".
*
* @property integer $id
* @property string $event_date
* @property string $event
* @property string $app_name
* @property integer $app_id
* @property string $subscription_name
* @property integer $subscription_id
* @property integer $subscription_group_id
* @property string $subscription_duration
* @property string $introductory_price_type
* @property string $introductory_price_duration
* @property string $marketing_opt_in
* @property string $marketing_opt_in_duration
* @property string $preserved_pricing
* @property string $proceeds_reason
* @property integer $consecutive_paid_periods
* @property string $original_start_date
* @property string $client
* @property string $device
* @property string $state
* @property string $country
* @property string $previous_subscription_name
* @property integer $previous_subscription_id
* @property integer $days_before_canceling
* @property string $cancellation_reason
* @property integer $days_canceled
* @property integer $quantity
*/
class AppleSubscribeEvent extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'apple_subscribe_events';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['event_date', 'original_start_date'], 'safe'],
[['app_id', 'subscription_id', 'subscription_group_id', 'consecutive_paid_periods', 'previous_subscription_id', 'days_before_canceling', 'days_canceled', 'quantity'], 'integer'],
[['event', 'app_name', 'subscription_name', 'subscription_duration', 'introductory_price_type', 'introductory_price_duration', 'marketing_opt_in', 'marketing_opt_in_duration', 'preserved_pricing', 'proceeds_reason', 'client', 'device', 'state', 'country', 'previous_subscription_name', 'cancellation_reason'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'event_date' => 'Event Date',
'event' => 'Event',
'app_name' => 'App Name',
'app_id' => 'App ID',
'subscription_name' => 'Subscription Name',
'subscription_id' => 'Subscription ID',
'subscription_group_id' => 'Subscription Group ID',
'subscription_duration' => 'Subscription Duration',
'introductory_price_type' => 'Introductory Price Type',
'introductory_price_duration' => 'Introductory Price Duration',
'marketing_opt_in' => 'Marketing Opt In',
'marketing_opt_in_duration' => 'Marketing Opt In Duration',
'preserved_pricing' => 'Preserved Pricing',
'proceeds_reason' => 'Proceeds Reason',
'consecutive_paid_periods' => 'Consecutive Paid Periods',
'original_start_date' => 'Original Start Date',
'client' => 'Client',
'device' => 'Device',
'state' => 'State',
'country' => 'Country',
'previous_subscription_name' => 'Previous Subscription Name',
'previous_subscription_id' => 'Previous Subscription ID',
'days_before_canceling' => 'Days Before Canceling',
'cancellation_reason' => 'Cancellation Reason',
'days_canceled' => 'Days Canceled',
'quantity' => 'Quantity',
];
}
}

53
models/Auth.php Normal file
View file

@ -0,0 +1,53 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "auth".
*
* @property integer $id
* @property integer $user_id
* @property string $source
* @property string $source_id
*/
class Auth extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'auth';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['source', 'source_id'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'source' => 'Source',
'source_id' => 'Source ID',
];
}
public function getUser()
{
return $this->hasOne(User::className(), ["id" => "user_id"]);
}
}

61
models/BlockPhone.php Normal file
View file

@ -0,0 +1,61 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "block".
*
* @property integer $id
* @property string $phone
* @property string $ip
* @property string $ua
* @property string $tm
* @property string $code
* @property integer $status
* @property integer $site_id
*/
class BlockPhone extends \yii\db\ActiveRecord
{
const STATUS_UNCONFIRMED = 0;
const STATUS_CONFIRMED = 1;
const STATUS_PAID = 2;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'block';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm'], 'safe'],
[['status', 'site_id'], 'integer'],
[['phone', 'ip', 'ua'], 'string', 'max' => 255],
[['code'], 'string', 'max' => 4],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'phone' => 'Phone',
'ip' => 'Ip',
'ua' => 'Ua',
'tm' => 'Tm',
'code' => 'Code',
'status' => 'Status',
];
}
}

60
models/Call.php Normal file
View file

@ -0,0 +1,60 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "calls".
*
* @property integer $id
* @property string $tm
* @property string $cuid
* @property integer $duration
* @property string $status
* @property integer $phone
* @property Organization $organization
*/
class Call extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'calls';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm'], 'safe'],
[['duration', 'phone'], 'integer'],
[['cuid', 'status'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'tm' => 'Tm',
'cuid' => 'Cuid',
'duration' => 'Duration',
'status' => 'Status',
'phone' => 'Phone',
];
}
public function getOrganization()
{
return $this->hasOne(Organization::className(), ['id' => 'org_id'])
->viaTable(OrganizationPhone::tableName(), ['phone2' => 'phone']);
}
}

56
models/Checkout.php Normal file
View file

@ -0,0 +1,56 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "checkouts".
*
* @property integer $id
* @property integer $user_id
* @property string $wallet
* @property string $sum
* @property string $tm_create
* @property string $tm_done
* @property integer $status
*/
class Checkout extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'checkouts';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'status'], 'integer'],
[['sum'], 'number'],
[['tm_create', 'tm_done'], 'safe'],
[['wallet'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'wallet' => 'Wallet',
'sum' => 'Sum',
'tm_create' => 'Tm Create',
'tm_done' => 'Tm Done',
'status' => 'Status',
];
}
}

27
models/ContactForm.php Normal file
View file

@ -0,0 +1,27 @@
<?php
namespace app\models;
class ContactForm extends \yii\base\Model {
public $email;
public $message;
public $reCaptcha;
public function rules() {
return [
["email", "email"],
["message", "safe"],
[["email", "message"], "required"],
[['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LdpNCMUAAAAABTYWw_Eaca7iGlbXaCWWe0fqqp7', 'uncheckedMessage' => 'Пожалуйста, подтвержите, что вы не бот!']
];
}
public function attributeLabels()
{
return [
"email" => "Ваш E-mail адреса",
"message" => "Сообщение"
];
}
}

53
models/EmailTemplates.php Normal file
View file

@ -0,0 +1,53 @@
<?php
namespace app\models;
use Yii;
class EmailTemplates extends \yii\db\ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
public static function getStatusName($status) {
switch ($status) {
case self::STATUS_INACTIVE: return 'Неактивный';
case self::STATUS_ACTIVE: return 'Активный';
default: return null;
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'email_templates';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['subject', 'message'], 'required'],
[['status'], 'integer'],
[['tm_create'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'subject' => 'Тема',
'message' => 'Сообщение',
'status' => 'Статус',
'tm_create' => 'Создан',
];
}
}

53
models/Facebook.php Normal file
View file

@ -0,0 +1,53 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "facebook".
*
* @property integer $id
* @property string $tm
* @property string $phone
* @property string $fb_id
* @property string $name
* @property string $photo
*/
class Facebook extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'facebook';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm'], 'safe'],
[['photo'], 'string'],
[['phone', 'fb_id', 'name'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'tm' => 'Tm',
'phone' => 'Phone',
'fb_id' => 'Fb ID',
'name' => 'Name',
'photo' => 'Photo',
];
}
}

46
models/File.php Normal file
View file

@ -0,0 +1,46 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "files".
*
* @property integer $id
* @property string $uuid
* @property string $type
*/
class File extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'files';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['uuid'], 'string', 'max' => 255],
[['type'], 'string', 'max' => 16],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'uuid' => 'Uuid',
'type' => 'Type',
];
}
}

60
models/Free.php Normal file
View file

@ -0,0 +1,60 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "free".
*
* @property integer $id
* @property integer $user_id
* @property integer $checks
* @property string $uuid
* @property integer $type_id
* @property string $tm
*/
class Free extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'free';
}
const TYPE_INSTALL = 7781;
const TYPE_RATE = 3902;
static function types() {
return [self::TYPE_INSTALL, self::TYPE_RATE];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'checks', 'type_id'], 'integer'],
[['tm'], 'safe'],
[['uuid'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'checks' => 'Checks',
'uuid' => 'Uuid',
'type_id' => 'Type ID',
'tm' => 'Tm',
];
}
}

66
models/Geo.php Normal file
View file

@ -0,0 +1,66 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "geo".
*
* @property integer $geoname_id
* @property string $locale_code
* @property string $continent_code
* @property string $continent_name
* @property string $country_iso_code
* @property string $country_name
* @property string $subdivision_1_iso_code
* @property string $subdivision_1_name
* @property string $subdivision_2_iso_code
* @property string $subdivision_2_name
* @property string $city_name
* @property string $metro_code
* @property string $time_zone
*/
class Geo extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'geo';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['geoname_id'], 'integer'],
[['locale_code', 'continent_code', 'continent_name', 'country_iso_code', 'country_name', 'subdivision_1_iso_code', 'subdivision_1_name', 'subdivision_2_iso_code', 'subdivision_2_name', 'city_name', 'metro_code', 'time_zone'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'geoname_id' => 'Geoname ID',
'locale_code' => 'Locale Code',
'continent_code' => 'Continent Code',
'continent_name' => 'Continent Name',
'country_iso_code' => 'Country Iso Code',
'country_name' => 'Country Name',
'subdivision_1_iso_code' => 'Subdivision 1 Iso Code',
'subdivision_1_name' => 'Subdivision 1 Name',
'subdivision_2_iso_code' => 'Subdivision 2 Iso Code',
'subdivision_2_name' => 'Subdivision 2 Name',
'city_name' => 'City Name',
'metro_code' => 'Metro Code',
'time_zone' => 'Time Zone',
];
}
}

59
models/Gibdd.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "gibdd".
*
* @property string $tm
* @property string $number
* @property string $model
* @property string $year
* @property string $lastname
* @property string $firstname
* @property string $middlename
* @property string $phone
*/
class Gibdd extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'gibdd';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm', 'number'], 'string', 'max' => 10],
[['model'], 'string', 'max' => 64],
[['year'], 'string', 'max' => 4],
[['lastname', 'firstname', 'middlename'], 'string', 'max' => 32],
[['phone'], 'string', 'max' => 11],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'tm' => 'Tm',
'number' => 'Number',
'model' => 'Model',
'year' => 'Year',
'lastname' => 'Lastname',
'firstname' => 'Firstname',
'middlename' => 'Middlename',
'phone' => 'Phone',
];
}
}

50
models/Link.php Normal file
View file

@ -0,0 +1,50 @@
<?php
namespace app\models;
use yii\db\ActiveRecord;
/**
* @property integer $id
* @property integer $user_id
* @property string $code
* @property User $user
*/
class Link extends ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'links';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['code'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'code' => 'Code',
];
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}

View file

@ -0,0 +1,25 @@
<?php
namespace app\models;
use yii\base\Model;
class NewPasswordForm extends Model {
public $password;
public $repassword;
public function rules() {
return [
[['password', 'repassword'], 'required'],
['password', 'string', 'min' => 5],
];
}
public function attributeLabels()
{
return [
"password" => "Пароль",
"repassword" => "Пароль ещё раз"
];
}
}

59
models/Notification.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "notifications".
*
* @property integer $id
* @property mixed tm_send
* @property mixed tm_create
* @property mixed payload
* @property mixed message
*/
class Notification extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'notifications';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['message', 'payload', 'tm_create', 'tm_send'], 'safe']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'message' => 'Сообщение',
'payload' => 'payload',
'tm_create' => 'Дата создания',
'tm_send' => 'Дата отправки'
];
}
public function getResults()
{
return $this->hasMany(NotificationResult::className(), ["notify_id" => "id"]);
}
public function getGoodResults()
{
return $this->hasMany(NotificationResult::className(), ["notify_id" => "id"])->where(["status" => 200]);
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "notification_results".
*
* @property integer $id
* @property int notify_id
* @property int user_id
* @property int status
*
*/
class NotificationResult extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'notification_results';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['notify_id', 'user_id', 'status'], 'integer']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
];
}
}

65
models/Organization.php Normal file
View file

@ -0,0 +1,65 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "orgs".
*
* @property integer $id
* @property string $name
* @property string $date
* @property string $maximum_sum
* @property string $inn
* @property string $number
* @property string $region
* @property OrganizationPhone[] $phones
* @property OrganizationEmail[] $emails
*/
class Organization extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'orgs';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['maximum_sum'], 'number'],
[['name', 'inn', 'number', 'region'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Name',
'maximum_sum' => 'Maximum Sum',
'inn' => 'Inn',
'number' => 'Number',
'region' => 'Region',
];
}
public function getPhones()
{
return $this->hasMany(OrganizationPhone::className(), ['org_id' => 'id']);
}
public function getEmails()
{
return $this->hasMany(OrganizationEmail::className(), ['org_id' => 'id']);
}
}

View file

@ -0,0 +1,48 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "org_emails".
*
* @property integer $id
* @property integer $org_id
* @property string $name
* @property string $email
*/
class OrganizationEmail extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'org_emails';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['org_id'], 'integer'],
[['name', 'email'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'org_id' => 'Org ID',
'name' => 'Name',
'email' => 'Email',
];
}
}

View file

@ -0,0 +1,49 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "org_phones".
*
* @property integer $id
* @property integer $org_id
* @property string $name
* @property string $phone
* @property string $phone2
*/
class OrganizationPhone extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'org_phones';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['org_id'], 'integer'],
[['name', 'phone'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'org_id' => 'Org ID',
'name' => 'Name',
'phone' => 'Phone',
];
}
}

102
models/Payment.php Normal file
View file

@ -0,0 +1,102 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "payments".
*
* @property integer $id
* @property string $sum
* @property string $amount
* @property integer $user_id
* @property string $tm
* @property string $operation_id
* @property string $operation_label
* @property integer $type_id
* @property integer $site_id
* @property User $user
* @property string $source
*/
class Payment extends \yii\db\ActiveRecord
{
const TYPE_YANDEX = 1;
const TYPE_QIWI = 2;
const TYPE_WEBMONEY = 3;
const TYPE_YANDEX_WALLET = 4;
const TYPE_QIWI_TERMINAL = 5;
const TYPE_COUPON = 6;
const TYPE_ANDROID = 7;
const TYPE_TESTAPPLE = 8;
const TYPE_APPLE = 9;
public static function primaryKey()
{
return ["id"];
}
public static function getTypeName($type_id) {
switch ($type_id) {
case Payment::TYPE_QIWI: return "Qiwi Wallet";
case Payment::TYPE_YANDEX: return "Яндекс.Деньги Card";
case Payment::TYPE_WEBMONEY: return "WebMoney ";
case Payment::TYPE_QIWI_TERMINAL: return "Qiwi терминал";
case Payment::TYPE_YANDEX_WALLET: return "Яндекс.Деньги Wallet";
case Payment::TYPE_COUPON: return "Купон";
case Payment::TYPE_ANDROID: return "Android";
case Payment::TYPE_TESTAPPLE: return "Apple Test";
case Payment::TYPE_APPLE: return "Apple";
}
return "";
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'payments';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['sum', 'amount'], 'number'],
[['user_id', 'type_id', 'site_id'], 'integer'],
[['tm'], 'safe'],
[['operation_id', 'operation_label', 'source'], 'string', 'max' => 255],
];
}
public function getSite()
{
return $this->hasOne(Site::className(), ["id" => "site_id"]);
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'sum' => 'Сумма',
'amount' => 'Зачисленно',
'user_id' => 'Пользователь',
'tm' => 'Дата и время',
'operation_id' => 'Транзакция',
'operation_label' => 'Комментарий',
'site_id' => 'Сайт'
];
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}

76
models/PhoneRequest.php Normal file
View file

@ -0,0 +1,76 @@
<?php
namespace app\models;
use app\components\FindPhoneValidator;
use Yii;
use yii\behaviors\AttributeBehavior;
use yii\db\ActiveRecord;
/**
* This is the model class for table "phone_request".
*
* @property integer $id
* @property integer $user_id
* @property string $tm
* @property string $ip
* @property string $data
* @property string $wallet
* @property string $contact
* @property integer $status
*/
class PhoneRequest extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'phone_request';
}
public function behaviors()
{
return [
'user_id' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['user_id'],
],
'value' => Yii::$app->request->isConsoleRequest?"":\Yii::$app->getUser()->getId(),
],
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['data'], 'required'],
['data', FindPhoneValidator::className()],
[['user_id', 'status'], 'integer'],
[['tm'], 'safe'],
[['data'], 'string'],
[['ip', 'wallet', 'contact'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'tm' => 'Tm',
'ip' => 'Ip',
'data' => 'Введите адрес страницы Вконтакте, Facebook, Instagram или email',
'wallet' => 'Кошелек',
'contact' => 'Контактная информация',
'status' => 'Status',
];
}
}

51
models/Plan.php Normal file
View file

@ -0,0 +1,51 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "plans".
*
* @property integer $id
* @property integer $cost
* @property integer $count
* @property string $title
* @property boolean $status
*/
class Plan extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'plans';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['cost', 'count'], 'integer'],
[['status'], 'boolean'],
[['title'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'cost' => 'Cost',
'count' => 'Count',
'title' => 'Title',
'status' => 'Status',
];
}
}

53
models/PlatiCode.php Normal file
View file

@ -0,0 +1,53 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "plati_codes".
*
* @property integer $id
* @property string $code
* @property integer $checks
* @property integer $user_id
* @property string $tm_create
* @property string $tm_used
*/
class PlatiCode extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'plati_codes';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['checks', 'user_id'], 'integer'],
[['tm_create', 'tm_used'], 'safe'],
[['code'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'code' => 'Code',
'checks' => 'Checks',
'user_id' => 'User ID',
'tm_create' => 'Tm Create',
'tm_used' => 'Tm Used',
];
}
}

21
models/Proxy.php Normal file
View file

@ -0,0 +1,21 @@
<?php
namespace app\models;
use yii\db\ActiveRecord;
/**
* @property integer $id
* @property string $host
* @property integer $port
*/
class Proxy extends ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'proxies';
}
}

24
models/RemindForm.php Normal file
View file

@ -0,0 +1,24 @@
<?php
namespace app\models;
use yii\base\Model;
class RemindForm extends Model {
public $email;
public function rules() {
return [
['email', 'email'],
];
}
public function remind() {
if(trim($this->email) == "") return false;
$user = User::findByEmail($this->email);
if(!$user) return false;
$user->generatePasswordResetToken();
return $user->save();
}
}

58
models/Repost.php Normal file
View file

@ -0,0 +1,58 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "reposts".
*
* @property integer $id
* @property integer $user_id
* @property integer $vk_id
* @property string $tm
* @property integer $status
* @property integer $site_id
* @property integer $sms_count
*/
class Repost extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'reposts';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'vk_id', 'status', 'site_id', 'sms_count'], 'integer'],
[['tm'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'vk_id' => 'Профиль',
'tm' => 'Дата',
'status' => 'Статус',
'sms_count' => 'Кол-во смс'
];
}
public function getUser()
{
return $this->hasOne(User::className(), ["id" => "user_id"]);
}
}

59
models/RequestResult.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "request_results".
*
* @property integer $id
* @property integer $request_id
* @property integer $type_id
* @property integer $index
* @property string $data
* @property integer $cache_id
* @property SearchRequest $request
*/
class RequestResult extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'request_results';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['request_id', 'type_id', 'index', 'cache_id'], 'integer'],
[['data'], 'string'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'request_id' => 'Request ID',
'type_id' => 'Type ID',
'index' => 'Index',
'data' => 'Data',
'cache_id' => 'Cache ID',
];
}
public function getRequest()
{
return $this->hasOne(SearchRequest::className(), ['id' => 'request_id']);
}
}

141
models/ResultCache.php Normal file
View file

@ -0,0 +1,141 @@
<?php
namespace app\models;
/**
* This is the model class for table "cache".
*
* @property integer $id
* @property string $phone
* @property string $data
* @property integer $type_id
* @property string $tm
*/
class ResultCache extends \yii\db\ActiveRecord
{
const TYPE_OPERATOR = 1;
const TYPE_BASIC = 2;
const TYPE_FACEBOOK = 3;
const TYPE_GOOGLE_PHONE = 4;
const TYPE_AVITO = 5;
const TYPE_VK = 6;
const TYPE_GOOGLE_PHOTOS = 7;
const TYPE_MAMBA = 8;
const TYPE_BADOO = 9;
const TYPE_VIBER = 10;
const TYPE_AVINFO = 11;
const TYPE_SPRUT = 12;
const TYPE_TRUECALLER = 13;
const TYPE_NUMBUSTER = 14;
const TYPE_VK_2012 = 15;
const TYPE_INSTAGRAM = 16;
const TYPE_ANTIPARKON = 17;
const TYPE_TELEGRAM = 18;
const TYPE_AVINFO_API = 19;
const TYPE_GIBDD = 20;
const TYPE_VK_OPEN = 21;
const TYPE_GETCONTACT = 22;
const TYPE_SCORISTA = 23;
public static function primaryKey()
{
return ["id"];
}
public static function getTypeSysname($id) {
switch($id) {
case 2: return "basic";
case 3: return "facebook";
case 5: return "avito";
case 6: return "vk";
case 15: return "vk_2012";
case 18: return "telegram";
case 10: return "viber";
case 13: return "truecaller";
case 14: return "numbuster";
case 16: return "instagram";
case 19: return "avinfo";
case 17: return "avinfo";
case 22: return "getcontact";
case 23: return "scorista";
}
return null;
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'cache';
}
public static function getTypeName($type_id)
{
switch ($type_id) {
case self::TYPE_OPERATOR: return 'Оператор и регион';
case self::TYPE_FACEBOOK: return 'Facebook';
case self::TYPE_GOOGLE_PHONE: return 'Поиск в Google';
case self::TYPE_GOOGLE_PHOTOS: return 'Поиск в google по фото';
case self::TYPE_AVITO: return 'Avito';
case self::TYPE_VK: return 'ВКонтакте';
case self::TYPE_VK_2012: return 'ВКонтакте 2012';
case self::TYPE_MAMBA: return 'Поиск на Мамбе';
case self::TYPE_BADOO: return 'Поиск в Badoo';
case self::TYPE_VIBER: return 'Viber';
case self::TYPE_AVINFO: return 'Auto.ru';
case self::TYPE_SPRUT: return 'Скориста';
case self::TYPE_TRUECALLER: return 'Truecaller';
case self::TYPE_NUMBUSTER: return 'Numbuster';
case self::TYPE_INSTAGRAM: return 'Instagram';
case self::TYPE_ANTIPARKON: return 'Антипаркон';
case self::TYPE_TELEGRAM: return 'Telegram';
case self::TYPE_AVINFO_API: return 'Avinfo API';
case self::TYPE_GIBDD: return 'Гибдд';
case self::TYPE_VK_OPEN: return 'Вконтакте открытые данные';
case self::TYPE_GETCONTACT: return 'GetContact';
case self::TYPE_SCORISTA: return 'Скориста';
default: return null;
}
}
public static function inactiveTypes()
{
return [
ResultCache::TYPE_GOOGLE_PHONE,
ResultCache::TYPE_GOOGLE_PHOTOS,
ResultCache::TYPE_MAMBA,
ResultCache::TYPE_BADOO,
ResultCache::TYPE_AVINFO,
ResultCache::TYPE_SPRUT
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['data'], 'string'],
[['phone'], 'string', 'max' => 255],
[['type_id'], 'integer'],
[['tm'], 'safe']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'phone' => 'Телефон',
'data' => 'Данные',
'type_id' => 'Тип',
'tm' => 'Дата/время'
];
}
}

97
models/Retargeting.php Normal file
View file

@ -0,0 +1,97 @@
<?php
namespace app\models;
use Yii;
use DateTime;
class Retargeting extends \yii\db\ActiveRecord
{
const STATUS_QUEUE = 0;
const STATUS_SENT = 1;
const STATUS_READ = 2;
const STATUS_CLICK = 3;
const STATUS_ERROR = 4;
/**
* @param $status
* @return null|string
* получаем статус отправики писем
*/
public static function getStatusName($status) {
switch ($status) {
case self::STATUS_QUEUE: return 'Письмо в очереди на отправку';
case self::STATUS_SENT: return 'Письмо отправлено';
case self::STATUS_READ: return 'Письмо прочитано';
case self::STATUS_CLICK: return 'По ссылке был сделан переход';
case self::STATUS_ERROR: return 'Ошибка отправки';
default: return null;
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'email_tokents';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'status'], 'integer'],
[['uuid'], 'string', 'max' => 255],
[['tm_create', 'tm_send', 'tm_read', 'tm_click'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'uuid' => 'Uiid',
'tm_create' => 'Дата создания',
'tm_send' => 'Дата отправики',
'tm_read' => 'Время прочтения',
'tm_click' => 'Время перехода',
'status' => 'Статус',
'descr' => 'Описание',
];
}
/**
* @param $date1
* @param $date2
* @return string
* @throws \Exception
* генератор случайных дат в временом промежутке
*/
public static function random_date_in_range( $date1, $date2 )
{
if (!is_a($date1, 'DateTime')) {
$date1 = new DateTime( (ctype_digit((string)$date1) ? '@' : '') . $date1);
$date2 = new DateTime( (ctype_digit((string)$date2) ? '@' : '') . $date2);
}
$random_u = random_int($date1->format('U'), $date2->format('U'));
$random_date = new DateTime();
$random_date->setTimestamp($random_u);
return $random_date->format('Y-m-d H:i');
}
/**
* @return \yii\db\ActiveQuery
*/
public function getUser()
{
return $this->hasOne(User::className(), ["id" => "user_id"]);
}
}

112
models/SearchRequest.php Normal file
View file

@ -0,0 +1,112 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "requests".
*
* @property integer $id
* @property integer $user_id
* @property string $phone
* @property string $ip
* @property string $ua
* @property string $result
* @property string $tm
* @property boolean $refresh
* @property int $source_id
* @property RequestResult[] $results
* @property \app\models\User $user
* @property integer $is_payed
* @property integer $site_id
* @property Site $site
* @property boolean $is_has_name
* @property boolean $is_has_photo
*/
class SearchRequest extends \yii\db\ActiveRecord
{
const SOURCE_WEB = 1;
const SOURCE_MOBILE = 2;
const SOURCE_ANDROID = 3;
const SOURCE_IOS = 4;
const SOURCE_FCHECK = 5;
const SOURCE_TELEGRAM = 6;
public static function primaryKey()
{
return ["id"];
}
public static function getSourceText($id)
{
switch ($id) {
case self::SOURCE_WEB:
return 'Web';
case self::SOURCE_MOBILE:
return 'Mobile';
case self::SOURCE_ANDROID:
return 'Android';
case self::SOURCE_IOS:
return 'iOS';
case self::SOURCE_FCHECK:
return 'FCHECK';
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'requests';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'is_payed', 'site_id', 'source_id'], 'integer'],
[['result'], 'string'],
[['tm'], 'safe'],
[['refresh', 'is_has_name', 'is_has_photo'], 'boolean'],
[['phone', 'ip', 'ua'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'Пользователь',
'phone' => 'Телефон',
'ip' => 'IP',
'ua' => 'Ua',
'result' => 'Result',
'tm' => 'Время поиска',
'refresh' => 'Refresh',
'site_id' => 'Сайт',
'source_id' => 'Источник'
];
}
public function getResults()
{
return $this->hasMany(RequestResult::className(), ['request_id' => 'id'])->select(['request_id', 'type_id', 'index', 'cache_id']);
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
public function getSite()
{
return $this->hasOne(Site::className(), ['id' => 'site_id']);
}
}

View file

@ -0,0 +1,27 @@
<?php
namespace app\models;
use yii\base\Model;
class SetPasswordForm extends Model {
public $oldpassword;
public $password;
public $repassword;
public function rules() {
return [
[['oldpassword', 'password', 'repassword'], 'required'],
['password', 'string', 'min' => 5],
];
}
public function attributeLabels()
{
return [
"oldpassword" => "Текущий пароль",
"password" => "Пароль",
"repassword" => "Пароль ещё раз"
];
}
}

62
models/Settings.php Normal file
View file

@ -0,0 +1,62 @@
<?php
namespace app\models;
use Yii;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "settings".
*
* @property integer $id
* @property string $param
* @property string $value
*/
class Settings extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'settings';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['param', 'value'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'param' => 'Param',
'value' => 'Value',
];
}
public static function get($param, $defaultValue = null) {
$p = self::find()->where(["param" => $param])->one();
if(is_null($p)) return $defaultValue;
return ArrayHelper::getValue($p, "value");
}
public static function set($param, $value) {
$p = self::find()->where(["param" => $param])->one();
if(is_null($p)) {
$p = new self;
$p->param = $param;
}
$p->value = $value;
$p->save();
}
}

49
models/SigninForm.php Normal file
View file

@ -0,0 +1,49 @@
<?php
namespace app\models;
use app\components\LoginValidator;
use yii\base\Model;
use yii\helpers\ArrayHelper;
use \yii\db\Expression;
class SigninForm extends Model {
public $email;
public $password;
public function rules() {
return [
['password', 'string', 'min' => 4],
['email', 'filter', 'filter' => 'trim'],
['email', LoginValidator::className()],
[['password', 'email'], 'required']
];
}
public function attributeLabels() {
return [
"email" => "E-mail или номер телефона",
'password' => 'Пароль'
];
}
public function login() {
$user = User::findByEmail($this->email);
if(!is_null($user) && $user->validatePassword($this->password)) {
$resultLogin = \Yii::$app->getUser()->login($user, 3600 * 24 * 90);
if($resultLogin) {
$site = Site::find()->where(["name" => $_SERVER["HTTP_HOST"]])->one();
$log = new UserAuthLog();
$log->user_id = $user->id;
$log->site_id = ArrayHelper::getValue($site, "id", 0);
$log->ip = \Yii::$app->request->getUserIP();
$log->tm = new Expression('NOW()');
$log->save();
}
return $resultLogin;
}
return false;
}
}

52
models/SignupForm.php Normal file
View file

@ -0,0 +1,52 @@
<?php
namespace app\models;
use app\components\LoginValidator;
use yii\base\Model;
use yii\helpers\ArrayHelper;
class SignupForm extends Model {
public $email;
public $password;
public $repassword;
public $agree;
public function rules() {
return [
[['password', 'email'], 'required'],
['password', 'string', 'min' => 4],
['email', 'filter', 'filter' => 'trim'],
['email', 'filter', 'filter' => 'strtolower'],
['email', LoginValidator::className()],
['email', 'unique', 'targetClass' => '\app\models\User', 'targetAttribute' => 'email', 'message' => 'Этот логин уже используется'],
];
}
public function createUser() {
$user = new User([
'email' => $this->email,
'password' => $this->password,
]);
$user->auth_key = \Yii::$app->getSecurity()->generateRandomString();
$ref = \Yii::$app->session->get("ref_id");
$ref = explode("-", $ref);
$refID = ArrayHelper::getValue($ref, 0, 0);
$refTM = ArrayHelper::getValue($ref, 1, 0);
if($refID && time() - $refTM <= 60 * 60 * 24 * 7) {
$user->ref_id = \Yii::$app->session->get("ref_id");
}
$user->save();
return $user;
}
public function attributeLabels()
{
return [
"email" => "E-mail или номер телефона",
"password" => "Пароль"
];
}
}

79
models/Site.php Normal file
View file

@ -0,0 +1,79 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "sites".
*
* @property integer $id
* @property string $name
* @property string $vk_id
* @property string $vk_secret
* @property string $fb_id
* @property string $fb_secret
* @property string $gg_id
* @property string $gg_secret
* @property boolean $is_demo
* @property string $phone
* @property string $yandex_money_account
* @property integer $platiru_id
* @property integer $type_id
*/
class Site extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'sites';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['is_demo'], 'boolean'],
['name', 'unique'],
[['platiru_id', 'type_id'], 'integer'],
[
[
'name',
'vk_id', 'vk_secret',
'fb_id', 'fb_secret',
'gg_id', 'gg_secret',
'phone',
'yandex_money_account',
'comment'
], 'string', 'max' => 255
],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Домен',
'vk_id' => 'VK ID приложения',
'vk_secret' => 'VK секретный ключ',
'fb_id' => 'FB ID приложения',
'fb_secret' => 'FB секретный ключ',
'gg_id' => 'Gg ID',
'gg_secret' => 'Gg Secret',
'is_demo' => 'Демо режим',
'phone' => 'Номер телефона',
'comment' => 'Комментарий',
'yandex_money_account' => 'Яндекс.Деньги',
'platiru_id' => 'plati.ru - № товара',
'type_id' => 'Тип поиска'
];
}
}

63
models/Telegram.php Normal file
View file

@ -0,0 +1,63 @@
<?php
namespace app\models;
use yii\db\ActiveRecord;
/**
* @property integer $id
* @property string $host
* @property integer $port
* @property integer $status
* @property string $tm_last
*/
class Telegram extends ActiveRecord
{
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
const STATUS_UNAVAILABLE = 2;
public static function getStatusName($status) {
switch ($status) {
case self::STATUS_INACTIVE: return 'Неактивный';
case self::STATUS_ACTIVE: return 'Активный';
case self::STATUS_UNAVAILABLE: return 'Сервер недоступен';
default: return null;
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'telegrams';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['host', 'port'], 'required'],
[['port', 'status'], 'integer'],
[['tm_last'], 'safe'],
[['host'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'host' => 'Host',
'port' => 'Port',
'status' => 'Status',
'tm_last' => 'Tm Last',
];
}
}

147
models/Ticket.php Normal file
View file

@ -0,0 +1,147 @@
<?php
namespace app\models;
use Yii;
use yii\behaviors\AttributeBehavior;
use yii\db\ActiveRecord;
use yii\db\Expression;
/**
* This is the model class for table "tickets".
*
* @property integer $id
* @property integer $user_id
* @property string $ip
* @property integer $subject_id
* @property string $subject
* @property string $text
* @property integer $status
* @property string $tm_create
* @property string $tm_read
* @property string $tm_close
* @property string $tm_reopen
* @property integer $is_deleted
* @property string $url
* @property int is_payed
*/
class Ticket extends \yii\db\ActiveRecord
{
const SUBJECTS = [
1 => 'Общие вопросы',
2 => 'Оплата',
3 => 'Сотрудничество',
4 => 'Удаление номера'
];
const STATUSES = [
0 => 'Администратор пока не прочитал',
1 => 'Администратор прочитал. Ждите ответ',
2 => 'Администратор ответил. Ждём вашего прочтения',
3 => 'Администратор ждет вашего ответа',
4 => 'Закрыта',
5 => 'Переоткрыта',
6 => 'Игнорируемая задача',
7 => 'Разработка'
];
public $reCaptcha;
public static function primaryKey()
{
return ["id"];
}
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['tm_create'],
],
'value' => new Expression('NOW()'),
],
'ip' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['ip'],
],
'value' => Yii::$app->request->isConsoleRequest?"":\Yii::$app->request->getUserIP(),
],
'user_id' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['user_id'],
],
'value' => Yii::$app->request->isConsoleRequest?"":(\Yii::$app->getUser()->getId()),
],
'status' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['status'],
],
'value' => 0,
],
];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'tickets';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['text', 'subject'], 'required'],
[['text'], 'string', 'min' => 10],
[['user_id', 'subject_id', 'status', 'site_id', 'is_deleted'], 'integer'],
['is_payed', 'boolean'],
[['text'], 'string'],
[['tm_create', 'tm_read', 'tm_close', 'tm_reopen'], 'safe'],
[['ip'], 'string', 'max' => 15],
[['subject', 'url'], 'string', 'max' => 255],
[['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LdpNCMUAAAAABTYWw_Eaca7iGlbXaCWWe0fqqp7', 'uncheckedMessage' => 'Пожалуйста, подтвержите, что вы не бот!']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'Пользователь',
'ip' => 'IP адрес',
'subject_id' => 'Раздел',
'subject' => 'Тема запроса',
'text' => 'Текст запроса',
'status' => 'Статус',
'tm_create' => 'Дата создания',
'tm_read' => 'Дата прочтения',
'tm_close' => 'Дата закрытия',
'tm_reopen' => 'Tm Reopen',
];
}
public function getUser() {
return $this->hasOne(User::className(), ["id" => "user_id"]);
}
public function getSite() {
return $this->hasOne(Site::className(), ["id" => "site_id"]);
}
public function getComments() {
return $this->hasMany(TicketComment::className(), ["ticket_id" => "id"])->where(["is_deleted" => 0]);
}
}

92
models/TicketComment.php Normal file
View file

@ -0,0 +1,92 @@
<?php
namespace app\models;
use Yii;
use yii\behaviors\AttributeBehavior;
use yii\db\ActiveRecord;
use yii\db\Expression;
/**
* This is the model class for table "ticket_comments".
*
* @property integer $id
* @property string $ticket_id
* @property integer $user_id
* @property string $text
* @property string $tm_create
* @property string $tm_read
* @property integer $type_id
* @property integer $is_deleted
*/
class TicketComment extends \yii\db\ActiveRecord
{
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['tm_create'],
],
'value' => new Expression('NOW()'),
],
'user_id' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['user_id'],
],
'value' => Yii::$app->request->isConsoleRequest?"":\Yii::$app->getUser()->getId(),
],
'type_id' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['user_id'],
],
'value' => \Yii::$app->getUser()->getIdentity()->is_admin?1:2,
],
];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'ticket_comments';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'ticket_id', 'type_id', 'is_deleted'], 'integer'],
[['text'], 'string', 'min' => 3],
[['text'], 'required'],
[['tm_create', 'tm_read'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'ticket_id' => 'Запрос',
'user_id' => 'Пользователь',
'text' => 'Ответ',
'tm_create' => 'Дата создания',
'tm_read' => 'Дата прочтения',
];
}
public function getUser() {
return $this->hasOne(User::className(), ["id" => "user_id"]);
}
}

46
models/TicketReply.php Normal file
View file

@ -0,0 +1,46 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "ticket_replies".
*
* @property integer $id
* @property integer $subject_id
* @property string $text
*/
class TicketReply extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'ticket_replies';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['subject_id'], 'integer'],
[['text'], 'string'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'subject_id' => 'Subject ID',
'text' => 'Text',
];
}
}

44
models/TmpVk.php Normal file
View file

@ -0,0 +1,44 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "tmpvk".
*
* @property integer $id
* @property string $phone
*/
class TmpVk extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'tmpvk';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['phone'], 'string', 'max' => 32],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'phone' => 'Phone',
];
}
}

77
models/Token.php Normal file
View file

@ -0,0 +1,77 @@
<?php
namespace app\models;
use yii\db\ActiveRecord;
/**
* @property integer $id
* @property integer $type
* @property integer $server_id
* @property string $token
* @property integer $status
* @property string $tm_ban
*/
class Token extends ActiveRecord
{
const TYPE_TRUECALLER = 1;
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
public static function getTypeName($type) {
switch ($type) {
case self::TYPE_TRUECALLER: return 'Truecaller';
default: return null;
}
}
public static function getTypes()
{
return [
self::TYPE_TRUECALLER => self::getTypeName(self::TYPE_TRUECALLER)
];
}
public static function getStatusName($status) {
switch ($status) {
case self::STATUS_INACTIVE: return 'Неактивный';
case self::STATUS_ACTIVE: return 'Активный';
default: return null;
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'tokens';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['type', 'token'], 'required'],
['server_id', 'integer'],
['server_id', 'default', 'value' => 0],
['status', 'in', 'range' => array_keys(self::getTypes())],
['tm_ban', 'safe']
];
}
public function attributeLabels()
{
return [
'id' => 'ID',
'type' => 'Тип',
'server_id' => 'Сервер',
'token' => 'Токен',
'status' => 'Статус',
'tm_ban' => 'Время блокировки'
];
}
}

76
models/UrlFilter.php Normal file
View file

@ -0,0 +1,76 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "urls".
*
* @property integer $id
* @property string $url
* @property integer $type
*/
class UrlFilter extends \yii\db\ActiveRecord
{
const TYPE_BANNED = 1;
const TYPE_TRUSTED = 2;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'urls';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['type'], 'integer'],
[['url'], 'string', 'max' => 255],
[['url', 'type'], 'required'],
['url', 'unique'],
['type', 'in', 'range' => [self::TYPE_BANNED, self::TYPE_TRUSTED]],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'url' => 'URL',
'type' => 'Тип',
];
}
/**
* @param int $type
* @return string
* @throws \Exception
*/
public static function typeText(int $type)
{
switch ($type) {
case self::TYPE_BANNED:
return 'Заблокированный';
case self::TYPE_TRUSTED:
return 'Доверенный';
default:
throw new \Exception('Unexpected UrlFilter type');
}
}
public static function getTypes(): array {
return [
self::TYPE_BANNED => self::typeText(self::TYPE_BANNED),
self::TYPE_TRUSTED => self::typeText(self::TYPE_TRUSTED)
];
}
}

381
models/User.php Normal file
View file

@ -0,0 +1,381 @@
<?php
namespace app\models;
use app\components\CostsHelper;
use Yii;
use yii\behaviors\AttributeBehavior;
use yii\db\ActiveRecord;
use yii\db\Expression;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\web\IdentityInterface;
/**
* This is the model class for table "users".
*
* @property integer $id
* @property string $uuid
* @property string $phone
* @property string $email
* @property string $password
* @property string $code
* @property string $auth_key
* @property integer $balance
* @property string $tm_create
* @property string $tm_update
* @property string $tm_last_auth
* @property boolean $is_admin
* @property boolean $is_vip
* @property integer $plan
* @property string $checks
* @property string $ip
* @property int $status
* @property int $ban
* @property boolean $is_confirm
* @property string $tm_confirm
* @property UserContact[] $contacts
* @property Payment[] $payments
* @property integer $geo_id
* @property Geo $geo
* @property integer $ref_checks
* @property integer $ref_id
* @property double $ref_balance
* @property Repost $repost
* @property string $comment
* @property string $token
*/
class User extends ActiveRecord implements IdentityInterface
{
const BAN_IP = 1;
const BAN_EVERCOOKIE = 2;
const BAN_FINGERPRINT = 3;
const BAN_PHONE = 4;
public static function primaryKey()
{
return ["id"];
}
public static function getBanStatusText($status)
{
switch ($status) {
case self::BAN_IP: return 'IP';
case self::BAN_EVERCOOKIE: return 'Evercookie';
case self::BAN_FINGERPRINT: return 'Fingerprint';
case self::BAN_PHONE: return 'Номер телефона';
}
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'users';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['tm_create', 'tm_update', 'tm_last_auth', 'tm_confirm'], 'safe'],
[['phone', 'code', 'auth_key', 'password_reset_token', 'ip', 'comment', 'email', 'token'], 'string', 'max' => 255],
[['balance', 'ref_checks', 'ref_balance'], 'number'],
[['plan', 'checks', 'status', 'ref_id'], 'integer'],
[['is_admin', 'is_test', 'is_vip', 'is_confirm'], 'boolean'],
[['comment'], 'filter', 'filter'=> '\yii\helpers\HtmlPurifier::process'],
];
}
public function behaviors()
{
return [
'timestamp' => [
'class' => 'yii\behaviors\TimestampBehavior',
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['tm_create'],
],
'value' => new Expression('NOW()'),
],
'ip' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['ip'],
],
'value' => Yii::$app->request->isConsoleRequest?"":\Yii::$app->request->getUserIP(),
],
'checks' => [
'class' => AttributeBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => ['checks'],
],
'value' => 0,
]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'phone' => 'Телефон',
'code' => 'Код',
'auth_key' => 'Секретный ключ',
'balance' => 'Баланс',
'tm_create' => 'Дата регистрации',
'tm_update' => 'Дата обновления',
'tm_last_auth' => 'Последний вход',
'is_admin' => 'Админ',
'is_vip' => 'VIP',
'checks' => 'Проверки',
'ban' => 'Статус',
'comment' => 'Комментарий'
];
}
/**
* Finds an identity by the given ID.
* @param string|int $id the ID to be looked for
* @return IdentityInterface the identity object that matches the given ID.
* Null should be returned if such an identity cannot be found
* or the identity is not in an active state (disabled, deleted, etc.)
*/
public static function findIdentity($id)
{
$identity = self::findOne($id);
if($identity) {
$ip = UserIp::find()->where(["user_id" => $id, "ip" => \Yii::$app->request->getUserIP()])->one();
if(is_null($ip)) {
$ip = new UserIp();
$ip->user_id = $id;
$ip->ip = \Yii::$app->request->getUserIP();
$ip->tm = new Expression('NOW()');
$ip->save();
}
}
return $identity;
}
public static function findByCode($code)
{
return self::find()->where(["code" => $code])->one();
}
/**
* @param $email
* @return \app\models\User|null
*/
public static function findByEmail($email)
{
return self::find()->where(["email" => mb_strtolower($email)])->one();
}
/**
* Finds an identity by the given token.
* @param mixed $token the token to be looked for
* @param mixed $type the type of the token. The value of this parameter depends on the implementation.
* For example, [[\yii\filters\auth\HttpBearerAuth]] will set this parameter to be `yii\filters\auth\HttpBearerAuth`.
* @return IdentityInterface the identity object that matches the given token.
* Null should be returned if such an identity cannot be found
* or the identity is not in an active state (disabled, deleted, etc.)
*/
public static function findIdentityByAccessToken($token, $type = null)
{
return self::find()->where(new Expression("MD5(concat_ws('-', 'nomer', id, 'io')) = '".$token."'"))->one();
}
/**
* Finds user by password reset token
*
* @param string $token password reset token
* @return static|null
*/
public static function findByPasswordResetToken($token)
{
$expire = \Yii::$app->params['user.passwordResetTokenExpire'];
$parts = explode('_', $token);
$timestamp = (int)end($parts);
if ($timestamp + $expire < time()) {
// token expired
return null;
}
return static::findOne([
'password_reset_token' => $token,
]);
}
/**
* Generates new password reset token
*/
public function generatePasswordResetToken()
{
$this->password_reset_token = Yii::$app->getSecurity()->generateRandomString() . '_' . time();
\Yii::$app->mailer->compose()
->setTextBody("Для восстановления пароля перейдите по ссылке: ".Url::toRoute(['site/set-password', 'token' => $this->password_reset_token], true))
->setFrom('noreply@'.\Yii::$app->name)
->setTo($this->email)
->setSubject(\Yii::$app->name." - восстановление пароля")
->send();
return $this;
}
/**
* Returns an ID that can uniquely identify a user identity.
* @return string|int an ID that uniquely identifies a user identity.
*/
public function getId()
{
return $this->id;
}
/**
* Returns a key that can be used to check the validity of a given identity ID.
*
* The key should be unique for each individual user, and should be persistent
* so that it can be used to check the validity of the user identity.
*
* The space of such keys should be big enough to defeat potential identity attacks.
*
* This is required if [[User::enableAutoLogin]] is enabled.
* @return string a key that is used to check the validity of a given identity ID.
* @see validateAuthKey()
*/
public function getAuthKey()
{
return $this->auth_key;
}
/**
* Validates the given auth key.
*
* This is required if [[User::enableAutoLogin]] is enabled.
* @param string $authKey the given auth key
* @return bool whether the given auth key is valid.
* @see getAuthKey()
*/
public function validateAuthKey($authKey)
{
return $this->getAuthKey() === $authKey;
}
/**
* @param $password
* @return bool
*/
public function validatePassword($password)
{
return trim($this->password) === $password;
}
public function getRequests() {
return $this->hasMany(SearchRequest::className(), ["user_id" => "id"]);
}
public function getAuth() {
return $this->hasMany(Auth::className(), ["user_id" => "id"]);
}
public function getSettings() {
return $this->hasMany(UserSetting::className(), ["user_id" => "id"])->indexBy("param");
}
public function getSetting($param, $defaultValue = null) {
return isset($this->settings[$param])?ArrayHelper::getValue($this->settings[$param], "value"):$defaultValue;
}
public function getContacts()
{
return $this->hasMany(UserContact::className(), ['user_id' => 'id']);
}
public function getPayments()
{
return $this->hasMany(Payment::className(), ['user_id' => 'id']);
}
public function getGeo()
{
return $this->hasOne(Geo::className(), ['geoname_id' => 'geo_id']);
}
public function getRepost()
{
return $this->hasOne(Repost::className(), ['user_id' => 'id']);
}
public function addBalance($sum, $amount, $balance = true, $siteID = 0)
{
$sum += $this->balance;
$this->balance = 0;
$cost = CostsHelper::getCost(1, $siteID);
if($sum >= CostsHelper::getCostTotal(500, $siteID)) {
$cost = CostsHelper::getCost(500, $siteID);
} elseif($sum >= CostsHelper::getCostTotal(300, $siteID)) {
$cost = CostsHelper::getCost(300, $siteID);
} elseif($sum >= CostsHelper::getCostTotal(100, $siteID)) {
$cost = CostsHelper::getCost(100, $siteID);
} elseif($sum >= CostsHelper::getCostTotal(50, $siteID)) {
$cost = CostsHelper::getCost(50, $siteID);
} elseif($sum >= CostsHelper::getCostTotal(20, $siteID)) {
$cost = CostsHelper::getCost(20, $siteID);
} elseif($sum >= CostsHelper::getCostTotal(10, $siteID)) {
$cost = CostsHelper::getCost(10, $siteID);
}
$checks = floor($sum / $cost);
$rest = $sum - $checks * $cost;
$this->checks += $checks;
if ($balance) $this->balance += $rest;
if ($this->save()) {
if ($this->ref_id) {
$refUser = User::find()->where(['id' => $this->ref_id])->one();
$refUser->ref_balance += $amount * 0.1;
$refUser->save();
}
}
return true;
}
public function getSubs() {
return $this->hasMany(UserSub::className(), ["user_id" => "id"]);
}
/**
* @return string
* @throws \Exception
*/
public function generateLink()
{
$code = implode(array_map(function($char) {
return rand(0, 1) ? strtoupper($char) : $char;
}, str_split(bin2hex(random_bytes(4)))));
$link = new Link();
$link->user_id = $this->id;
$link->code = $code;
try {
$link->save();
} catch (\Exception $e) {
if ($e->getCode() == 23505) return $this->generateLink();
throw $e;
}
return 'https://tels.gg/c/' . $code;
}
}

57
models/UserAuthLog.php Normal file
View file

@ -0,0 +1,57 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "user_auth_log".
*
* @property integer $id
* @property integer $user_id
* @property integer $site_id
* @property string $ip
* @property string $tm
* @property Site $site
*/
class UserAuthLog extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_auth_log';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'site_id'], 'integer'],
[['tm'], 'safe'],
[['ip'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'site_id' => 'Сайт',
'ip' => 'IP',
'tm' => 'Время',
];
}
public function getSite()
{
return $this->hasOne(Site::className(), ['id' => 'site_id']);
}
}

40
models/UserContact.php Normal file
View file

@ -0,0 +1,40 @@
<?php
namespace app\models;
use yii\db\ActiveRecord;
/**
* @property integer $id
* @property integer $user_id
* @property string $name
* @property string $phone
* @property string $tm
* @property string $last_check
* @property User $user
*/
class UserContact extends ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_contacts';
}
public function attributeLabels()
{
return [
'id' => 'ID',
'name' => 'Имя',
'phone' => 'Номер телефона',
'last_check' => 'Время последней проверки'
];
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}

51
models/UserEvercookie.php Normal file
View file

@ -0,0 +1,51 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "user_evercookies".
*
* @property integer $id
* @property integer $user_id
* @property string $ip
* @property string $data
* @property string $tm
*/
class UserEvercookie extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_evercookies';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['tm'], 'safe'],
[['ip', 'data'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'ip' => 'Ip',
'data' => 'Data',
'tm' => 'Tm',
];
}
}

View file

@ -0,0 +1,57 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "user_fingerprints".
*
* @property integer $id
* @property integer $user_id
* @property string $ip
* @property string $hash
* @property string $tm
* @property User $user
*/
class UserFingerprint extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_fingerprints';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['tm'], 'safe'],
[['ip', 'hash'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'Пользователь',
'ip' => 'IP',
'hash' => 'Hash',
'tm' => 'Tm',
];
}
public function getUser()
{
return $this->hasOne(User::className(), ['id' => 'user_id']);
}
}

49
models/UserIp.php Normal file
View file

@ -0,0 +1,49 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "user_ips".
*
* @property integer $id
* @property integer $user_id
* @property string $ip
* @property string $tm
*/
class UserIp extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_ips';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['tm'], 'safe'],
[['ip'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'ip' => 'Ip',
'tm' => 'Tm',
];
}
}

48
models/UserSetting.php Normal file
View file

@ -0,0 +1,48 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "user_settings".
*
* @property integer $id
* @property integer $user_id
* @property string $param
* @property string $value
*/
class UserSetting extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'user_settings';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['param', 'value'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'param' => 'Param',
'value' => 'Value',
];
}
}

59
models/UserSub.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "subs".
*
* @property integer $id
* @property integer $user_id
* @property integer $transaction_id
* @property integer $original_transaction_id
* @property string $tm_expires
* @property integer status
* @property string tm_purchase
*/
class UserSub extends \yii\db\ActiveRecord
{
public static function primaryKey()
{
return ["id"];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'subs';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'transaction_id', 'original_transaction_id', 'status'], 'integer'],
[['tm_purchase', 'tm_expires'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'Пользователь',
'transaction_id' => 'Транзакция',
'original_transaction_id' => 'Основная транзакция',
'tm_purchase' => 'Дата подписки',
'tm_expires' => 'Окончание подписки',
];
}
}

50
models/UserTest.php Normal file
View file

@ -0,0 +1,50 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "tests".
*
* @property integer $id
* @property integer $user_id
* @property string $tm
* @property string $ip
*/
class UserTest extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'tests';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id'], 'integer'],
[['tm'], 'safe'],
[['ip'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'tm' => 'Tm',
'ip' => 'Ip',
];
}
}

59
models/Vk.php Normal file
View file

@ -0,0 +1,59 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "vk".
*
* @property integer $id
* @property string $www
* @property string $skype
* @property string $instagram
* @property string $twitter
* @property string $facebook
* @property string $phone1
* @property string $phone2
* @property string $phone3
* @property string $phone4
*/
class Vk extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'vk';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['www', 'skype', 'instagram', 'twitter', 'facebook', 'phone1', 'phone2', 'phone3', 'phone4'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'www' => 'Www',
'skype' => 'Skype',
'instagram' => 'Instagram',
'twitter' => 'Twitter',
'facebook' => 'Facebook',
'phone1' => 'Phone1',
'phone2' => 'Phone2',
'phone3' => 'Phone3',
'phone4' => 'Phone4',
];
}
}

62
models/VkComment.php Normal file
View file

@ -0,0 +1,62 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "vk_comments".
*
* @property integer $id
* @property integer $pid
* @property integer $site_id
* @property string $tm
* @property string $name
* @property string $comment
* @property string $vk_id
* @property string $photo
*/
class VkComment extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'vk_comments';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['pid', 'site_id'], 'integer'],
[['tm'], 'safe'],
[['comment', 'photo'], 'string'],
[['name', 'vk_id'], 'string', 'max' => 255],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'pid' => 'Pid',
'site_id' => 'Site ID',
'tm' => 'Tm',
'name' => 'Name',
'comment' => 'Comment',
'vk_id' => 'Vk ID',
'photo' => 'Photo',
];
}
public function getComments() {
return $this->hasMany(VkComment::className(), ["pid" => "id"])->andWhere(["site_id" => $this->site_id]);
}
}

44
models/VkRaw.php Normal file
View file

@ -0,0 +1,44 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "vk_raw".
*
* @property integer $id
* @property string $data
*/
class VkRaw extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'vk_raw';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id'], 'integer'],
[['data'], 'string'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'data' => 'Data',
];
}
}

86
models/Wallet.php Normal file
View file

@ -0,0 +1,86 @@
<?php
namespace app\models;
use Yii;
/**
* This is the model class for table "wallets".
*
* @property integer $id
* @property integer $type_id
* @property string $wallet_id
* @property string $login
* @property string $password
* @property double $balance
* @property string $tm_last_balance
* @property string $tm_last_transaction
* @property string $tm_last_transaction_out
* @property integer $site_id
* @property Site $site
* @property boolean $status
*/
class Wallet extends \yii\db\ActiveRecord
{
const TYPE_YANDEX = 1;
const TYPE_QIWI = 2;
public static function getWalletTypes()
{
return [
self::TYPE_YANDEX => 'Яндекс.Деньги',
self::TYPE_QIWI => 'Qiwi'
];
}
/**
* @inheritdoc
*/
public static function tableName()
{
return 'wallets';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['type_id', 'wallet_id', 'login', 'password'], 'required'],
[['type_id', 'site_id', 'status'], 'integer'],
[['balance'], 'number'],
[['tm_last_balance', 'tm_last_transaction', 'tm_last_transaction_out'], 'safe'],
[['wallet_id', 'password', 'login'], 'string', 'max' => 255],
[['phone'], 'string', 'max' => 11],
['comment', 'safe']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'type_id' => 'Тип',
'site_id' => 'Сайт',
'wallet_id' => 'Кошелек',
'login' => 'Логин',
'password' => 'Пароль',
'balance' => 'Баланс',
'tm_last_balance' => 'Дата получения баланса',
'tm_last_transaction' => 'Приход',
'tm_last_transaction_out' => 'Расход',
'phone' => 'Номер телефона',
'comment' => 'Комментарии',
'status' => 'Статус'
];
}
public function getSite()
{
return $this->hasOne(Site::className(), ['id' => 'site_id']);
}
}

50
models/WebmoneyOrder.php Normal file
View file

@ -0,0 +1,50 @@
<?php
namespace app\models;
/**
* This is the model class for table "webmoney_orders".
*
* @property integer $id
* @property integer $user_id
* @property string $tm_create
* @property string $sum
* @property integer $status
* @property integer $site_id
*/
class WebmoneyOrder extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'webmoney_orders';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['user_id', 'status', 'site_id'], 'integer'],
[['tm_create'], 'safe'],
[['sum'], 'number']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'user_id' => 'User ID',
'tm_create' => 'Tm Create',
'sum' => 'Sum',
'status' => 'Status',
];
}
}

View file

@ -0,0 +1,45 @@
<?php
namespace app\models\forms;
use yii\base\Model;
class AdminHistoryFilterForm extends Model
{
/**
* @var string
*/
public $from;
/**
* @var string
*/
public $to;
/**
* @var int
*/
public $user;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['from', 'to'], 'required'],
['user', 'integer']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'from' => 'От',
'to' => 'До'
];
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace app\models\forms;
use yii\base\Model;
class BlockForm extends Model {
public $reCaptcha;
public $phone;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['phone'], 'required'],
[['phone'], 'string', 'min' => 10],
[['reCaptcha'], \himiklab\yii2\recaptcha\ReCaptchaValidator::className(), 'secret' => '6LdpNCMUAAAAABTYWw_Eaca7iGlbXaCWWe0fqqp7', 'uncheckedMessage' => 'Пожалуйста, подтвержите, что вы не бот!']
];
}
}

98
models/forms/WmForm.php Normal file
View file

@ -0,0 +1,98 @@
<?php
namespace app\models\forms;
use yii\web\BadRequestHttpException;
class WmForm extends \yii\base\Model
{
public $LMI_PAYEE_PURSE;
public $LMI_PAYMENT_AMOUNT;
public $LMI_PAYMENT_NO;
public $LMI_MODE;
public $LMI_SYS_INVS_NO;
public $LMI_SYS_TRANS_NO;
public $LMI_SYS_TRANS_DATE;
public $LMI_SECRET_KEY;
public $LMI_PAYER_PURSE;
public $LMI_PAYER_WM;
public $LMI_HASH;
private $_options = [
'secret' => 'fsdfsdSdad12312asZZXvcfdf',
'purse' => 'R626242660214',
'mode' => 0
];
/**
* Declares the validation rules.
*/
public function rules(){
return array(
[['LMI_PAYMENT_NO', 'LMI_MODE', 'LMI_SYS_INVS_NO', 'LMI_SYS_TRANS_NO', 'LMI_PAYER_WM'], 'integer'],
[['LMI_PAYMENT_AMOUNT'], 'number'],
[['LMI_PAYER_WM'], 'match', 'pattern' => '/\d{12}/i', 'message' => 'WMID должен содержать 12 цифр'],
[['LMI_PAYEE_PURSE', 'LMI_PAYER_PURSE'], 'match', 'pattern' => '/[z,u,r]\d{12}/i', 'message' => 'Кошелек должен содержать 1 букву и 12 цифр'],
[['LMI_SECRET_KEY'], 'safe'],
[['LMI_HASH'], 'isTrueSign'],
[['LMI_PAYEE_PURSE'], 'isTruePurse'],
[['LMI_MODE'], 'isTrueMode'],
[['LMI_PAYMENT_AMOUNT'], 'isTrueAmount'],
);
}
/**
* Check true payee purse
*/
public function isTruePurse($attribute,$params)
{
if($this->_options['purse'] != $this->LMI_PAYEE_PURSE){
throw new BadRequestHttpException('Ошибка в кошельке');
}
}
/**
* Check true mode
*/
public function isTrueMode($attribute,$params)
{
if($this->_options['mode'] != $this->LMI_MODE){
throw new BadRequestHttpException('Ошибка в режиме');
}
}
/**
* Check true paymant amount
*/
public function isTrueAmount($attribute,$params)
{
/*
$order = WebmoneyOrder::findOne($this->LMI_PAYMENT_NO);
if($order->sum != $this->LMI_PAYMENT_AMOUNT){
throw new BadRequestHttpException('Ошибка в сумме платежа');
}
*/
}
/**
* Check true sign
*/
public function isTrueSign($attribute,$params)
{
$sign = $this->LMI_PAYEE_PURSE.
$this->LMI_PAYMENT_AMOUNT.
$this->LMI_PAYMENT_NO.
$this->LMI_MODE.
$this->LMI_SYS_INVS_NO.
$this->LMI_SYS_TRANS_NO.
$this->LMI_SYS_TRANS_DATE.
$this->_options['secret'].
$this->LMI_PAYER_PURSE.
$this->LMI_PAYER_WM;
//$sign = strtoupper(md5($sign));
$sign = strtoupper(hash('sha256', $sign));
if($sign != $this->LMI_HASH){
throw new BadRequestHttpException('Ошибка в подписи');
}
}
}

View file

@ -0,0 +1,58 @@
<?php
namespace app\models\search;
use Yii;
use yii\data\ActiveDataProvider;
use app\models\UserContact;
class UserContactSearch extends UserContact
{
/**
* @var string
*/
public $phone;
/**
* @var string
*/
public $name;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['phone', 'name'], 'string']
];
}
/**
* @param array $params
* @return ActiveDataProvider
*/
public function search(array $params)
{
$query = UserContact::find()->where(['user_id' => Yii::$app->getUser()->getIdentity()->id]);
$dataProvider = new ActiveDataProvider([
'query' => $query,
'sort' => ['defaultOrder' => ['name' => SORT_ASC]]
]);
if (!($this->load($params) && $this->validate())) {
return $dataProvider;
}
if ($this->phone) {
$query->andFilterWhere(['like', 'phone', $this->phone]);
}
if ($this->name) {
$query->andFilterWhere(['like', 'name', $this->name]);
}
return $dataProvider;
}
}