Exemple #1
0
 public function helpfulAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $view = new Zend_View();
     $category = Engine_Api::_()->getItem('ynfeedback_category', $this->_getParam('id'));
     if (!$category->checkHasIdea()) {
         echo Zend_Json::encode(array('error' => 1));
     } else {
         echo Zend_Json::encode(array('error' => 0, 'popup_helpful_view' => $view->partial('_popup_helpful.tpl', 'ynfeedback', array('category' => $category))));
     }
 }
    public function save(array $data)
    {
        $keyAlgorithm = array_key_exists('algorithm', $data) ? $data['algorithm'] : 'hmac-md5';
        $keySecret = $data['secret'];
        $slaveIp = $data['ip'];
        $slavePort = array_key_exists('port', $data) ? $data['port'] : 953;
        $view = new Zend_View();
        $view->setScriptPath(pm_Context::getPlibDir() . 'views/scripts');
        $rndc = new Modules_SlaveDnsManager_Rndc();
        $pleskIp = $view->escape($rndc->getServerIP());
        $slaveConfiguration = $view->partial('index/slave-config.phtml', array('pleskIp' => $pleskIp, 'secret' => $keySecret));
        $slaveConfiguration = trim(html_entity_decode(strip_tags($slaveConfiguration)));
        $slaveConfiguration = preg_replace('/^/m', '    ', $slaveConfiguration);
        $configuration = <<<CONF
/*
{$slaveConfiguration}
*/

key "rndc-key" {
    algorithm {$keyAlgorithm};
    secret "{$keySecret}";
};

options {
    default-key "rndc-key";
    default-server {$slaveIp};
    default-port {$slavePort};
};
CONF;
        if (null === $this->_config) {
            $this->_config = "slave_{$slaveIp}.conf";
        }
        $result = file_put_contents($this->getConfigPath(), $configuration);
        if (false === $result) {
            throw new pm_Exception("Failed to save configuration {$this->_config}");
        }
        $acl = new Modules_SlaveDnsManager_Acl();
        $acl->add($slaveIp);
    }
 /**
  * Build HTML for the carousel
  * @param array $args
  * @param Zend_View $view
  * @return string HTML to display
  */
 public static function carousel($args, $view)
 {
     static $id_suffix = 0;
     if (isset($args['is_featured'])) {
         $params['featured'] = $args['is_featured'];
     }
     if (isset($args['tags'])) {
         $params['tags'] = $args['tags'];
     }
     if (isset($args['user'])) {
         $params['user'] = $args['user'];
     }
     if (isset($args['ids'])) {
         $params['range'] = $args['ids'];
     }
     if (isset($args['sort'])) {
         $params['sort_field'] = $args['sort'];
     }
     if (isset($args['order'])) {
         $params['sort_dir'] = $args['order'];
     }
     if (isset($args['collection'])) {
         $params['collection'] = $args['collection'];
     }
     if (isset($args['num'])) {
         $limit = $args['num'];
     } else {
         $limit = 10;
     }
     $params['hasImage'] = 1;
     $items = get_records('Item', $params, $limit);
     //handle the configs for jCarousel
     $configs = array('carousel' => array());
     //carousel configs
     if (isset($args['speed'])) {
         if (is_numeric($args['speed'])) {
             $configs['carousel']['animation'] = (int) $args['speed'];
         } else {
             $configs['carousel']['animation'] = $args['speed'];
         }
     }
     if (isset($args['showtitles']) && $args['showtitles'] == 'true') {
         $configs['carousel']['showTitles'] = true;
     }
     //autoscroll configs
     if (isset($args['autoscroll']) && $args['autoscroll'] == 'true') {
         $configs['autoscroll'] = array();
         if (isset($args['interval'])) {
             $configs['autoscroll']['interval'] = (int) $args['interval'];
         }
     }
     $html = $view->partial('carousel.php', array('items' => $items, 'id_suffix' => $id_suffix, 'configs' => $configs));
     $id_suffix++;
     return $html;
 }
