Skip to content

Commit

Permalink
fix style code
Browse files Browse the repository at this point in the history
  • Loading branch information
osben committed Sep 12, 2016
1 parent 63b14d8 commit 631b56c
Show file tree
Hide file tree
Showing 81 changed files with 6,923 additions and 7,241 deletions.
69 changes: 35 additions & 34 deletions ajax/cart.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,35 @@
<?php
session_start();
require_once('../api/Simpla.php');

class CartAjax extends Simpla
{
public function fetch()
{
$this->cart->add_item($this->request->get('variant', 'integer'), $this->request->get('amount', 'integer'));
$cart = $this->cart->get_cart();
$this->design->assign('cart', $cart);

$currencies = $this->money->get_currencies(array('enabled'=>1));
if(isset($_SESSION['currency_id']))
$currency = $this->money->get_currency($_SESSION['currency_id']);
else
$currency = reset($currencies);

$this->design->assign('currency', $currency);

return $this->design->fetch('cart_informer.tpl');
}
}

$cart_ajax = new CartAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
<?php
session_start();
require_once('../api/Simpla.php');

class CartAjax extends Simpla
{
public function fetch()
{
$this->cart->add_item($this->request->get('variant', 'integer'), $this->request->get('amount', 'integer'));
$cart = $this->cart->get_cart();
$this->design->assign('cart', $cart);

$currencies = $this->money->get_currencies(array('enabled'=>1));
if (isset($_SESSION['currency_id'])) {
$currency = $this->money->get_currency($_SESSION['currency_id']);
} else {
$currency = reset($currencies);
}

$this->design->assign('currency', $currency);

return $this->design->fetch('cart_informer.tpl');
}
}

$cart_ajax = new CartAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
109 changes: 54 additions & 55 deletions ajax/search_products.php
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
<?php
require_once('../api/Simpla.php');

class SearchProductsAjax extends Simpla
{
private $limit = 30;
public function fetch()
{
$result = new stdClass;
$result->suggestions = array();
$result->query = $this->request->get('query', 'string');

if(!empty($result->query))
{
$kw = $this->db->escape($result->query);

$this->db->query("SELECT p.id, p.name, i.filename as image FROM __products p
LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1)
WHERE (p.name LIKE '%$kw%' OR p.meta_keywords LIKE '%$kw%' OR p.id in (SELECT product_id FROM __variants WHERE sku LIKE '%$kw%'))
AND visible=1
GROUP BY p.id
ORDER BY p.name
LIMIT ?", $this->limit);
$products = $this->db->results();

$suggestions = array();

foreach($products as $product)
{
$suggestion = new stdClass();

if(!empty($product->image))
$product->image = $this->design->resize_modifier($product->image, 35, 35);

$suggestion->value = $product->name;
$suggestion->data = $product;
$result->suggestions[] = $suggestion;
}
}


return $result;
}
}

$cart_ajax = new SearchProductsAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex, noarchive, nosnippet");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
<?php
require_once('../api/Simpla.php');

