Skip to content

Commit a5efa88

Browse files
committed
imroved favorites handler
1 parent cd43728 commit a5efa88

File tree

4 files changed

+13
-57
lines changed

4 files changed

+13
-57
lines changed

web/add/favorite/index.php

Lines changed: 3 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,23 @@
11
<?
22

3-
echo 'adding favorite <br><br>';
4-
5-
// Init
63
error_reporting(NULL);
7-
ob_start();
84
session_start();
95

106

11-
// mail_acc
12-
// firewall
13-
147
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
158

16-
// Check POST request
17-
//if (!empty($_POST['ok'])) {
18-
19-
// Check token
9+
// Check token
2010
// if ((!isset($_POST['token'])) || ($_SESSION['token'] != $_POST['token'])) {
2111
// header('location: /login/');
2212
// exit();
2313
// }
2414

25-
26-
// v-list-user-favourites
27-
// v-delete-user-favourites admin web test0011.com
28-
2915
// Protect input
30-
// $v_section = escapeshellarg($_POST['v_section']);
31-
// $v_unit_id = escapeshellarg($_POST['v_unit_id']);
32-
3316
$v_section = escapeshellarg($_REQUEST['v_section']);
3417
$v_unit_id = escapeshellarg($_REQUEST['v_unit_id']);
3518

36-
// $v_section = 'web';
37-
// $v_unit_id = 'test0011.com';
38-
19+
$_SESSION['favourites'][strtoupper($_REQUEST['v_section'])][$_REQUEST['v_unit_id']] = 1;
3920

40-
echo VESTA_CMD."v-add-user-favourites ".$_SESSION['user']." ".$v_section." ".$v_unit_id;
41-
42-
echo ' - ';
43-
44-
// Add cron job
4521
exec (VESTA_CMD."v-add-user-favourites ".$_SESSION['user']." ".$v_section." ".$v_unit_id, $output, $return_var);
46-
check_return_code($return_var,$output);
47-
48-
var_dump($return_var);
49-
echo '<br> -------------------- <br>';
50-
51-
var_dump($output);
52-
echo '<br> -------------------- <br>';
53-
54-
55-
/*
56-
echo '<br>favorites:<br>';
57-
58-
// Data
59-
exec (VESTA_CMD."v-list-user-favourites $user json", $output, $return_var);
60-
$data = json_decode(implode('', $output), true);
61-
$data = array_reverse($data,true);
62-
print_r($data);
63-
*/
64-
//}
22+
// check_return_code($return_var,$output);
6523
?>

web/delete/favorite/index.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
<?php
22

3-
echo 'delete Favorites<br>';
4-
5-
63
error_reporting(NULL);
7-
ob_start();
84
session_start();
95

106
include($_SERVER['DOCUMENT_ROOT']."/inc/main.php");
117

8+
unset($_SESSION['favourites'][strtoupper($_REQUEST['v_section'])][$_REQUEST['v_unit_id']]);
9+
1210
$v_section = escapeshellarg($_REQUEST['v_section']);
1311
$v_unit_id = escapeshellarg($_REQUEST['v_unit_id']);
1412

1513
exec (VESTA_CMD."v-delete-user-favourites ".$_SESSION['user']." ".$v_section." ".$v_unit_id, $output, $return_var);
16-
check_return_code($return_var,$output);
17-
18-
14+
// check_return_code($return_var,$output);
1915
?>

web/inc/main.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,9 @@ function _translate() {
8989
case 'es':
9090
setlocale(LC_ALL, 'es_ES.utf8');
9191
break;
92+
case 'ja':
93+
setlocale(LC_ALL, 'ja_JP.utf8');
94+
break;
9295
default:
9396
setlocale(LC_ALL, 'en_US.utf8');
9497
}
@@ -102,11 +105,7 @@ function _translate() {
102105
$user = $_SESSION['look'];
103106
}
104107

105-
if (isset($_SESSION['user'])) {
106-
get_favorites();
107-
}
108-
109-
function get_favorites(){
108+
function get_favourites(){
110109
exec (VESTA_CMD."v-list-user-favourites ".$_SESSION['user']." json", $output, $return_var);
111110
// $data = json_decode(implode('', $output).'}', true);
112111
$data = json_decode(implode('', $output), true);

web/login/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@
6767
$_SESSION['user'] = key($data);
6868
$v_user = $_SESSION['user'];
6969

70+
// Get user favorites
71+
get_favourites();
72+
7073
// Define language
7174
if (!empty($data[$v_user]['LANGUAGE'])) $_SESSION['language'] = $data[$v_user]['LANGUAGE'];
7275

0 commit comments

Comments
 (0)