public function execute()
 {
     if (wa()->getUser()->getRights('wacab', 'backend') >= 2) {
         $apps_model = new wacabAppsModel();
         $app = waRequest::get('apps');
         if ($app['parent'] === 'null') {
             $app['parent'] = null;
         }
         if (isset($app['id']) && $app['id'] > 0) {
             $old = $apps_model->getById($app['id']);
             if ($old['app_id'] != $app['app_id'] && $app['type'] == 'app') {
                 $apps_model->exec('UPDATE wacab_apps SET app_id = s:app_id WHERE app_id = s:old_app_id', array('app_id' => $app['app_id'], 'old_app_id' => $old['app_id']));
             }
             $apps_model->updateById($app['id'], $app);
         } else {
             unset($app['id']);
             $app['name'] = json_encode(array($app['name']));
             $apps_model->insert($app);
         }
         $view = self::getView();
         $apps = $apps_model->getAll();
         $types = $apps_model->getTypes();
         $parents = $apps_model->getParents();
         $view->assign('parents', $parents);
         $view->assign('types', $types);
         $view->assign('apps', $apps);
         $view->assign('edit', 0);
         $view->assign('app', array());
         $this->response = array('apps' => $view->fetch(wacabHelper::getAppPath() . '/templates/actions/apps/apps_table.html'), 'form' => $view->fetch(wacabHelper::getAppPath() . '/templates/actions/apps/apps_form.html'));
     } else {
         $this->setError(_wp('No permission to add the app'));
     }
 }
 public function postSearch($options)
 {
     $result = null;
     if (!empty($options['plugin'])) {
         if (!empty($options['plugin'][$this->id])) {
             $result = array();
             $result['join'] = array();
             $category_model = new blogCategoryModel();
             if ($category = $category_model->getByField('url', $options['plugin'][$this->id], 'id')) {
                 $result['join'] = array();
                 $result['join']['blog_post_category'] = array('condition' => 'blog_post_category.post_id = blog_post.id');
                 $result['where'] = array('blog_post_category.category_id IN (' . implode(', ', array_keys($category)) . ')');
             } else {
                 $category = array();
                 $result['where'] = 'FALSE';
             }
             $title = array();
             if ($category) {
                 foreach ($category as $item) {
                     $title[] = $item['name'];
                 }
             } else {
                 $title[] = _wp('not found');
             }
             wa()->getResponse()->setTitle(implode(', ', $title));
         }
     }
     return $result;
 }
Esempio n. 3
0
 public static function formatValue($c, $curr = null)
 {
     static $currencies = null;
     if ($currencies === null) {
         if ($curr) {
             $currencies = $curr;
         } else {
             $curm = new shopCurrencyModel();
             $currencies = $curm->getAll('code');
         }
     }
     if ($c['type'] == '$FS') {
         return _wp('Free shipping');
     } else {
         if ($c['type'] === '%') {
             return waCurrency::format('%0', $c['value'], 'USD') . '%';
         } else {
             if (!empty($currencies[$c['type']])) {
                 return waCurrency::format('%0{s}', $c['value'], $c['type']);
             } else {
                 // Coupon of unknown type. Possibly from a plugin?..
                 return '';
             }
         }
     }
 }
