2022-12-11 13:55:49 +05:00
|
|
|
<?php
|
2023-01-25 14:20:32 +05:00
|
|
|
ini_set( 'display_errors', 1 );
|
2022-12-11 13:55:49 +05:00
|
|
|
switch(@$_POST['act']) {
|
|
|
|
case 'foto_upload':
|
2023-01-25 14:20:32 +05:00
|
|
|
@mkdir( 'img/' . $_SERVER['SERVER_NAME'] . '/pages', 0700 );
|
|
|
|
@mkdir( 'img/' . $_SERVER['SERVER_NAME'] . '/pages/' . $_SESSION['page_id'], 0700 );
|
2022-12-11 13:55:49 +05:00
|
|
|
if ( $_FILES['file']['tmp_name'] ){
|
|
|
|
if ( preg_match( '/[.](jpg)|(jpeg)|(JPG)|(JPEG)$/', $_FILES['file']['name'] ) ){
|
2023-01-25 14:20:32 +05:00
|
|
|
$img_name = \core::genpassword( 30 );
|
2022-12-11 13:55:49 +05:00
|
|
|
$source = $_FILES['file']['tmp_name'];
|
2023-01-25 14:20:32 +05:00
|
|
|
$target_original = 'img/' . $_SERVER['SERVER_NAME'] . '/pages/' . $_SESSION['page_id'] . '/' . $img_name . '.jpg';
|
2022-12-11 13:55:49 +05:00
|
|
|
copy( $source, $target_original );
|
2023-01-25 14:20:32 +05:00
|
|
|
\DB::add( "INSERT INTO `pages_img` (`file_name`, `status`, `page_id`, `user_id`) VALUES (?, ?, ?, ?)", array( $img_name, 1, $_SESSION['page_id'], $_SESSION['user_id'] ) );
|
2022-12-11 13:55:49 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2023-01-25 14:20:32 +05:00
|
|
|
/*
|
2022-12-11 13:55:49 +05:00
|
|
|
case 'update_settings':
|
|
|
|
unset($_POST['act']);
|
|
|
|
$db->update_settings($_POST);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'upload_main_img':
|
|
|
|
|
|
|
|
//echo 'uploader';
|
|
|
|
$settings_mod = $db -> get_settings_json($_POST['mod']);
|
|
|
|
unset($_POST['act']);
|
|
|
|
$tmp_name = $db -> upload_img( $_FILES, 'pages', 'main_img');
|
|
|
|
$db -> resize_img($tmp_name, $settings_mod['w'], $settings_mod['h'], 80, false, 'pages');
|
|
|
|
$db -> resize_img($tmp_name, $settings_mod['p_w'], $settings_mod['p_h'], 80, true, 'pages');
|
|
|
|
unset($a);
|
|
|
|
$a['id']=$_POST['id'];
|
|
|
|
$json=$db->get_val('pages', $a, 'json');
|
|
|
|
$massiv=$db->from_j($db-> clear_json($json));
|
|
|
|
$massiv['main_img']=$tmp_name;
|
|
|
|
$json=$db->to_j($massiv);
|
|
|
|
$db->free_sql( "UPDATE `pages` SET `json` = '" . $json . "' WHERE `id` = " . $_POST['id'] );
|
|
|
|
echo $tmp_name;
|
|
|
|
break;
|
2023-01-25 14:20:32 +05:00
|
|
|
*/
|
2022-12-11 13:55:49 +05:00
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
}
|
|
|
|
?>
|