Beispiel #1
0
 function incroute($data)
 {
     if (is_array($data)) {
         foreach ($data as $modulename => $route_function) {
             //wake up module
             if ($module = Common::inc_module_factory($modulename)) {
                 //execute + result context
                 $module->executex($route_function, $this);
             }
         }
     }
 }
Beispiel #2
0
 function send_link($params)
 {
     global $_COMMON_SITE_CONF;
     $m = Common::inc_module_factory('Mail');
     $m->From($_COMMON_SITE_CONF['admin_email']);
     $m->To($params['email']);
     $m->Content_type('text/html');
     $m->Subject('ссылка с сайта ' . HOST . ' от ' . $_SESSION['siteuser']['userdata']['Name']);
     $m->Body('Ђ«дравствуйте, ваш коллега ' . $_SESSION['siteuser']['userdata']['Name'] . ' из компании ' . $_SESSION['siteuser']['userdata']['Company'] . ' просматрива¤ ассортимент бизнес-сувениров на сайте <a href="upress.by">upress.by</a>  решил рекомендовать вам следующий товар: 
                     <a href=' . $params['href'] . '>' . $params['href'] . '</a>', 'windows-1251');
     $m->Priority(1);
     $m->Send();
     $this->result['ok'] = true;
 }
Beispiel #3
0
 function list_recycled($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_RECYCLEOBJ');
     $options['columnsAsParameters'] = array('name' => 'Name', 'createTime' => 'createTime', 'module' => 'module');
     $options['filter']['createTime'] = array('name' => 'fromtimestamp', 'format' => 'd-m-y H:i:s');
     $options['preventDots'] = true;
     $options['columnsAsStructs'] = array('id' => 'id');
     $options['sequence'] = array('id', 'name', 'createTime', 'module');
     $options['gridFormat'] = 1;
     $TD->init_from_source($this->_tree);
     $TD->setOptions($options);
     $TD->CreateView(1);
     $this->result['data_set'] = $TD->result['data_set'];
 }
Beispiel #4
0
 function rss()
 {
     global $REQUEST_ASSOC, $TPA;
     if ($node = $this->_tree->getNodeInfo($REQUEST_ASSOC['id'])) {
         Common::inc_module_factory('feedWriter', true);
         //Creating an instance of FeedWriter class.
         //The constant RSS2 is passed to mention the version
         $feed = new FeedWriter();
         //Setting the channel elements
         //Use wrapper functions for common channel elements
         $feed->setTitle(CHOST . ' - ' . $node['basic']);
         $feed->setLink(CHOST);
         $feed->setDescription(CHOST);
         //Image title and link must match with the 'title' and 'link' channel elements for RSS 2.0
         //$TestFeed->setImage('Testing the RSS writer class','http://www.ajaxray.com/projects/rss','http://www.rightbrainsolution.com/images/logo.gif');
         //Use core setChannelElement() function for other optional channels
         $node['params']['lang'] = 'ru';
         $feed->setChannelElement('language', $node['params']['lang']);
         if ($interval = $this->_common_obj->select_news_interval($node_id, 0, 10, '', '', false, $active = 1)) {
             foreach ($interval as $news) {
                 //Create an empty FeedItem
                 $newItem = $feed->createNewItem();
                 //Add elements to the feed item
                 //Use wrapper functions to add common feed elements
                 $newItem->setTitle($news['header']);
                 $newItem->setLink($TPA->page_link . '/~shownews/' . $news['id']);
                 //The parameter is a timestamp for setDate() function
                 $date = strtotime($news['sortdate']);
                 $newItem->setDate($date);
                 $newItem->setDescription($news['news_short']);
                 $newItem->addElement('author', '*****@*****.**');
                 //Attributes have to passed as array in 3rd parameter
                 $newItem->addElement('guid', 'http://www.ajaxray.com', array('isPermaLink' => 'true'));
                 //Now add the feed item
                 $feed->addItem($newItem);
             }
             $feed->genarateFeed();
             die;
         }
     }
 }
Beispiel #5
0
 function add_question($params)
 {
     global $TDB, $TMS, $TPA, $_COMMON_SITE_CONF;
     if ($_SESSION['captcha'][intval($_POST["category"])] == $_POST['captcha']) {
         unset($_SESSION['captcha'][(int) $_POST["category"]]);
     } else {
         return $TMS->parseSection('error');
     }
     $TMS->AddFileSection(Common::get_fmodule_tpl_path('faq', $params['cTemplate']));
     $cat_id = (int) $_POST['category'];
     $cat = $this->_tree->getNodeInfo($cat_id);
     $cat["params"]["moderation"] ? $active = 2 : ($active = 1);
     $fields = array("active" => $active, "date" => "'" . date('Y-m-d  G:i:s') . "'", "user" => "'" . mysql_real_escape_string($_POST["user"]) . "'", "email" => "'" . mysql_real_escape_string($_POST["email"]) . "'", "question" => "'" . mysql_real_escape_string($_POST["question"]) . "'", "sanswer" => "''", "answer" => "''");
     $HL = array_keys($fields);
     $query = 'INSERT INTO `faq` (cat_id,' . implode(',', $HL) . ') VALUES(' . $cat_id . ', ' . implode(',', array_values($fields)) . ');';
     if ($TDB->query($query)) {
         if ($cat['params']['email'] != '') {
             $TMS->AddMassReplace('letter', $fields);
             $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"]);
         }
         $TMS->AddReplace('success', 'backlink', $TPA->page_link);
         return $TMS->parseSection('success');
     } else {
         return $TMS->parseSection('error');
     }
 }
Beispiel #6
0
 function start_subscribe($params)
 {
     global $TDB, $TMS, $_CONFIG;
     if ($params['first']) {
         unset($_SESSION['emails'], $_SESSION['slist'], $_SESSION['sended'], $_SESSION['total'], $_SESSION['subcur']);
     }
     if (!isset($_SESSION['slist']) && !isset($_SESSION['emails'])) {
         if ($subs = $TDB->get_results("SELECT * FROM subscribe WHERE status = 'incoming' ORDER BY cat_id, id")) {
             $i = 0;
             $ucount = 0;
             $scount = count($subs);
             // сохраняем список рассылки сессию
             foreach ($subs as $sub) {
                 $_SESSION['slist'][$i] = $sub;
                 $users = $TDB->get_results('
                         SELECT subscribers_params.user_id AS user_id, subscribers_list.email AS email
                         FROM subscribers_params
                         LEFT JOIN subscribers_list ON subscribers_params.user_id = subscribers_list.id
                         WHERE subscribers_params.subscribe_id = ' . $sub['cat_id'] . ' AND subscribers_list.status = \'active\'
                 ');
                 $ucount += count($users);
                 $_SESSION['emails'][$i] = array_values($users);
                 $i++;
             }
             $_SESSION['sended'] = 0;
             $_SESSION['total'] = $ucount;
         } else {
             // рассылок, ожидающих отправки нет
             $this->result['ready'] = false;
             $this->result['error'] = true;
             return $this->result;
         }
         // возвращаем для повторного входа
         $this->result['ready'] = true;
         $this->result['error'] = false;
         $this->result['scount'] = $scount;
         $this->result['ucount'] = $ucount;
         return $this->result;
     }
     if (isset($_SESSION['emails']) && is_array($_SESSION['emails']) && isset($_SESSION['slist']) && is_array($_SESSION['slist'])) {
         $list = $_SESSION['slist'];
         $arr = $_SESSION['emails'];
         $last_sub = end(array_keys($list));
         reset($list);
         reset($arr);
         $sended = array();
         while (list($key, $item) = each($list)) {
             if (isset($arr[$key])) {
                 $cat_params = $this->_tree->getNodeParam($item['cat_id']);
                 $fields = $this->parseMessageFields($item, $cat_params);
                 $theme = $cat_params['theme'];
                 if (!empty($item['theme'])) {
                     $theme = $item['theme'];
                 }
                 $theme = XCODE::win2utf($theme);
                 $m = Common::inc_module_factory('Mail');
                 $m->From($cat_params['from']);
                 $m->Subject($theme);
                 $m->Content_type($fields['content-type']);
                 $m->Body($fields['message'], $fields['encoding']);
                 if (!empty($item['files'])) {
                     if (is_string($item['files'])) {
                         $item['files'] = split(',', $item['files']);
                     }
                     if (is_array($item['files'])) {
                         foreach ($item['files'] as $f) {
                             $type = pathinfo($f, PATHINFO_EXTENSION);
                             $f = DOCUMENT_ROOT . $f;
                             if (isset($this->mtype[$type])) {
                                 $m->Attach($f, $this->mtype[$type]);
                             } else {
                                 $m->Attach($f);
                             }
                         }
                     }
                 }
                 $start = Common::getmicrotime();
                 $last_key = end(array_keys($arr[$key]));
                 foreach ($arr[$key] as $k => $i) {
                     $m->sendto = array();
                     $m->To($i['email']);
                     if ($m->Send()) {
                         $sended = array_shift($_SESSION['emails'][$key]);
                         $_SESSION['sended']++;
                         if ($last_key == $k) {
                             // если последний адрес
                             $this->markSent($item['cat_id']);
                             //                                array_shift($_SESSION['slist'][$key]);
                             unset($_SESSION['slist'][$key]);
                         }
                         if (Common::getmicrotime() - $start > $_CONFIG['subscribe']['update_interval']) {
                             $this->result['next'] = true;
                             $this->result['sub'] = $item;
                             // инфо о рассылке
                             $this->result['sended'] = $sended;
                         }
                     }
                 }
                 if ($last_sub == $key) {
                     $this->result['next'] = false;
                     $this->result['complete'] = true;
                     $this->result['sub'] = $item;
                     $this->result['sended'] = $sended;
                 }
             } else {
                 // подписчики отсутствуют у данной рассылки
                 unset($_SESSION['slist'][$key]);
                 $this->result['next'] = true;
                 $this->result['sended'] = NULL;
             }
         }
     }
 }
Beispiel #7
0
 function indexes_table($parameters)
 {
     global $_CONFIG;
     $TTS = Common::inc_module_factory('TTableSource');
     $options['table'] = 'search_pages_index';
     $options['where'] = '1=1 order by id';
     $options['gridFormat'] = 1;
     $options['columns'] = array('id', 'url', 'title', 'body', 'status');
     $options['sequence'] = array('id', 'url', 'title', 'body', 'status');
     $options['filter']['body'] = array('name' => 'cutwords', 'count' => '30');
     $TTS->setOptions($options);
     $this->result['data_set'] = $TTS->CreateView();
 }
Beispiel #8
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 #9
0
 function parse_xls_file($params)
 {
     $params = $params[0];
     Common::inc_module_factory('ExcelReader', true);
     $data = new Spreadsheet_Excel_Reader(PATH_ . $params['xls_file']);
     return $data->dump(false, false, 0, $params['class']);
 }
Beispiel #10
0
 function load_xlist_data($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_CONTENTGROUP', '_CONTENT');
     $options['columnsAsParameters'] = array('LastModified' => 'LastModified', 'name' => 'Name');
     $options['columnsAsStructs'] = array('image' => 'obj_type');
     $options['transformResults']['image'] = array('_CONTENTGROUP' => 'group', '_CONTENT' => 'page');
     $options['selectable'] = array('image' => array('_CONTENT'));
     //obj_tree является прямым потомком Tree поэтому его использование обосновано
     $this->result['data_set'] = null;
     $TD->init_from_source($this->_common_obj->obj_tree);
     $TD->setOptions($options);
     $TD->CreateView($parameters['anc_id']);
     $this->result['data_set'] = $TD->result['data_set'];
 }
Beispiel #11
0
 function fusers_table($params)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $params['id'];
     $options['shownodesWithObjType'] = array('_FUSER');
     $options['columnsAsParameters'] = array('name' => 'Name', 'fio' => 'Email', 'active' => 'Active');
     $options['preventDots'] = true;
     $options['columnsAsStructs'] = array('id' => 'id', 'basic' => 'basic');
     $options['gridFormat'] = 1;
     $TD->init_from_source($this->_tree);
     $TD->setOptions($options);
     $TD->CreateView($params['id']);
     $this->result = $TD->result;
 }
Beispiel #12
0
 function goods_to_order($user_id, $template = null)
 {
     global $TDB, $TMS, $_COMMON_SITE_CONF;
     if (!empty($_SESSION['siteuser']['cart'])) {
         $_POST['hours'] = isset($_POST['hours']) ? $_POST['hours'] : '00';
         $_POST['minutes'] = isset($_POST['minutes']) ? $_POST['minutes'] : '00';
         $deliv_time = $_POST['hours'] . ':' . $_POST['minutes'] . ':' . '00';
         $tunes = $this->_common_obj->get_tunes();
         if (!$_SESSION['siteuser']['paysystem']) {
             $_SESSION['siteuser']['paysystem'] = $_POST['payment_method'];
         }
         if ($_SESSION['siteuser']['userdata']) {
             if (isset($_POST['address']) && $_POST['address']) {
                 $address = mysql_real_escape_string(isset($_POST['address']) ? $_POST['address'] : ' ');
             } else {
                 $address = mysql_real_escape_string($_SESSION['siteuser']['userdata']['address']);
             }
             $phone = $_SESSION['siteuser']['userdata']['Phone'];
             $email = $_SESSION['siteuser']['userdata']['Email'];
             $name = $_SESSION['siteuser']['userdata']['Name'];
         } else {
             $address = mysql_real_escape_string(isset($_POST['address']) ? $_POST['address'] : ' ');
             $phone = isset($_POST['phone']) ? $_POST['phone'] : ' ';
             $email = mysql_real_escape_string(isset($_POST['email']) ? $_POST['email'] : ' ');
             $name = $_POST['fio'];
         }
         if ($paysystem = $_SESSION['siteuser']['paysystem']) {
             $paysystem_order_num = $_SESSION['siteuser']['cart'][$paysystem . '_order_num'];
         }
         $order_data = array('id' => 'null', 'date' => 'NOW()', 'client' => isset($user_id) ? (int) $user_id : 0, 'currency' => isset($_SESSION['currency']) ? $_SESSION['currency']['alias'] : ' ', 'delivery_type' => isset($_POST['deliveryType']) ? $_POST['deliveryType'] : ' ', 'Name' => $name, 'address' => $address, 'phone' => $phone, 'email' => $email, 'total_sum' => 0, 'status' => 1, 'comments' => mysql_real_escape_string($_POST['comments']), 'deliv_time' => $deliv_time, 'paysystem' => $paysystem, 'paysystem_order_num' => $paysystem_order_num);
         if ($paysystem) {
             if (method_exists($this, $paysystem)) {
                 $order_data = $this->{$paysystem}($order_data);
             }
         }
         $TMS->AddMassReplace('ishop_cart_email', $order_data);
         if ($TDB->InsertIN('ishop_orders', $order_data)) {
             $lid = $TDB->last_inserted;
             $total_sum = 0;
             $order_data['id'] = $lid;
             foreach ($_SESSION['siteuser']['cart'] as $id => $obj) {
                 if ($obj['ext_data']['outer_price']) {
                     $price = (double) str_replace(array(',', ' '), array('.', ''), $obj['ext_data']['outer_price']);
                 } else {
                     $price = $obj['details']['props'][$tunes['PriceProperty']];
                 }
                 if (!$tunes['NameProperty']) {
                     $tunes['NameProperty'] = 'Name';
                 }
                 $order_item = array('id' => 'null', 'order_id' => $lid, 'cat_id' => $obj['details']['id'], 'count' => $obj['count'], 'name' => $obj['details']['props'][$tunes['NameProperty']], 'comments' => $obj['comments'], 'price' => $price);
                 $TMS->AddMassReplace('ishop_cart_object_email', $obj['details']['props']);
                 $TMS->AddMassReplace('ishop_cart_object_email', $order_item);
                 $TMS->parseSection('ishop_cart_object_email', true);
                 $TDB->InsertIN('ishop_orders_goods', $order_item);
                 $total_sum += floatval($price) * $obj['count'];
             }
             $ts = round($total_sum, 2);
             if ($_POST['extended']) {
                 $TMS->AddMassReplace('ishop_cart_email', $_POST['extended']);
             }
             $order_data['total_sum'] = $ts;
             if ($_SESSION['siteuser']['userdata']) {
                 $order_data['email'] = $_SESSION['siteuser']['userdata']['Email'];
                 $order_data['Name'] = $_SESSION['siteuser']['userdata']['Name'];
                 $order_data['company'] = $_SESSION['siteuser']['userdata']['Company'];
             }
             if ($paysystem) {
                 if (method_exists($this, $pa = $paysystem . '_after')) {
                     $order_data = $this->{$pa}($order_data);
                 }
             }
             $this->order_data = $order_data;
             $TMS->AddMassReplace('ishop_cart_email', $order_data);
             if ($tunes['Emails'] && ($emails = explode(',', $tunes['Emails']))) {
                 $m = Common::inc_module_factory('Mail');
                 $m->From($_COMMON_SITE_CONF['admin_email']);
                 $m->To($emails);
                 $m->Content_type('text/html');
                 $m->Subject($tunes['EmailSubject']);
                 $m->Body($TMS->parseSection('ishop_cart_email'), $tunes['EmailEncoding']);
                 $m->Priority(2);
                 $m->Send();
             }
             $TDB->UpdateIN('ishop_orders', $lid, array('total_sum' => $ts));
             return true;
         }
     }
 }
Beispiel #13
0
 function load_xlist_link_pages($parameters)
 {
     Common::call_common_instance('pages');
     $pages =& pages_module_common::getInstance(true);
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_PAGE', '_LINK', '_GROUP', '_ROOT');
     $options['columnsAsParameters'] = array('name' => 'Name');
     $options['columnsAsStructs'] = array('image' => 'obj_type');
     $options['transformResults']['image'] = array('_GROUP' => 'group', '_PAGE' => 'page', '_LINK' => 'page', '_ROOT' => 'group');
     $options['selectable'] = array('image' => array('_PAGE', '_LINK', '_GROUP', '_ROOT'));
     $this->result['data_set'] = null;
     $TD->init_from_source($pages->obj_tree);
     $TD->setOptions($options);
     $TD->CreateView($parameters['anc_id']);
     $this->result = array_merge_recursive($TD->result, $this->result);
 }
Beispiel #14
0
 function get_banner_info($fname, $type)
 {
     $fname = Common::media_path($this->_module_name) . $params['fname'];
     switch ($type) {
         case 'gif':
             $size = getimagesize($fname);
             $banner_info = array('width' => $size[0], 'height' => $size[1]);
             break;
         case 'flash':
             $SWF = Common::inc_module_factory('swfheader');
             $SWF->loadswf($fname);
             $banner_info = array('width' => $SWF->width, 'height' => $SWF->height);
             break;
     }
     return $banner_info;
 }
Beispiel #15
0
 function load_messages($parameters)
 {
     global $_CONFIG;
     $TTS = Common::inc_module_factory('TTableSource');
     $options['startRow'] = 0;
     $options['table'] = 'messages';
     $options['where'] = 'archive=' . $parameters['archive'] . ' order by id DESC';
     $options['rows_per_page'] = $_CONFIG['news']['admin_rows_per_page'];
     $options['columns'] = array('id', 'form_id', 'Name', 'date', 'status', 'archive');
     $options['gridFormat'] = 1;
     $options['sequence'] = array('id', 'date', 'Name', 'status');
     $this->result['data_set'] = null;
     $TTS->setOptions($options);
     $this->result['data_set'] = $TTS->CreateView();
 }
Beispiel #16
0
 function cobject_table($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['id'];
     $options['shownodesWithObjType'] = array('_COBJECT');
     $options['columnsAsParameters'] = array('name' => 'Marker', 'module' => 'Module', 'active' => 'Active');
     $options['preventDots'] = true;
     $options['columnsAsStructs'] = array('id' => 'id');
     $this->result['data_set'] = array();
     $options['gridFormat'] = 1;
     $TD->init_from_source($this->_tree);
     $TD->setOptions($options);
     $TD->CreateView($parameters['id']);
     $this->result = $TD->result;
 }
Beispiel #17
0
 function routes_table()
 {
     global $_CONFIG;
     $TTS = Common::inc_module_factory('TTableSource');
     $options['startRow'] = 0;
     $options['table'] = 'routes';
     $options['where'] = ' 1';
     $options['rows_per_page'] = 30;
     $options['gridFormat'] = 1;
     $options['columns'] = array('*');
     //obj_tree является прямым потомком Tree поэтому его использование обосновано
     $this->result['data_set'] = null;
     $options['sequence'] = array('id', 'from', 'to', 'is301');
     $TTS->setOptions($options);
     $this->result['data_set'] = $TTS->CreateView();
 }
Beispiel #18
0
 function roles_table($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_ROLE');
     $options['columnsAsParameters'] = array('name' => 'Name');
     $options['preventDots'] = true;
     $options['gridFormat'] = 1;
     $options['columnsAsStructs'] = array('id' => 'id');
     //_tree является прямым потомком Tree поэтому его использование обосновано
     $this->result['data_set'] = array();
     $TD->init_from_source($this->_common_obj->rolesTree);
     $TD->setOptions($options);
     $TD->CreateView(1);
     $this->result = array_merge_recursive($TD->result, $this->result);
 }
Beispiel #19
0
 function load_xlist_data($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_VOTESGROUP', '_VOTES');
     $options['columnsAsParameters'] = array('LastModified' => 'LastModified');
     $options['columnsAsStructs'] = array('name' => 'basic', 'image' => 'obj_type');
     $options['transformResults']['image'] = array('_VOTESGROUP' => 'group', '_VOTES' => 'page');
     $options['selectable'] = array('image' => array('_VOTES'));
     $this->result['data_set'] = null;
     $TD->init_from_source($this->_common_obj->obj_tree);
     $TD->setOptions($options);
     $TD->CreateView($parameters['anc_id']);
     $this->result = array_merge_recursive($TD->result, $this->result);
 }
Beispiel #20
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 #21
0
 function load_xlist_data_albums($parameters)
 {
     $this->module_name = 'gallery';
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_ROOT', '_GALLERY', '_ALBUM');
     $options['columnsAsParameters'] = array('LastModified' => 'LastModified', 'name' => 'Name');
     $options['columnsAsStructs'] = array('image' => 'obj_type');
     $options['transformResults']['image'] = array('_ROOT' => 'group', '_GALLERY' => 'group', '_ALBUM' => 'page');
     //$options['endLeafs']=array('_PHOTO');
     $options['selectable'] = array('image' => array('_ALBUM'));
     //obj_tree является прямым потомком Tree поэтому его использование обосновано
     $this->result['data_set'] = null;
     $TD->init_from_source($this->_common_obj->obj_tree);
     $TD->setOptions($options);
     $TD->CreateView($parameters['anc_id']);
     $this->result = array_merge_recursive($TD->result, $this->result);
 }
Beispiel #22
0
 function discount_schemes($parameters)
 {
     $TD = Common::inc_module_factory('TTreeSource');
     $options['startNode'] = $parameters['anc_id'];
     $options['shownodesWithObjType'] = array('_DSCHEME');
     $options['columnsAsParameters'] = array('Name' => 'Name');
     $options['preventDots'] = true;
     $options['columnsAsStructs'] = array('id' => 'id');
     $options['sequence'] = array('id', 'Name');
     $options['gridFormat'] = 1;
     $TD->init_from_source($this->_common_obj->discount_scheme_tree);
     $TD->setOptions($options);
     $TD->CreateView(1);
     $this->result['data_set'] = $TD->result['data_set'];
 }
Beispiel #23
0
 function forgotpassword($params)
 {
     global $TMS, $TPA, $_COMMON_SITE_CONF;
     $TMS->AddFileSection(Common::get_site_tpl($this->_module_name, $params['Template']));
     if ($_POST['Email']) {
         $usr_email = trim($_POST['Email']);
         $User = $this->_tree->Search(array('Email' => $usr_email), true, array('obj_type' => '_FUSER'), null, '=', false);
         if (is_array($User)) {
             $uid = array_keys($User);
             $uid = $uid[0];
             $New_password = substr(Common::GenerateHash(rand(), 12), 0, 8);
             $New_password_hash = md5(strrev($New_password));
             $l = $this->_common_obj->get_translation('back_interface');
             $pages =& pages_module_common::getInstance();
             $plink = $pages->create_page_path($TPA->page_node['id']);
             $TMS->AddMassReplace('fuser_forgot_password_mailtext', array('HOST' => HOST, 'new_password' => $New_password, 'auth_link' => $plink . '/~auth'));
             $mailtext = $TMS->parseSection('fuser_forgot_password_mailtext', true);
             $m = Common::inc_module_factory('Mail');
             $m->From($_COMMON_SITE_CONF['admin_email']);
             $m->To($usr_email);
             $m->Content_type('text/html');
             $m->Subject($l['{password_recovery}'] . ' (' . HOST . ')');
             $m->Body($mailtext, $_COMMON_SITE_CONF['site_encoding']);
             if ($this->_tree->WriteNodeParam($uid, 'password', $New_password_hash) && $m->Send()) {
                 $TMS->AddReplace('fuser_forgot_password_email_send', 'auth_link', $plink . '/~auth');
                 return $TMS->parseSection('fuser_forgot_password_email_send');
             } else {
                 $error = $TMS->parseSection('fuser_forgot_password_email_notsend', true);
                 $TMS->AddReplace('fuser_forgot_password_enter_email', 'error', $error);
                 return $TMS->parseSection('fuser_forgot_password_enter_email');
             }
         } else {
             $error = $TMS->parseSection('fuser_forgot_password_email_notuser', true);
             $TMS->AddReplace('fuser_forgot_password_enter_email', 'error', $error);
             $TMS->AddReplace('fuser_forgot_password_enter_email', 'Email', $usr_email);
             return $TMS->parseSection('fuser_forgot_password_enter_email');
         }
     } else {
         return $TMS->parseSection('fuser_forgot_password_enter_email');
     }
 }
Beispiel #24
0
 function news_table($parameters)
 {
     global $_CONFIG;
     $TTS = Common::inc_module_factory('TTableSource');
     $options['startRow'] = $parameters['startRow'];
     $options['table'] = 'news';
     $options['where'] = 'ctg_id=' . $parameters['id'] . ' order by sortdate DESC';
     $options['page_num_where'] = 'ctg_id=' . $parameters['anc_id'];
     $options['gridFormat'] = 1;
     $options['columns'] = array('id', 'DATE_FORMAT(date,"%d-%m-%Y %H:%i:%s") as date', 'header', 'date as sortdate', 'active');
     $options['sequence'] = array('id', 'date', 'header', 'active');
     $this->result['data_set'] = null;
     $TTS->setOptions($options);
     $this->result['data_set'] = $TTS->CreateView();
     $this->result['pages_num'] = $TTS->pages_num;
 }