Esempio n. 4
0
function smarty_gettext_translate($matches)
{
    if ($str = waLocale::getString($matches[1])) {
        return $str;
    }
    return _wp(str_replace('\\"', '"', $matches[1]));
}
 public function execute()
 {
     if (!$this->getUser()->getRights('photos', 'edit')) {
         throw new waException(_w("Access denied"));
     }
     $moderation = waRequest::post('moderation', '', waRequest::TYPE_STRING_TRIM);
     $id = waRequest::post('id', '', waRequest::TYPE_INT);
     $photo_model = new photosPhotoModel();
     $photo = $photo_model->getById($id);
     if (!$photo) {
         $this->errors[] = _wp('Unknown photo');
     }
     if ($moderation == 'approve') {
         $photo_model->updateById($id, array('moderation' => 1));
         $photo_model->updateAccess($id, 1, array(0));
     }
     if ($moderation == 'decline') {
         $photo_model->updateById($id, array('moderation' => -1));
         $photo_model->updateAccess($id, 0, array(0));
     }
     $this->response['photo'] = $photo_model->getById($id);
     // update for making inline-editable widget
     $this->response['frontend_link_template'] = photosFrontendPhoto::getLink(array('url' => '%url%'));
     $this->response['counters'] = array('declined' => $photo_model->countByField('moderation', -1), 'awaiting' => $photo_model->countByField('moderation', 0));
     // l18n string
     $count = (int) waRequest::post('count');
     $total_count = (int) waRequest::post('total_count');
     $this->response['string'] = array('loaded' => _w('%d photo', '%d photos', $count), 'of' => sprintf(_w('of %d'), $total_count), 'chunk' => $count < $total_count ? _w('%d photo', '%d photos', min($this->getConfig()->getOption('photos_per_page'), $count - $total_count)) : false);
 }
    public function frontend_head()
    {
        if (!$this->getSettings('enabled')) {
            return false;
        }
        if (waRequest::cookie('agecheck') == 1) {
            return false;
        } else {
            $enter = !empty($this->getSettings('enter')) ? $this->getSettings('enter') : _wp('Enter');
            $leave = !empty($this->getSettings('leave')) ? $this->getSettings('leave') : _wp('Leave');
            $header = !empty($this->getSettings('header')) ? $this->getSettings('header') : _wp('Adults only');
            $style = !empty($this->getSettings('css')) ? $this->getSettings('css') : '';
            $logo = !empty($this->getSettings('logo_url')) ? $this->getSettings('logo_url') : $this->getPluginStaticUrl(true) . 'img/' . $this->getSettings('logo') . '.png';
            $html = '<div id="agecheck" class="agecheck-fade">';
            $html .= '<script type="text/javascript">
			$(document).on("click","#s-agecheck-enter",function(){var e=new Date;e.setTime(e.getTime()+31536e7),document.cookie="agecheck=1;path=/;expires="+e.toUTCString(),$("#agecheck").hide()}),$(document).on("click","#s-agecheck-leave",function(){""==document.referrer?window.close():window.location.href=document.referrer});
</script>';
            $html .= '<style>.agecheck-fade{height:100%;width:100%;background-color:rgba(0,0,0,.9);position:fixed;overflow:hidden;left:0;top:0;display:block;z-index:10000}.agecheck-cont{padding:20px;margin:10% auto 0;width:350px;background-color:#FFF!important;-moz-box-shadow:0 0 100px 1px #444;-webkit-box-shadow:0 0 100px 1px #444;font-size:20px}.agecheck-button{font-family:inherit;font-size:100%;padding:.5em 1em;color:#444;border:1px solid #999;background-color:#E6E6E6;text-decoration:none;border-radius:2px}</style>';
            if (!empty($style)) {
                $html .= '<style>' . $style . '</style>';
            }
            $html .= '
		<div class="agecheck-cont" align="center">
			<img align="middle" class="agecheck-logo" style="clear:both" src="' . $logo . '"></img><br><br>
			<h3>' . $header . '</h3>
			<button class="agecheck-button" id="s-agecheck-enter">' . $enter . '</button>&nbsp;&nbsp;<button class="agecheck-button" id="s-agecheck-leave">' . $leave . '</button>
		</div></div>';
            return $html;
        }
    }
 public function getPosts()
 {
     $this->log(__METHOD__, self::LOG_DEBUG);
     $ids = array();
     if (version_compare($this->version, '3.4', '>=')) {
         $filter = array('number' => 9999);
         $posts = $this->xmlrpc("wp.getPosts", 1, $this->option('login'), $this->option('password'), $filter, array('post_id', 'ID'));
         foreach ($posts as $post) {
             if (isset($post['post_id'])) {
                 $ids[] = $post['post_id'];
             } elseif (isset($post['ID'])) {
                 $ids[] = $post['ID'];
             }
         }
     } elseif (version_compare($this->version, '1.5.0', '>=')) {
         $posts = $this->xmlrpc('mt.getRecentPostTitles', 1, $this->option('login'), $this->option('password'), 9999);
         foreach ($posts as $post) {
             $ids[] = $post['postid'];
         }
     } else {
         throw new waException(_wp("WordPress version should be at least 1.5.0"));
     }
     $this->log(var_export($ids, true), self::LOG_DEBUG);
     return $ids;
 }
 public function initOptions()
 {
     $this->options['host'] = array('title' => _wp('MySQL Host'), 'value' => 'localhost', 'settings_html_function' => waHtmlControl::INPUT);
     $this->options['user'] = array('title' => _wp('MySQL User'), 'value' => '', 'settings_html_function' => waHtmlControl::INPUT);
     $this->options['password'] = array('title' => _wp('MySQL Password'), 'value' => '', 'settings_html_function' => waHtmlControl::PASSWORD);
     $this->options['database'] = array('title' => _wp('MySQL Database'), 'value' => 'webasyst', 'settings_html_function' => waHtmlControl::INPUT);
     $this->options['path'] = array('title' => _wp('Path to folder'), 'value' => wa()->getConfig()->getRootPath(), 'description' => _wp('Path to folder <strong>data/[DBNAME]/attachments/pd</strong> of the WebAsyst Photos (old version) installation'), 'settings_html_function' => waHtmlControl::INPUT);
 }
 protected function getSettingsConfig()
 {
     $blogs = array();
     $blog_model = new blogBlogModel();
     $blogs[''] = _wp('All blogs');
     foreach ($blog_model->getAvailable(wa()->getUser()) as $b) {
         $blogs[$b['id']] = $b['name'];
     }
     $result = parent::getSettingsConfig();
     $result['blog_id']['options'] = $blogs;
     return $result;
 }
