core/api/modules/cart/class.php

154 lines
7.1 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
class main extends MySQL{
var $id;
private $settings;
public $user_info;/* Array: Информация о пользователе*/
public $keywords;
public $comments;
/* ------------------------------------------------------------------------------------------------------------------------- */
/*function __construct($smarty, $settings){
@mkdir (MYDIR . '/img/avatars', 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE, 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE, 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_img', 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_files', 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_img', 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_files', 0700);
$db=$this->db;
/* Создаем каталог под файлы раздела и определяемся с кэшем */
/* if( $settings['cachePage'] > 0 ){
if( !@$_SESSION['user_id'] ) { /* если не авторизован - кешируем на часок */
/* $smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
}
$this -> settings = $settings;
}*/
/* ------------------------------------------------------------------------------------------------------------------------- */
private function user_info($id) { /* Получаем инормацию об авторе */
$db=$this->db;
$db -> or_by_desc = 0;
$a['id']=$id;
$this -> user_info = $db->get_massiv('users', $a, '', 1);
return $this -> user_info;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function gen_keywords($txt){ /* Генератор ключевых слов */
include_once MYDIR . '/api/php/kwg.php';
$keywords=seokeywords($txt, 5, 10);
return explode(",", $keywords);
}
/* ------------------------------------------------------------------------------------------------------------------------- */
private function redirect($page){ /* Редиректы куда надо */
if ( @$page[0]['alias'] && ID != @$page[0]['alias'] ){
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: /' . $page[0]['alias'] . '.html' );
}
if (@$page[0]['rdir']){//редирект на новую страницу
header( 'HTTP/1.1 301 Moved Permanently' );
header( 'Location: ' . $page[0]['rdir'] );
}
}
/* ------------------------------------------------------------------------------------------------------------------------- */
private function set_viewers($id, $reyt){/* меняем количество просмотров */
if (!@$_SESSION['user_id']){
$db=$this->db;
$p['reyt']=$reyt+1;
$db->update('pages', $id, $p);
}
}
/* ------------------------------------------------------------------------------------------------------------------------- */
private function get_comments($id){
$db=$this->db;
$db -> or_by_desc = 1;
$tmp['page_id']=$id;
$tmp['public']=1;
$postrow = $db -> get_massiv ( 'pages_comments', $tmp, 'id' );
$num = count($postrow);
for($i = 0; $i < $num; $i++){
$user=$this->user_info($postrow[$i]['user_id']);
$postrow[$i]['fio'] = $user[0]['fio'];
$postrow[$i]['ava'] = $user[0]['ava'];
unset($user);
}
$this -> comments = $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
/* function get_page($id){ // получение страницы
$db = $this -> db;
$id != '' ? $tmp['alias'] = ID : $tmp['id'] = $settings['main_page'];
$postrow = $db -> get_massiv ( 'pages', $tmp, '', '1' );//Пробуем найти по алиасу
if ( !@$postrow[0]['id'] ){//Если не получилось - по ID
unset($tmp);
$tmp['id'] = $id;
$postrow = $db -> get_massiv ( 'pages', $tmp, '', '1' );
}
$this -> redirect ($postrow);
// $this -> get_comments ($postrow[0]['id']);
$this -> user_info ($postrow[0]['user_id']);
$this -> gen_keywords ($postrow[0]['txt']);
$this -> set_viewers($postrow[0]['id'], $postrow[0]['reyt']);//отправляем на апргрейд ид страницы и текущий рейтинг
if ($_SESSION['user_id']==$postrow[0]['user_id']){
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_img/' . $postrow[0]['id'], 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_files/' . $postrow[0]['id'], 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_img/' . $postrow[0]['id'] . '/' . $_SESSION['user_id'], 0700);
@mkdir (MYDIR . '/api/modules/page/' . SITE . '/user_files/' . $postrow[0]['id'] . '/' . $_SESSION['user_id'], 0700);
}
return $postrow;
}*/
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_breadcrumb($id){
$db=$this->db;
$tmp['id']=$id;
$postrow = $db -> get_massiv ( 'pages_cat', $tmp, '', 1 );
$x=0;
$parent=$postrow[0]['parent'];
while ($parent != 0){
$x++;
unset($tmp);
$tmp['id']=$parent;
$postrow[$x] = $db -> get_massiv ( 'pages_cat', $tmp, '', 1 );
$parent=$postrow[$x]['parent'];
}
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_cat_info($id){
unset($a);
$a['id']=$id;
$a['tip']='category';
}
/* ------------------------------------------------------------------------------------------------------------------------- */
/*
26.12.2021
список категорий + количества статей в них
*/
function get_cat_list($parent=0){
$tmp['tip']='category';
$tmp['public']=1;
$tmp['parent']=$parent;
$postrow = $this -> get_massiv ( 'pages', $tmp );
$num = count($postrow);
for($i = 0; $i < $num; $i++){
unset($tmp);
$tmp['parent']=$postrow[$i]['id'];
$tmp['tip']='page';
$tmp['public']=1;
$postrow[$i]['posts_count'] = $this->count_sql('pages', $tmp);
}
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
}
?>