public static function send($id) { foreach ($_POST as $key => $value) { $_POST[$key] = htmlspecialchars(trim(strip_tags($value))); } if ($_SESSION['captcha_keystring'] == $_POST['kcaptcha'] && $_SESSION['captcha_keystring'] != '') { $text = ''; foreach ($_POST as $name => $item) { if ($_POST[$name . '_text'] && strpos($name, '_text') === false) { if (strpos($name, '_area') !== false) { $text .= '<b>' . $_POST[$name . '_text'] . ':</b> <br />' . nl2br($item) . '<br />'; } else { $text .= '<b>' . $_POST[$name . '_text'] . ':</b> ' . $item . '<br />'; } } } $mail = new Email(); $info = Tree::getInfo($id); if (Funcs::$conf['mail'][$info['path']]) { $mail->To(Funcs::$conf['mail'][$info['path']]); } elseif (Funcs::$conf['settings']['email']) { $mail->To(Funcs::$conf['settings']['email']); } else { return false; } $mail->Subject($_POST['subject'] . ' на сайте ' . $_SERVER['HTTP_HOST']); $mail->Text($text); $mail->Send(); return true; } else { return false; } }
public static function Report() { $sql = 'SELECT * FROM {{orders}} WHERE loyalty=1 AND sent=0'; $list = DB::getAll($sql); foreach ($list as $order) { $sql = ' SELECT * FROM {{orders_items}} WHERE orders=' . $order['id'] . ' '; $items = DB::getAll($sql); $data = $order; foreach ($items as $item) { $temp = Tree::getInfo($item['tree']); if ($temp['path'] != 'catalogopt') { $data['list'][] = Catalog::getOne($item['tree']); } } $text = View::getRenderEmpty('email/report', $data); $mail = new Email(); $mail->Text($text); $mail->Subject('Оставьте отзыв о товаре на сайте www.' . str_replace('www.', '', $_SERVER["HTTP_HOST"])); $mail->From('robot@' . str_replace('www.', '', $_SERVER["HTTP_HOST"])); $mail->To($order['email']); $mail->Send(); $sql = ' UPDATE {{orders}} SET sent=1 WHERE id=' . $order['id'] . ' '; DB::exec($sql); } }
public static function getBranch($tree) { foreach ($tree as $item) { $info = Tree::getInfo($item['id']); if ($info['type'] == 'cat') { Prepare::$tree[] = $item; } Prepare::getBranch($item['sub']); } }
function getList() { $data = array(); $xml = Sitemap::getSitemapXML(); //$site=Control::getSite(Funcs::$siteDB); $sql = 'SELECT * FROM {{tree}} WHERE visible=1 ORDER BY mdate DESC, cdate DESC'; $list = DB::getAll($sql); foreach ($list as $item) { $info = Tree::getInfo($item['id']); if ($info['id2'] != 0 && $info['params'] != '') { $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id'], $info['params']); } else { $path = 'http://' . $_SERVER['HTTP_HOST'] . Tree::getPathToTree($item['id']); } $data[] = array('id' => $item['id'], 'name' => $item['name'], 'path' => $path, 'mdate' => date('Y-m-d', strtotime($item['mdate'])), 'changefreq' => $xml[str_replace('/', '_', $path)]['changefreq'], 'priority' => $xml[str_replace('/', '_', $path)]['priority'], 'checked' => is_array($xml[str_replace('/', '_', $path)]) ? 'checked' : ''); } return $data; }
public function getResult() { $data = array(); $q = trim(strip_tags($_GET['q'])); if ($q) { $sql = ' SELECT * FROM {{search}} INNER JOIN {{tree}} ON {{search}}.tree={{tree}}.id WHERE search LIKE \'%' . $q . '%\' AND visible=1 ORDER BY {{search}}.cdate DESC '; $list = DB::getAll($sql); foreach ($list as $item) { $fields = Fields::getFieldsByTree($item['tree'], 'gal'); $path = Tree::getPathToTree($item['tree']); $data[] = array('id' => $item['tree'], 'name' => $item['name'], 'path' => $path, 'fields' => $fields, 'info' => Tree::getInfo($item['tree'])); } } return $data; }
public static function getMarket($id) { $data = array(); $tree = Tree::getInfo($id); if (strpos($tree['modul2'], 'catalog') !== 'false') { $sql = 'SHOW COLUMNS FROM {{catalog}}'; $cols = DB::getAll($sql); $x = 0; foreach ($cols as $item) { if ($item['Field'] == 'market') { $x = 1; } } if ($x) { $ids = Tree::getChilds($id); $ids[] = $id; $sql = ' SELECT COUNT(*) FROM {{catalog}} WHERE tree IN (' . implode(',', $ids) . ') AND market=1 '; $m1 = DB::getOne($sql); $sql = ' SELECT COUNT(*) FROM {{catalog}} WHERE tree IN (' . implode(',', $ids) . ') AND market=0 '; $m2 = DB::getOne($sql); if ($m1 >= $m2) { return 1; } else { return 0; } } else { return 0; } } return 0; }
public function getTreeselect($id, $treeId, $path) { $data = array(); $tree = array(); $module = Tree::getInfo($treeId); $sql = ' SELECT * FROM {{fields}} WHERE module=' . $module['id'] . ' AND path=\'' . $path . '\' '; $field = DB::getRow($sql); $data['name'] = $field['name']; $data['params'] = $field['params']; $params = explode('-', $data['params']); $module = Module::getModuleByPath($params[0]); if (count($params) == 2) { $sql = ' SELECT * FROM {{' . $params[0] . '}} ORDER BY num '; } else { $sql = 'SELECT id FROM {{' . $params[0] . '}} WHERE path=\'' . $params[1] . '\''; $parent = DB::getOne($sql); if ($parent) { $sql = ' SELECT * FROM {{' . $params[0] . '}} WHERE parent=' . $parent . ' ORDER BY num '; } } $list = DB::getAll($sql); $left = 0; foreach ($list as $item) { $item['value'] = $item['id']; if ($id) { $sql = 'SELECT \'checked\' FROM {{relations}} WHERE modul1=\'data\' AND modul2=\'' . $params[0] . '\' AND id1=' . $id . ' AND id2=' . $item['id'] . ''; $item['checked'] = DB::getOne($sql); } $item['sub'] = Fields::getTreeselectBranch($item['id'], $params, $id); $item['admin'] = Fields::getTreeselectAdminField($item['id']); $tree[] = $item; } $data['list'] = $tree; return $data; }
public function addTree($parent, $tree, $module = '') { $path = $tree['path']; if ($path == '') { $path = $tree['name']; } $path = Funcs::Transliterate($path); if ($tree['seo_title'] == '') { $tree['seo_title'] = $tree['name']; } if ($tree['seo_keywords'] == '') { $tree['seo_keywords'] = $tree['name']; } if ($tree['seo_description'] == '') { $tree['seo_description'] = $tree['name']; } $udate = $tree['udate']; if (trim($udate) == '') { $udate = date("d.m.Y H:i:00"); } $sql = ' INSERT INTO {{tree}} SET parent=' . $parent . ', name=\'' . $tree['name'] . '\', path=\'' . $path . '\', seo_title=\'' . $tree['seo_title'] . '\', seo_keywords=\'' . $tree['seo_keywords'] . '\', seo_description=\'' . $tree['seo_description'] . '\', udate=\'' . date('Y-m-d H:i:s', strtotime($udate)) . '\', cdate=NOW(), visible=' . ($tree['visible'] == '' ? '0' : '1') . ', menu=0, site=' . $_SESSION['site'] . ' '; $id = DB::exec($sql); if ($module) { $tree['info']['path'] = $module; } else { $tree['info'] = Tree::getInfo($parent); } $sql = ' INSERT INTO {{relations}} SET modul1=\'tree\', modul2=\'' . $tree['info']['path'] . '\', id1=\'' . $id . '\', id2=1, cdate=NOW() '; DB::exec($sql); //Tree::saveSearch($id); return $id; }