Merge lp:~vierbergenlars/remotecp-panel/plugins_api into lp:remotecp-panel/1.x
- plugins_api
- Merge into 1.x
Proposed by
Lars Vierbergen
Status: | Superseded |
---|---|
Proposed branch: | lp:~vierbergenlars/remotecp-panel/plugins_api |
Merge into: | lp:remotecp-panel/1.x |
Diff against target: | 352 lines |
To merge this branch: | bzr merge lp:~vierbergenlars/remotecp-panel/plugins_api |
Related bugs: | |
Related blueprints: |
Add plugin API support
(High)
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Lars Vierbergen | Approve | ||
Review via email: mp+47017@code.launchpad.net |
This proposal has been superseded by a proposal from 2011-01-21.
Commit message
Description of the change
Add the addons api support
To post a comment you must log in.
Revision history for this message
Lars Vierbergen (vierbergenlars) : | # |
review:
Approve
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'cpanel-incs/plugins/cms/api.php' |
2 | --- cpanel-incs/plugins/cms/api.php 1970-01-01 00:00:00 +0000 |
3 | +++ cpanel-incs/plugins/cms/api.php 2011-01-21 08:48:59 +0000 |
4 | @@ -0,0 +1,107 @@ |
5 | +<?php |
6 | +class cms { |
7 | + function get_pages() { |
8 | + global $remote_connection; |
9 | + $q=$remote_connection->query('SELECT * FROM `'.SITE.'_pageindex` ORDER BY `page_order` ASC'); |
10 | + $PAGES=array(); |
11 | + while($page=$q->fetch_assoc()) { |
12 | + $PAGES[]=$page; |
13 | + } |
14 | + return $PAGES; |
15 | + } |
16 | + function get_page($id) { |
17 | + global $remote_connection; |
18 | + return $remote_connection->query('SELECT * FROM `'.SITE.'_pageindex` WHERE `id`='.$id)->fetch_assoc(); |
19 | + } |
20 | + function get_sections($page_id) { |
21 | + global $remote_connection; |
22 | + $q=$remote_connection->query('SELECT * FROM `'.SITE.'_pages` WHERE `page_id`='.$page_id.' ORDER BY `section_order` ASC'); |
23 | + $SECTIONS=array(); |
24 | + while($section=$q->fetch_assoc()) { |
25 | + $SECTIONS[]=$section; |
26 | + } |
27 | + return $SECTIONS; |
28 | + } |
29 | + function get_section($id) { |
30 | + global $remote_connection; |
31 | + return $remote_connection->query('SELECT * FROM `'.SITE.'_pages` WHERE `id`='.$id)->fetch_assoc(); |
32 | + } |
33 | + function delete_page($id) { |
34 | + global $remote_connection; |
35 | + $remote_connection->query('DELETE FROM `'.SITE.'_pageindex` WHERE `id`='.$id); |
36 | + $remote_connection->query('DELETE FROM `'.SITE.'_pages` WHERE `page_id`='.$id); |
37 | + return true; |
38 | + } |
39 | + function delete_section($id) { |
40 | + global $remote_connection; |
41 | + return $remote_connection->query('DELETE FROM `'.SITE.'_pages` WHERE `id`='.$id); |
42 | + } |
43 | + function add_page($props) { |
44 | + global $remote_connection; |
45 | + $defaults=array('type'=>0,'page_title'=>'API_added_page','link'=>'','access'=>0,'visible'=>1); |
46 | + $props=array_merge($defaults,$props); |
47 | + $order=$remote_connection->query('SELECT * FROM `'.SITE.'_pageindex` ORDER BY `page_order` DESC')->fetch_assoc(); |
48 | + $order=$order['page_order']+1; |
49 | + $remote_connection->query('INSERT INTO `'.SITE.'_pageindex` VALUES(NULL,'.$props['type'].','.$order.',\''.$props['page_title'].'\',\''.$props['link'].'\','.$props['access'].','.$props['visible'].')'); |
50 | + return $remote_connection->insert_id; |
51 | + } |
52 | + function add_section($page_id,$props) { |
53 | + global $remote_connection; |
54 | + $defaults=array('type'=>0,'section_title'=>'API_added_section','section_main'=>''); |
55 | + $props=array_merge($defaults,$props); |
56 | + $order=$remote_connection->query('SELECT * FROM `'.SITE.'_pages` WHERE `page_id`='.$page_id.' ORDER BY `section_order` DESC')->fetch_assoc(); |
57 | + $order=$order['section_order']+1; |
58 | + $remote_connection->query('INSERT INTO `'.SITE.'_pages` VALUES(NULL,'.$page_id.','.$props['type'].','.$order.',\''.$props['section_title'].'\',\''.$props['section_main'].'\')'); |
59 | + return $remote_connection->insert_id; |
60 | + } |
61 | + function move_page($id,$where) { |
62 | + // $where > 0 : UP |
63 | + // $where < 0 : DOWN |
64 | + global $remote_connection; |
65 | + $q0=$remote_connection->query('SELECT * FROM `'.SITE.'_pageindex` WHERE `id`='.$id); |
66 | + $q1=$remote_connection->query('SELECT * FROM `'.SITE.'_pageindex` ORDER BY `page_order` DESC'); |
67 | + if(!$q0||!$q1) return false; |
68 | + $r0=$q0->fetch_assoc(); |
69 | + $r1=$q1->fetch_assoc(); |
70 | + $old_pos=$r0['page_order']; |
71 | + $max_pos=$r1['page_order']; |
72 | + $new_pos=$old_pos-$where; |
73 | + if($new_pos<1||$new_pos>$max_pos) return false; |
74 | + return $remote_connection->query('UPDATE `'.SITE.'_pageindex` SET `page_order` = IF( `page_order` ='.$old_pos.', '.$new_pos.', '.$old_pos.' ) WHERE `page_order` IN ( '.$old_pos.', '.$new_pos.' )'); |
75 | + } |
76 | + function move_section($id,$where) { |
77 | + // $where > 0 : UP |
78 | + // $where < 0 : DOWN |
79 | + global $remote_connection; |
80 | + $section=self::get_section($id); |
81 | + $page_id=$section['page_id']; |
82 | + $q0=$remote_connection->query('SELECT * FROM `'.SITE.'_pages` WHERE `id`='.$id); |
83 | + $q1=$remote_connection->query('SELECT * FROM `'.SITE.'_pages` WHERE `page_id`='.$page_id.' ORDER BY `section_order` DESC'); |
84 | + if(!$q0||!$q1) return false; |
85 | + $r0=$q0->fetch_assoc(); |
86 | + $r1=$q1->fetch_assoc(); |
87 | + $old_pos=$r0['section_order']; |
88 | + $max_pos=$r1['section_order']; |
89 | + $new_pos=$old_pos-$where; |
90 | + if($new_pos<1||$new_pos>$max_pos) return false; |
91 | + return $remote_connection->query('UPDATE `'.SITE.'_pages` SET `section_order` = IF( `section_order` ='.$old_pos.', '.$new_pos.', '.$old_pos.' ) WHERE `section_order` IN ( '.$old_pos.', '.$new_pos.' )'); |
92 | + } |
93 | + function edit_page($id,$new_props) { |
94 | + global $remote_connection; |
95 | + $sets=''; |
96 | + foreach($new_props as $col=>$prop) { |
97 | + $sets.='`'.$col.'`=\''.$prop.'\', '; |
98 | + } |
99 | + $sets=substr($sets,0,-2); |
100 | + return $remote_connection->query('UPDATE `'.SITE.'_pageindex` SET '.$sets.' WHERE `id`='.$id); |
101 | + } |
102 | + function edit_section($id,$new_props) { |
103 | + global $remote_connection; |
104 | + $sets=''; |
105 | + foreach($new_props as $col=>$prop) { |
106 | + $sets.='`'.$col.'`=\''.$prop.'\', '; |
107 | + } |
108 | + $sets=substr($sets,0,-2); |
109 | + return $remote_connection->query('UPDATE `'.SITE.'_pages` SET '.$sets.' WHERE `id`='.$id); |
110 | + } |
111 | +} |
112 | \ No newline at end of file |
113 | |
114 | === modified file 'cpanel-incs/plugins/cms/default.php' |
115 | --- cpanel-incs/plugins/cms/default.php 2011-01-21 08:42:04 +0000 |
116 | +++ cpanel-incs/plugins/cms/default.php 2011-01-21 08:48:59 +0000 |
117 | @@ -13,13 +13,13 @@ |
118 | if(!hasSiteAddonLevel()) {$session->log('403','Site access denied ('.$site.')'); exit;} //Kill & log non-siteadmins (ze zouden hier nooit mogen geweest zijn :) |
119 | if(!isset($_GET['function'])) { $_GET['function']="list"; } |
120 | if($_GET['function']=="list") { |
121 | - $query = $remote_connection->query('SELECT * FROM `'.$site.'_pageindex` ORDER BY `page_order` ASC'); ?> |
122 | + $pagesq = cms::get_pages();?> |
123 | <table><tr><th></th><th colspan="2"><?php echo $t->_('Title'); ?></th><th title="<?php $t->_("Link path"); ?>"><?php $t->_("Link"); ?></th><th><?php $t->_("Actions"); ?></th></tr> |
124 | -<?php while ($pages = $query->fetch_assoc()) { ?> |
125 | +<?php foreach($pagesq as $pages) { ?> |
126 | <tr><td <?php if($pages['type']=='0'||$pages['type']=='2') { ?> ondblclick="cms.page.edit_rights.expand('<?php echo $site; ?>','<?php echo $pages['id']; ?>',this,'<?php echo $pages['access']; ?>')"><img src="<?php echo URL_IMG; ?>/Silk/bullet_<?php if($pages['access']==0) { ?>green<?php } else if($pages['access']==1) { ?>orange<?php } else if($pages['access']==2) { ?>red<?php } ?>.png"><?php } else { ?>><img src="<?php echo URL_IMG; ?>/Silk/link.png"><?php } ?></td><td colspan="2" ondblclick="cms.page.edit_title.expand('<?php echo $site; ?>','<?php echo $pages['id']; ?>',this)"><?php echo $pages['page_title']; ?></td><td<?php if($pages['type']=='0'||$pages['type']=='2') { ?>>/<?php echo $pages['id'].'-'.preg_replace('/[^a-zA-Z0-9]/','_',$pages['page_title']);?><?php } else { ?> ondblclick="cms.page.edit_link.expand('<?php echo $site; ?>','<?php echo $pages['id']; ?>',this)"><?php echo $pages['link']; ?><?php }?></td><td><?php if($pages['type']=='0'||$pages['type']=='1') { ?><a onclick="cms.page.delete('<?php echo $site; ?>','<?php echo $pages['id'] ?>');"><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete page'); ?>"></a> <?php } ?><a onclick="cms.page.edit_order.down('<?php echo $site; ?>','<?php echo $pages['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move the page down'); ?>"></a> <a onclick="cms.page.edit_order.up('<?php echo $site; ?>','<?php echo $pages['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move the page up'); ?>"></a> <a onclick="cms.page.visiblity.<?php if($pages['visible']){ echo "off";} else { echo "on";} ?>('<?php echo $site; ?>','<?php echo $pages['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/lightbulb<?php if(!$pages['visible']) { echo "_off";} ?>.png" alt="<?php if($pages['visible']) { echo $t->_('Visible');} else { echo $t->_('Invisible');} ?>" title="<?php if($pages['visible']) { echo $t->_('Make page invisible');} else { echo $t->_('Make page visible');} ?>"></a></td></tr> |
127 | <?php if($pages['type']=='0'||$pages['type']=='2') { |
128 | - $query2 = $remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `page_id`='.$pages['id'].' ORDER BY `section_order` ASC'); |
129 | - while ($sections = $query2->fetch_assoc()) {?> |
130 | + $sectionsq = cms::get_sections($pages['id']); |
131 | + foreach ($sectionsq as $sections) {?> |
132 | <tr><td> </td><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_black.png"></td><td ondblclick="cms.section.edit_title.expand('<?php echo $site; ?>','<?php echo $sections['id']; ?>',this)"><?php echo $sections['section_title']; ?></td><td>/<?php echo $pages['id'].'-'.preg_replace('/[^a-zA-Z0-9]/','_',$pages['page_title']).'/#'.preg_replace('/[^a-zA-Z0-9]/','_',$sections['section_title']); ?></td><td><a onclick="cms.section.delete('<?php echo $site; ?>','<?php echo $sections['id'] ?>');"><?php if($sections['type']==0) { ?><img src="<?php echo URL_IMG; ?>/Silk/delete.png" alt="<?php echo $t->_('Delete'); ?>" title="<?php echo $t->_('Delete section'); ?>"></a> <?php } ?><a onclick="cms.section.edit_order.down('<?php echo $site; ?>','<?php echo $sections['id'];?>',this);"><img src="<?php echo URL_IMG ?>/Silk/arrow_down.png" alt="<?php echo $t->_('Down'); ?>" title="<?php echo $t->_('Move section down'); ?>"></a> <a onclick="cms.section.edit_order.up('<?php echo $site; ?>','<?php echo $sections['id']; ?>');"><img src="<?php echo URL_IMG ?>/Silk/arrow_up.png" alt="<?php echo $t->_('Up'); ?>" title="<?php echo $t->_('Move section up'); ?>"></a> <?php if($sections['type']==0) { ?><a onclick="cms.section.open_mce('<?php echo $site; ?>','<?php echo $sections['id']; ?>');"><img src="<?php echo URL_IMG; ?>/Silk/pencil.png" alt="<?php echo $t->_('Edit'); ?>" title="<?php echo $t->_('Edit section content'); ?>"></a> <?php } ?><a onclick="cms.section.switch_page.expand('<?php echo $site; ?>','<?php echo $sections['id']; ?>','<?php echo $pages['id']; ?>',this)"><img src="<?php echo URL_IMG; ?>/Silk/arrow_switch.png" alt="<?php echo $t->_('Other page'); ?>" title="<?php echo $t->_('Move this section to another page'); ?>"></a></td></tr> |
133 | <?php } ?> |
134 | <tr onclick="cms.section.add('<?php echo $site; ?>',<?php echo $pages['id']; ?>)" class="<?php echo $site; ?>_cms_page_<?php echo $pages['id']?>_sections cms_page_sections"><td> </td><td><img src="<?php echo URL_IMG; ?>/Silk/bullet_add.png" alt=""></td><td colspan="3"><?php echo $t->_('Add a section to this page'); ?></td></tr> |
135 | @@ -30,34 +30,12 @@ |
136 | <?php } |
137 | else if($_GET['function']=="delete") { |
138 | if($_GET['type']=="page" && $_GET['id']!=1) { |
139 | - $query0=$remote_connection->query('DELETE FROM `'.$site.'_pages` WHERE `page_id`='.$_GET['id']); |
140 | - if(!$query0) { |
141 | - echo "false"; |
142 | - exit; //DO NOT execute page delete query (else memory waste!) |
143 | - } |
144 | - $q= $remote_connection->query('DELETE FROM `'.$site.'_pageindex` WHERE `id`='.$_GET['id']); |
145 | - //Rearrange order |
146 | - $res=$remote_connection->query('SELECT * FROM `'.$site.'_pageindex` ORDER BY `page_order` ASC'); |
147 | - $order=0; |
148 | - while($nul=$res->fetch_assoc()) { |
149 | - $order++; |
150 | - $remote_connection->query('UPDATE `'.$site.'_pageindex` SET page_order='.$order.' WHERE `id`='.$nul['id']); |
151 | - } |
152 | - if($q) { echo "true"; } else { echo "false"; } |
153 | + if(cms::delete_page($_GET['id'])) echo "true"; |
154 | + else echo "false"; |
155 | } |
156 | else if($_GET['type']=="section") { |
157 | - $res=$remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `id`='.$_GET['id']); |
158 | - $page=$res->fetch_assoc(); |
159 | - $page=$page['page_id']; |
160 | - $q= $remote_connection->query('DELETE FROM `'.$site.'_pages` WHERE `id`='.$_GET['id']); |
161 | - //Rearrange order |
162 | - $res=$remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `page_id`='.$page.' ORDER BY `section_order` ASC'); |
163 | - $order=0; |
164 | - while($nul=$res->fetch_assoc()) { |
165 | - $order++; |
166 | - $remote_connection->query('UPDATE `'.$site.'_pages` SET `section_order`='.$order.' WHERE `id`='.$nul['id']); |
167 | - } |
168 | - if($q) { echo "true"; } else { echo "false"; } |
169 | + if(cms::delete_section($_GET['id'])) echo "true"; |
170 | + else echo "false"; |
171 | } |
172 | } |
173 | else if($_GET['function']=="edit_title") { |
174 | @@ -72,77 +50,30 @@ |
175 | } |
176 | else if($_GET['function']=="move") { |
177 | if($_GET['type']=="page") { |
178 | - $query0=$remote_connection->query('SELECT * FROM `'.$site.'_pageindex` WHERE `id`='.$_GET['id']); |
179 | - if(!$query0) { echo "false"; exit; } //KILL bij query fout (vermijd foute update) |
180 | - $res0=$query0->fetch_assoc(); |
181 | - $old_pos=$res0['page_order']; |
182 | - if($_GET['move']=="up") { |
183 | - $new_pos=$old_pos-1; |
184 | - } |
185 | - else if($_GET['move']=="down") { |
186 | - $new_pos=$old_pos+1; |
187 | - } |
188 | - if(!isset($new_pos)||$new_pos<1) { |
189 | - echo "false"; |
190 | - exit; //DO NOT execute query |
191 | - } |
192 | - $query1=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `page_order` = IF( `page_order` ='.$old_pos.', '.$new_pos.', '.$old_pos.' ) WHERE `page_order` IN ( '.$old_pos.', '.$new_pos.' )'); |
193 | - if($query1) { echo "true"; } else { echo "false"; } |
194 | + if($_GET['move']=="up") $q=cms::move_page($_GET['id'],1); |
195 | + else if($_GET['move']=="down") $q=cms::move_page($_GET['id'],-1); |
196 | + if($q) echo "true"; |
197 | + else echo "false"; |
198 | } |
199 | else if($_GET['type']=="section") { |
200 | - $query0=$remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `id`='.$_GET['id']); |
201 | - if(!$query0) { echo "false"; exit; } //KILL bij query fout (vermijd foute update) |
202 | - $res0=$query0->fetch_assoc(); |
203 | - $old_pos=$res0['section_order']; |
204 | - if($_GET['move']=="up") { |
205 | - $new_pos=$old_pos-1; |
206 | - } |
207 | - else if($_GET['move']=="down") { |
208 | - $new_pos=$old_pos+1; |
209 | - } |
210 | - if(!isset($new_pos)||$new_pos<1) { |
211 | - echo "false"; |
212 | - exit; //DO NOT execute query |
213 | - } |
214 | - $query1=$remote_connection->query('UPDATE `'.$site.'_pages` SET `section_order` = IF( `section_order` ='.$old_pos.', '.$new_pos.', '.$old_pos.' ) WHERE `section_order` IN ( '.$old_pos.', '.$new_pos.' )'); |
215 | - if($query1) { echo "true"; } else { echo "false"; } |
216 | + if($_GET['move']=="up") $q=cms::move_section($_GET['id'],1); |
217 | + else if($_GET['move']=="down") $q=cms::move_section($_GET['id'],-1); |
218 | + if($q) echo "true"; |
219 | + else echo "false"; |
220 | } |
221 | } |
222 | else if($_GET['function']=="new") { |
223 | if($_GET['type']=="page") { |
224 | - $query0=$remote_connection->query('SELECT * FROM `'.$site.'_pageindex` ORDER BY `page_order` DESC'); |
225 | - if(!$query0) { |
226 | - echo "false"; |
227 | - exit; //DO NOT execute query, error with first request. |
228 | - } |
229 | - $res0=$query0->fetch_assoc(); |
230 | - $order_last=$res0['page_order']; |
231 | - $new_order_last=$order_last+1; |
232 | - $q=$remote_connection->query('INSERT INTO `'.$site.'_pageindex` VALUES(NULL,0,'.$new_order_last.',"'.$t->_('New page').'","",0,1)'); |
233 | - if($q) { echo "true"; } else { echo "false"; } |
234 | + if(cms::add_page(array('page_title'=>$t->_('New page')))) echo "true"; |
235 | + else echo "false"; |
236 | } |
237 | else if($_GET['type']=="section") { |
238 | - $query0=$remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `page_id`='.$_GET['page'].' ORDER BY `section_order` DESC'); |
239 | - $res0=$query0->fetch_assoc(); |
240 | - $order_last=$res0['section_order']; |
241 | - if(!$query0) { |
242 | - $order_last=0; //No sections? |
243 | - } |
244 | - $new_order_last=$order_last+1; |
245 | - $q=$remote_connection->query('INSERT INTO `'.$site.'_pages` VALUES(NULL, '.$_GET['page'].',0,'.$new_order_last.',"'.$t->_('New section').'", "")'); |
246 | - if($q) { echo "true"; } else { echo "false"; } |
247 | + if(cms::add_section($_GET['page'],array('section_title'=>$t->_('New section')))) echo "true"; |
248 | + else echo "false"; |
249 | } |
250 | else if($_GET['type']=="link") { |
251 | - $query0=$remote_connection->query('SELECT * FROM `'.$site.'_pageindex` ORDER BY `page_order` DESC'); |
252 | - if(!$query0) { |
253 | - echo "false"; |
254 | - exit; //DO NOT execute query, error with first request. |
255 | - } |
256 | - $res0=$query0->fetch_assoc(); |
257 | - $order_last=$res0['page_order']; |
258 | - $new_order_last=$order_last+1; |
259 | - $q=$remote_connection->query('INSERT INTO `'.$site.'_pageindex` VALUES(NULL, 1, '.$new_order_last.',"'.$t->_('New link').'","#",0,1)'); |
260 | - if($q) { echo "true"; } else { echo "false"; } |
261 | + if(cms::add_page(array('type'=>1,'page_title'=>$t->_('New link'),'link'=>'#'))) echo "true"; |
262 | + else echo "false"; |
263 | } |
264 | } |
265 | else if($_GET['function']=="switch_page") { |
266 | @@ -162,41 +93,32 @@ |
267 | $res0=$query0->fetch_assoc(); |
268 | $order_last=$res0['section_order']; |
269 | $new_order_last=$order_last+1; |
270 | - $query1=$remote_connection->query('UPDATE `'.$site.'_pages` SET `page_id`='.$_GET['newpage'].', `section_order`='.$new_order_last.' WHERE `id`='.$_GET['id']); |
271 | - if($query1) { echo "true"; } |
272 | - else { echo "false"; } |
273 | + if(cms::edit_section($_GET['id'],array('page_id'=>$_GET['newpage'],'section_order'=>$new_order_last))) echo "true"; |
274 | + else echo "false"; |
275 | } |
276 | } |
277 | else if($_GET['function']=="edit_link") { |
278 | $_GET['newlink']=urldecode($_GET['newlink']); |
279 | - $query=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `link`="'.$_GET['newlink'].'" WHERE `id`='.$_GET['id']); |
280 | - if($query) { echo "true"; } |
281 | - else { echo "false"; } |
282 | + if(cms::edit_page($_GET['id'],array('link'=>$_GET['newlink']))) echo "true"; |
283 | + else echo "false"; |
284 | } |
285 | else if($_GET['function']=="edit_rights") { |
286 | - $query=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `access`='.$_GET['rights'].' WHERE `id`='.$_GET['id']); |
287 | - if($query) { echo "true"; } |
288 | - else { echo "false"; } |
289 | + if(cms::edit_page($_GET['id'],array('access'=>$_GET['rights']))) echo "true"; |
290 | + else echo "false"; |
291 | } |
292 | else if($_GET['function']=="visiblity") { |
293 | - if($_GET['v']=="on") { |
294 | - $query=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `visible`=1 WHERE `id`='.$_GET['id']); |
295 | - if($query) { echo "true"; } |
296 | - else { echo "false"; } |
297 | - } |
298 | - if($_GET['v']=="off") { |
299 | - $query=$remote_connection->query('UPDATE `'.$site.'_pageindex` SET `visible`=0 WHERE `id`='.$_GET['id']); |
300 | - if($query) { echo "true"; } |
301 | - else { echo "false"; } |
302 | - } |
303 | + if($_GET['v']=="on") $q=cms::edit_page($_GET['id'],array('visible'=>1)); |
304 | + if($_GET['v']=="off") $q=cms::edit_page($_GET['id'],array('visible'=>1)); |
305 | + if($q) echo "true"; |
306 | + else echo "false"; |
307 | } |
308 | else if($_GET['function']=="mce") { |
309 | if(isset($_GET['save'])) { |
310 | - if($remote_connection->query('UPDATE `'.$site.'_pages` SET `section_main`="'.str_replace('"','\'',$_POST['section_main']).'" WHERE `id`='.$_GET['id'])) |
311 | - { echo '<script language="JavaScript">alert("'.$t->_('Saved').'");</script>'; } |
312 | - else { echo '<script language="JavaScript">alert("'.$t->_('Error while saving').'");</script>'; } |
313 | + if(cms::edit_section($_GET['id'],array('section_main'=>$remote_connection->escape($_POST['section_main'])))) echo '<script language="JavaScript">alert("'.$t->_('Saved').'");</script>'; |
314 | + else echo '<script language="JavaScript">alert("'.$t->_('Error while saving').'");</script>'; |
315 | } |
316 | - $edit_data=$remote_connection->query('SELECT * FROM `'.$site.'_pages` WHERE `id`='.$_GET['id'])->fetch_assoc();?> |
317 | + $edit_data=cms::get_section($_GET['id']); |
318 | +?> |
319 | <script language="JavaScript" src="<?php echo URL_TINYMCE; ?>/tiny_mce/tiny_mce.js"></script> |
320 | <script type="text/javascript"> |
321 | |
322 | |
323 | === added file 'cpanel-incs/plugins/init.php' |
324 | --- cpanel-incs/plugins/init.php 1970-01-01 00:00:00 +0000 |
325 | +++ cpanel-incs/plugins/init.php 2011-01-21 08:48:59 +0000 |
326 | @@ -0,0 +1,1 @@ |
327 | +<?php |
328 | $dh=opendir('cpanel-incs/plugins'); |
329 | $PLUGINS=array(); |
330 | while($file=readdir($dh)) { |
331 | if($file=='.'||$file=='..') continue; |
332 | if(is_dir('cpanel-incs/plugins/'.$file)) |
333 | $PLUGINS[]=$file; |
334 | } |
335 | foreach($PLUGINS as $plugin) { |
336 | if(file_exists('cpanel-incs/plugins/'.$plugin.'/api.php')) |
337 | require('cpanel-incs/plugins/'.$plugin.'/api.php'); |
338 | } |
339 | \ No newline at end of file |
340 | |
341 | === modified file 'inc/accountlevels.php' |
342 | --- inc/accountlevels.php 2011-01-19 18:02:42 +0000 |
343 | +++ inc/accountlevels.php 2011-01-21 08:48:59 +0000 |
344 | @@ -12,6 +12,7 @@ |
345 | //exit; |
346 | } |
347 | $site=addslashes($site); |
348 | +define('SITE',$site); |
349 | |
350 | function getLevel($user,$ref) { |
351 | global $remote_connection; |
352 | |
353 | === modified file 'panel.php' |
354 | --- panel.php 2011-01-19 18:02:42 +0000 |
355 | +++ panel.php 2011-01-21 08:48:59 +0000 |
356 | @@ -257,6 +257,7 @@ |
357 | require_once('cpanel-incs/cms.php'); |
358 | } |
359 | else if($_GET['control']=="addons") { |
360 | + require_once('cpanel-incs/plugins/init.php'); //Load APIs |
361 | //Load cpanel-incs/plugins/?????.php |
362 | if(!require_once('cpanel-incs/plugins/'.$_GET['aref'].'/default.php')) { exit; } |
363 | } |