Beispiel #1
0
 function show_from_folder($params)
 {
     global $TMS, $HTTP_HOST, $REQUEST_VARS, $_WEBPATH;
     $TMS->AddFileSection(Common::get_fmodule_tpl_path('gallery', $params['Template']));
     $TMS->AddReplace('_show_from_folder', 'image_folder', $params["ImageFolder"]);
     $TMS->AddReplace('_show_from_folder', 'rows', $params["rows"]);
     return $TMS->parseSection('_show_from_folder');
 }
Beispiel #2
0
 function complete_unsubscribe($params)
 {
     global $TDB, $TMS, $REQUEST_ASSOC;
     $sub_id = (int) $REQUEST_ASSOC['id'];
     $code = substr($REQUEST_ASSOC['code'], 0, 32);
     if ($REQUEST_ASSOC['code'] && $sub_id) {
         $query = sprintf("SELECT id, email FROM subscribers_list WHERE code='%s'", mysql_real_escape_string($code));
         if ($user = $TDB->get_results($query)) {
             $user_id = $user[1]['id'];
             $query = 'DELETE FROM subscribers_params WHERE user_id = ' . $user_id . ' AND subscribe_id = ' . $sub_id;
             $TDB->get_results($query);
             $query = 'DELETE FROM subscribers_list WHERE id = ' . $user_id;
             $TDB->get_results($query);
             $subscr = $this->_tree->getNodeParam($sub_id);
             $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['aTemplate']));
             $TMS->AddMassReplace('unsubscribe_completed', array('email' => $user[1]['email'], 'subscribe' => $subscr['basic']));
             return $TMS->parseSection('unsubscribe_completed');
         }
     }
 }
Beispiel #3
0
 function show_faq_search_server($params)
 {
     global $TDB, $TMS, $TPA, $REQUEST_ASSOC;
     Common::call_common_instance('pages');
     $pages =& pages_module_common::getInstance();
     $TMS->AddFileSection(Common::get_fmodule_tpl_path('faq', $params["MTemplate"]));
     if (isset($REQUEST_ASSOC['sl'])) {
         $request = $_SESSION["faq"]["last_search"];
     } else {
         $request = urldecode($_POST["faqsearch"]);
     }
     if (!$request) {
         return $TMS->parseSection('_no_request');
     }
     $_SESSION["faq"]["last_search"] = $request;
     $words = explode(' ', $request);
     $OM = array();
     $sfields = array('question', 'answer', 'sanswer');
     $first = true;
     foreach ($words as $word) {
         $value = trim(mysql_real_escape_string($word));
         $cond = array();
         foreach ($sfields as $sfield) {
             $cond[] = " `" . $sfield . "` LIKE '%" . $value . "%' ";
         }
         $query = "SELECT `id` FROM `faq` WHERE (" . implode('OR', $cond) . ") AND `active`=1;";
         $r = $TDB->get_results($query, 'ARRAY_N');
         if (!count($r)) {
             $TMS->AddReplace('_no_results', 'request', $request);
             return $TMS->parseSection('_no_results');
         }
         $Mas = array();
         foreach ($r as $v) {
             $Mas[] = $v[0];
         }
         if ($first) {
             $OM = $Mas;
         } else {
             $OM = array_intersect($OM, $Mas);
         }
         if (!count($OM)) {
             $TMS->AddReplace('_no_results', 'request', $request);
             return $TMS->parseSection('_no_results');
         }
         $first = false;
     }
     $sl = $REQUEST_ASSOC['sl'] ? (int) $REQUEST_ASSOC['sl'] : 0;
     $dst = $pages->create_page_path($params["MDestination_page"]);
     $total = count($OM);
     if ($params["OnPage"] < $total && $params["OnPage"]) {
         $OM = array_slice($OM, $sl, $params["OnPage"]);
         Common::parse_nav_pages($total, $params["OnPage"], $sl, $TPA->page_link . '/~faqsearch');
     }
     $query = "SELECT * FROM `faq` WHERE `id` in ('" . implode("', '", $OM) . "');";
     $questions = $TDB->get_results($query);
     foreach ($questions as $question) {
         $question["timestamp"] = strtotime($question["date"]);
         $question["Link"] = $dst . "/~show_question/qid/" . $question["id"];
         $question["Destination"] = $dst;
         $TMS->AddMassReplace('_search_list_item', $question);
         $TMS->parseSection('_search_list_item', true);
     }
     $TMS->AddMassReplace('_faq_search_results', array("total" => $total, "Destination" => $dst));
     return $TMS->parseSection('_faq_search_results');
 }
