Beispiel #1
0
function search_content_handler(&$sm)
{
    $um =& $sm->get_url_manager();
    if ($um->isset_param('search_do_advanced')) {
        require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Articles.class.php';
        $params = Articles_list::get_search_params_from_url($sm);
        unset($params['pg']);
        if ($um->isset_param('search_archive')) {
            $params['search_archive'] = 1;
        }
        $params['search_do_advanced'] = true;
        $params = strtr(rtrim(base64_encode(serialize($params)), '='), '+/', '-_');
        //$params = rtrim($params, '=');
        if ($um->isset_param('search_archive')) {
            header('Location:' . make_proxied_url('archive/index.html?search_options=' . $params));
        } else {
            header('Location:' . make_proxied_url('index.html?search_options=' . $params));
        }
        exit;
    }
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $content_template = new template($sm, $template);
    $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/advanced_search.tpl');
    $template->assign('PAGE_CONTENT', $content_template->get_output());
}
Beispiel #2
0
function usercp_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $dm->restore_dump(md5(VIVVO_PROXY_URL . 'usercp.html'));
    $template->assign('DUMP_MESSAGES', $dm->_dump_pool);
    $content_template = new template($sm, $template);
    $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/usercp.tpl');
    $template->assign('PAGE_CONTENT', $content_template->get_output());
}
Beispiel #3
0
 /**
  * Reutrn module template output
  *
  * @return string
  */
 function get_output()
 {
     if ($this->cache && $this->cache_output) {
         return $this->cache_output;
     } else {
         if ($this->_template instanceof template) {
             $output = $this->_template->get_output();
         } else {
             $output = $this->output;
         }
         if ($this->cache) {
             $class = get_class($this);
             vivvo_cache::get_instance()->put($this->_cache_id . '!' . $class, $output, array($class), VIVVO_MODULE_CACHE_TIME);
             vivvo_lite_site::get_instance()->debug_push('Box cache:', 'Save ' . $class);
         }
         return $output;
     }
 }
Beispiel #4
0
function login_content_handler(&$sm)
{
    $template = $sm->get_template();
    $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'frame/default.tpl');
    $um = $sm->get_url_manager();
    $dm = $sm->get_dump_manager();
    $dm->restore_dump(md5(make_proxied_url('login.html')));
    if (defined('VIVVO_ABSOLUTE_URL')) {
        $index_url = VIVVO_ABSOLUTE_URL;
    } else {
        $index_url = make_absolute_url('');
    }
    $action = $sm->action_status;
    $template->assign('DUMP_MESSAGES', $dm->_dump_pool);
    if ($action) {
        if ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'login') {
            header('Location: ' . $index_url);
            exit;
        } elseif ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'register' or $um->get_param('action') == 'login' && $um->get_param('cmd') == 'confirm') {
            $template->assign('REGISTRATION', strval('1'));
        } elseif ($um->get_param('action') == 'login' && $um->get_param('cmd') == 'changePassword') {
            $template->assign('REGISTRATION', strval('0'));
        } else {
            $template->assign('REGISTRATION', strval('0'));
        }
    } elseif ($um->isset_param('action') && $action === false) {
        $in_user = $um->get_param_regexp('/^USER_/');
        $current_user = new Users($sm, $in_user);
        $template->assign('user', $current_user);
    } else {
        $template->assign('REGISTRATION', strval('0'));
    }
    $content_template = new template($sm, $template);
    if ($um->get_param('activation_key')) {
        $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/change_password.tpl');
        $content_template->assign('key', htmlspecialchars($um->get_param('activation_key')));
    } else {
        $content_template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . 'system/register.tpl');
    }
    $template->assign('PAGE_CONTENT', $content_template->get_output());
}
Beispiel #5
0
 /**
  * Renders responses
  *
  * @param	string	$template_file
  * @return	string
  */
 public function render_responses($template_file)
 {
     $template = new template(null, vivvo_lite_site::get_instance()->get_template());
     $template->set_template_file(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . $template_file);
     $template->assign('comment_list', $this->respones);
     return $template->get_output();
 }
Beispiel #6
0
 function forgot_mail($username, $email)
 {
     if (!$this->check_token()) {
         return false;
     }
     if (!vivvo_hooks_manager::call('login_forgotMail', array(&$username, &$email))) {
         return vivvo_hooks_manager::get_status();
     }
     if (isset($_SESSION['vivvo']['register_time']) && $_SESSION['vivvo']['register_time'] + 60 > VIVVO_START_TIME) {
         $this->set_error_code(2755);
         return false;
     }
     require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/core/Users.class.php';
     $lang = vivvo_lang::get_instance();
     $user_list = new Users_list();
     if (!$username && !$email) {
         $this->set_error_code(2712);
         return false;
     } else {
         if ($username) {
             $user_list->search(array('search_username' => $username));
             $user = current($user_list->list);
         } elseif ($email) {
             $user_list->search(array('search_email_address' => $email));
             $user = current($user_list->list);
         }
         if ($user) {
             $search = array('(', ')', '<', '>', '@', ';', ':', '\\', '"', '.', '[', ']');
             $replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
             $vivvo_website_title = str_replace($search, $replace, VIVVO_WEBSITE_TITLE);
             $vivvo_website_title = "=?UTF-8?B?" . base64_encode($vivvo_website_title) . "?=";
             $headers['From'] = $vivvo_website_title . '<' . VIVVO_EMAIL_SEND_FROM . '>';
             $recipients = array();
             $recipients[] = $user->email_address;
             $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_FORGOT_SUBJECT) . "?=";
             $headers['Content-Type'] = "text/plain; charset=UTF-8;";
             $body_template = new template();
             $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_FORGOT_BODY);
             $body_template->set_string_template($template_sting);
             $confirm_url = make_absolute_url('login.html?activation_key=' . md5($user->username . $user->email_address . $user->password));
             $body_template->assign('activation_url', $confirm_url);
             $body_template->assign('user', $user);
             $body = $body_template->get_output() . "\n\n";
             if (VIVVO_EMAIL_SMTP_PHP == 1) {
                 $mail_object = new Mail();
                 $mail_object->send($recipients, $headers, $body);
             } else {
                 $mail_options['driver'] = 'smtp';
                 $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                 $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                 $mail_options['localhost'] = 'localhost';
                 if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                     $mail_options['auth'] = true;
                     $mail_options['username'] = VIVVO_EMAIL_SMTP_PASSWORD;
                     $mail_options['password'] = VIVVO_EMAIL_SMTP_USERNAME;
                 } else {
                     $mail_options['auth'] = false;
                     $mail_options['username'] = '';
                     $mail_options['password'] = '';
                 }
                 $mail_object = Mail::factory('smtp', $mail_options);
                 $mail_object->send($recipients, $headers, $body);
             }
         }
         $_SESSION['vivvo']['register_time'] = time();
         return true;
     }
 }