Exemple #4
0
 /**
  * Format an exception using an internal script
  *
  * @param Exception $e exception to be formatted
  *
  * @return string
  */
 protected function formatException(Exception $e)
 {
     $view = new Zend_View(array('scriptPath' => dirname(__FILE__)));
     return $view->partial('exception.phtml', array('exception' => $e));
 }
 /**
  * Build HTML for the carousel
  * @param array $args
  * @param Zend_View $view
  * @return string HTML to display
  */
 public static function carousel($args, $view)
 {
     static $id_suffix = 0;
     if (isset($args['float'])) {
         $params['float'] = $args['float'];
     } else {
         $params['float'] = 'left';
     }
     if (isset($args['width'])) {
         $params['width'] = $args['width'];
     } else {
         $params['width'] = '100%';
     }
     if (isset($args['navbar'])) {
         $params['noNav'] = $args['navbar'];
     } else {
         $params['noNav'] = 'true';
     }
     if (isset($args['ids'])) {
         $params['range'] = $args['ids'];
     }
     if (isset($args['captionposition'])) {
         $params['captionLocation'] = $args['captionposition'];
     } else {
         $params['captionLocation'] = 'left';
     }
     if (isset($args['showdescription'])) {
         $params['showDescr'] = $args['showdescription'];
     } else {
         $params['showDescr'] = 'false';
     }
     $params['hasImage'] = 1;
     $result = preg_replace_callback('/(\\d+)-(\\d+)/', function ($m) {
         return implode(',', range($m[1], $m[2]));
     }, $args['ids']);
     $ids = explode(',', $result);
     foreach ($ids as $key => $item) {
         if (get_record_by_id('item', $item)) {
             $items[$key] = get_record_by_id('item', $item);
         }
     }
     //handle the configs for Slick
     //$configs = array('slick' => array());
     //carousel configs
     if (isset($args['slides'])) {
         $configs['slidesToShow'] = $args['slides'];
     } else {
         $configs['slidesToShow'] = 5;
     }
     if (isset($args['scroll'])) {
         $configs['slidesToScroll'] = $args['scroll'];
     } else {
         $configs['slidesToScroll'] = 1;
     }
     if (isset($args['center'])) {
         $configs['centerMode'] = $args['center'];
     } else {
         $configs['centerMode'] = 'false';
     }
     if (isset($args['slideshow'])) {
         $configs['autoPlay'] = $args['slideshow'];
     } else {
         $configs['autoPlay'] = 'false';
     }
     if (isset($args['speed'])) {
         if (is_numeric($args['speed'])) {
             $configs['autoplaySpeed'] = (int) $args['speed'];
         } else {
             $configs['autoplaySpeed'] = $args['speed'];
         }
     } else {
         $configs['autoplaySpeed'] = 2000;
     }
     if (isset($args['focus'])) {
         $configs['focusOnSelect'] = $args['focus'];
     } else {
         $configs['focusOnSelect'] = 'true';
     }
     if (isset($args['navigation'])) {
         $configs['arrows'] = $args['navigation'];
     } else {
         $configs['arrows'] = 'false';
     }
     $html = $view->partial('carousel.php', array('items' => $items, 'id_suffix' => $id_suffix, 'params' => $params, 'configs' => $configs));
     $id_suffix++;
     return $html;
 }