Beispiel #4
0
 function construct_message($form_id, $tpl, $data = array())
 {
     global $TMS, $TDB;
     if (empty($data) && !empty($_POST)) {
         $data = $_POST;
     }
     $TMS->AddFileSection(Common::get_fmodule_tpl_path('forms', $tpl));
     $form = $this->_tree->getNodeInfo($form_id);
     $fields = $this->_tree->GetChildsParam($form_id, '%', true, array('obj_type' => array('_FIELDS')));
     foreach ($fields as $id => $field) {
         switch ($field['params']['field_type']) {
             case 'flag':
                 $value = $data[$field['params']['identifier']] || $data['field_' . $form_id . $id] ? 'Yes' : 'No';
                 break;
             default:
                 $value = $field['params']['identifier'] ? $data[$field['params']['identifier']] : $data['field_' . $form_id . $id];
                 break;
         }
         if (is_array($value)) {
             $value = implode('<br />', $value);
         }
         $TMS->AddMassReplace('row', array('name' => $field['params']['Name'], 'value' => $value));
         $TMS->parseSection('row', true);
     }
     $TMS->AddMassReplace('message', $form['params']);
     $TMS->AddMassReplace('saved_message', $form['params']);
     $message['to_email'] = XHTML::xss_clean($TMS->parseSection('message'));
     //htmlentities();
     $message['to_save'] = XHTML::xss_clean($TMS->parseSection('saved_message'));
     return $message;
 }
Beispiel #5
0
 function showUserMenu($params)
 {
     //global $this->_TMS, $TDB, $TPA;
     $menu = $TDB->get_results('select pages, header from user_menu where id=' . $params['menu']);
     $pages = $menu[1]['pages'];
     $pages1 = explode(',', $pages);
     $w = array();
     $x = array_keys($pages1);
     $items = $this->_tree->GetNodesByIdArray($pages1);
     $cur_page_id = $TPA->page_node['id'];
     $cur_page_basic = $TPA->page_node['basic'];
     foreach ($x as $x1) {
         $w[$pages1[$x1]] = $x1;
     }
     foreach ($items as $i) {
         $key = $w[$i['id']];
         $arr[$key] = array('id' => $i['id'], 'text' => $i['params']['Name'], 'obj_type' => $i['obj_type'], 'Icon' => $i["params"]["Icon"], 'basic' => $i["basic"], 'Comment' => $i["params"]["Comment"], 'StartPage' => $i["params"]["StartPage"]);
     }
     ksort($arr);
     Common::call_common_instance('pages');
     $pages =& pages_module_common::getInstance();
     $this->_TMS->AddFileSection(Common::get_fmodule_tpl_path('menu', $params['Template']));
     $i = 0;
     $umenu = '';
     foreach ($arr as $p) {
         if ($p['obj_type'] != '_LINK') {
             $alink = $pages->create_page_path($p['id']);
         } else {
             $alink = $items[$p['id']]['params']['Link'];
         }
         $selected = '';
         if ($p["id"] == $TPA->page_node["id"] || $p['obj_type'] == '_GROUP' && $TPA->page_node['id'] == $p['StartPage']) {
             $selected = 'selected_';
         }
         $r = array('link' => $alink, 'basic' => $p["basic"], 'caption' => $p['text'], '_num' => $i, 'oddeven' => $i % 2, 'Icon' => $p['Icon'], 'Comment' => $p['Comment']);
         if ($i == 0 && $this->_TMS->isSectionDefined('_menu_item_first_' . $selected . 'level0')) {
             $this->_TMS->AddMassReplace('_menu_item_first_' . $selected . 'level0', $r);
             $umenu .= $this->_TMS->parseSection('_menu_item_first_' . $selected . 'level0');
         } elseif ($i == sizeof($arr) - 1 && $this->_TMS->isSectionDefined('_menu_item_last_' . $selected . 'level0')) {
             $this->_TMS->AddMassReplace('_menu_item_last_' . $selected . 'level0', $r);
             $umenu .= $this->_TMS->parseSection('_menu_item_last_' . $selected . 'level0');
         } else {
             $this->_TMS->AddMassReplace('_menu_item_middle_' . $selected . 'level0', $r);
             $umenu .= $this->_TMS->parseSection('_menu_item_middle_' . $selected . 'level0');
         }
         $i++;
     }
     $this->_TMS->AddReplace('_menu_main_level0', 'menu_buff', $umenu);
     $this->_TMS->AddReplace('_menu_main_level0', 'header', $menu[1]['header']);
     $menu = $this->_TMS->parseSection('_menu_main_level0');
     return $menu;
 }
