47 lines
1.6 KiB
PHP
Executable File
47 lines
1.6 KiB
PHP
Executable File
<?php
|
|
ini_set('display_errors', 0 );
|
|
switch(@$_POST['act']) {
|
|
|
|
case 'add_comment':
|
|
print_r($_POST);
|
|
if (!$_SESSION['user_id'] || !$_POST['txt'])die();
|
|
$_POST['t']=time();
|
|
$_POST['user_id']=$_SESSION['user_id'];
|
|
unset($_POST['act']);
|
|
$db->add ( 'pages_comments', $_POST );
|
|
break;
|
|
|
|
case 'like':
|
|
unset($a);
|
|
unset($b);
|
|
$a['id']=$_POST['id'];
|
|
$b['likes']=$db->get_val('pages', $a, 'likes')+1;
|
|
setcookie ("page_like", $a['id'], time()+31536000, '/', $_SERVER['SERVER_NAME']);
|
|
$db->update('pages', $a['id'], $b);
|
|
echo 1;
|
|
break;
|
|
|
|
|
|
case 'foto_upload'://загрузка обложки каталогов
|
|
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
|
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'] ) ) {
|
|
//print_r($_FILES);
|
|
require_once MYDIR . '/api/php/genpass.php';
|
|
$src = $_FILES['file']['tmp_name'];
|
|
$f1 = generate_password(30);
|
|
$original = MYDIR . '/tmp/' . $f1 . '.jpg';
|
|
@mkdir(MYDIR . '/tmp/', 0700);
|
|
copy( $src, $original );
|
|
// из оригинала создаем обложку
|
|
require_once MYDIR . '/api/php/img2.php';
|
|
$obl=MYDIR . '/tmp/' . $f1 . '_obl.jpg';
|
|
rimg($original, 1024, 200, $obl, 90);
|
|
// из оригинала создаем превью
|
|
$obl_prw=MYDIR . '/tmp/' . $f1 . '_obl_prw.jpg';
|
|
rimg($original, 300, 300, $obl_prw, 90);
|
|
}
|
|
|
|
break;
|
|
default:
|
|
}
|
|
?>
|