Esempio n. 1
0
 public static function set($name, $value)
 {
     if (self::get($name)) {
         $setting = Setting::find()->where(['name' => $name])->one();
         $setting->value = $value;
     } else {
         $setting = new Setting(['name' => $name, 'value' => $value, 'title' => $name, 'visibility' => self::VISIBLE_NONE]);
     }
     $setting->save();
 }
 public function actionDeliveryCost($code)
 {
     //check the api for the returned data
     //check country
     $city = City::find()->where('Name="' . $code . '"')->one();
     //var_dump($city);
     if ($city->CountryCode == 'EGY') {
         //calculate weight
         $sum = 0;
         foreach (Shopcart::goods() as $good) {
             $sum += $good->item->product_weight;
         }
         // return "the new cost--".$city->Name .$city->CountryCode;
         //$city->CountryCode;
         $cost = $this->GetCost($city->Name, $sum);
         if ($cost == '' or $cost == 0) {
             return Setting::get('deliver_cost');
         } else {
             return $cost;
         }
     } else {
         return Setting::get('deliver_cost');
         //.'-99'. $city->CountryCode;
     }
 }
Esempio n. 3
0
 public function getParsedText($params = [])
 {
     $match = null;
     $text = $this->text;
     if (preg_match_all('/{{page:([\\w-]+)}}/i', $text, $match)) {
         foreach ($match[0] as $key => $value) {
             $page = Page::get($match[1][$key]);
             if ($page) {
                 $content = $page->parsedText;
             } else {
                 $content = '';
             }
             $text = str_ireplace($value, $content, $text);
         }
     }
     if (preg_match_all('/{{setting:([\\w-]+)}}/i', $text, $match)) {
         foreach ($match[0] as $key => $value) {
             $content = Setting::get($match[1][$key]);
             $text = str_ireplace($value, $content, $text);
         }
     }
     if (preg_match_all('/{{var:([\\w-]+)}}/i', $text, $match)) {
         foreach ($match[0] as $key => $value) {
             if (isset($params[$match[1][$key]])) {
                 $text = str_ireplace($value, $params[$match[1][$key]], $text);
             }
         }
     }
     return $text;
 }
Esempio n. 4
0
 public function actionUpdate()
 {
     $result = WebConsole::migrate();
     Setting::set('easyii_version', \yii\easyii\AdminModule::VERSION);
     Yii::$app->cache->flush();
     return $this->render('update', ['result' => $result]);
 }
Esempio n. 5
0
 public function mailAdmin()
 {
     $settings = Yii::$app->getModule('admin')->activeModules['guestbook']->settings;
     if (!$settings['mailAdminOnNewPost']) {
         return false;
     }
     return Mail::send(Setting::get('admin_email'), $settings['subjectOnNewPost'], $settings['templateOnNewPost'], ['post' => $this, 'link' => Url::to(['/admin/guestbook/a/view', 'id' => $this->primaryKey], true)]);
 }
 public function actionDelete($id)
 {
     if ($model = Setting::findOne($id)) {
         $model->delete();
     } else {
         $this->error = Yii::t('easyii', 'Not found');
     }
     return $this->formatResponse(Yii::t('easyii', 'Setting deleted'));
 }
Esempio n. 7
0
 public static function logo()
 {
     $logo = Setting::find()->where(['name' => 'logo'])->one();
     if (isset($logo) && $logo->value) {
         return $logo;
     } else {
         return false;
     }
 }
Esempio n. 8
0
 public function actionIndex()
 {
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->contact(Setting::get('admin_email'))) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     }
     return $this->render('index', ['contactForm' => $model]);
 }
Esempio n. 9
0
 private function send($model)
 {
     $text = $model->body . "<br><br>" . "--------------------------------------------------------------------------------";
     foreach (Subscriber::find()->all() as $subscriber) {
         $unsubscribeLink = '<br><a href="' . Url::to(['/admin/subscribe/send/unsubscribe', 'email' => $subscriber->email], true) . '" target="_blank">' . Yii::t('easyii/subscribe', 'Unsubscribe') . '</a>';
         if (Yii::$app->mailer->compose()->setFrom(Setting::get('robot_email'))->setTo($subscriber->email)->setSubject($model->subject)->setHtmlBody($text . $unsubscribeLink)->setReplyTo(Setting::get('admin_email'))->send()) {
             $model->sent++;
         }
     }
     return $model->save();
 }