Beispiel #6
0
 function parseMessageFields($sub_params, $cat_params)
 {
     global $TDB, $TMS, $_COMMON_SITE_CONF;
     $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $cat_params['Template']));
     $msg_type = 'text';
     if ($cat_params['html']) {
         $fields['content-type'] = 'text/html';
         $msg_type = 'html';
     } else {
         $fields['content-type'] = 'text/plain';
     }
     $fields['encoding'] = $_COMMON_SITE_CONF['site_encoding'];
     Common::call_common_instance('pages');
     $pages =& pages_module_common::getInstance();
     $news_page = $pages->create_page_path($cat_params['news_page']);
     if ($sub_params['news']) {
         $query = 'SELECT * FROM news WHERE id IN(' . $sub_params['news'] . ')';
         $news = $TDB->get_results($query);
         foreach ($news as $n) {
             $n['link'] = $news_page . '/~shownews/' . $n['id'];
             $TMS->AddMassReplace('news_item', $n);
             $TMS->parseSection('news_item', true);
         }
         $TMS->parseSection('news');
     }
     $TMS->AddMassReplace($msg_type . '_message', array_merge($cat_params, $sub_params));
     $fields['message'] = $TMS->parseSection($msg_type . '_message');
     $fields['files'] = array();
     if ($files = explode(',', $sub_params['files'])) {
         if (is_array($files)) {
             foreach ($files as $f) {
                 $info = pathinfo($f, PATHINFO_EXTENSION);
                 $fields['files'][] = DOCUMENT_ROOT . $f;
             }
         }
     }
     return $fields;
 }
Beispiel #7
0
 function save_edited_question($params)
 {
     global $_COMMON_SITE_CONF, $TMS;
     if ($params) {
         global $TDB;
         $q = "UPDATE `faq` SET `cat_id` = '" . (int) $params['category'] . "'" . ",`question` = '" . mysql_real_escape_string($params['question']) . "'" . ",`date` = '" . mysql_real_escape_string($params['date']) . "'" . ",`sanswer` = '" . mysql_real_escape_string($params['sanswer']) . "'" . ",`answer`  = '" . mysql_real_escape_string($params['answer']) . "'" . ",`user`    = '" . mysql_real_escape_string($params['user']) . "'" . ",`email`   = '" . mysql_real_escape_string($params['email']) . "'" . ",`active`  =  '" . (int) $params['active'] . "'" . ' WHERE id = ' . (int) $params['id'];
         $TDB->get_results($q);
         $this->result['is_saved'] = $TDB->result;
         $cat = $this->_tree->getNodeParam($params['category']);
         $answer = $params['answer'];
         if ($params["lTemplate"] && $params["send_answer"]) {
             $TMS->AddFileSection(Common::get_fmodule_tpl_path('faq', $params["lTemplate"]));
             $TMS->AddMassReplace('letter', $params);
             $TMS->AddMassReplace('letter', array('server' => $_SERVER['HTTP_HOST']));
             $TMS->AddReplace('letter', 'category_name', $cat["Name"]);
             $TMS->AddReplace('letter_subject', 'category_name', $cat["Name"]);
             $m = Common::inc_module_factory('Mail');
             $m->To($params['email']);
             if ($cat["email"]) {
                 $m->From($cat["email"]);
             }
             $m->Subject($TMS->parseSection('letter_subject'));
             $m->Content_type('text/html');
             $m->Body($TMS->parseSection('letter'), $_COMMON_SITE_CONF['site_encoding']);
             $this->result['emailed'] = $m->Send();
         } else {
             $this->result['emailed'] = false;
         }
         $this->reinit_formsgroup($params['category']);
     }
 }
