Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions protected/components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,5 +220,77 @@ public function logFromEmailActivity($type)
}
return $result;
}

protected function getInputAsJson()
{
return CJSON::decode(file_get_contents('php://input'));
}

/**
* Send raw HTTP response
* @param int $status HTTP status code
* @param string $body The body of the HTTP response
* @param string $contentType Header content-type
* @return HTTP response
*/
protected function sendResponse($status = 200, $body = '', $contentType = 'application/json')
{
// Set the status
$statusHeader = 'HTTP/1.1 ' . $status . ' ' . $this->getStatusCodeMessage($status);
header($statusHeader);
// Set the content type
header('Content-type: ' . $contentType);

echo $body;
Yii::app()->end();
}

protected function getStatusCodeMessage($status)
{
$codes = array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
205 => 'Reset Content',
206 => 'Partial Content',
300 => 'Multiple Choices',
301 => 'Moved Permanently',
302 => 'Found',
303 => 'See Other',
304 => 'Not Modified',
305 => 'Use Proxy',
306 => '(Unused)',
307 => 'Temporary Redirect',
400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
406 => 'Not Acceptable',
407 => 'Proxy Authentication Required',
408 => 'Request Timeout',
409 => 'Conflict',
410 => 'Gone',
411 => 'Length Required',
412 => 'Precondition Failed',
413 => 'Request Entity Too Large',
414 => 'Request-URI Too Long',
415 => 'Unsupported Media Type',
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported',
);
return (isset($codes[$status])) ? $codes[$status] : '';
}

}
104 changes: 3 additions & 101 deletions protected/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@
'application.extensions.sweekit.Sweeml',
'application.extensions.MobileDetect.Mobile_Detect',
'application.extensions.calc.eqEOS',
'ext.eoauth.*',
'ext.eoauth.lib.*',
'ext.lightopenid.*',
'ext.eauth.*',
'ext.eauth.services.*',
'application.vendors',
'ext.yii-mail.YiiMailMessage',
'ext.imperavi-redactor-widget.ImperaviRedactorWidget',
),
'modules' => array(
'gii' => array(
Expand All @@ -35,9 +31,6 @@
'admin' => array(
'defaultController' =>'user',
),
'exel' => array(
'defaultController' =>'index',
),
'mailingList'=>array(
'defaultController'=>'email',
),
Expand Down Expand Up @@ -68,12 +61,12 @@
),
//'session' => array(
//'timeout' => 86400,
//),
//),
'request' => array(
'class' => 'HttpRequest',
'enableCsrfValidation' => true,
'enableCookieValidation' => true,
'noCsrfValidationRoutes' => array('admin/item', 'register/SaveComment'), ///, 'logg/History'
'noCsrfValidationRoutes' => array('admin/item', 'register/SaveComment','site/modal','site/Getmenu'), ///, 'logg/History'
),
'languageManager' => array(
'class' => 'DbLanguageManager',
Expand Down Expand Up @@ -158,104 +151,13 @@
'class' => 'ext.image.ImageComponent',
'driver' => 'Gd',
),
'loid' => array(
'class' => 'ext.lightopenid.loid',
),
'mail' => array(
'class' => 'ext.yii-mail.YiiMail',
'transportType' => 'php',
'viewPath' => 'application.views.mail',
'logging' => false,
'dryRun' => false
),
'eauth' => array(
'class' => 'ext.eauth.EAuth',
'popup' => true, // Use the popup window instead of redirecting.
'cache' => false, // Cache component name or false to disable cache. Defaults to 'cache'.
'cacheExpire' => 0, // Cache lifetime. Defaults to 0 - means unlimited.
'services' => array(// You can change the providers and their classes.
// 'google' => array(
// 'class' => 'GoogleOpenIDService',
// ),
// 'yandex' => array(
// 'class' => 'YandexOpenIDService',
// ),
// 'twitter' => array(
// register your app here: https://dev.twitter.com/apps/new
// 'class' => 'TwitterOAuthService',
// 'key' => '...',
// 'secret' => '...',
// ),
'google_oauth' => array(
// register your app here: https://code.google.com/apis/console/
'class' => 'CustomGoogleService',
'client_id' => '121482514649-7orl2mum6mco54pe33rvl743j9bp2353.apps.googleusercontent.com',
'client_secret' => 's19p91oTKTLJvvMKGVEi_kebs',
'title' => 'Google (OAuth)',
),
// 'yandex_oauth' => array(
// register your app here: https://oauth.yandex.ru/client/my
// 'class' => 'YandexOAuthService',
// 'client_id' => '...',
// 'client_secret' => '...',
// 'title' => 'Yandex (OAuth)',
// ),
'facebook' => array(
// register your app here: https://developers.facebook.com/apps/
'class' => 'CustomFacebookService',
'client_id' => '689556884392541',
'client_secret' => '5af00ac919412ac2dcaa416e29adeec3',
),
// 'linkedin' => array(
// register your app here: https://www.linkedin.com/secure/developer
// 'class' => 'LinkedinOAuthService',
// 'key' => '...',
// 'secret' => '...',
// ),
// 'github' => array(
// register your app here: https://github.com/settings/applications
// 'class' => 'GitHubOAuthService',
// 'client_id' => '...',
// 'client_secret' => '...',
// ),
// 'live' => array(
// register your app here: https://manage.dev.live.com/Applications/Index
// 'class' => 'LiveOAuthService',
// 'client_id' => '...',
// 'client_secret' => '...',
// ),
'vkontakte' => array(
// register your app here: https://vk.com/editapp?act=create&site=1
'class' => 'CustomVKontakteService',
'client_id' => '3792586',
'client_secret' => 'VY2T0rp0SMkHtyRmrTSJ',
),
// 'mailru' => array(
// register your app here: http://api.mail.ru/sites/my/add
// 'class' => 'MailruOAuthService',
// 'client_id' => '...',
// 'client_secret' => '...',
// ),
// 'moikrug' => array(
// register your app here: https://oauth.yandex.ru/client/my
// 'class' => 'MoikrugOAuthService',
// 'client_id' => '...',
// 'client_secret' => '...',
// ),
// 'odnoklassniki' => array(
// register your app here: http://dev.odnoklassniki.ru/wiki/pages/viewpage.action?pageId=13992188
// ... or here: http://www.odnoklassniki.ru/dk?st.cmd=appsInfoMyDevList&st._aid=Apps_Info_MyDev
// 'class' => 'OdnoklassnikiOAuthService',
// 'client_id' => '...',
// 'client_public' => '...',
// 'client_secret' => '...',
// 'title' => 'Odnokl.',
// ),
),
),
'excel'=>array(
'class'=>'application.extensions.PHPExcel',
),
),
'params' => array(
'adminEmail' => 'dobrynina@astrafit.com',
Expand Down
23 changes: 20 additions & 3 deletions protected/controllers/SiteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public function accessRules() {
return array(
array('allow',
'roles' => array('client','superadmin','admin'),
'actions' => array('myData'),
'actions' => array('myData','modal'),
),
array('deny',
'roles' => array('guest'),
Expand Down Expand Up @@ -218,9 +218,26 @@ public function actionError() {
$this->render('error', $error);
}
}
public static function Logging() {
// $this->actionLogin();

public function actionModal() {
$data = $this->getInputAsJson();
$model = new Joinus();
if(empty($data['name']) || empty($data['email']))
{
$this->sendResponse(401, 'There was an error while sending data');
} else {
$model->attributes = $data;
if($model->validate()) {
$model->save();
$this->sendResponse(200, 'Email was sended successfull');
}
}
}

public function actionGetmenu() {
echo json_encode(Pages::getPages());
}

public function actionLogin() {
$this->layout = '//layouts/main-temp';
$model = new User('login');
Expand Down
90 changes: 90 additions & 0 deletions protected/models/JoinUs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php
class Joinus extends CActiveRecord {

public $_id;
public $name;
public $company;
public $url;
public $phone;
public $email;
public $text;



public static function model($className = __CLASS__) {
return parent::model($className);
}

public function tableName() {
return 'join_us';
}

public function behaviors() {
return array(
'zii.behaviors.CTimestampBehavior',
);
}

public function attributeLabels() {
return array(
'name' => Yii::t('page', 'Ваше имя'),
'company' => Yii::t('page', 'Название компании'),
'url' => Yii::t('page', 'Ссылка на сайт магазина'),
'phone' => Yii::t('page', 'Телефон для обратной связи'),
'email'=> Yii::t('page', 'Емейл'),
'text'=>Yii::t('page', 'Коментарии'),
);
}

public function scopes() {
return array(
'notBlocked' => array(
'condition' => 'is_blocked=0',
),
);
}

public function getPages() {
return self::model()->findAll();
}

public function rules() {
return array(
array('name', 'required', 'on' => 'insert,update'),
array('company', 'required', 'on' => 'insert,update'),
array('email', 'required', 'on' => 'insert,update'),
array('url', 'required', 'on' => 'insert,update'),
array('name,company,url,phone,email,text', 'safe', 'on' => 'search,insert,update'),
);
//$charset = Yii::app()->charset;
}

public function getId() {
return $this->_id;
}

public function getName() {
return $this->name;
}

public function getCompany() {
return $this->company;
}

public function getUrl() {
return $this->url;
}

public function getPhone() {
return $this->phone;
}

public function getEmail() {
return $this->email;
}

public function getText() {
return $this->text;
}

}
Loading