public function actionAddShoppingList() { if (VF::app()->user->isAuth() && !empty($_POST['name'])) { $user_id = VF::app()->user->getId(); $name = trim(mysql_real_escape_string(strip_tags($_POST['name']))); VF::app()->database->insert('user_shopping_list', array('user_id' => $user_id, 'name' => $name)); } }
public function send($user_id, $title, $text) { $email = VF::app()->database->sql("SELECT email FROM t_users WHERE id = '{$user_id}'")->queryScalar(); $headers = 'From: Tooby <*****@*****.**>' . "\n"; $headers .= 'Mime-Version: 1.0' . "\n"; $headers .= 'Content-Type: text/plain; charset= UTF-8' . "\n"; mail($email, $title, $text, $headers); }
public function run($controller = '', $action = '') { if (!empty($controller) && !empty($action)) { $this->loadMethod($this->loadController($controller), $action); } else { $request_url = $_SERVER['REQUEST_URI']; $routing = Vinal::app()->config('general')->routing; $route = explode("/", $request_url); VF::app()->_route = $route; if ($route[1] == 'ru' || $route[1] == 'by' || $route[1] == 'us') { header("Location: " . str_replace(array("ru/", 'by/', 'us/'), array('', '', ''), $_SERVER['REQUEST_URI'])); die; } foreach ($routing as $key => $r) { if ($key == $request_url) { $route = explode("/", $r); break; } else { $chk_url = str_replace(array('.', '?', '*', '&'), array('\\.', '\\?', '\\*', '\\&'), $key); if (preg_match('#<.*?:.*?>#is', $chk_url)) { $chk_url = preg_replace('/<(.*?):(.*?)>/is', '($2{1,})', $chk_url); if (preg_match("#{$chk_url}#is", $request_url, $a)) { $route = explode("/", $r); preg_match_all('#<(.*?):(.*?)>#is', $key, $b); foreach ($b[1] as $k => $c) { if ($c == 'controller') { $route[0] = $a[$k + 1]; } elseif ($c == 'action') { $route[1] = $a[$k + 1]; } else { $route['params'][$c] = $a[$k + 1]; } } if (count($route) > 0) { break; } } } } } if (!empty($route)) { $controller = $this->loadController($route[0]); $controller->id = $route[0]; Vinal::app()->controller_id = $route[0]; Vinal::app()->action_id = $route[1]; $this->loadMethod($controller, $route[1], $route['params']); } else { throw new ClassesException(404); } //TODO: Сделать страницу 404 } }
function L($name) { if (VF::app()->lang_id == 1) { return $name; } if (empty($this->cache)) { include __ROOT__ . $this->lang[VF::app()->lang_id]; $this->cache = $_lang_array; } if (isset($this->cache[$name])) { return $this->cache[$name]; } return $name; }
function __construct($message) { if ($message == 404) { header("HTTP/1.0 404 Not Found"); VF::app()->render->renderPartial('errors/404'); die; } if ($message == 1) { VF::app()->render->renderPartial('errors/1'); die; } $this->message = "<b>Произошла ошибка:</b> {$message}"; parent::__construct(); }
public function actionAdd() { if (VF::app()->is_admin || isset($_GET['key']) && $_GET['key'] == 'eb4db0c51005d73ae57064be10c17145') { $new_id = 0; if (isset($_POST['title'])) { $title = trim(mysql_real_escape_string($_POST['title'])); $lang_id = (int) $_POST['lang_id']; $category_id = (int) $_POST['category_id']; $holiday_id = (int) $_POST['holiday_id']; $instructions = trim(mysql_real_escape_string($_POST['instructions'])); $prep_time = trim(mysql_real_escape_string($_POST['prep_time'])); $cook_time = trim(mysql_real_escape_string($_POST['cook_time'])); $total_time = trim(mysql_real_escape_string($_POST['total_time'])); $ingredients = $_POST['ingredient']; $blob_name = ''; if (!empty($_FILES['image']['tmp_name'])) { $connectionString = "DefaultEndpointsProtocol=http;AccountName=trecipes;AccountKey=FoleK8mHGV5MaOvnJaZV6MFD7WadIEc12SL5hhwj7h949ysaXcp7VeTHimfQt6qxSwdQIEVkba0NQ/o58cgdXw=="; // Create blob REST proxy. $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($connectionString); $options = new CreateBlobOptions(); $options->setBlobContentType("image/jpeg"); $blob_name = md5(time()) . ".jpg"; system("convert " . $_FILES['image']['tmp_name'] . " -resize 200x200 " . $_FILES['image']['tmp_name']); $content = fopen($_FILES['image']['tmp_name'], "r"); $blobRestProxy->createBlockBlob("previews", $blob_name, $content, $options); $blob_name = "http://s1.resepte.net/previews/{$blob_name}"; } VF::app()->database->query("INSERT INTO recipes (title, image_url, image_mobile_url, category_id, instructions, lang_id,\n prep_time, cook_time, total_time, holiday_id) VALUES ('{$title}', '{$blob_name}', '', {$category_id}, '{$instructions}', '{$lang_id}', '{$prep_time}', '{$cook_time}', '{$total_time}', {$holiday_id})\n "); $new_id = VF::app()->database->getLastId(); if ($new_id > 0) { foreach ($ingredients as $i => $ing) { $ing = mysql_real_escape_string(trim($ing)); if (!empty($ing)) { $i_id = VF::app()->database->sql("SELECT id FROM `ingredients` WHERE name = '{$ing}'")->queryRow(); $i_id = (int) $i_id['id']; if ($i_id == 0) { VF::app()->database->query("INSERT INTO `ingredients` (name, lang_id) VALUES ('{$ing}', {$lang_id})"); $i_id = VF::app()->database->getLastId(); } $amount = mysql_real_escape_string(trim($_POST['ingredient_append'][$i])); VF::app()->database->query("INSERT INTO recipes2ingredients (recipe_id, ingredient_id, append) VALUES ('{$new_id}', '{$i_id}', '{$amount}')"); } } } } $this->render('add', array('new_id' => $new_id)); } }
private function renderLang($content) { preg_match_all('#{\\*(.*?)\\*}#', $content, $langes); if (count($langes) > 0) { foreach ($langes[1] as $l) { $ll = explode("-", $l); $nn = ''; if (count($ll) == 2) { $nn = VF::app()->lang->load($ll[0], $ll[1]); } else { $nn = VF::app()->lang->load($ll[0]); } $content = str_replace('{*' . $l . '*}', $nn, $content); } } return $content; }
public function actionFacebook() { require __ROOT__ . 'classes/user/facebook.php'; // Include facebook SDK file $facebook = new Facebook(array('appId' => '319157091579613', 'secret' => '7647ed626e8a8e928bbcf64629f50f97', 'cookie' => true)); $user = $facebook->getUser(); if ($user) { $id = VF::app()->database->sql("SELECT id FROM users WHERE social_network = 2 and social_user_id = '{$user}'")->queryScalar(); if ($id == 0) { $user_profile = $facebook->api('/me?fields=id,picture.width(100).height(100),first_name,last_name,gender'); $sex = $user_profile['gender'] == 'male' ? 2 : 1; VF::app()->database->insert('users', array('first_name' => $user_profile['first_name'], 'last_name' => $user_profile['last_name'], 'sex' => $sex, 'avatar' => $user_profile['picture']['data']['url'], 'social_network' => 2, 'social_user_id' => $user)); $id = VF::app()->database->getLastId(); } $this->setSession($id); } else { $loginUrl = $facebook->getLoginUrl(array('scope' => 'public_profile')); $this->redirect($loginUrl); } }
public function actionAndroid() { $r = isset($_GET['r']) ? urldecode($_GET['r']) : '/'; $r .= preg_match('/\\?/is', $r) ? '&na=1' : '?na=1'; VF::app()->database->query("UPDATE banners SET views=views+1 WHERE id = 3"); $this->renderPartial('android', array('r' => $r)); }
?> <li><a href="<?php echo VF::app()->postopt->generateLink($advanced, array('page' => $advanced['page'] + 1)); ?> "><?php echo __('Назад'); ?> </a></li> <?php } ?> <?php if ($advanced['page'] > 0) { ?> <li><a href="<?php echo VF::app()->postopt->generateLink($advanced, array('page' => $advanced['page'] - 1)); ?> "><?php echo __('Вперед'); ?> </a></li> <?php } ?> </ul> <?php } else { ?> <div class="alert alert-info"> <?php
function getBanner() { $banner = VF::app()->database->sql("SELECT url, url_to_image, id FROM banners WHERE lang_id = " . VF::app()->lang_id . " and hidden = 0 LIMIT 1")->queryRow(); if (!empty($banner)) { VF::app()->database->query("UPDATE banners SET views=views+1 WHERE id = " . $banner['id']); } return $banner; }
public function actionTest() { $names = VF::app()->database->sql("SELECT id,name FROM `ingredients` WHERE id > 1000")->queryAll(); foreach ($names as $name) { $data = simplexml_load_string(file_get_contents("http://export.yandex.ru/inflect.xml?name=" . urlencode($name['name']))); $name_sk = $data->inflection[4]; VF::app()->database->query("UPDATE `ingredients` SET name_sk = '{$name_sk}' WHERE id = " . $name['id']); } }
</div> <div class="clearfix"></div> </div> <div class="sn fb"> <div class="img"><img src="/tpl/images/sn/fb.png"></div> <div class="text">Facebook</div> <div class="clearfix"></div> </div> <div class="clearfix"></div> </div> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div><!-- /.modal --> <?php } ?> </body> <script type="text/javascript"> var g_user_id = <?php echo (int) VF::app()->user->getId(); ?> ; </script> <!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter26367501 = new Ya.Metrika({id:26367501, webvisor:true, clickmap:true, trackLinks:true, accurateTrackBounce:true}); } catch(e) { } }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f, false); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/26367501" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter --> </html>
<!-- Put this div tag to the place, where the Comments block will be --> <div id="vk_comments"></div> <script type="text/javascript"> VK.Widgets.Comments("vk_comments", {limit: 10, width: "660", attach: "*", onChange: addCommentCallback}, "post_<?php echo $recipe['id']; ?> "); </script> <?php } ?> <?php if (VF::app()->lang_id == 2) { ?> <div id="fb-root"></div> <script> window.fbAsyncInit = function() { FB.init({ appId : '319157091579613', xfbml : true, version : 'v2.0' }); FB.Event.subscribe('comment.create', function(response) { $.post('/recipe/updateComments/', {post_id: <?php echo $recipe['id']; ?> });
public function actionSetNotes() { if (isset($_GET['recipe_id']) && (int) $_GET['recipe_id'] > 0 && isset($_GET['user_id']) && (int) $_GET['user_id'] > 0) { $recipe_id = (int) $_GET['recipe_id']; $user_id = (int) $_GET['user_id']; $notes = trim(strip_tags(mysql_real_escape_string($_POST['notes']))); var_dump($_REQUEST); VF::app()->database->query("INSERT INTO user_notes (user_id, recipe_id, notes) VALUES ('{$user_id}', '{$recipe_id}', '{$notes}') ON DUPLICATE KEY UPDATE notes = '{$notes}'"); } else { echo 'Error'; } }
public function actionAuth() { if (isset($_POST['login']) && isset($_POST['password'])) { echo VF::app()->user->login($_POST['login'], $_POST['password']); } }
/** * Получаем client из куки */ public function getClient() { if (isset($_COOKIE['client']) and !empty($_COOKIE['client'])) { return urlencode($_COOKIE['client']); } else { unset($_SESSION); VF::app()->redirect('/?action=user&method=auth'); } return ""; }
public function run($controller = '', $action = '') { try { Loader::I()->run(); //Автозагрузка классов //Мультиязычность //Кеширование if (Vinal::app()->config("general")->cache == true) { $this->cache = new VCache(); } $this->database = Loader::I()->loadClass('database'); $route = new VRouting(); if (VF::app()->user->isAuth()) { VF::app()->database->update('users', array('last_view' => time()), 'id = ' . VF::app()->user->getId()); } if (isset($_GET['lang_id'])) { if ((int) $_GET['lang_id'] > 2 && $_GET['lang_id'] < 1) { $_GET['lang_id'] = 1; } setcookie('lang_id', (int) $_GET['lang_id'], time() + 9000000, '/'); $_COOKIE['lang_id'] = (int) $_GET['lang_id']; VF::app()->lang_id = (int) $_GET['lang_id']; } if ($_SERVER['HTTP_CF_CONNECTING_IP'] == '108.46.198.12' || $_SERVER['HTTP_CF_CONNECTING_IP'] == '67.80.30.28') { $this->is_admin = true; } if (preg_match('/android/is', $_SERVER['HTTP_USER_AGENT']) && !preg_match('#index/android#', $_SERVER['REQUEST_URI']) && !preg_match('#auth#', $_SERVER['REQUEST_URI'])) { if (isset($_GET['na'])) { setcookie('no_android_page', 1, time() + 9000000, '/'); } else { if (isset($_COOKIE['no_android_page'])) { } else { $this->redirect('/index/android/?r=' . urlencode($_SERVER['REQUEST_URI'])); } } } if (!isset($_COOKIE['lang_id'])) { $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if ($lang == 'ru' || $lang == 'by' || $lang == 'ua' || $lang == 'kz') { $lang_id = 1; } else { $lang_id = 2; } setcookie('lang_id', $lang_id, time() + 9000000, '/'); VF::app()->lang_id = $lang_id; } else { VF::app()->lang_id = (int) $_COOKIE['lang_id']; } $route->run($controller, $action); } catch (ClassesException $e) { echo $e->getMessage(); //TODO: Вывод ошибок } }
<option value="<?php echo $cat['id']; ?> "><?php echo $cat['name']; ?> </option> <?php } ?> </select><br> Holiday:<Br> <select name="holiday_id" class="form-control"> <option value="0">Not selected</option> <?php foreach (VF::app()->database->sql("SELECT id,name FROM holidays")->queryAll() as $cat) { ?> <option value="<?php echo $cat['id']; ?> "><?php echo $cat['name']; ?> </option> <?php } ?> </select><br> Instructions:<br> <textarea name="instructions" class="form-control" style="height: 200px;"></textarea><br> <table width="100%">
public function redirect($url) { VF::app()->redirect($url); }