Beispiel #8
0
 function download($params)
 {
     global $TMS, $TPA, $REQUEST_ASSOC, $HTTP_SERVER_VARS;
     $link = isset($REQUEST_ASSOC['link']) ? $REQUEST_ASSOC['link'] : 0;
     switch ($params["Action"]) {
         case 'show_folder':
             $filesnames = XFILES::files_list(substr($params["Folder"], 1), 'files', $extensions, 0, true);
             $pos = -1;
             for ($i = 0; $i < count($filesnames); $i++) {
                 if ($link == md5(strrev($params["Folder"] . $filesnames[$i]))) {
                     $pos = $i;
                     break;
                 }
             }
             if ($pos != -1) {
                 $file = substr($params["Folder"], 1) . $filesnames[$pos];
                 if (!$this->send_file($file)) {
                     $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                     return $TMS->parseSection('_file_not_found');
                 }
             }
             break;
         default:
             $found = $this->hashfile_search($params['category'], $link);
             if ($found === false) {
                 //$found = $this->hashfile_recursive_search($params['category'], $link);
                 /* медленный вариант поиска, если hash не был вычислен при добавлении (для совместимости со старыми версиями модуля), перебирает всех элементы и проверяет по имени файла */
                 //if ($found === false)
                 $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                 return $TMS->parseSection('_file_not_found');
             }
             if (!$this->send_file($found)) {
                 $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
                 return $TMS->parseSection('_file_not_found');
             }
             break;
     }
 }
Beispiel #9
0
 function showvresult($params, $info = null)
 {
     global $TMS, $TDB, $REQUEST_ASSOC;
     $TMS->AddFileSection(Common::get_fmodule_tpl_path('votes', $params['Template']));
     if ($params['id'] > 0) {
         $id = $params['id'];
     } else {
         $id = abs((int) $REQUEST_ASSOC['id']);
     }
     if ($id) {
         if (!($a = $this->_tree->getNodeInfo($id))) {
             return '';
         }
         if ($info) {
             $TMS->parseSection($info);
         }
         $this->generate_results_stats($REQUEST_ASSOC['id']);
         $TMS->AddMassReplace('results', $a);
         $TMS->AddMassReplace('results', $a['params']);
         $results = $TMS->parseSection('results');
     }
     return $results;
 }