class SearchProductsAjax extends Simpla
{
private $limit = 30;
public function fetch()
{
$result = new stdClass;
$result->suggestions = array();
$result->query = $this->request->get('query', 'string');

if (!empty($result->query)) {
$kw = $this->db->escape($result->query);

$this->db->query("SELECT p.id, p.name, i.filename as image FROM __products p
LEFT JOIN __images i ON i.product_id=p.id AND i.position=(SELECT MIN(position) FROM __images WHERE product_id=p.id LIMIT 1)
WHERE (p.name LIKE '%$kw%' OR p.meta_keywords LIKE '%$kw%' OR p.id in (SELECT product_id FROM __variants WHERE sku LIKE '%$kw%'))
AND visible=1
GROUP BY p.id
ORDER BY p.name
LIMIT ?", $this->limit);
$products = $this->db->results();

$suggestions = array();

foreach ($products as $product) {
$suggestion = new stdClass();

if (!empty($product->image)) {
$product->image = $this->design->resize_modifier($product->image, 35, 35);
}

$suggestion->value = $product->name;
$suggestion->data = $product;
$result->suggestions[] = $suggestion;
}
}


return $result;
}
}

$cart_ajax = new SearchProductsAjax();
$result = $cart_ajax->fetch();

header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
header("X-Robots-Tag: noindex, noarchive, nosnippet");
header("Pragma: no-cache");
header("Expires: -1");
print json_encode($result);
exit;
99 changes: 50 additions & 49 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,70 +19,71 @@
$view = new IndexView();


if(isset($_GET['logout']))
{
header('WWW-Authenticate: Basic realm="Simpla CMS"');
header('HTTP/1.0 401 Unauthorized');
unset($_SESSION['admin']);
if (isset($_GET['logout'])) {
header('WWW-Authenticate: Basic realm="Simpla CMS"');
header('HTTP/1.0 401 Unauthorized');
unset($_SESSION['admin']);
}

// Если все хорошо
if(($res = $view->fetch()) !== false)
{
// Выводим результат
header("Content-type: text/html; charset=UTF-8");
print $res;

// Сохраняем последнюю просмотренную страницу в переменной $_SESSION['last_visited_page']
if(empty($_SESSION['last_visited_page']) || empty($_SESSION['current_page']) || $_SERVER['REQUEST_URI'] !== $_SESSION['current_page'])
{
if(!empty($_SESSION['current_page']) && !empty($_SESSION['last_visited_page']) && $_SESSION['last_visited_page'] !== $_SESSION['current_page'])
$_SESSION['last_visited_page'] = $_SESSION['current_page'];
$_SESSION['current_page'] = $_SERVER['REQUEST_URI'];
}
}
else
{
// Иначе страница об ошибке
header("http/1.0 404 not found");

// Подменим переменную GET, чтобы вывести страницу 404
$_GET['page_url'] = '404';
$_GET['module'] = 'PageView';
print $view->fetch();
if (($res = $view->fetch()) !== false) {
// Выводим результат
header("Content-type: text/html; charset=UTF-8");
print $res;

// Сохраняем последнюю просмотренную страницу в переменной $_SESSION['last_visited_page']
if (empty($_SESSION['last_visited_page']) || empty($_SESSION['current_page']) || $_SERVER['REQUEST_URI'] !== $_SESSION['current_page']) {
if (!empty($_SESSION['current_page']) && !empty($_SESSION['last_visited_page']) && $_SESSION['last_visited_page'] !== $_SESSION['current_page']) {
$_SESSION['last_visited_page'] = $_SESSION['current_page'];
}
$_SESSION['current_page'] = $_SERVER['REQUEST_URI'];
}
} else {
// Иначе страница об ошибке
header("http/1.0 404 not found");

// Подменим переменную GET, чтобы вывести страницу 404
$_GET['page_url'] = '404';
$_GET['module'] = 'PageView';
print $view->fetch();
}


$p=11; $g=2; $x=7; $r = ''; $s = $x;
$bs = explode(' ', $view->config->license);
foreach($bs as $bl){
for($i=0, $m=''; $i<strlen($bl)&&isset($bl[$i+1]); $i+=2){
$a = base_convert($bl[$i], 36, 10)-($i/2+$s)%26;
$b = base_convert($bl[$i+1], 36, 10)-($i/2+$s)%25;
$m .= ($b * (pow($a,$p-$x-1) )) % $p;}
$m = base_convert($m, 10, 16); $s+=$x;
for ($a=0; $a<strlen($m); $a+=2) $r .= @chr(hexdec($m{$a}.$m{($a+1)}));}
foreach ($bs as $bl) {
for ($i=0, $m=''; $i<strlen($bl)&&isset($bl[$i+1]); $i+=2) {
$a = base_convert($bl[$i], 36, 10)-($i/2+$s)%26;
$b = base_convert($bl[$i+1], 36, 10)-($i/2+$s)%25;
$m .= ($b * (pow($a, $p-$x-1))) % $p;
}
$m = base_convert($m, 10, 16); $s+=$x;
for ($a=0; $a<strlen($m); $a+=2) {
$r .= @chr(hexdec($m{$a}.$m{($a+1)}));
}
}

@list($l->domains, $l->expiration, $l->comment) = explode('#', $r, 3);

$l->domains = explode(',', $l->domains);

$h = getenv("HTTP_HOST");
if(substr($h, 0, 4) == 'www.') $h = substr($h, 4);
if((!in_array($h, $l->domains) || (strtotime($l->expiration)<time() && $l->expiration!='*')))
{
print "<div style='text-align:center; font-size:22px; height:100px;'>Лицензия недействительна<br><a href='http://simplacms.ru'>Скрипт интернет-магазина Simpla</a></div>";
if (substr($h, 0, 4) == 'www.') {
$h = substr($h, 4);
}
if ((!in_array($h, $l->domains) || (strtotime($l->expiration)<time() && $l->expiration!='*'))) {
print "<div style='text-align:center; font-size:22px; height:100px;'>Лицензия недействительна<br><a href='http://simplacms.ru'>Скрипт интернет-магазина Simpla</a></div>";
}

// Отладочная информация
if(1)
{
print "<!--\r\n";
$time_end = microtime(true);
$exec_time = $time_end-$time_start;

if(function_exists('memory_get_peak_usage'))
print "memory peak usage: ".memory_get_peak_usage()." bytes\r\n";
print "page generation time: ".$exec_time." seconds\r\n";
print "-->";
if (1) {
print "<!--\r\n";
$time_end = microtime(true);
$exec_time = $time_end-$time_start;

if (function_exists('memory_get_peak_usage')) {
print "memory peak usage: ".memory_get_peak_usage()." bytes\r\n";
}
print "page generation time: ".$exec_time." seconds\r\n";
print "-->";
}
Loading

0 comments on commit 631b56c

Please sign in to comment.