Esempio n. 10
0
 /**
  * @param string $value
  * @return array|null
  * @throws Exception
  */
 protected function validateValue($value)
 {
     if (empty($value)) {
         if (!($value = Yii::$app->request->post(self::CAPTCHA_RESPONSE_FIELD))) {
             return [$this->message, []];
         }
     }
     $request = self::SITE_VERIFY_URL . '?' . http_build_query(['secret' => Setting::get('recaptcha_secret'), 'response' => $value, 'remoteip' => Yii::$app->request->userIP]);
     $response = $this->getResponse($request);
     if (!isset($response['success'])) {
         throw new Exception('Invalid recaptcha verify response.');
     }
     return $response['success'] ? null : [$this->message, []];
 }
Esempio n. 11
0
 public static function send($toEmail, $subject, $template, $data = [], $options = [])
 {
     if (!filter_var($toEmail, FILTER_VALIDATE_EMAIL) || !$subject || !$template) {
         return false;
     }
     $data['subject'] = trim($subject);
     $message = Yii::$app->mailer->compose($template, $data)->setTo($toEmail)->setSubject($data['subject']);
     if (filter_var(Setting::get('robot_email'), FILTER_VALIDATE_EMAIL)) {
         $message->setFrom(Setting::get('robot_email'));
     }
     if (!empty($options['replyTo']) && filter_var($options['replyTo'], FILTER_VALIDATE_EMAIL)) {
         $message->setReplyTo($options['replyTo']);
     }
     return $message->send();
 }
Esempio n. 12
0
 public function actionOrder()
 {
     $model = new OrderForm();
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         $result = ActiveForm::validate($model);
         Yii::$app->response->format = Response::FORMAT_JSON;
         if (!empty($result)) {
             return $result;
         }
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             if ($model->sendEmail(Setting::get('admin_email'))) {
                 return 'success';
             } else {
                 return 'error';
             }
         }
     }
 }
Esempio n. 13
0
 public function run()
 {
     $this->customFieldPrepare();
     $divOptions = ['class' => 'g-recaptcha', 'data-sitekey' => Setting::get('recaptcha_key')];
     if (empty($this->jsCallback)) {
         $divOptions['data-callback'] = $this->jsCallback;
     }
     if (empty($this->theme)) {
         $divOptions['data-theme'] = $this->theme;
     }
     if (empty($this->type)) {
         $divOptions['data-type'] = $this->type;
     }
     if (isset($this->widgetOptions['class'])) {
         $divOptions['class'] = "{$divOptions['class']} {$this->widgetOptions['class']}";
     }
     $divOptions = $divOptions + $this->widgetOptions;
     echo Html::tag('div', '', $divOptions);
 }
Esempio n. 14
0
 public function login()
 {
     $cache = Yii::$app->cache;
     if (($tries = (int) $cache->get(self::CACHE_KEY)) > 5) {
         $this->addError('username', Yii::t('easyii', 'You tried to login too often. Please wait 5 minutes.'));
         return false;
     }
     $this->ip = $_SERVER['REMOTE_ADDR'];
     $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $this->time = time();
     if ($this->validate()) {
         $this->password = '******';
         $this->success = 1;
     } else {
         $this->success = 0;
         $cache->set(self::CACHE_KEY, ++$tries, 300);
     }
     $this->insert(false);
     return $this->success ? Yii::$app->user->login($this->getUser(), Setting::get('auth_time') ?: null) : false;
 }
Esempio n. 15
0
 public function actionView($id)
 {
     $model = Feedback::findOne($id);
     if ($model === null) {
         $this->flash('error', Yii::t('easyii', 'Not found'));
         return $this->redirect(['/admin/' . $this->module->id]);
     }
     if ($model->status == Feedback::STATUS_NEW) {
         $model->status = Feedback::STATUS_VIEW;
         $model->update();
     }
     $postData = Yii::$app->request->post('Feedback');
     if ($postData) {
         if (filter_var(Setting::get('admin_email'), FILTER_VALIDATE_EMAIL)) {
             $model->answer_subject = filter_var($postData['answer_subject'], FILTER_SANITIZE_STRING);
             $model->answer_text = filter_var($postData['answer_text'], FILTER_SANITIZE_STRING);
             if ($model->sendAnswer()) {
                 $model->status = Feedback::STATUS_ANSWERED;
                 $model->save();
                 $this->flash('success', Yii::t('easyii/feedback', 'Answer successfully sent'));
             } else {
                 $this->flash('error', Yii::t('easyii/feedback', 'An error has occurred while sending mail'));
             }
         } else {
             $this->flash('error', Yii::t('easyii/feedback', 'Please fill correct `Admin E-mail` in Settings'));
         }
         return $this->refresh();
     } else {
         if (!$model->answer_text) {
             $model->answer_subject = Yii::t('easyii/feedback', $this->module->settings['answerSubject']);
             if ($this->module->settings['answerHeader']) {
                 $model->answer_text = Yii::t('easyii/feedback', $this->module->settings['answerHeader']) . " " . $model->name . ".\n";
             }
             if ($this->module->settings['answerFooter']) {
                 $model->answer_text .= "\n\n" . Yii::t('easyii/feedback', $this->module->settings['answerFooter']);
             }
         }
         return $this->render('view', ['model' => $model]);
     }
 }
