core/api/modules/portfolio/class.php

69 lines
3.4 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{
//private $db; // Здесь объект для работы с MySQL
private $settings;
/* ------------------------------------------------------------------------------------------------------------------------- */
/*function __construct($smarty, $settings){
$db=$this->db;
if( $settings['cachePage'] > 0 && !ID){
if( !@$_SESSION['user_id'] ) {
$smarty -> caching = true;
$smarty -> cache_lifetime = $settings['cachePage'];
}
}
$this -> settings = $settings;
}*/
/* ------------------------------------------------------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------------------------------------------------------- */
private function check_assess( $user_id ) { //проверка доступа к редактору
$a = 0;
if ( $_SESSION['dostup'] == 'u' && $user_id == $_SESSION['user_id'] ) $a = 1;
if ( $_SESSION['dostup'] == 'a' || $_SESSION['dostup'] == 'a' ) $a = 1;
if ( $a==0 ) header( 'Location: /403/' );
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function get_page_old($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->check_assess($postrow[0]['user_id']);
return $postrow;
}
/* ------------------------------------------------------------------------------------------------------------------------- */
function upload_main_img($file){ // загружает обложку
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $file['oblozhka']['name'] ) ) {
require_once MYDIR . '/api/php/genpass.php';
$src = $file['oblozhka']['tmp_name'];
$f1 = generate_password(10);
$original = MYDIR . '/img/pages/' . $f1 . '.jpg';
@mkdir(MYDIR . '/img/pages/', 0700);
copy( $src, $original );
// из оригинала создаем обложку
require_once MYDIR . '/api/php/img2.php';
$obl=MYDIR . '/img/pages/' . $f1 . '_obl.jpg';
rimg($original, $mod_settings['w'], $mod_settings['h'], $obl, 90);
// из оригинала создаем превью
$obl_prw=MYDIR . '/img/pages/' . $f1 . '_obl_prw.jpg';
rimg($original, $mod_settings['p_w'], $mod_settings['p_h'], $obl_prw, 90);
}
return $f1;
}
function get_images($id){ // получает список изображений
unset($a);
$a['pages_id']=$id;
$a['type']='img';
return $this->get_massiv('upload', $a);
}
/* ------------------------------------------------------------------------------------------------------------------------- */
}
?>