Beispiel #7
0
/**
 * Step 6, sets administration parameters in database and creates welcome email.
 * At this step installation is finished and user can choose further action.
 *
 * @param template $template
 * @param dump_manager $dm
 * @param vivvo_lang $lang
 * @return void
 */
function step6(&$template, &$dm, &$lang)
{
    require_once dirname(__FILE__) . '/../conf.php';
    if ($db = @mysql_connect(VIVVO_DB_HOST, VIVVO_DB_USER, VIVVO_DB_PASSWORD)) {
        if (mysql_select_db(VIVVO_DB_DATABASE, $db)) {
            @mysql_query('SET NAMES utf8', $db);
            $web_site_title = $_REQUEST['web_site_title'];
            $administrator_email = $_REQUEST['administrator_email'];
            $admin_username = $_REQUEST['admin_username'];
            $admin_password = $_REQUEST['admin_password'];
            $admin_password_retype = $_REQUEST['admin_password_retype'];
            if (!preg_match("/^[-_a-zA-Z0-9]+(\\.[-_a-zA-Z0-9]+)*@[-a-zA-Z0-9]+(\\.[-a-zA-Z0-9]+)*\\.[a-zA-Z]{2,6}\$/", $administrator_email)) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_WRONG_EMAIL'));
                $template->assign('step', strval(5));
            } elseif ($admin_username == '') {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_WRONG_USERNAME'));
                $template->assign('step', strval(5));
            } elseif (strlen($admin_password) < 6) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_PASSWORD_MINIMUM_6_CHAR'));
                $template->assign('step', strval(5));
            } elseif ($admin_password != $admin_password_retype) {
                $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_PASSWORD_AND_RETYPE_PASSWORD_MUST_BE_SAME'));
                $template->assign('step', strval(5));
            } else {
                define('VIVVO_WEBSITE_TITLE', $web_site_title);
                define('VIVVO_ADMINISTRATORS_EMAIL', $administrator_email);
                define('VIVVO_EMAIL_SEND_FROM', $administrator_email);
                define('VIVVO_ADMIN_USERNAME', $admin_username);
                define('VIVVO_ADMIN_PASSWORD', $admin_password);
                require_once VIVVO_FS_INSTALL_ROOT . 'lib/vivvo/framework/sqlrunner.class.php';
                // load sql runner
                $sqlRunner = new SQLRunner(array('db' => $db, 'stop_on_error' => true));
                // Execute scheme.sql
                if ($sqlRunner->load(dirname(__FILE__) . '/db/post-install.sql') > 0) {
                    try {
                        $scheme = $sqlRunner->run();
                    } catch (SQLRunnerException $e) {
                        $dm->add_dump('error', 0, $lang->get_value('LNG_INSTALLER_ERROR_EXECUTING_SQL'), $e->getMessage());
                        $template->assign('step', strval(4));
                        return;
                    }
                } else {
                    $dm->add_dump('error', 0, $lang->get_value('LNG_INSTALLER_INVALID_SQL_FILE') . 'post-install.sql');
                    $template->assign('step', strval(4));
                    return;
                }
                $template->assign('step', strval(6));
                // Send information email
                $header = "From: Vivvo CMS Installation Wizard <" . $administrator_email . ">\r\n";
                $header .= "MIME-Version: 1.0\r\n";
                $header .= "Content-type: text/html; charset=utf-8\r\n";
                $subject = "=?UTF-8?B?" . base64_encode('Installation Complete') . "?=";
                $email_template = new template(null, $template);
                $email_template->set_template_file(VIVVO_FS_ROOT . 'installer/templates/email.xml');
                $body = $email_template->get_output();
                @mail($administrator_email, $subject, $body, $header);
            }
        } else {
            $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_CANT_SELECT_DATABASE'));
            $template->assign('step', strval(5));
        }
    } else {
        $dm->add_dump('info', 0, $lang->get_value('LNG_INSTALLER_CANT_CONNECT_TO_DATABASE'));
        $template->assign('step', strval(5));
    }
}
 /**
  * Get site output.
  *
  * @return string   Parsed generated content as HTML string.
  */
 public function get_output()
 {
     $output = $this->_template->get_output();
     $output = str_replace('{$css__}', $this->_header_manager->get_css_output(), $output);
     $output = str_replace('{$scripts__}', $this->_header_manager->get_script_output(), $output);
     $output = str_replace('{$rss__}', $this->_header_manager->get_rss_output(), $output);
     $output = str_replace('{$meta_names__}', $this->_header_manager->get_meta_output(), $output);
     $output = str_replace('{$dump__}', $this->_dump_manager->get_output(), $output);
     return $output;
 }