Esempio n. 16
0
 public static function send($toEmail, $subject, $template, $data = [], $options = [])
 {
     if (!filter_var($toEmail, FILTER_VALIDATE_EMAIL) || !$subject || !$template) {
         /** @TODO */
         // return false;
     }
     $data['subject'] = trim($subject);
     $message = null;
     if (strncmp($template, 'p@', 2) === 0) {
         $page = Page::get(substr($template, 2));
         if ($page) {
             $message = Yii::createObject(['class' => Yii::$app->mailer->messageClass, 'mailer' => Yii::$app->mailer]);
             $message->setHtmlBody($page->getParsedText($data));
         }
     } else {
         try {
             $message = Yii::$app->mailer->compose($template, $data);
         } catch (\Exception $ex) {
             ob_clean();
         }
     }
     if (!$message) {
         return false;
     }
     $message->setTo(explode(',', str_ireplace(' ', '', $toEmail)));
     $message->setSubject($data['subject']);
     if (filter_var(Setting::get('robot_email'), FILTER_VALIDATE_EMAIL)) {
         $message->setFrom(Setting::get('robot_email'));
     }
     if (!empty($options['replyTo']) && filter_var($options['replyTo'], FILTER_VALIDATE_EMAIL)) {
         $message->setReplyTo($options['replyTo']);
     }
     $result = $message->send();
     if (!$result) {
     }
     return $result;
 }
Esempio n. 17
0
 public function down()
 {
     $this->dropTable(models\Admin::tableName());
     $this->dropTable(models\LoginForm::tableName());
     $this->dropTable(models\Module::tableName());
     $this->dropTable(models\Photo::tableName());
     $this->dropTable(models\Setting::tableName());
     $this->dropTable(Carousel::tableName());
     $this->dropTable(catalog\models\Category::tableName());
     $this->dropTable(catalog\models\Item::tableName());
     $this->dropTable(article\models\Category::tableName());
     $this->dropTable(article\models\Item::tableName());
     $this->dropTable(Feedback::tableName());
     $this->dropTable(File::tableName());
     $this->dropTable(gallery\models\Category::tableName());
     $this->dropTable(Guestbook::tableName());
     $this->dropTable(News::tableName());
     $this->dropTable(Page::tableName());
     $this->dropTable(Subscriber::tableName());
     $this->dropTable(History::tableName());
     $this->dropTable(Text::tableName());
 }
Esempio n. 18
0
 public function mailAdmin()
 {
     $settings = Yii::$app->getModule('admin')->activeModules['shopcart']->settings;
     if (!$settings['mailAdminOnNewOrder']) {
         return false;
     }
     try {
         return Mail::send(Setting::get('admin_email'), $settings['subjectOnNewOrder'], $settings['templateAdminOnNewOrder'], ['order' => $this, 'link' => Url::to(['/admin/shopcart/a/view', 'id' => $this->primaryKey], true)]);
     } catch (\Swift_SwiftException $ex) {
         Yii::error('Отправка письма не удалась: ' . $ex->getMessage());
         return true;
     }
 }
Esempio n. 19
0
/favicon.ico" type="image/x-icon">
        <link rel="icon" href="<?php 
echo $asset->baseUrl;
?>
/favicon.ico" type="image/x-icon">
        <?php 
$this->head();
?>
    </head>
    <body>
        <?php 
$this->beginBody();
?>

        <?php 
NavBar::begin(['brandLabel' => Setting::get('sitename'), 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse  navbar-fixed-top']]);
$navs = Menu::getItems();
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => $navs]);
NavBar::end();
?>

        <div class="page-wrap">
            <?php 