Exemple #6
0
 /**
  * Enviar um feedback de acordo com as configurações do arquivo .INI
  *  - O arquivo deve estar na pasta /configs
  *  - O nome do arquivo deve ser feedback.ARQUIVO.ini
  *
  * @todo colocar valores padrões para limpar o INI e previnir possiveis erros
  * @todo verificar SPAM
  * @todo colocar em uma classe separada
  *
  * @param array 	$post campos do formulário
  * @param string	$config arquivo ini com as configurações
  *
  * @uses   Zend_Config_Ini
  * @throws RW_Exception
  * @see    RW_Exception
  */
 public function sendFeedback($post, $configfile)
 {
     $configpath = realpath(APPLICATION_PATH . "/../configs/feedback.{$configfile}.ini");
     if (!file_exists($configpath)) {
         // Tenta outro diretório
         $configpath = realpath(APPLICATION_PATH . "/configs/feedback.{$configfile}.ini");
     }
     if (!file_exists($configpath)) {
         throw new Exception("Arquivo de configuração '{$configfile}' não encontrado do diretório /configs");
     }
     $config = new Zend_Config_Ini($configpath, APPLICATION_ENV);
     $config = $config->toArray();
     $opts = array();
     // arruma os destinatarios
     foreach ($config['destinatarios'] as $id => $campo) {
         $c = explode(':', $campo);
         if (count($c) == 1) {
             $config['destinatarios'][$c[0]] = null;
         } elseif (count($c) == 2) {
             $config['destinatarios'][$c[1]] = $c[0];
         }
         unset($config['destinatarios'][$id]);
     }
     // arruma os campos
     foreach ($config['campos'] as $id => $campo) {
         $c = explode(':', $campo);
         if (count($c) == 1) {
             $config['campos'][$c[0]] = $c[0];
         } elseif (count($c) == 2) {
             $config['campos'][$c[0]] = $c[1];
         }
         unset($config['campos'][$id]);
     }
     // Verifica se há variáveis no titulo
     if (strpos($config['titulo'], '$') !== false) {
         foreach ($post as $c => $v) {
             $config['titulo'] = str_replace('$' . $c, $v, $config['titulo']);
         }
     }
     // Verifica se vai usar um modelo
     if (isset($config['modelo'])) {
         $view = new Zend_View();
         $view->setScriptPath(APPLICATION_PATH . '/views/scripts');
         $html = $emailCliente = $view->partial('/_modelos/feedback/' . $config['modelo'] . '.phtml', array('valores' => $post, 'config' => $config));
         $text = $this->_extractText($html);
     } else {
         // Cria o HTML para enviar no email
         $html = '<table>';
         $text = '';
         foreach ($config['campos'] as $campo => $nome) {
             if (isset($post[$campo]) && $post[$campo] != '' || $config['mostraVazios'] == 1) {
                 $text .= "{$nome}: " . (isset($post[$campo]) ? $post[$campo] : '') . "\n";
                 $html .= '<tr>';
                 $html .= '<td align="right" valign="top"><font face="verdana" size="2">' . $nome . '</font></td>';
                 $html .= '<td></td>';
                 $html .= '<td valign="top"><font face="verdana" size="2">' . (isset($post[$campo]) ? $post[$campo] : '') . '</font></td>';
                 $html .= '</tr>';
             }
         }
         $html .= "</table>";
     }
     // Coloca a assinatura
     if (isset($text) && $text != '') {
         $text .= "\n\n";
         $text .= 'Realejo Feedback v1.0' . "\n";
         $text .= 'Este e-mail foi gerado automaticamente em ' . date("d/m/y H:m:s") . "\n";
         $text .= '(C)2010, Realejo (http://www.realejo.com.br)' . "\n";
     }
     if (isset($html) && $html != '') {
         $html .= '<p>&nbsp;</p><center>';
         $html .= '<table width=95% cellspacing=0 cellpadding=0>';
         $html .= '<tr><td align="right" colspan="2"><font face="verdana" size="1">Este e-mail foi gerado automaticamente em ' . date("d/m/y H:m:s") . '.</font></td></tr>';
         $html .= '<tr bgcolor="#6E6E6E"><td height="1" colspan="2"></td></tr>';
         $html .= '<tr>';
         $html .= '<td><font size="1" face="verdana">Realejo Feedback v1.0</font></td>';
         $html .= '<td align=right>';
         $html .= '<font size="1" face="verdana">&copy; 2010, <a href="http://www.realejo.com.br"><font color="black">Realejo</font></a></font>';
         $html .= '</td></tr>';
         $html .= '</table></center>';
     }
     if ($config['verificar'] == 1 && APPLICATION_ENV != 'production') {
         echo "<h1>Verificação do Feedback</h1>";
         echo "<p>veja abaixo as configurações e o email enviado</p>";
         echo "<h2>Configuração feedback.{$configfile}.ini</h2>";
         RW_Debug::dump($config, '$config');
         echo "<hr/>";
         RW_Debug::dump($post, '$post');
         echo "<hr/>";
         echo "<h2>HTML</h2>{$html} <hr>";
         echo "<h2>TEXTO</h2><pre>{$text}</pre><hr>";
     }
     if ($config['destinatarios_unir'] == 1) {
         // verifica se tem cópia oculta
         if (isset($config['bcc']) && $config['bcc'] != '') {
             $opts['bcc'] = $config['bcc'];
         }
         $this->SendEmail($post[$config['nome']], $post[$config['email']], null, $config['destinatarios'], $config['titulo'], array('html' => $html, 'text' => $text), $opts);
     } else {
         foreach ($config['destinatarios'] as $email => $nome) {
             $this->SendEmail($post[$config['nome']], $post[$config['email']], $nome, $email, $config['titulo'], array('html' => $html, 'text' => $text));
         }
         // verifica se tem cópia oculta
         // @todo permitir que tenha nome no bcc
         // @todo informar que recebeu os emails
         if (isset($config['bcc']) && $config['bcc'] != '') {
             $this->SendEmail($post[$config['nome']], $post[$config['email']], $config['bcc'], $config['bcc'], $config['titulo'], array('html' => $html, 'text' => $text));
         }
     }
     if ($config['verificar'] == 1 && APPLICATION_ENV != 'production') {
         die('<hr/>email enviado');
     }
 }