function full_page_cache_replace_boxes($sm, $uncached_boxes)
{
    $sm != null or $sm = vivvo_lite_site::get_instance();
    if (VIVVO_CACHE_ENABLE == 2 && !empty($uncached_boxes)) {
        $output = $sm->output;
        $template = $sm->get_template();
        $box_output = array();
        foreach ($uncached_boxes as $box_key => $box) {
            $sm->debug_push("Full page cache:", 'Render ' . $box);
            $template_file = preg_replace('/[^a-zA-Z0-9\\_\\-\\/\\.]/', '', $box);
            if (file_exists(VIVVO_FS_TEMPLATE_ROOT . VIVVO_TEMPLATE_DIR . $template_file)) {
                $box_template = new template($sm, $template);
                $box_template->set_template_file(VIVVO_TEMPLATE_DIR . $template_file);
                $output = preg_replace('/<!--NoCache ' . preg_quote($box, '/') . '-->.*<!--NoCache-->/sU', $box_template->get_output(), $output);
            }
        }
        if (defined('VIVVO_DEBUG_MODE')) {
            $output = str_replace('</body>', $sm->format_debug_output(), $output);
        }
        echo $output;
        exit;
    }
}
 /**
  * Creates string output for every VTE template element, and common html tag,
  * that need to be parsed for the final HTML content.
  *
  * @return string    Parsed HTML string
  */
 function get_output()
 {
     $output = '';
     if ($this->_type == 'CDATA' || $this->_type == 'after_schock') {
         return $this->_value;
     }
     // non-vte tags
     if (substr($this->_type, 0, 4) != 'vte:' and $this->_type != 'comment') {
         return $this->get_output_default();
     }
     if ($this->_type == 'comment') {
         $output = '';
         if (preg_match('/\\{/', $this->_value)) {
             $split_tpl = preg_split('/({.*?})/', $this->_value, -1, PREG_SPLIT_DELIM_CAPTURE);
             if (is_array($split_tpl) && !empty($split_tpl)) {
                 foreach ($split_tpl as $v) {
                     $output .= preg_match('/\\{/', trim($v)) ? $this->param_value($v) : $v;
                 }
                 unset($v);
             }
         } else {
             $output .= $this->_value;
         }
         return $output;
     }
     switch ($this->_type) {
         case 'vte:else':
             return '';
         case 'vte:if':
             $countinue = false;
             if (!empty($this->attributes['isset'])) {
                 $countinue = $this->_template->has_value($this->attributes['isset']);
             } else {
                 if (preg_match('/(\'[^\']*\'|\\"[^"]*\\"|-?\\d+|true|false|\\{[\\w\\.\\[\\]\\|:,\\-]+\\})\\s*(=|==|!=|&lt;|&gt;|&lt;=|&gt;=|lt|lte|gt|gte|eq|neq|in)\\s*(\'[^\']*\'|\\"[^"]*\\"|-?\\d+|true|false|\\{[\\w\\.\\[\\]\\|:,\\-]+\\})/i', $this->attributes['test'], $if_statment)) {
                     $variable =& $this->param_value($if_statment[1]);
                     $value =& $this->param_value($if_statment[3]);
                     switch ($if_statment[2]) {
                         case 'eq':
                         case '=':
                         case '==':
                             if ($variable == $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'neq':
                         case '!=':
                             if ($variable != $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'lt':
                         case '&lt;':
                             if ($variable < $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'lte':
                         case '&lt;=':
                             if ($variable <= $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'gt':
                         case '&gt;':
                             if ($variable > $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'gte':
                         case '&gt;=':
                             if ($variable >= $value) {
                                 $countinue = true;
                             }
                             break;
                         case 'in':
                             if (is_string($variable) or is_numeric($variable) or is_bool($variable)) {
                                 if (is_string($value) and $value != '') {
                                     $value = explode(',', $value);
                                     if (in_array($variable, $value)) {
                                         $countinue = true;
                                     }
                                 } elseif (is_array($value) and !empty($value)) {
                                     if (in_array($variable, $value)) {
                                         $countinue = true;
                                     }
                                 }
                             }
                             break;
                     }
                 } elseif (preg_match('/^!(\\{[\\*\\w\\.\\[\\]\\|:,\\-\']+\\})$/i', $this->attributes['test'], $if_statment)) {
                     $variable =& $this->param_value($if_statment[1]);
                     if (empty($variable)) {
                         $countinue = true;
                     }
                 } elseif (preg_match('/^(\\{[\\*\\w\\.\\[\\]\\|:,\\-\']+\\})$/i', $this->attributes['test'], $if_statment)) {
                     $variable =& $this->param_value($if_statment[1]);
                     if (!empty($variable)) {
                         $countinue = true;
                     }
                 }
             }
             if ($countinue) {
                 //$output .= $this->nodes_output();
                 if (is_array($this->_nodes)) {
                     foreach ($this->_nodes as $k => $node) {
                         $output .= $this->_nodes[$k]->get_output();
                     }
                 }
             } else {
                 $else_node =& $this->get_child_by_tag('vte:else');
                 if ($else_node) {
                     //$output = $else_node->nodes_output();
                     $output = '';
                     if (is_array($else_node->_nodes)) {
                         foreach ($else_node->_nodes as $k => $node) {
                             $output .= $else_node->_nodes[$k]->get_output();
                         }
                     }
                 }
             }
             return $output;
         case 'vte:for':
             $output = '';
             if (isset($this->attributes['from'])) {
                 $array = $this->param_value($this->attributes['from']);
             } else {
                 $array = false;
             }
             $key = false;
             if (isset($this->attributes['key'])) {
                 $key = $this->attributes['key'];
             }
             $start = isset($this->attributes['start']) ? intval($this->get_attribute_output('start')) : 1;
             $step = isset($this->attributes['step']) ? intval($this->get_attribute_output('step')) : 1;
             if ($step == 0) {
                 $step = 1;
             }
             if (is_array($array) && !empty($array)) {
                 $count = count($array);
                 $loop = isset($this->attributes['loop']) ? intval($this->get_attribute_output('loop')) + $start : $count;
             } else {
                 $loop = isset($this->attributes['loop']) ? intval($this->get_attribute_output('loop')) + $start : 0;
             }
             if ($key !== false && $loop != 0) {
                 for ($j = $start; $j <= $loop; $j = $j + $step) {
                     $this->_template->assign($key, $j);
                     $this->_template->assign($key . '_count', $loop);
                     if (is_array($this->_nodes)) {
                         foreach ($this->_nodes as $k => $node) {
                             $output .= $this->_nodes[$k]->get_output();
                         }
                     }
                 }
             }
             return $output;
         case 'vte:foreach':
             if (isset($this->attributes['from'])) {
                 $array = $this->param_value($this->attributes['from']);
             } else {
                 $array = false;
             }
             $key = false;
             if (isset($this->attributes['key'])) {
                 $key = $this->attributes['key'];
             }
             if (is_array($array) && !empty($array)) {
                 $item_name = $this->attributes['item'];
                 $count = count($array);
                 $start = isset($this->attributes['start']) ? intval($this->get_attribute_output('start')) : 1;
                 $loop = isset($this->attributes['loop']) ? intval($this->get_attribute_output('loop')) + $start - 1 : $count;
                 $step = isset($this->attributes['step']) ? intval($this->get_attribute_output('step')) : 1;
                 if ($start > $count) {
                     return '';
                 }
                 $index = 0;
                 $internal_index = $start;
                 reset($array);
                 do {
                     $current_key = key($array);
                     if ($index >= $start - 1 && $index < $loop) {
                         if ($key) {
                             $this->_template->assign($key, $internal_index);
                             $this->_template->assign($key . '_count', $loop);
                         }
                         $this->_template->assign($item_name, $array[$current_key]);
                         //$output .= $this->nodes_output();
                         if (is_array($this->_nodes)) {
                             foreach ($this->_nodes as $k => $node) {
                                 $output .= $this->_nodes[$k]->get_output();
                             }
                         }
                         $internal_index += $step;
                     }
                     $index++;
                     for ($i = 1; $i < $step; $i++) {
                         if (!next($array)) {
                             break;
                         }
                         $index++;
                     }
                 } while (next($array));
             } else {
                 $else_node = $this->get_child_by_tag('vte:else');
                 if ($else_node) {
                     $output = '';
                     if (is_array($else_node->_nodes)) {
                         foreach ($else_node->_nodes as $k => $node) {
                             $output .= $else_node->_nodes[$k]->get_output();
                         }
                     }
                 }
             }
             return $output;
         case 'vte:literal':
             $output = '';
             if (is_array($this->_nodes) && !empty($this->_nodes)) {
                 foreach ($this->_nodes as $k => $node) {
                     $output .= $this->_nodes[$k]->get_literal_output();
                 }
             }
             return $output;
         case 'vte:variable':
             $output = '';
             $content = '';
             if (isset($this->attributes['name']) && !empty($this->attributes['name'])) {
                 $literal = isset($this->attributes['literal']) && $this->attributes['literal'] == 1;
                 if (isset($this->attributes['value'])) {
                     $content = $literal ? $this->attributes['value'] : $this->get_attribute_output('value');
                 } elseif (is_array($this->_nodes) && !empty($this->_nodes)) {
                     foreach ($this->_nodes as $k => $node) {
                         $content .= $literal ? $this->_nodes[$k]->get_literal_output() : $this->_nodes[$k]->get_output();
                     }
                 }
                 if (isset($this->attributes['json']) && $this->attributes['json'] == 1) {
                     $content = json_decode($content, true);
                 }
                 if (isset($this->attributes['global']) && $this->attributes['global'] == 1) {
                     vivvo_lite_site::get_instance()->get_template()->assign($this->attributes['name'], $content);
                 } else {
                     $this->_template->assign($this->attributes['name'], $content);
                 }
             }
             return $output;
         case 'vte:header':
             $output = '';
             if (isset($this->attributes['type'])) {
                 $sm =& $this->_template->get_site_manager();
                 $header =& $sm->get_header_manager();
                 if ($this->attributes['type'] == 'script') {
                     if (isset($this->attributes['href'])) {
                         $header->add_script($this->get_attribute_output('href'));
                     }
                 } elseif ($this->attributes['type'] == 'css') {
                     if (isset($this->attributes['href'])) {
                         $media = 'screen';
                         if (isset($this->attributes['media'])) {
                             $media = $this->attributes['media'];
                         }
                         $header->add_css($this->get_attribute_output('href'), $media);
                     }
                 } elseif ($this->attributes['type'] == 'description') {
                     $header->add_description($this->get_attribute_output('value'));
                 } elseif ($this->attributes['type'] == 'keyword') {
                     $header->add_keyword($this->get_attribute_output('value'));
                 } elseif ($this->attributes['type'] == 'feed') {
                     if (isset($this->attributes['href'])) {
                         $title = '';
                         if (isset($this->attributes['title'])) {
                             $title = $this->get_attribute_output('title');
                         }
                         $header->add_rss($this->get_attribute_output('href'), $title);
                     }
                 }
             }
             return $output;
         case 'vte:lang':
             $output = '';
             if (isset($this->attributes['src']) && !empty($this->attributes['src'])) {
                 $sm =& $this->_template->get_site_manager();
                 $lang =& $sm->get_lang();
                 if (defined('VIVVO_ADMIN_LANG')) {
                     $lang->load_lang(VIVVO_ADMIN_LANG, $this->attributes['src']);
                 } else {
                     $lang->load_lang(VIVVO_DEFAULT_LANG, $this->attributes['src']);
                 }
             }
             return $output;
         case 'vte:include':
             $output = '';
             if (isset($this->attributes['file'])) {
                 $cache_output = '';
                 $href = $this->get_attribute_output('file');
                 if (isset($this->attributes['nocache']) && $this->attributes['nocache'] == 1) {
                     $cache_output = '<!--NoCache ' . substr($href, strlen(VIVVO_TEMPLATE_DIR)) . '-->';
                 }
                 if (is_file(VIVVO_FS_TEMPLATE_ROOT . $href)) {
                     $used_file = VIVVO_FS_TEMPLATE_ROOT . $href;
                     $output = file_get_contents(VIVVO_FS_TEMPLATE_ROOT . $href);
                 }
                 if (!isset($this->attributes['parse']) || $this->attributes['parse'] != 'off') {
                     $sm =& $this->_template->get_site_manager();
                     $tmp_tpl =& new template($sm, $this->_template);
                     if (isset($used_file)) {
                         $tmp_tpl->set_template_file($used_file);
                         $sm->debug_push("tpl:", $used_file);
                     }
                     $tmp_tpl->set_string_template($output);
                     if (!empty($this->attributes)) {
                         foreach ($this->attributes as $k => $v) {
                             if (preg_match('/^\\{[^\\}]*\\}$/', $v)) {
                                 $tmp_tpl->assign($k, $this->param_value($v));
                             } else {
                                 $tmp_tpl->assign($k, $this->get_attribute_output($k));
                             }
                         }
                     }
                     $output = $tmp_tpl->get_output();
                     $tmp_tpl->__destruct();
                 }
                 $cache_output .= $output;
                 if (isset($this->attributes['nocache']) && $this->attributes['nocache'] == 1) {
                     $cache_output .= '<!--NoCache-->';
                 }
                 $output = $cache_output;
             } elseif (isset($this->attributes['href'])) {
                 //include url
                 $output = @file_get_contents($this->attributes['href']);
             }
             return $output;
         case 'vte:param':
             return '';
         case 'vte:attribute':
             if (is_a($this->parent, 'xml_template_node')) {
                 $value = trim($this->nodes_output());
                 $name = $this->attributes['name'];
                 if (!empty($value) && !empty($name)) {
                     $this->parent->attributes[$name] = $value;
                 } else {
                     unset($this->parent->attributes[$name]);
                 }
             }
             return '';
         case 'vte:cdata':
             return '<![CDATA[' . $this->nodes_output() . ']]>';
         case 'vte:params':
             $params = array();
             if (is_array($this->_nodes) && !empty($this->_nodes)) {
                 foreach ($this->_nodes as $k => $v) {
                     if ($this->_nodes[$k]->_type == 'vte:param') {
                         if (preg_match('/^\\{[^\\}]*\\}$/', $this->_nodes[$k]->attributes['value'])) {
                             $params[$this->_nodes[$k]->attributes['name']] =& $this->param_value($this->_nodes[$k]->attributes['value']);
                         } else {
                             $params[$this->_nodes[$k]->attributes['name']] = $this->xmlentities_decode($this->_nodes[$k]->get_attribute_output('value'));
                         }
                     }
                 }
             }
             return $params;
         case 'vte:load':
             $module_name = $this->attributes['module'];
             if (isset($module_name) && trim($module_name) != '') {
                 $params = array();
                 if (isset($this->attributes['params'])) {
                     $params = $this->param_value($this->attributes['params']);
                 } elseif (!empty($this->attributes)) {
                     foreach ($this->attributes as $k => $v) {
                         if (preg_match('/^\\{[^\\}]*\\}$/', $v)) {
                             $params[$k] =& $this->param_value($v);
                         } else {
                             $params[$k] = $this->xmlentities_decode($this->get_attribute_output($k));
                         }
                     }
                 }
                 $site_manager =& $this->_template->get_site_manager();
                 return $site_manager->get_module_output($module_name, $params, $this->_template);
             }
             return '';
         case 'vte:box':
             $module_name = $this->attributes['module'];
             if (isset($module_name) && trim($module_name) != '') {
                 if (isset($this->attributes['params'])) {
                     $params = $this->param_value($this->attributes['params']);
                 }
                 $params_node = $this->get_child_by_tag('vte:params');
                 if (empty($params) || !is_array($params)) {
                     $params = array();
                 }
                 if ($params_node) {
                     $params = array_merge($params, $params_node->get_output());
                 }
                 $site_manager =& $this->_template->get_site_manager();
                 $template_node = $this->get_child_by_tag('vte:template');
                 if ($this->_type == 'vte:box' && $template_node) {
                     $params['template_string'] = $template_node->get_literal_output();
                 }
                 return $site_manager->get_module_output($module_name, $params, $this->_template);
             }
             return '';
         case 'vte:template':
             $output = '';
             if (!empty($this->attributes['template_string'])) {
                 $template = new template(null, $this);
                 $template->set_string_template($this->param_value($this->attributes['template_string']));
                 foreach ($this->attributes as $name => $value) {
                     $template->assign($name, $this->param_value($value));
                 }
                 $output = $template->get_output();
             } else {
                 if (!empty($this->attributes['recursive'])) {
                     $literal = '';
                     if (is_array($this->_nodes) && !empty($this->_nodes)) {
                         foreach ($this->_nodes as $k => $node) {
                             $literal .= $this->_nodes[$k]->get_literal_output();
                         }
                     }
                     $this->_template->assign('template_string', $literal);
                 }
                 if (is_array($this->_nodes)) {
                     foreach ($this->_nodes as $k => $node) {
                         $output .= $this->_nodes[$k]->get_output();
                     }
                 }
             }
             return $output;
         case 'vte:value':
             return $this->param_value($this->attributes['select']);
         default:
             return $this->get_output_default();
     }
 }
 function email_to_a_friend($article_id, $to, $bcc, $your_email, $message)
 {
     require_once VIVVO_FS_FRAMEWORK . 'PEAR/Mail.php';
     if (!vivvo_hooks_manager::call('article_mail', array(&$article_id, &$to, &$bcc, &$your_email, &$message))) {
         return vivvo_hooks_manager::get_status();
     }
     if (VIVVO_EMAIL_ENABLE == 1) {
         if (isset($_SESSION['vivvo']['email_to_friend_time']) && $_SESSION['vivvo']['email_to_friend_time'] + VIVVO_EMAIL_FLOOD_CHECK > VIVVO_START_TIME) {
             $this->set_error_code(2202);
             return false;
         }
         $article_list = new Articles_list();
         $article = $article_list->get_article_by_id($article_id);
         $lang = vivvo_lang::get_instance();
         if ($article !== false) {
             $to = strip_tags($to);
             $bcc = strip_tags($bcc);
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $your_email)) {
                 $this->set_error_code(2032);
                 return false;
             }
             if (!preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $bcc)) {
                 $bcc = '';
             }
             if (VIVVO_EMAIL_SEND_BCC) {
                 if ($bcc) {
                     $bcc .= ', ' . VIVVO_EMAIL_SEND_BCC;
                 } else {
                     $bcc = VIVVO_EMAIL_SEND_BCC;
                 }
             }
             if (VIVVO_EMAIL_SEND_CC) {
                 $headers['Cc'] = VIVVO_EMAIL_SEND_CC;
             }
             if (preg_match('/^[a-zA-Z0-9_\\-\\/\\.]+@[a-zA-Z0-9_\\-\\/]{2,}([\\.][a-zA-Z0-9_\\-\\/]{2,}){1,}$/', $to)) {
                 $body_template = new template();
                 $template_sting = xml_template_node::xmlentities_decode(VIVVO_EMAIL_TO_A_FRIEND_BODY);
                 $body_template->set_string_template($template_sting);
                 $body_template->assign('article', $article);
                 $body_template->assign('user_email_address', $your_email);
                 $body_template->assign('message', $message);
                 $body = $body_template->get_output() . "\n\n";
                 $headers['From'] = $your_email;
                 $recipients = array();
                 $recipients[] = $to;
                 if ($bcc != '') {
                     $headers['Bcc'] = $bcc;
                 }
                 $headers['Subject'] = "=?UTF-8?B?" . base64_encode(VIVVO_EMAIL_TO_A_FRIEND_SUBJECT) . "?=";
                 $headers['Content-Type'] = "text/plain; charset=UTF-8;";
                 if (VIVVO_EMAIL_SMTP_PHP == 1) {
                     $mail_object = new Mail();
                     $mail_object->send($to, $headers, $body);
                 } else {
                     $mail_options['driver'] = 'smtp';
                     $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                     $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                     $mail_options['localhost'] = 'localhost';
                     if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                         $mail_options['auth'] = true;
                         $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                         $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                     } else {
                         $mail_options['auth'] = false;
                         $mail_options['username'] = '';
                         $mail_options['password'] = '';
                     }
                     $mail_object = Mail::factory('smtp', $mail_options);
                     $mail_object->send($to, $headers, $body);
                 }
                 $article->set_emailed($article->emailed + 1);
                 $this->_post_master->set_data_object($article);
                 if ($this->_post_master->sql_update()) {
                     $_SESSION['vivvo']['email_to_friend_time'] = time();
                     return true;
                 } else {
                     $this->set_error_code(2033);
                     return false;
                 }
             } else {
                 $this->set_error_code(2034);
                 return false;
             }
         } else {
             $this->set_error_code(2035);
             return false;
         }
     }
 }
Beispiel #12
0
 /**
  * Generates box output
  *
  * @param	array	$params		Parameters passed from VTE
  */
 public function generate_output($params = array())
 {
     if (empty($params['name']) or empty(self::$hooks[$params['name']])) {
         return;
     }
     !empty($params['template_set']) or $params['template_set'] = self::$template_set;
     if (empty($params['template_string'])) {
         $filename = VIVVO_FS_TEMPLATE_ROOT . "templates/_system/hooks/{$params['template_set']}/{$params['name']}.xml";
         if (is_file($filename)) {
             $params['template_string'] = file_get_contents($filename);
         } else {
             return;
         }
     }
     if (!$this->_parent_template) {
         $this->_parent_template = vivvo_lite_site::get_instance()->get_template();
     }
     $output = '';
     foreach (self::$hooks[$params['name']] as &$hook) {
         $template = new template(vivvo_lite_site::get_instance(), $this->_parent_template);
         $template->set_string_template($params['template_string']);
         if (!empty($hook['handler'])) {
             if (!$hook['handler']['loaded']) {
                 if (is_file(VIVVO_FS_INSTALL_ROOT . $hook['handler']['file'])) {
                     include_once VIVVO_FS_INSTALL_ROOT . $hook['handler']['file'];
                 }
                 if (!empty($hook['handler']['class'])) {
                     if (class_exists($hook['handler']['class']) and in_array($hook['handler']['function'], get_class_methods($hook['handler']['class']))) {
                         $hook['handler']['function'] = array($hook['handler']['class'], $hook['handler']['function']);
                         $hook['handler']['loaded'] = true;
                     }
                 } else {
                     if (function_exists($hook['handler']['function'])) {
                         $hook['handler']['loaded'] = true;
                     }
                 }
             }
             if ($hook['handler']['loaded']) {
                 $ret = call_user_func_array($hook['handler']['function'], array($template, $params, &$hook, $hook['handler']['params']));
                 if ($ret !== true) {
                     $output .= $ret;
                     continue;
                 }
             }
         }
         if (!empty($hook['params'])) {
             if (!empty($hook['params']['lang_file'])) {
                 vivvo_lang::get_instance()->load_lang(defined('VIVVO_ADMIN_LANG') ? VIVVO_ADMIN_LANG : VIVVO_DEFAULT_LANG, $template->eval_string($hook['params']['lang_file']));
             }
             foreach ($hook['params'] as $name => $value) {
                 $value = $template->eval_string($value);
                 $template->assign($name, $value);
             }
             $output .= $template->get_output();
         }
     }
     unset($hook);
     $this->set_template(array('template_string' => '<vte:value select="{output}" />'));
     $this->_template->assign('output', $output);
 }
 function get_admin_content(&$sm)
 {
     $template =& $sm->get_template();
     $um =& $sm->get_url_manager();
     $pm =& $sm->get_plugin_manager();
     $content_template = new template($sm, $template);
     if ($um->get_param('search_id')) {
         $content_template->assign('search_id', $um->get_param('search_id'));
     }
     $content_template->set_template_file(VIVVO_FS_PLUGIN_ROOT . $pm->plugins['image_gallery']['root_dir'] . 'admin/templates/image_list.xml');
     echo $content_template->get_output();
 }
    function send_newsletter($newsletter_id)
    {
        $sm = vivvo_lite_site::get_instance();
        $db = $sm->get_db();
        if ($sm->user) {
            if ($sm->user->is_admin()) {
                $newsletter_list = new newsletter_list();
                $newsletter = $newsletter_list->get_newsletter_by_id($newsletter_id);
                if ($newsletter !== false) {
                    if ($newsletter->test == 1) {
                        $to = $newsletter->test_email;
                        if ($newsletter->vte_template == '1') {
                            $body_template = new template();
                            $template_sting = xml_template_node::xmlentities_decode($newsletter->body);
                            $body_template->set_string_template($template_sting);
                            $body = $body_template->get_output() . "\n\n";
                        } else {
                            $body = xml_template_node::xmlentities_decode($newsletter->body);
                        }
                        $unsubscribe_url = VIVVO_PROXY_URL . 'newsletter/index.html?&action=newsletter&cmd=subscriberUnSubscribe&dack=' . md5('test');
                        if (!preg_match('/^[^:]+:/', $unsubscribe_url)) {
                            $unsubscribe_url = VIVVO_URL . $unsubscribe_url;
                        }
                        $body = $body . "\n\n\n" . VIVVO_PLUGIN_NEWSLETTER_UNSUBSCRIBE_TEXT . "\n" . $unsubscribe_url;
                        $from = VIVVO_ADMINISTRATORS_EMAIL;
                        $search = array('(', ')', '<', '>', '@', ';', ':', '\\', '"', '.', '[', ']');
                        $replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
                        $from_name = str_replace($search, $replace, VIVVO_WEBSITE_TITLE);
                        $from_name = "=?UTF-8?B?" . base64_encode($from_name) . "?=";
                        $from_params = !empty($from_name) ? '"' . $from_name . '" <' . $from . '>' : '<' . $from . '>';
                        $headers['From'] = $from_params;
                        $recipients = array();
                        $recipients[] = $to;
                        $subject = "=?UTF-8?B?" . base64_encode($newsletter->subject) . "?=";
                        $headers['Subject'] = $subject;
                        $headers['Content-Type'] = "text/plain; charset=UTF-8;";
                        if (VIVVO_EMAIL_SMTP_PHP == 1) {
                            $mail_object = new Mail();
                            $mail_object->send($to, $headers, $body);
                        } else {
                            $mail_options['driver'] = 'smtp';
                            $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                            $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                            $mail_options['localhost'] = 'localhost';
                            if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                                $mail_options['auth'] = true;
                                $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                                $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                            } else {
                                $mail_options['auth'] = false;
                                $mail_options['username'] = '';
                                $mail_options['password'] = '';
                            }
                            $mail_object =& Mail::factory('smtp', $mail_options);
                            $mail_object->send($to, $headers, $body);
                        }
                    } else {
                        $container_options = array('type' => 'mdb2', 'dsn' => VIVVO_DB_TYPE . '://' . VIVVO_DB_USER . ':' . VIVVO_DB_PASSWORD . '@' . VIVVO_DB_HOST . '/' . VIVVO_DB_DATABASE, 'mail_table' => VIVVO_DB_PREFIX . 'mail_queue');
                        $mail_options['driver'] = 'smtp';
                        $mail_options['host'] = VIVVO_EMAIL_SMTP_HOST;
                        $mail_options['port'] = VIVVO_EMAIL_SMTP_PORT;
                        $mail_options['localhost'] = 'localhost';
                        if (VIVVO_EMAIL_SMTP_PASSWORD != '' && VIVVO_EMAIL_SMTP_USERNAME != '') {
                            $mail_options['auth'] = true;
                            $mail_options['username'] = VIVVO_EMAIL_SMTP_USERNAME;
                            $mail_options['password'] = VIVVO_EMAIL_SMTP_PASSWORD;
                        } else {
                            $mail_options['auth'] = false;
                            $mail_options['username'] = '';
                            $mail_options['password'] = '';
                        }
                        $mail_queue = new Mail_Queue($container_options, $mail_options);
                        $from = VIVVO_ADMINISTRATORS_EMAIL;
                        $search = array('(', ')', '<', '>', '@', ';', ':', '\\', '"', '.', '[', ']');
                        $replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ');
                        $from_name = str_replace($search, $replace, VIVVO_WEBSITE_TITLE);
                        $from_name = "=?UTF-8?B?" . base64_encode($from_name) . "?=";
                        $from_params = !empty($from_name) ? '"' . $from_name . '" <' . $from . '>' : '<' . $from . '>';
                        if ($newsletter->vte_template == '1') {
                            $body_template = new template();
                            $template_sting = xml_template_node::xmlentities_decode($newsletter->body);
                            $body_template->set_string_template($template_sting);
                            $body = $body_template->get_output() . "\n\n";
                        } else {
                            $body = xml_template_node::xmlentities_decode($newsletter->body);
                        }
                        $groups = explode(',', $newsletter->groups);
                        foreach ($groups as $key) {
                            if ($key == -1) {
                                $res =& $db->query('SELECT email, ip, time FROM ' . VIVVO_DB_PREFIX . 'maillist WHERE `confirm` = \'1\'');
                                if (!is_a($res, 'mdb2_error')) {
                                    while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
                                        $subject = "=?UTF-8?B?" . base64_encode($newsletter->subject) . "?=";
                                        $recipient = $row['email'];
                                        $hdrs = array('From' => $from_params, 'To' => $recipient, 'Subject' => $subject, 'Content-Type' => "text/plain; charset=UTF-8;");
                                        $body_all = $body . "\n\n\n" . VIVVO_PLUGIN_NEWSLETTER_UNSUBSCRIBE_TEXT . "\n" . VIVVO_URL . 'newsletter/index.html?action=newsletter&cmd=subscriberUnSubscribe&dack=' . md5($row['ip'] . $row['time'] . $row['email']);
                                        $mail_queue->put($from, $recipient, $hdrs, $body_all);
                                    }
                                }
                            } elseif ($key >= 0) {
                                $res = $db->query('SELECT email_address, userid, created FROM ' . VIVVO_DB_PREFIX . 'users as u
														INNER JOIN ' . VIVVO_DB_PREFIX . 'group_user  as gu
														ON gu.user_id=u.userid
														WHERE gu.group_id = \'' . $key . '\' and `subscriber` = \'1\'');
                                if (!is_a($res, 'mdb2_error')) {
                                    while ($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
                                        $recipient = $row['email_address'];
                                        $subject = "=?UTF-8?B?" . base64_encode($newsletter->subject) . "?=";
                                        $hdrs = array('From' => $from_params, 'To' => $recipient, 'Subject' => $subject, 'Content-Type' => "text/plain; charset=UTF-8;");
                                        $unsubscribe_url = VIVVO_PROXY_URL . 'newsletter/index.html?action=newsletter&cmd=userUnSubscribe&dack=' . md5($row['email_address'] . $row['userid'] . $row['created']);
                                        if (!preg_match('/^[^:]+:/', $unsubscribe_url)) {
                                            $unsubscribe_url = VIVVO_URL . $unsubscribe_url;
                                        }
                                        $body_all = $body . "\n\n\n" . VIVVO_PLUGIN_NEWSLETTER_UNSUBSCRIBE_TEXT . "\n" . $unsubscribe_url;
                                        $mail_queue->put($from, $recipient, $hdrs, $body_all);
                                    }
                                }
                            }
                        }
                    }
                    return true;
                } else {
                    $this->set_error_code(10225);
                    return false;
                }
            } else {
                $this->set_error_code(10226);
                return false;
            }
        } else {
            $this->set_error_code(10227);
            return false;
        }
    }
Beispiel #15
0
 /**
  * Uninstall Plugin
  *
  * @param vivvo_site 	$site_manager
  * @param integer		$step
  */
 function uninstall(&$site_manager, $step = 1)
 {
     $template = $site_manager->get_template();
     $template->assign('PLUGIN_ROOT', $this->get_root_dir());
     $template->assign('PLUG_IN_HREF', $this->plugin_name);
     $content_template = new template(null, $template);
     if ($step == 2) {
         $content_template->set_template_file(VIVVO_FS_INSTALL_ROOT . VIVVO_FS_ADMIN_DIR . 'templates/plugins/uninstall/step_2.xml');
     } else {
         $content_template->set_template_file(VIVVO_FS_INSTALL_ROOT . VIVVO_FS_ADMIN_DIR . 'templates/plugins/uninstall/step_1.xml');
     }
     $template->assign('content', $content_template->get_output());
     $template->assign('step', strval($step));
     $search_template = new template(null, $template);
     $search_template->set_template_file(VIVVO_FS_INSTALL_ROOT . VIVVO_FS_ADMIN_DIR . 'templates/plugins/uninstall/tabs.xml');
     $template->assign('left', $search_template->get_output());
 }