73 lines
3.0 KiB
PHP
Executable File
73 lines
3.0 KiB
PHP
Executable File
<?php
|
|
|
|
if ( $_SESSION['dostup'] !=='a' && $_SESSION['dostup'] !== 'e' ) header( 'Location: /403/' );
|
|
switch(@$_POST['act']) {
|
|
case 'upload':
|
|
if( $_FILES['img2']['tmp_name'] ) {
|
|
if ( preg_match( '/[.](jpg)|(JPG)$/', $_FILES['img2']['name'] ) ) {
|
|
//подключаем ген случайных значений
|
|
include( MYDIR . '/api/php/genpass.php' );
|
|
$_POST['img'] = generate_password(30);
|
|
$source = $_FILES['img2']['tmp_name'];//откуда
|
|
$target = MYDIR . '/img/pages/' . $_POST['img'] . '.jpg';//Куда загружаем:
|
|
$target270_300 = MYDIR . '/img/pages/' . $_POST['img'] . '_270_300.jpg';//Куда загружаем:
|
|
$target307_315 = MYDIR . '/img/pages/' . $_POST['img'] . '_307_315.jpg';//Куда загружаем:
|
|
$target568_495 = MYDIR . '/img/pages/' . $_POST['img'] . '_568_495.jpg';//Куда загружаем:
|
|
$target270_200 = MYDIR . '/img/pages/' . $_POST['img'] . '_270_200.jpg';//Куда загружаем:
|
|
$target150_150 = MYDIR . '/img/pages/' . $_POST['img'] . '_150_150.jpg';//Куда загружаем:
|
|
copy ($source, $target);
|
|
unlink($source);
|
|
include( MYDIR . '/api/php/img2.php' );
|
|
rimg($target, 270, 300, $target270_300, 80);
|
|
rimg($target, 307, 315, $target307_315, 80);
|
|
rimg($target, 568, 495, $target568_495, 80);
|
|
rimg($target, 270, 200, $target270_200, 80);
|
|
rimg($target, 150, 150, $target150_150, 80);
|
|
echo $_POST['img'];
|
|
unset($a);
|
|
$a['img']=$_POST['img'];
|
|
$a['page_id']=$_POST['id'];
|
|
$db -> add( 'img', $a );
|
|
}
|
|
}
|
|
break;
|
|
case "del_img":
|
|
$db -> del_id( 'img', $_POST['id'] );
|
|
array_map("unlink", glob(MYDIR . "/img/pages/" . $_POST['img'] . "*.jpg"));
|
|
break;
|
|
case 'del_oblozhka':/*сохранение данных*/
|
|
$id=$_POST['id'];
|
|
$db->free_sql('UPDATE `pages` SET `oblozhka` = "", `oblozhka_big` = "", `oblozhka_show` = ""
|
|
WHERE `id` = "' . $id . '";');
|
|
break;
|
|
case 'load-keywords':/*сохранение данных*/
|
|
$page_id=$_POST['page_id'];
|
|
//берем тег слов:
|
|
unset($a);
|
|
$a['id']=$_POST['page_id'];
|
|
$keywords=$db->get_val('pages', $a, 'keywords');
|
|
if (!$keywords){
|
|
unset($a);
|
|
$a['alias']=$_POST['page_id'];
|
|
$keywords=$db->get_val('pages', $a, 'keywords');
|
|
if ($keywords)$page_id=$db->get_val('pages', $a, 'id');
|
|
}
|
|
if(preg_match('/[.](txt)|(TXT)$/', $_FILES['input_keys']['name'])) {
|
|
$f=MYDIR . '/../tmp/' . $_FILES['input_keys']['name'];
|
|
copy ($_FILES['input_keys']['tmp_name'], $f);
|
|
include MYDIR . '/api/php/findtxt.php';
|
|
$handle = fopen($f, "r");
|
|
while (!feof($handle)) {
|
|
$buffer = fgets($handle, 4096);
|
|
$buffer=trim($buffer);
|
|
if (findtxt($keywords, $buffer && strlen($buffer)>3)==0) $keywords .= ', ' . $buffer;
|
|
}
|
|
fclose($handle);
|
|
}
|
|
unset($a);
|
|
$a['keywords']=$keywords;
|
|
$db->update('pages', $page_id, $a);
|
|
break;
|
|
}
|
|
|
|
?>
|