Esempio n. 10
0
 public function execute()
 {
     echo "AppsAddController";
     if (wa()->getUser()->getRights('wacab', 'backend') >= 2) {
         $model = new wacabAppsModel();
         $tmp_name = array();
         $tmp_name[] = waRequest::post('name');
         $new_app = array('app_id' => waRequest::post('app_id'), 'plugin_id' => waRequest::post('plugin_id'), 'regexp' => json_encode($tmp_name));
         $model->insert($new_app);
     } else {
         $this->setError(_wp('No permission to add the server'));
     }
 }
 private static function verifyRegexp(&$pattern, $delimiter = '/')
 {
     $errors = array(-1 => true, PREG_NO_ERROR => _wp('Invalid regex'), PREG_INTERNAL_ERROR => _wp('There was an internal PCRE error'), PREG_BACKTRACK_LIMIT_ERROR => _wp('Backtrack limit was exhausted'), PREG_RECURSION_LIMIT_ERROR => _wp('Recursion limit was exhausted'), PREG_BAD_UTF8_ERROR => _wp('The offset didn\'t correspond to the begin of a valid UTF-8 code point'));
     if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
         $errors[PREG_BAD_UTF8_OFFSET_ERROR] = _wp('Malformed UTF-8 data');
     }
     $res = @preg_match($pattern, null);
     if ($res === false) {
         $code = preg_last_error();
     } else {
         $code = -1;
     }
     return $errors[$code];
 }
 public function execute()
 {
     $transport = ucfirst($this->getRequest()->post('transport', '', waRequest::TYPE_STRING_TRIM));
     $class = "blogImportPlugin{$transport}Transport";
     if ($transport && class_exists($class)) {
         $plugin = wa()->getPlugin('import');
         $settings = $plugin->getSettings();
         $instance = new $class($settings);
         $namespace = $this->getApp() . '_import_' . strtolower($transport);
         $this->response = $instance->getControls($namespace);
     } else {
         $this->errors['transport'] = sprintf(_wp("Transport type %s not found"), $transport);
     }
 }
 public function run($params = NULL)
 {
     $app_settings_model = new waAppSettingsModel();
     $app_settings_model->set(array('blog', 'emailsubscription'), 'last_emailsubscription_cron_time', time());
     $model = new blogEmailsubscriptionLogModel();
     $row = $model->getByField('status', 0);
     if ($row) {
         $post_id = $row['post_id'];
         $post_model = new blogPostModel();
         $post = $post_model->getById($post_id);
         $blog_model = new blogBlogModel();
         $blog = $blog_model->getById($post['blog_id']);
         $subject = $blog['name'] . ': ' . $post['title'];
         $post_title = htmlspecialchars($post['title']);
         if ($blog['status'] == blogBlogModel::STATUS_PUBLIC) {
             $post_url = blogPost::getUrl($post);
         } else {
             $app_settings_model = new waAppSettingsModel();
             $post_url = $app_settings_model->get(array('blog', 'emailsubscription'), 'backend_url', wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl());
             $post_url .= "/blog/?module=post&id=" . $post_id;
         }
         $blog_name = htmlspecialchars($blog['name']);
         $body = '<html><body>' . sprintf(_wp("New post in the blog “%s”"), $blog_name) . ': <strong><a href="' . $post_url . '">' . $post_title . '</a></strong></body></html>';
         $message = new waMailMessage();
         $message->setEncoder(Swift_Encoding::getBase64Encoding());
         $message->setSubject($subject);
         $message->setBody($body);
         $rows = $model->getByField(array('status' => 0, 'post_id' => $post_id), true);
         $message_count = 0;
         foreach ($rows as $row) {
             try {
                 $message->setTo($row['email'], $row['name']);
                 $status = $message->send() ? 1 : -1;
                 $model->setStatus($row['id'], $status);
                 if ($status) {
                     $message_count++;
                 }
             } catch (Exception $e) {
                 $model->setStatus($row['id'], -1, $e->getMessage());
             }
         }
         /**
          * Notify plugins about sending emailsubscripition
          * @event followup_send
          * @return void
          */
         wa()->event('emailsubscription_send', $message_count);
     }
 }
 protected function init()
 {
     $transport = ucfirst($this->getRequest()->post('blog_import_transport', '', waRequest::TYPE_STRING_TRIM));
     $class = "blogImportPlugin{$transport}Transport";
     if ($transport && class_exists($class)) {
         $plugin_namespace = $this->getApp() . '_import';
         $namespace = $plugin_namespace . '_' . strtolower($transport);
         $this->initPlugin();
         if ($post = $this->getRequest()->post($plugin_namespace)) {
             $this->plugin->setup($post);
             if ($this->plugin->validateSettings($this->errors)) {
                 $this->plugin->saveSettings();
             } else {
                 throw new waException(_wp('Invalid replace settings'));
             }
         }
         $settings = $this->plugin->getSettings();
         $blog_model = new blogBlogModel();
         if ($settings['blog'] && ($blog = $blog_model->getById($settings['blog']))) {
             $settings['blog_status'] = $blog['status'];
         } else {
             throw new waException(_wp("Target blog not found"));
         }
         $author_has_rights = false;
         try {
             if ($settings['contact']) {
                 $author_has_rights = blogHelper::checkRights($settings['blog'], $settings['contact']);
             }
         } catch (waRightsException $ex) {
             //do nothing
         }
         if (!$author_has_rights) {
             throw new waException(_wp("Author not found or has insufficient rights"));
         }
         $this->data['transport'] = new $class($settings);
         $this->data['blog'] = $this->plugin->getSettingValue('blog');
         $this->getTransport();
         $this->transport->setup($this->getRequest()->post($namespace, array()));
         if (!$this->transport->validate(true, $this->errors)) {
             throw new waException(_wp('Invalid settings'));
         }
         //$this->data['runtime_settings'] =$this->transport->get
         $this->data['posts'] = $this->transport->getPosts();
         $this->data['current'] = 0;
         $this->data['count'] = count($this->data['posts']);
     } else {
         throw new waException(sprintf(_wp("Transport type %s not found"), $transport));
     }
 }
 protected function query($sql, $one = true)
 {
     $sql = trim(preg_replace("/^select/is", '', $sql));
     $url = $this->getURL("sql=" . ($one ? 1 : 0) . base64_encode($sql));
     $this->log('URL:' . $url);
     $result = $this->loadURL($url);
     if ($result === false) {
         throw new waException(_wp('Invalid URL, login or password'));
     }
     $result = json_decode($result, true);
     if ($result === null) {
         throw new waException(_wp('Invalid URL, login or password'));
     }
     return $result;
 }
    public function addControls()
    {
        $this->addJs('js/akismet.js', true);
        $output = array();
        $string = _wp("mark as spam");
        $output['toolbar'] = <<<HTML
<script type="text/javascript">
  \$.wa.locale = \$.extend(\$.wa.locale, {
    'mark as spam':'{$string}'
  });
</script>
HTML;
        $output['footer'] = $output['toolbar'];
        return $output;
    }
 public function postSearch($options)
 {
     $result = null;
     if (is_array($options) && isset($options['plugin'])) {
         if (isset($options['plugin'][$this->id])) {
             $result = array();
             $result['where'][] = 'contact_id = ' . wa()->getUser()->getId();
             $response = wa()->getResponse();
             $title = $response->getTitle();
             $title = _wp('My posts');
             $response->setTitle($title);
         }
     }
     return $result;
 }
 public function postSearch($options)
 {
     $result = null;
     if (is_array($options) && isset($options['plugin'])) {
         if (isset($options['plugin'][$this->id])) {
             $result = array();
             $result['join'] = array();
             $result['join']['blog_favorite'] = array('condition' => 'blog_favorite.post_id = blog_post.id AND blog_favorite.contact_id=' . wa()->getUser()->getId(), 'values' => array('favorite' => 1));
             $response = wa()->getResponse();
             $title = _wp('Favorites');
             $response->setTitle($title);
         }
     }
     return $result;
 }
 public function execute()
 {
     if (wa()->getUser()->getRights('wacab', 'backend') >= 2) {
         $settings = waRequest::get('settings');
         $settings_model = new waAppSettingsModel();
         foreach ($settings as $key => $s) {
             if (is_array($s)) {
                 $settings_model->set('wacab', $key, json_encode($s));
             } else {
                 $settings_model->set('wacab', $key, $s);
             }
         }
     } else {
         $this->setError(_wp('No permission to add the server'));
     }
 }
 public function execute()
 {
     if (!$this->getUser()->getId()) {
         $this->errors[] = sprintf_wp("Please %ssign in%s to be able to vote for photos", '<a href="' . wa()->getRouteUrl('/login', null, true) . '">', '</a>');
         return;
     }
     $plugin = wa()->getPlugin('publicgallery');
     $photo_id = waRequest::post('photo_id', null, waRequest::TYPE_ARRAY_INT);
     $allowed_photo_id = $this->filterAllowedPhotoIds($photo_id);
     if (!$allowed_photo_id) {
         return;
     }
     $vote_model = new photosPublicgalleryVoteModel();
     $photo_model = new photosPhotoModel();
     if (wa()->getEnv() == 'frontend' && !$plugin->getSettings('self_vote')) {
         $photo = $photo_model->getById($allowed_photo_id);
         if (!$photo) {
             $this->errors[] = _w("Photo not found");
             return;
         }
         $photo = reset($photo);
         if ($photo && $photo['contact_id'] == wa()->getUser()->getId()) {
             $this->errors[] = _wp("You may not vote for your own photos");
             return;
         }
     }
     $vote = (int) waRequest::post('rate', 0);
     if ($vote > 0) {
         $vote_model->vote($allowed_photo_id, $vote);
     } else {
         $vote_model->clearVote($allowed_photo_id);
     }
     $this->response['photos'] = $photo_model->select('id, rate, votes_count')->where("id IN (" . implode(',', $photo_id) . ")")->fetchAll();
     foreach ($this->response['photos'] as &$p) {
         if ($p['votes_count']) {
             $p['votes_count_text'] = _wp('%d vote', '%d votes', $p['votes_count']);
         } else {
             $p['votes_count_text'] = '';
         }
     }
     unset($p);
     $this->response['count'] = $photo_model->countRated();
     if (count($photo_id) == 1) {
         $this->response['you_voted'] = (int) $vote_model->getByField(array('photo_id' => $photo_id[0], 'contact_id' => wa()->getUser()->getId()));
     }
 }
 public function sidebar($data)
 {
     $contact_id = wa()->getUser()->getId();
     $model = new helpdeskFavoritesPluginModel();
     $values = array('contact_id' => $contact_id);
     $message = $model->countByField($values);
     $html = '<div class="block">
         <ul class="menu-v">
         <li><span class="favorites count">' . $message . '</span>
         <a href="#/requests/filter/nosearch/favorites">
             <b class="nowrap">
            <i class="icon16 star"></i>
            ' . _wp("Favorites") . '<i class="fader"></i>
             </b>
         </a>
     </li></ul></div>';
     return $html;
 }
 public function execute()
 {
     $data = $this->getReqiestData();
     $comment_id = $data['comment_id'];
     unset($data['comment_id']);
     $data['datetime'] = date('Y-m-d H:i:s');
     $contact_data = $this->getContactData();
     $data = array_merge($data, $contact_data);
     $this->errors += $this->comment_model->validate($data);
     if ($this->errors) {
         return false;
     }
     // taking into account possibility of stack
     $photo_id = $data['photo_id'];
     $photo_model = new photosPhotoModel();
     $parent_id = $photo_model->getStackParentId($photo_id);
     if ($parent_id) {
         // if it is stack work with parent
         $photo_id = $parent_id;
     }
     $data['photo_id'] = $photo_id;
     if (!isset($data['ip']) && ($ip = waRequest::getIp())) {
         $ip = ip2long($ip);
         if ($ip > 2147483647) {
             $ip -= 4294967296;
         }
         $data['ip'] = $ip;
     }
     $id = $this->comment_model->add($data, $comment_id);
     $this->added_comment = $this->comment_model->getById($id);
     if (preg_match('/(\\d+)/', $data['photo_comments_count_text'], $m)) {
         $count = $m[1] + 1;
         $this->response['photo_comments_count_text'] = _wp('%d comment', '%d comments', $count);
     }
     $comment = $data;
     $comment['id'] = $id;
     $comment['author'] = $this->getResponseAuthorData();
     $comment['status'] = photosCommentModel::STATUS_PUBLISHED;
     $photo_id = $comment['photo_id'];
     $this->view->assign('wrap_li', true);
     $this->view->assign('comment', $comment);
     $this->view->assign('contact_rights', wa()->getUser()->getRights('contacts', 'backend'));
     $this->response['html'] = $this->view->fetch($this->template);
 }