Beispiel #10
0
 function add_question_async($params)
 {
     global $TDB, $TMS, $TPA, $_COMMON_SITE_CONF;
     $fdata = $params["fdata"];
     if ($_SESSION['captcha'][(int) $fdata["category"]] == $fdata['captcha'] || $_SESSION['captcha'][(int) $fdata["captcha_id"]] == $fdata['captcha']) {
         unset($_SESSION['captcha'][(int) $fdata["category"]]);
         unset($_SESSION['captcha'][(int) $fdata["captcha_id"]]);
     } else {
         $this->result["send"] = false;
         $this->result["error"] = "captcha";
         return false;
     }
     $cat_id = (int) $fdata['category'];
     $cat = $this->_tree->getNodeInfo($cat_id);
     if (!$cat_id || !$cat) {
         $this->result["send"] = false;
         $this->result["error"] = "category";
         return;
     }
     if ($fdata["letter_template"] && file_exists(Common::get_fmodule_tpl_path('faq', $fdata["letter_template"] . '.html'))) {
         $TMS->AddFileSection(Common::get_fmodule_tpl_path('faq', $fdata["letter_template"] . '.html'));
     } else {
         $TMS->AddFileSection(Common::get_fmodule_tpl_path('faq', 'letter.html'));
     }
     $blocks = explode("\n", $fdata['question']);
     $question = '';
     if (count($blocks)) {
         foreach ($blocks as $block) {
             $question .= '<p>' . mysql_real_escape_string($block) . '</p>';
         }
     } else {
         $question = mysql_real_escape_string($fdata['question']);
     }
     $cat["params"]["moderation"] ? $active = 2 : ($active = 1);
     $fields = array("active" => $active, "date" => "'" . date('Y-m-d  G:i:s') . "'", "user" => "'" . mysql_real_escape_string($fdata["user"]) . "'", "email" => "'" . mysql_real_escape_string($fdata["email"]) . "'", "question" => "'" . $question . "'", "sanswer" => "''", "answer" => "''");
     $query = 'INSERT INTO `faq` (cat_id,`' . implode('`,`', array_keys($fields)) . '`) VALUES(' . $cat_id . ', ' . implode(',', array_values($fields)) . ');';
     if ($TDB->query($query)) {
         if ($cat['params']['email'] != '') {
             $TMS->AddMassReplace('letter', $fdata);
             $TMS->AddReplace('letter', "category_name", $cat["params"]["Name"]);
             $TMS->AddReplace('letter_subject', 'category_name', $cat['params']['Name']);
             $m = Common::inc_module_factory('Mail');
             $m->To($cat['params']['email']);
             $m->From($_COMMON_SITE_CONF['admin_email']);
             $m->Subject($TMS->parseSection('letter_subject'));
             $m->Content_type('text/html');
             $m->Body($TMS->parseSection('letter'), $_COMMON_SITE_CONF['site_encoding']);
             $m->Send();
         }
         if (!$cat["params"]["moderation"]) {
             $query = "SELECT count(*) as xcount FROM `faq` WHERE `cat_id` = " . $cat["id"] . " AND `active` = 1;";
             $r = $TDB->get_results($query);
             $cat["params"]["count"] = $r[1]["xcount"];
             $this->_tree->ReInitTreeOBJ($cat["id"], '%SAME%', $cat["params"]);
         }
         $this->result["send"] = true;
     } else {
         $this->result["send"] = false;
         $this->result["error"] = "insert";
     }
 }
Beispiel #11
0
 function show_level_catmenu($params)
 {
     global $TMS;
     $this->_tree->EXPcache = null;
     $this->_tree->FullBonesMas = null;
     $this->prev_start_node = null;
     $TMS->AddFileSection(Common::get_fmodule_tpl_path($this->_module_name, $params['Template']));
     Common::call_common_instance('pages');
     $pages =& pages_module_common::getInstance();
     $link = $pages->create_page_path($params['Destination_page']);
     if ($d = $pages->get_module_by_action($params['Destination_page'], 'show_catalog_server')) {
         $anc = $d['params']['showBasicPointId'];
     }
     if ($params['Cat_destination_page']) {
         $this->cat_destination_page = $pages->create_page_path($params['Cat_destination_page']);
     }
     if ($params['ObjectInRows']) {
         $this->devide_by_rows = (int) $params['ObjectInRows'];
     }
     $this->menu_ancestor = $this->_tree->getNodeInfo($params['showGroupId']);
     $obj_sel_arr[] = '_CATGROUP';
     if ($params['GetCatObj']) {
         $obj_sel_arr[] = '_CATOBJ';
     }
     $this->_sel_arr = $select_obj_type['obj_type'] = $obj_sel_arr;
     $mark = Common::createMark(array($params['showGroupId'], 0, $select_obj_type, 'ASC', $obj_sel_arr, $params['Levels']));
     $this->_tree->recursiveChildCollectFast($params['showGroupId'], $select_obj_type['obj_type'], 'ASC', $stop_level);
     if (!($this->_tree->EXPcache = Common::cacheSerializeRead('pages', $mark))) {
         $this->_tree->recursiveChildCollect2($params['showGroupId'], 0, $select_obj_type, 'ASC', $obj_sel_arr, $params['Levels']);
         Common::cacheSerialize($this->_tree->EXPcache, 'pages', $mark);
     }
     $pages =& pages_module_common::getInstance();
     $menu =& $this->render_multi_level_menu($this->_tree->EXPcache, $params['showGroupId'], $link, 0, $anc);
     $this->devide_by_rows = 0;
     if ($this->_tree->EXPcache) {
         $this->menu_builds_from = array_shift(array_shift($this->_tree->EXPcache));
     }
     return $menu;
 }