<?php
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
define( 'DATALIFEENGINE', true );
define( 'ROOT_DIR', substr( dirname( __FILE__ ), 0, -12 ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );
include ENGINE_DIR . '/data/config.php';
date_default_timezone_set ( $config['date_adjust'] );
if( $config['http_home_url'] == "" ) {
$config['http_home_url'] = explode( "engine/ajax/favorites.php", $_SERVER['PHP_SELF'] );
$config['http_home_url'] = reset( $config['http_home_url'] );
$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
dle_session();
require_once ENGINE_DIR . '/modules/sitelogin.php';
if( !$is_logged ) die( "error" );
$response = array();
if( $_REQUEST['action'] === "delete") {
$db->query( "UPDATE `" . USERPREFIX . "_users` SET favorites='' WHERE user_id = '{$member_id['user_id']}'" );
if {$db->get_affected_rows()) {
$response['success'] = true;
$response['reason'] = "Favorites deleted";
} else {
$response['success'] = false;
$response['error'] = "Nothing to delete";
}
} else {
$response['success'] = false;
$response['error'] = "Bad action";
}
$db->close();
header('Content-Type: application/json');
echo json_encode($response);
function deleteFaforites() {
$.ajax({
type: "POST",
url: "/engine/ajax/givemeuser.php", // Имя файла к которому будет идти AJAX запрос
data: 'action=delete', // передаем действие
success: function(data){
alert(data.success); // Итог: Алерт с Именем пользователя
}
});
}
require_once ENGINE_DIR . '/modules/sitelogin.php';