if (isset($this->params['title'])) {
    ?>
                <div class="container">
                    <div class="row">
                        <div class="col-lg-12">
                            <h1 class="page-header"><?php 
    echo $this->params['title'];
    ?>
Esempio n. 20
0
 public function sendAnswer($model)
 {
     $text = $model->answer;
     $text .= "\n\n\n";
     $text .= "-------------------------------------------------------------------------------- \n";
     $text .= Yii::$app->formatter->asDatetime($model->time, 'medium') . " you wrote: \n";
     foreach (explode("\n", $model->text) as $line) {
         $text .= '> ' . $line;
     }
     $sent = Yii::$app->mailer->compose()->setFrom(Setting::get('robot_email'))->setTo($model->email)->setSubject(strtoupper(Yii::$app->request->serverName) . ' ' . Yii::t('easyii/feedback', 'feedback answer'))->setTextBody($text)->setReplyTo(Setting::get('admin_email'))->send();
     if ($sent) {
         $model->status = Feedback::STATUS_ANSWER;
         $model->update();
         return true;
     }
     return false;
 }
Esempio n. 21
0
<?php

use yii\easyii\modules\page\api\Page;
use yii\easyii\modules\shopcart\api\Shopcart;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\easyii\models\Setting;
$page = Page::get('page-shopcart');
$this->title = yii::t('easyii', 'Checkout');
$this->params['breadcrumbs'][] = $page->model->title;
$delivery = Setting::get('deliver_cost');
?>

<?php 
$page = Page::get('shopcartpage');
?>



<div class="content">
    <div class="container">
        <h2 class="title"><?php 
echo $page->title;
?>
</h2>
        <div class="sub-title"><?php 
echo $page->text;
?>
</div>

    </div>
Esempio n. 22
0
?>
</div>
                </div>
                <div class="col-md-3 col-sm-6">
                    <div class="circleGraphic3 circle circle-3"><?php 
echo Setting::get('stickiness');
?>
</div>
                    <div class="circletitle"><?php 
echo Yii::t('easyii', 'stickiness');
?>
</div>
                </div>
                <div class="col-md-3 col-sm-6">
                    <div class="circleGraphic4 circle circle-4"><?php 
echo Setting::get('fittingclothes');
?>
</div>
                    <div class="circletitle"><?php 
echo Yii::t('easyii', 'fitting clothes');
?>
</div>
                </div>
                 
            </div>
            </div>
            
            
            </div>
      
            <div class="col-md-12">
Esempio n. 23
0
 public static function createRootUser()
 {
     return new static(array_merge(self::$rootUser, ['password' => Setting::get('root_password'), 'auth_key' => Setting::get('root_auth_key')]));
 }
Esempio n. 24
0
</h3>
                <ul class="social list-inline center-block">
                    <li><a href="<?php 
echo Setting::get('facebook');
?>
" target="_blank"><i class="fa fa-facebook fa-2x"></i></a></li>
                    <li><a href=" <?php 
echo Setting::get('twitter');
?>
" target="_blank"><i class="fa fa-tumblr fa-2x"></i></a></li>
                    <li><a href="<?php 
echo Setting::get('instagram');
?>
" target="_blank"><i class="fa fa-instagram fa-2x"></i></a></li>
                    <li><a href="<?php 
echo Setting::get('youtube');
?>
" target="_blank"><i class="fa fa-youtube fa-2x"></i></a></li>
                </ul>
            </div>
        </div>
        <div class="col-md-12">
            <ul class="footer-menu list-inline text-center">
                <li><a href="<?php 
echo Url::home();
?>
"><?php 
echo Yii::t('easyii', 'home');
?>
</a></li>|
                <li><a href="/products"><?php 
Esempio n. 25
0
 public function sendAnswer()
 {
     $settings = Yii::$app->getModule('admin')->activeModules['awarness']->settings;
     return Mail::send($this->email, $this->answer_subject, $settings['answerTemplate'], ['awarness' => $this], ['replyTo' => Setting::get('admin_email')]);
 }
Esempio n. 26
0
<?php

use yii\easyii\models\Setting;
use yii\helpers\Url;
$this->title = Yii::t('easyii', 'System');
?>

<h4><?php 
echo Yii::t('easyii', 'Current version');
?>
: <b><?php 
echo Setting::get('easyii_version');
?>
</b>
    <?php 
if (\yii\easyii\AdminModule::VERSION > floatval(Setting::get('easyii_version'))) {
    ?>
        <a href="<?php 
    echo Url::to(['/admin/system/update']);
    ?>
" class="btn btn-success"><?php 
    echo Yii::t('easyii', 'Update');
    ?>
</a>
    <?php 
}
?>
</h4>

<br>
Esempio n. 27
0
 public function getPlacesTypes()
 {
     return explode(',', Setting::get('places-types'));
 }
Esempio n. 28
0
<?php

use yii\helpers\Html;
use yii\helpers\Url;
use yii\easyii\assets\FrontendAsset;
use yii\easyii\models\Setting;
$asset = FrontendAsset::register($this);
$position = Setting::get('toolbar_position') === 'bottom' ? 'bottom' : 'top';
$this->registerCss('body {padding-' . $position . ': 50px;}');
?>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
<nav id="easyii-navbar" class="navbar navbar-inverse navbar-fixed-<?php 
echo $position;
?>
">
    <div class="container">
        <ul class="nav navbar-nav navbar-left">
            <li><a href="<?php 
echo Url::to(['/admin']);
?>
"><span class="glyphicon glyphicon-arrow-left"></span> <?php 
echo Yii::t('easyii', 'Control Panel');
?>
</a></li>
        </ul>
        <p class="navbar-text"><i class="glyphicon glyphicon-pencil"></i> <?php 
echo Yii::t('easyii', 'Live edit');
?>
</p>
        <?php 
echo Html::checkbox('', LIVE_EDIT, ['data-link' => Url::to(['/admin/system/live-edit'])]);
Esempio n. 29
0
echo Yii::t('easyii', 'Open site');
?>
</a>
                    <a href="<?php 
echo Url::to(['/admin/sign/out']);
?>
" class="pull-right"><i class="glyphicon glyphicon-log-out"></i> <?php 
echo Yii::t('easyii', 'Logout');
?>
</a>
                </div>
            </div>
            <div class="main">
                <div class="box sidebar">
                    <?php 
if ($logo = Setting::logo()) {
    ?>
                        <div class="text-center">
                            <a href="<?php 
    echo Url::to(['/']);
    ?>
"><img src="<?php 
    echo $logo->value;
    ?>
" width="80%" style="margin:10px;text-align: center"></a>
                        </div>
                    <?php 
}
?>
                    <a href="<?php 
echo Url::to(['/admin/settings/logo']);
Esempio n. 30
0
 private function insertSettings($installForm)
 {
     $db = Yii::$app->db;
     $password_salt = Yii::$app->security->generateRandomString();
     $root_auth_key = Yii::$app->security->generateRandomString();
     $root_password = sha1($installForm->root_password . $root_auth_key . $password_salt);
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'recaptcha_key', 'value' => $installForm->recaptcha_key, 'title' => Yii::t('easyii/install', 'ReCaptcha key'), 'visibility' => Setting::VISIBLE_ROOT])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'password_salt', 'value' => $password_salt, 'title' => 'Password salt', 'visibility' => Setting::VISIBLE_NONE])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'root_auth_key', 'value' => $root_auth_key, 'title' => 'Root authorization key', 'visibility' => Setting::VISIBLE_NONE])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'root_password', 'value' => $root_password, 'title' => Yii::t('easyii/install', 'Root password'), 'visibility' => Setting::VISIBLE_ROOT])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'auth_time', 'value' => 86400, 'title' => Yii::t('easyii/install', 'Auth time'), 'visibility' => Setting::VISIBLE_ROOT])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'robot_email', 'value' => $installForm->robot_email, 'title' => Yii::t('easyii/install', 'Robot E-mail'), 'visibility' => Setting::VISIBLE_ROOT])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'admin_email', 'value' => $installForm->admin_email, 'title' => Yii::t('easyii/install', 'Admin E-mail'), 'visibility' => Setting::VISIBLE_ALL])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'recaptcha_secret', 'value' => $installForm->recaptcha_secret, 'title' => Yii::t('easyii/install', 'ReCaptcha secret'), 'visibility' => Setting::VISIBLE_ROOT])->execute();
     $db->createCommand()->insert(Setting::tableName(), ['name' => 'toolbar_position', 'value' => 'top', 'title' => Yii::t('easyii/install', 'Frontend toolbar position') . ' ("top" or "bottom")', 'visibility' => Setting::VISIBLE_ROOT])->execute();
 }