1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | global $template, $conf, $user; |
---|
4 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
5 | load_language('plugin.lang', IDS_PATH); |
---|
6 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
7 | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | Check Access and exit when user status is not ok | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | check_status(ACCESS_ADMINISTRATOR); |
---|
12 | |
---|
13 | //-------------------------------------------------------- sections definitions |
---|
14 | |
---|
15 | // Gestion des onglets |
---|
16 | if (!isset($_GET['tab'])) |
---|
17 | $page['tab'] = 'IDS'; |
---|
18 | else |
---|
19 | $page['tab'] = $_GET['tab']; |
---|
20 | |
---|
21 | $tabsheet = new tabsheet(); |
---|
22 | $tabsheet->add('IDS', |
---|
23 | l10n('ids_tab1'), |
---|
24 | $my_base_url.'&tab=IDS'); |
---|
25 | $tabsheet->select($page['tab']); |
---|
26 | $tabsheet->assign(); |
---|
27 | |
---|
28 | switch ($page['tab']) |
---|
29 | { |
---|
30 | // tab switch |
---|
31 | case 'IDS': |
---|
32 | |
---|
33 | $groups = array(); |
---|
34 | $query = ' |
---|
35 | select id,name |
---|
36 | FROM ' . IMAGES_TABLE . ' |
---|
37 | ORDER BY id ASC;'; |
---|
38 | $result = pwg_query($query); |
---|
39 | |
---|
40 | while ($row = mysql_fetch_array($result)) |
---|
41 | { |
---|
42 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
43 | } |
---|
44 | |
---|
45 | $selected = 0; |
---|
46 | $options[] = l10n('ids_select'); |
---|
47 | $options['a'] = '----------------------'; |
---|
48 | |
---|
49 | foreach($groups as $listid => $listid2) |
---|
50 | { |
---|
51 | $options[$listid] = $listid2; |
---|
52 | } |
---|
53 | $template->assign( |
---|
54 | 'gestion', |
---|
55 | array( |
---|
56 | 'OPTIONS' => $options, |
---|
57 | 'SELECTED' => $selected |
---|
58 | )); |
---|
59 | |
---|
60 | //action |
---|
61 | if (isset($_POST['IDS'])and is_numeric($_POST['IDS1']) and (!$_POST['IDS1'])==0 and is_numeric($_POST['IDS2']) and (!$_POST['IDS2'])==0) |
---|
62 | { |
---|
63 | |
---|
64 | $query = ' |
---|
65 | select id, hit, has_high, average_rate, path |
---|
66 | FROM ' . IMAGES_TABLE . ' |
---|
67 | WHERE id = \''.$_POST['IDS1'].'\' |
---|
68 | ;'; |
---|
69 | $result = pwg_query($query); |
---|
70 | $row = mysql_fetch_array($result); |
---|
71 | $id1=$row['id']; |
---|
72 | $hit1=$row['hit']; |
---|
73 | $has_high1=$row['has_high']; |
---|
74 | $average_rate1=$row['average_rate']; |
---|
75 | |
---|
76 | $query = ' |
---|
77 | select id, hit, has_high, average_rate, path |
---|
78 | FROM ' . IMAGES_TABLE . ' |
---|
79 | WHERE id = \''.$_POST['IDS2'].'\' |
---|
80 | ;'; |
---|
81 | $result = pwg_query($query); |
---|
82 | $row = mysql_fetch_array($result); |
---|
83 | $id2=$row['id']; |
---|
84 | $hit2=$row['hit']; |
---|
85 | $has_high2=$row['has_high']; |
---|
86 | $average_rate2=$row['average_rate']; |
---|
87 | |
---|
88 | $query = ' |
---|
89 | select id |
---|
90 | FROM ' . IMAGES_TABLE . ' |
---|
91 | ORDER BY id DESC;'; |
---|
92 | $result = pwg_query($query); |
---|
93 | $row = mysql_fetch_array($result); |
---|
94 | $tempoids=$row['id']+1000; |
---|
95 | |
---|
96 | $query = ' |
---|
97 | UPDATE ' . IMAGES_TABLE . ' |
---|
98 | SET id= \''.$tempoids.'\' |
---|
99 | WHERE id = \''.$_POST['IDS1'].'\' |
---|
100 | ;'; |
---|
101 | $result = pwg_query($query); |
---|
102 | |
---|
103 | $query = ' |
---|
104 | UPDATE ' . IMAGES_TABLE . ' |
---|
105 | SET id= \''.$_POST['IDS1'].'\', |
---|
106 | hit= \''.$hit1.'\', |
---|
107 | average_rate= \''.$average_rate1.'\' |
---|
108 | WHERE id = \''.$_POST['IDS2'].'\' |
---|
109 | ;'; |
---|
110 | $result = pwg_query($query); |
---|
111 | |
---|
112 | $query = ' |
---|
113 | UPDATE ' . IMAGES_TABLE . ' |
---|
114 | SET id= \''.$_POST['IDS2'].'\', |
---|
115 | hit= \''.$hit2.'\', |
---|
116 | average_rate= \''.$average_rate2.'\' |
---|
117 | WHERE id = \''.$tempoids.'\' |
---|
118 | ;'; |
---|
119 | $result = pwg_query($query); |
---|
120 | |
---|
121 | $groups = array(); |
---|
122 | $query = ' |
---|
123 | select id,name |
---|
124 | FROM ' . IMAGES_TABLE . ' |
---|
125 | ORDER BY id ASC;'; |
---|
126 | $result = pwg_query($query); |
---|
127 | |
---|
128 | while ($row = mysql_fetch_array($result)) |
---|
129 | { |
---|
130 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
131 | } |
---|
132 | |
---|
133 | $selected = 0; |
---|
134 | $options[] = l10n('ids_select'); |
---|
135 | $options['a'] = '----------------------'; |
---|
136 | |
---|
137 | foreach($groups as $listid => $listid2) |
---|
138 | { |
---|
139 | $options[$listid] = $listid2; |
---|
140 | } |
---|
141 | $template->assign( |
---|
142 | 'gestion', |
---|
143 | array( |
---|
144 | 'OPTIONS' => $options, |
---|
145 | 'SELECTED' => $selected |
---|
146 | )); |
---|
147 | |
---|
148 | array_push( $page['infos'], l10n('ids_ok') ); |
---|
149 | } |
---|
150 | |
---|
151 | break; |
---|
152 | |
---|
153 | } |
---|
154 | |
---|
155 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
156 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
157 | ?> |
---|