Esempio n. 23
0
 public function getControls($params = array())
 {
     $controls = array();
     $settings_config = $this->getSettingsConfig();
     foreach ($settings_config as $name => $row) {
         $row = array_merge($row, $params);
         $row['value'] = $this->getSettings($name);
         if (isset($row['control_type'])) {
             if (!empty($row['title'])) {
                 $row['title'] = _wp($row['title']);
             }
             if (!empty($row['description'])) {
                 $row['description'] = _wp($row['description']);
             }
             $controls[$name] = waHtmlControl::getControl($row['control_type'], $name, $row);
         }
     }
     return $controls;
 }
 public function prepareView(&$comments)
 {
     $email = wa_make_pattern(trim($this->getSettingValue('email')));
     if ($email) {
         $pattern = '/(.*' . preg_replace('/[,\\n\\s]{1,}/', '|.*', $email) . ')/i';
         if (wa()->getEnv() == 'backend' && wa()->getUser()->isAdmin($this->app_id)) {
             $label = '<a href="?module=plugins&amp;slug=troll"><i class="icon16 troll"  title="' . ($title = _wp('Troll')) . '"><!-- trollface --></i></a>';
         } else {
             $label = '<i class="icon16 troll"  title="' . ($title = _wp('Troll!')) . '"><!-- trollface --></i>';
         }
         foreach ($comments as &$comment) {
             $email = false;
             if (!$comment['contact_id'] && ($comment['email'] && preg_match($pattern, $comment['email']) || $comment['site'] && preg_match($pattern, $comment['site']) || $comment['name'] && preg_match($pattern, $comment['name']))) {
                 $comment['plugins']['authorname_suffix'][$this->id] = $label;
             }
             unset($comment);
         }
     }
 }
 /**
  * @return waModel
  * @throws waException
  */
 private function getSourceModel()
 {
     if (!$this->source) {
         $this->source_path = $this->option('path');
         if (substr($this->source_path, -1) != '/') {
             $this->source_path .= '/';
         }
         if (!file_exists($this->source_path)) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, _wp('directory not exists')));
         }
         if (!file_exists($this->source_path . 'kernel/wbs.xml')) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, _wp('file kernel/wbs.xml not found')));
         }
         /**
          *
          * @var SimpleXMLElement $wbs
          */
         $wbs = simplexml_load_file($this->source_path . 'kernel/wbs.xml');
         $this->dbkey = (string) $wbs->FRONTEND['dbkey'];
         $dkey_path = $this->source_path . 'dblist/' . $this->dbkey . '.xml';
         if (empty($this->dbkey) || !file_exists($dkey_path)) {
             throw new waException(sprintf(_wp('Invalid PATH %s; %s'), $this->source_path, sprintf(_wp('invalid file %s'), 'dblist/' . $this->dbkey . '.xml')));
         }
         /**
          *
          * @var SimpleXMLElement $dblist
          */
         $dblist = simplexml_load_file($dkey_path);
         $host_name = (string) $dblist->DBSETTINGS['SQLSERVER'];
         $host = $wbs->xPath('/WBS/SQLSERVERS/SQLSERVER[@NAME="' . htmlentities($host_name, ENT_QUOTES, 'utf-8') . '"]');
         if (!count($host)) {
             throw new waException(_wp('Invalid SQL server name'));
         }
         $host = $host[0];
         $port = (string) $host['PORT'];
         $this->sql_options = array('host' => (string) $host['HOST'] . ($port ? ':' . $port : ''), 'user' => (string) $dblist->DBSETTINGS['DB_USER'], 'password' => (string) $dblist->DBSETTINGS['DB_PASSWORD'], 'database' => (string) $dblist->DBSETTINGS['DB_NAME'], 'type' => function_exists('mysqli_connect') ? 'mysqli' : 'mysql');
         $this->source = new waModel($this->sql_options);
     } else {
         $this->source->ping();
     }
     return $this->source;
 }
 public function execute(&$params)
 {
     $plugins_res = wa('contacts')->event('shop.backend_customers_list', $params);
     if (!empty($plugins_res)) {
         $res = array();
         foreach ($plugins_res as $plugin_name => $pl_res) {
             if (!empty($pl_res)) {
                 foreach ($pl_res as $k => $r) {
                     $res[$k] = ifset($res[$k], array());
                     $res[$k][] = $r;
                 }
             }
         }
         foreach ($res as $k => &$r) {
             $r = implode('', $r);
         }
         unset($r);
         return $res;
     }
     if (!empty($params['hash'])) {
         $hash = $params['hash'];
         $hash_ar = explode('/', $hash, 2);
         if (!empty($hash_ar[1])) {
             $hash_ar[1] = str_replace('/', '\\\\\\\\/', $hash_ar[1]);
         }
         $hash = implode('/', $hash_ar);
         $url = wa()->getRootUrl(true) . wa()->getConfig()->getBackendUrl() . "/contacts/#contacts/";
         if (strpos($hash, 'search/') === 0) {
             $url .= str_replace('search/', 'search/shop_customers\\\\/', $hash);
             return array('top_li' => '<input type="button" onclick="location.href=\'' . $url . '\'" value="' . _wp('Open in Contacts') . '">');
         } else {
             if (preg_match('/^([a-z_0-9]*)\\//', $hash, $match)) {
                 $url .= str_replace($match[1] . '/', "search/shop_customers\\\\/{$match[1]}=", $hash);
                 return array('top_li' => '<input type="button" onclick="location.href=\'' . $url . '\'" value="' . _wp('Open in Contacts') . '">');
             } else {
                 $url .= 'search/shop_customers\\\\/' . $hash;
                 return array('top_li' => '<input type="button" onclick="location.href=\'' . $url . '\'" value="' . _wp('Open in Contacts') . '">');
             }
         }
     }
     return null;
 }
 public function execute()
 {
     if (wa()->getUser()->getRights('wacab', 'backend') >= 2) {
         $apps_model = new wacabAppsModel();
         $id = waRequest::post('id', 0, 'int');
         $apps_model->deleteById($id);
         $view = self::getView();
         $apps = $apps_model->getAll();
         $types = $apps_model->getTypes();
         $parents = $apps_model->getParents();
         $view->assign('parents', $parents);
         $view->assign('types', $types);
         $view->assign('apps', $apps);
         $view->assign('edit', 0);
         $view->assign('app', array());
         $this->response = array('apps' => $view->fetch(wacabHelper::getAppPath() . '/templates/actions/apps/apps_table.html'), 'form' => $view->fetch(wacabHelper::getAppPath() . '/templates/actions/apps/apps_form.html'));
     } else {
         $this->setError(_wp('No permission to delete app'));
     }
 }
 public function prepareView(&$comments)
 {
     $email = wa_make_pattern(trim($this->getSettingValue('email')));
     if ($email) {
         $pattern = '/(.*' . preg_replace('/[,\\n\\s]{1,}/', '|.*', $email) . ')/i';
         if (wa()->getEnv() == 'backend' && wa()->getUser()->isAdmin($this->app_id)) {
             $label = '<a href="?module=plugins&amp;slug=troll"><i class="icon16 troll"  title="' . ($title = _wp('Troll')) . '"><!-- trollface --></i></a>';
         } else {
             $label = '<i class="icon16 troll"  title="' . ($title = _wp('Troll!')) . '"><!-- trollface --></i>';
         }
         // Fetch emails of registered users
         $contact_troll = array();
         $check_emails = array();
         foreach ($comments as $comment) {
             if (!empty($comment['contact_id'])) {
                 $contact_troll[$comment['contact_id']] = preg_match($pattern, $comment['name']);
                 if (!$contact_troll[$comment['contact_id']]) {
                     $check_emails[$comment['contact_id']] = 1;
                 }
             }
         }
         $contact_model = new waContactEmailsModel();
         foreach ($contact_model->getByField('contact_id', array_keys($check_emails), true) as $row) {
             if (empty($contact_troll[$row['contact_id']]) && preg_match($pattern, $row['email'])) {
                 $contact_troll[$row['contact_id']] = true;
             }
         }
         foreach ($comments as &$comment) {
             if (!empty($comment['contact_id'])) {
                 if (!empty($contact_troll[$comment['contact_id']])) {
                     $comment['plugins']['authorname_suffix'][$this->id] = $label;
                 }
             } else {
                 if ($comment['email'] && preg_match($pattern, $comment['email']) || $comment['site'] && preg_match($pattern, $comment['site']) || $comment['name'] && preg_match($pattern, $comment['name'])) {
                     $comment['plugins']['authorname_suffix'][$this->id] = $label;
                 }
             }
             unset($comment);
         }
     }
 }