Exemple #7
0
 public function registermail($to, $mailSubject, array $row, $confirmationAction = '/publicms/profile/confirm/init/2', $generatePassword = false, array $partialMailConfirm = array('profile/mailconfirm.phtml', 'publicms'), array $partialMailPassword = array('profile/mailpassword.phtml', 'publicms'))
 {
     // Init
     $data = $row;
     //->toArray();
     // Mail content
     $objectByPass = new Sydney_Auth_Bypass();
     $sBypass = $objectByPass->get($row['id']);
     $data['link_confirmation'] = Sydney_Tools::getConf('general')->siteDomain . $confirmationAction . '/passid/' . $row['id'] . '/pass/' . $sBypass;
     if (empty($mailSubject)) {
         $mailSubject = 'Confirmation ' . Sydney_Tools::getConf('general')->siteTitle;
     }
     if (count($partialMailConfirm) >= 2) {
         $view = new Zend_View();
         $tmsg = $view->partial($partialMailConfirm[0], $partialMailConfirm[1], array('data' => $data));
         if (array_key_exists(2, $partialMailConfirm) && !empty($partialMailConfirm[2])) {
             $mailSubject = $partialMailConfirm[2];
         }
     } else {
         $view = new Zend_View();
         $tmsg = $view->partial('profile/mailconfirm.phtml', 'publicms', array('data' => $data));
     }
     $mail = new Zend_Mail('UTF-8');
     $mail->setBodyHtml($tmsg);
     $mail->setFrom(Sydney_Tools::getConf('general')->siteEmail, Sydney_Tools::getConf('general')->siteTitle);
     $mail->addTo($to, $to);
     $mail->setSubject($mailSubject);
     $mail->send();
     if ($generatePassword) {
         // Change password
         $data['password'] = Sydney_Tools_Security::generatePassword($length = 8, $use_lower = true, $use_upper = true, $use_number = true, $use_custom = '');
         $user = new Users($row->id);
         $user->changePassword($data['password'], $row->id);
         // Send informations by email
         $view = new Zend_View();
         $tmsg = $view->partial($partialMailPassword[0], $partialMailPassword[1], array('data' => $data));
         // Mailer
         $mail = new Zend_Mail('UTF-8');
         $mail->setBodyHtml($tmsg);
         $mail->setFrom(Sydney_Tools::getConf('general')->siteEmail, Sydney_Tools::getConf('general')->siteTitle);
         $mail->addTo($row->login, $row->login);
         $mail->setSubject($mailSubject);
         $mail->send();
     }
     //}
 }