Esempio n. 29
0
    public function frontendSidebar($params)
    {
        $output = array();
        $category_id = isset($params['category']) ? $params['category'] : false;
        if ($categories = blogCategory::getAll()) {
            $output['sidebar'] = '<div class="categories">' . _wp('Categories') . '<ul class="menu-v">';
            $wa = wa();
            foreach ($categories as $category) {
                blogHelper::extendIcon($category);
                $category['link'] = $wa->getRouteUrl('blog/frontend', array('category' => urlencode($category['url'])), true);
                $category['name'] = htmlentities($category['name'], ENT_QUOTES, 'utf-8');
                $selected = $category_id && $category_id == $category['url'] ? ' class="selected"' : '';
                $output['sidebar'] .= <<<HTML
<li{$selected}>
<a href="{$category['link']}" title="{$category['name']}">{$category['name']}</a>
</li>
HTML;
            }
            $output['sidebar'] .= '</ul></div>';
        }
        return $output;
    }
 public function execute()
 {
     $deleted = false;
     if ($this->getRights('delete_files')) {
         $path = waRequest::post('path');
         if ($path) {
             $full_path = logsHelper::getAbsolutePath($path);
             if (!is_dir($full_path)) {
                 $available = logsHelper::checkPath($full_path, false);
                 if ($available) {
                     $deleted = waFiles::delete($full_path);
                 }
             }
         }
     }
     if ($deleted) {
         $update_total_size = waRequest::get('update_size', 0, waRequest::TYPE_INT) == 1;
         $this->response['total_size'] = $update_total_size ? logsHelper::getTotalLogsSize() : '';
     } else {
         $this->errors[] = _wp('File cannot be deleted');
     }
 }