1 | <?php
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * odl_admin_structure.php
|
---|
5 | * wordpress plugin open directory project
|
---|
6 | * @author Mohammad Forgani
|
---|
7 | * @copyright Copyright 2008, Oh Jung-Su
|
---|
8 | * @version 1.0.0-a
|
---|
9 | * @link http://www.forgani.com
|
---|
10 | */
|
---|
11 |
|
---|
12 |
|
---|
13 | function process_odlinksposts(){
|
---|
14 | global $_GET, $_POST, $table_prefix, $PHP_SELF, $wpdb;
|
---|
15 | $odlinkssettings=get_option('odlinksdata');
|
---|
16 | $loadpage=true;
|
---|
17 |
|
---|
18 | ?>
|
---|
19 | <div class="wrap"><h2>ODLinks - Edit/Remove links</h2><p>
|
---|
20 | <input type="button" value="Main" onclick="document.location.href='<?php echo $PHP_SELF;?>?page=odlinksposts&odlinks_admin_page_arg=<?php echo $_GET['odlinks_admin_page_arg'];?>&odlinks_admin_action=main&id=0';">
|
---|
21 |
|
---|
22 | <input type="button" value="Approve" onclick="document.location.href='<?php echo $PHP_SELF;?>?page=odlinksposts&odlinks_admin_page_arg=<?php echo $_GET['odlinks_admin_page_arg'];?>&odlinks_admin_action=approvelinks&id=0';">
|
---|
23 |
|
---|
24 | <input type="button" value="Banned" onclick="document.location.href='<?php echo $PHP_SELF;?>?page=odlinksposts&odlinks_admin_page_arg=<?php echo $_GET['odlinks_admin_page_arg'];?>&odlinks_admin_action=bannedlinks&id=0';">
|
---|
25 |
|
---|
26 | <?php
|
---|
27 | switch($_GET['odlinks_admin_action']){
|
---|
28 | case "main":
|
---|
29 | odlinksadmin_main_links($_GET['id']*1, $_GET['action']);
|
---|
30 | $loadpage=false;
|
---|
31 | break;
|
---|
32 | case "approvelinks":
|
---|
33 | odlinksadmin_approve_links($_GET['id']*1, $_GET['action']);
|
---|
34 | $loadpage=false;
|
---|
35 | break;
|
---|
36 | case "bannedlinks":
|
---|
37 | odlinksadmin_banned_links($_GET['id']*1, $_GET['action']);
|
---|
38 | $loadpage=false;
|
---|
39 | break;
|
---|
40 | case "editlinks":
|
---|
41 | odlinksadmin_edit_links($_GET['id']*1);
|
---|
42 | $loadpage=false;
|
---|
43 | break;
|
---|
44 | case "editban":
|
---|
45 | odlinksadmin_edit_ban($_GET['id']*1);
|
---|
46 | $loadpage=false;
|
---|
47 | break;
|
---|
48 | }
|
---|
49 |
|
---|
50 | if($msg!='')
|
---|
51 | echo '<div id="message" class="updated fade">' . $msg . '</div>';
|
---|
52 | if($loadpage==true)
|
---|
53 | odlinksadmin_main_links(0, 0);
|
---|
54 | echo '</div>';
|
---|
55 | }
|
---|
56 |
|
---|
57 |
|
---|
58 | function odlinksadmin_approve_links($id, $action){
|
---|
59 | global $_GET, $_POST, $wpdb, $table_prefix;
|
---|
60 | $odlinkssettings=get_option('odlinksdata');
|
---|
61 | $linkb=$PHP_SELF."?page=odlinksposts&odlinks_admin_page_arg=odlinksposts";
|
---|
62 | if(isset($id) && $action){
|
---|
63 | switch($action){
|
---|
64 | case "ok":
|
---|
65 | ?><p>Approving new link ....</p><?
|
---|
66 | $sql="SELECT * FROM {$table_prefix}odnew_links WHERE n_id=$id";
|
---|
67 | $news=$wpdb->get_results($sql);
|
---|
68 | for($i=0; $i<count($news); $i++){
|
---|
69 | $new=$news[$i];
|
---|
70 | $warning="";
|
---|
71 | $sql="SELECT * FROM {$table_prefix}odlinks";
|
---|
72 | $result=$wpdb->get_results($sql);
|
---|
73 | for($x=0; $x<count($result); $x++){
|
---|
74 | $row=$result[$x];
|
---|
75 | if($new->n_url == $row>l_id){
|
---|
76 | $warning .= '<font color=red>Warning: This URL already exists:';
|
---|
77 | $warning .= '<a href="'. $linkb . '&odlinks_admin_action=main&id=' .$row->l_id. '">';
|
---|
78 | $warning .= '<img border=0 src="'. get_bloginfo('wpurl') . '"/wp-content/plugins/odlinks/images/edit.gif"></a></font><p>';
|
---|
79 | }
|
---|
80 | }
|
---|
81 | ?>
|
---|
82 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=approvelinks&id=<?php echo $new->n_id; ?>&action=insert">
|
---|
83 | <input type="hidden" name="odlinksdata[new_link]" value="1"> <?php $warning?> URL:<br>
|
---|
84 | <input type="text" name="odlinksdata[url]" value="<?php echo $new->n_url?>" size="80">
|
---|
85 | <a target="_blank" href="<?php $new->n_url?>"><img src="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/odlinks/images/nw2.png"></a> <p> Title:<br>
|
---|
86 | <input type="text" name="odlinksdata[title]" value="<?php echo $new->n_title; ?>" size="80"> <p> Email:<br>
|
---|
87 | <input type="text" name="odlinksdata[email]" value="<?php echo $new->n_email; ?>" size="80">
|
---|
88 | <p> Description:<br>
|
---|
89 | <textarea rows="5" name="odlinksdata[description]" cols="60"><?php echo $new->n_description?></textarea>
|
---|
90 | <p> Visible?<br>
|
---|
91 | <select name="odlinksdata[visible]">
|
---|
92 | <option value="1">visible</option>
|
---|
93 | <option value="0">hide</option>
|
---|
94 | </select><p> Category:<br>
|
---|
95 | <select name="odlinksdata[parent]">
|
---|
96 | <?
|
---|
97 | odl_list_cats(0,0,0,$new->n_category);
|
---|
98 | ?> </select> <p>
|
---|
99 | <input type="submit" value="Add Link!"> <input type=button value="Cancel" onclick="history.go(-1);"></form>
|
---|
100 | <?
|
---|
101 | }
|
---|
102 | break;
|
---|
103 | case "delete":
|
---|
104 | if(isset($_POST['odlinksdata']['delete_link'])){
|
---|
105 | ?><h3>Deleted link...</h3><?
|
---|
106 | $sql="SELECT * FROM {$table_prefix}odnew_links WHERE n_id=$id";
|
---|
107 | $results=$wpdb->get_results($sql);
|
---|
108 | for($i=0; $i<count($results); $i++){
|
---|
109 | $row=$results[$i];
|
---|
110 | echo "URL: ".$row->n_url."<br>";
|
---|
111 | echo "Title: ".$row->n_title."<br>";
|
---|
112 | echo "Description: ".$row->n_description."<br>";
|
---|
113 | echo "Email: ".$row->n_email."<br>";
|
---|
114 | }
|
---|
115 |
|
---|
116 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=approvelinks");
|
---|
117 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
118 |
|
---|
119 | $sql="DELETE FROM {$table_prefix}odnew_links WHERE n_id=$id";
|
---|
120 | $wpdb->query($sql);
|
---|
121 | }else{
|
---|
122 | ?><h3>Removing a new link...</h3><?
|
---|
123 | $sql="SELECT * FROM {$table_prefix}odnew_links WHERE n_id=$id";
|
---|
124 | $results=$wpdb->get_results($sql);
|
---|
125 | for($i=0; $i<count($results); $i++){
|
---|
126 | $row=$results[$i];
|
---|
127 | ?>
|
---|
128 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=approvelinks&action=delete&id=<?php echo $id; ?>" method="POST">
|
---|
129 | <p>Are you sure you want to delete the website <strong><?php echo $row->n_url ?></strong>?</p>
|
---|
130 | <input type="submit" name="odlinksdata[delete_link]" value="Delete Link"> <input type=button value="Cancel" onclick="history.go(-1);"></form>
|
---|
131 | <?php
|
---|
132 | }
|
---|
133 | }
|
---|
134 | break;
|
---|
135 | case "insert":
|
---|
136 | $url=$_POST['odlinksdata']['url'];
|
---|
137 | $title=$_POST['odlinksdata']['title'];
|
---|
138 | $description=$_POST['odlinksdata']['description'];
|
---|
139 | $parent=$_POST['odlinksdata']['parent'];
|
---|
140 | $email=$_POST['odlinksdata']['email'];
|
---|
141 | $sql="INSERT INTO {$table_prefix}odlinks (l_url, l_title, l_description, l_c_id, l_date, l_hide, l_author_mail) VALUES ('".$url."', '".$title."', '".$description."', '".$parent."', '".date("Y-m-d")."', 'visible', '".$email."')";
|
---|
142 | $wpdb->query($sql);
|
---|
143 | ?>
|
---|
144 | <p>New link added:</p>
|
---|
145 | <br> URL: <?php echo $url?>
|
---|
146 | <br> Title: <?php echo $title?>
|
---|
147 | <br> Email: <?php echo $email?>
|
---|
148 | <br> Description: <?php echo $description?>
|
---|
149 | <br> Category id: <?php echo $parent?>
|
---|
150 | <?php
|
---|
151 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=approvelinks");
|
---|
152 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
153 | $sql="DELETE FROM {$table_prefix}odnew_links WHERE n_url='$url'";
|
---|
154 | $wpdb->query($sql);
|
---|
155 | break;
|
---|
156 |
|
---|
157 | case "edit":
|
---|
158 | $id=$_POST['odlinksdata']['id'];
|
---|
159 | $url=$_POST['odlinksdata']['url'];
|
---|
160 | $title=$_POST['odlinksdata']['title'];
|
---|
161 | $description=$_POST['odlinksdata']['description'];
|
---|
162 | $parent=$_POST['odlinksdata']['parent'];
|
---|
163 | $email=$_POST['odlinksdata']['email'];
|
---|
164 | $sql="update {$table_prefix}odlinks (l_url, l_title, l_description, l_c_id, l_hide, l_author_mail) VALUES ('".$url."', '".$title."', '".$description."', '".$parent."', 'visible', '".$email."') WHERE l_id=" .$id;
|
---|
165 | $wpdb->query($sql);
|
---|
166 | ?>
|
---|
167 | <p>Updated:</p>
|
---|
168 | <br> URL: <?php echo $url?>
|
---|
169 | <br> Title: <?php echo $title?>
|
---|
170 | <br> Email: <?php echo $email?>
|
---|
171 | <br> Description: <?php echo $description?>
|
---|
172 | <br> Category id: <?php echo $parent?> <p>
|
---|
173 | <p>
|
---|
174 | <?php
|
---|
175 | break;
|
---|
176 | case "ban":
|
---|
177 | if(isset($_POST['odlinksdata']['new_ban'])){
|
---|
178 | $new_ban_url=$_POST['odlinksdata']['new_ban_url'];
|
---|
179 | ?>
|
---|
180 | <h3><?php echo $new_ban_url; ?>The site removed from the approval list.</h3>
|
---|
181 | <?php
|
---|
182 | $sql="DELETE FROM {$table_prefix}odnew_links WHERE n_id=". $id;
|
---|
183 | $wpdb->query($sql);
|
---|
184 | $sql="INSERT INTO {$table_prefix}odbanned (c_domain) VALUES('".$new_ban_url."')";
|
---|
185 | $wpdb->query($sql);
|
---|
186 | echo "and added as ban to the banned list!";
|
---|
187 | }else{
|
---|
188 | ?><h3>Banning a new link/site ...</h3>
|
---|
189 | <?php
|
---|
190 | $sql="SELECT * FROM {$table_prefix}odnew_links WHERE n_id=".$id;
|
---|
191 | $results=$wpdb->get_results($sql);
|
---|
192 | for($i=0; $i<count($results); $i++){
|
---|
193 | $row=$results[$i];
|
---|
194 | ?>
|
---|
195 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=approvelinks&id=<?php echo $row->n_id; ?>&action=ban" method="POST">
|
---|
196 | The URL, or URL parts to be added to the "banned URLs" list:<br />
|
---|
197 | <input type="text" name="odlinksdata[new_ban_url]" size="80" value="<?php echo $row->n_url?>"><p>
|
---|
198 | <input type="submit" name="odlinksdata[new_ban]" value="Submit"> <input type=button value="Cancel" onclick="history.go(-1);"></form>
|
---|
199 | <?
|
---|
200 | }
|
---|
201 | }
|
---|
202 | break;
|
---|
203 | }
|
---|
204 | }else{
|
---|
205 | ?>
|
---|
206 | <p>Newly submitted links ready to be approved:</P>
|
---|
207 | <?
|
---|
208 | $sql="SELECT * FROM {$table_prefix}odnew_links LIMIT 0, 10";
|
---|
209 | $results=$wpdb->get_results($sql);
|
---|
210 | if(!empty($results)){
|
---|
211 | ?>
|
---|
212 | <table width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td>
|
---|
213 | <table width="100%" cellspacing="1" cellpadding="3" border="0"><tr bgcolor="#CCCCCC"><td>Ok</td>
|
---|
214 | <td>Website URL </td>
|
---|
215 | <td>Title & Description</td>
|
---|
216 | <td width="3%">Category</td> <td nowrap>Email</td>
|
---|
217 | <td>Delete</td><td>Ban</td> </tr>
|
---|
218 | <?
|
---|
219 | for($i=0; $i<count($results); $i++){
|
---|
220 | $row=$results[$i];
|
---|
221 | ?>
|
---|
222 | <tr bgcolor="#F4F4F4" onMouseOver="this.bgColor='#FFFFFF';" onMouseOut="this.bgColor='#F4F4F4';"><td>
|
---|
223 | <a href="<?php echo $linkb; ?>&odlinks_admin_action=approvelinks&id=<?php echo $row->n_id;?>&action=ok">
|
---|
224 | <img border="0" src="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/odlinks/images/ok.gif"></a></td>
|
---|
225 | <?
|
---|
226 | print "<td><font color=green>".$row->n_url."</font></td>";
|
---|
227 | print "<td><a target=\"_blank\" href=\"".$row->n_url."\">".$row->n_title."</a>";
|
---|
228 | print "<br />".$row->n_description."</font></td>";
|
---|
229 | print "<form><td><select>";
|
---|
230 | odl_list_cats(0,0,0,$row->n_category);
|
---|
231 | print "</select></td></form>";
|
---|
232 | print "<td>".$row->n_email."</td>"; ?><td>
|
---|
233 | <a href="<?php echo $linkb ?>&odlinks_admin_action=approvelinks&id=<?php echo $row->n_id?>&action=delete"><img border="0" src="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/odlinks/images/delete.png"></a></td><td>
|
---|
234 | <a href="<?php echo $linkb ?>&odlinks_admin_action=approvelinks&id=<?php echo $row->n_id?>&action=ban"><img border="0" src="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/odlinks/images/ban.jpg"></a></td></tr><?
|
---|
235 | } ?>
|
---|
236 | </table></td></tr></table><?
|
---|
237 | }
|
---|
238 | }
|
---|
239 | }
|
---|
240 |
|
---|
241 |
|
---|
242 | function odlinksadmin_banned_links($id, $action){
|
---|
243 | global $_GET, $_POST, $wpdb, $table_prefix;
|
---|
244 | $odlinkssettings=get_option('odlinksdata');
|
---|
245 | $linkb=$PHP_SELF."?page=odlinksposts&odlinks_admin_page_arg=odlinksposts";
|
---|
246 | if(isset($id) && $action){
|
---|
247 | switch($action){
|
---|
248 | case "insert":
|
---|
249 | $url=$_POST['odlinksdata']['url'];
|
---|
250 | $sql="INSERT INTO {$table_prefix}odbanned (c_domain) VALUES('".$url."')";
|
---|
251 | $wpdb->query($sql);
|
---|
252 | ?>
|
---|
253 | <p>The record added to the list of banned IP addresses.</p>
|
---|
254 | <b>Record:</b> <?php echo $url?><br>
|
---|
255 | <?php
|
---|
256 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=bannedlinks");
|
---|
257 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
258 | break;
|
---|
259 | case "edit":
|
---|
260 | $sql="SELECT * FROM {$table_prefix}odbanned WHERE b_id=$id";
|
---|
261 | $results=$wpdb->get_results($sql);
|
---|
262 | for($i=0; $i<count($results); $i++){
|
---|
263 | $row=$results[$i];
|
---|
264 | ?>
|
---|
265 | <P>
|
---|
266 | <style type="text/css">
|
---|
267 | fieldset {
|
---|
268 | padding: 1em;
|
---|
269 | font:12px;
|
---|
270 | font-weight:bold;
|
---|
271 | border:1px solid #ddd;
|
---|
272 | }
|
---|
273 | label {
|
---|
274 | float:left;
|
---|
275 | width:25%;
|
---|
276 | margin-right:0.5em;
|
---|
277 | padding-top:0.2em;
|
---|
278 | text-align:right;
|
---|
279 | font-weight:bold;}
|
---|
280 | </style>
|
---|
281 |
|
---|
282 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=editban&id=<?php echo $row->b_id; ?>">
|
---|
283 | <fieldset>
|
---|
284 | <legend>Edit Banned Strings/Urls</legend>
|
---|
285 | <input type="hidden" name="odlinksdata[id]" value="<?php echo $row->b_id; ?>">
|
---|
286 | <label>String:</label>
|
---|
287 | <input type="text" name="odlinksdata[url]" value="<?php echo $row->c_domain; ?>" size="80">
|
---|
288 | <P><label> </label>
|
---|
289 | <input type="submit" value="Save"> <input type=button value="Cancel" onclick="history.go(-1);">
|
---|
290 | </fieldset>
|
---|
291 | </form>
|
---|
292 | <?
|
---|
293 | }
|
---|
294 | break;
|
---|
295 | case "delete":
|
---|
296 | if(isset($_POST['odlinksdata']['delete_ban'])){
|
---|
297 | ?><h3>The selected ban record deleted from the list successfully.</h3><?
|
---|
298 | $sql="SELECT * FROM {$table_prefix}odbanned WHERE b_id=$id";
|
---|
299 | $results=$wpdb->get_results($sql);
|
---|
300 | for($i=0; $i<count($results); $i++){
|
---|
301 | $row=$results[$i];
|
---|
302 | echo "<b>Record: </b>".$row->c_domain."<br>";
|
---|
303 | }
|
---|
304 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=bannedlinks");
|
---|
305 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
306 |
|
---|
307 | $sql="DELETE FROM {$table_prefix}odbanned WHERE b_id=$id";
|
---|
308 | $wpdb->query($sql);
|
---|
309 | }else{
|
---|
310 | ?><h3>Removing a Banned record...</h3><?
|
---|
311 | $sql="SELECT * FROM {$table_prefix}odbanned WHERE b_id=$id";
|
---|
312 | $results=$wpdb->get_results($sql);
|
---|
313 | for($i=0; $i<count($results); $i++){
|
---|
314 | $row=$results[$i];
|
---|
315 | ?>
|
---|
316 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=bannedlinks&id=<?php echo $id; ?>&action=delete" method="POST">
|
---|
317 | <p>Are you sure you want to delete this entry?<br>
|
---|
318 | <strong>String: </strong><?php echo $row->c_domain?></p>
|
---|
319 | <input type="submit" name="odlinksdata[delete_ban]" value="Delete Ban"> <input type=button value="Cancel" onclick="history.go(-1);"></form>
|
---|
320 | <?
|
---|
321 | }
|
---|
322 | }
|
---|
323 | break;
|
---|
324 | }
|
---|
325 | }else{
|
---|
326 | ?>
|
---|
327 | <p>This page displays the banned IP/URL addresses.<br>
|
---|
328 | You can choose to edit or delete a specific ban record.<br>
|
---|
329 | The URLs that contains any banned string will be automatically rejected.</p>
|
---|
330 | <p><b>Add a banned address to the list</b><br>
|
---|
331 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=bannedlinks&id=<?php echo $new->b_id; ?>&action=insert">
|
---|
332 | <input type="hidden" name="odlinksdata[ban_link]" value="1"> <?php $warning?>
|
---|
333 | Record: <input type="text" name="odlinksdata[url]" value="<?php echo $new->b_url?>" size="40">
|
---|
334 | <input type="submit" value="Add Ban!"></p>
|
---|
335 | <HR>
|
---|
336 | <?
|
---|
337 | $sql="SELECT * FROM {$table_prefix}odbanned";
|
---|
338 | $results=$wpdb->get_results($sql);
|
---|
339 | if(!empty($results)){
|
---|
340 | ?>
|
---|
341 | <table width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr><td>
|
---|
342 | <table width="100%" cellspacing="1" cellpadding="3" border="0"><tr bgcolor="#CCCCCC">
|
---|
343 | <td>Edit URL/IP/String</td>
|
---|
344 | <td>Delete</td></tr>
|
---|
345 | <?
|
---|
346 | for($i=0; $i<count($results); $i++){
|
---|
347 | $row=$results[$i];
|
---|
348 | ?>
|
---|
349 | <tr bgcolor="#F4F4F4" onMouseOver="this.bgColor='#FFFFFF';" onMouseOut="this.bgColor='#F4F4F4';">
|
---|
350 | <?
|
---|
351 | echo "<td><a href=\"".$linkb."&odlinks_admin_action=bannedlinks&action=edit&id=".$row->b_id."\">".$row->c_domain."</a>";
|
---|
352 | echo "<td><a href=\"". $linkb ."&odlinks_admin_action=bannedlinks&action=delete&id=".$row->b_id ."\"><img border=0 src=\"" .get_bloginfo('wpurl'). "/wp-content/plugins/odlinks/images/delete.png\"</a>";
|
---|
353 | }
|
---|
354 | ?>
|
---|
355 | </table></td></tr></table><?
|
---|
356 | }
|
---|
357 | }
|
---|
358 | } // odlinksadmin_banned_links
|
---|
359 |
|
---|
360 |
|
---|
361 | function odlinksadmin_edit_links($id){
|
---|
362 | global $_GET, $_POST, $wpdb, $table_prefix;
|
---|
363 | $odlinkssettings=get_option('odlinksdata');
|
---|
364 | if(isset($id)){
|
---|
365 | $id=$_POST['odlinksdata']['id'];
|
---|
366 | $title=$_POST['odlinksdata']['title'];
|
---|
367 | $url=$_POST['odlinksdata']['url'];
|
---|
368 | $description=$_POST['odlinksdata']['description'];
|
---|
369 | $parent=$_POST['odlinksdata']['parent'];
|
---|
370 | $email=$_POST['odlinksdata']['email'];
|
---|
371 | $sql="update {$table_prefix}odlinks set l_url='".$url."',
|
---|
372 | l_title = '".$title."', l_description='".$description."',
|
---|
373 | l_c_id='".$parent."', l_hide='visible', l_author_mail='".$email."' WHERE l_id=" .$id;
|
---|
374 | $wpdb->query($sql);
|
---|
375 | ?>
|
---|
376 | <p>Record updated successfully.</p>
|
---|
377 | <br> URL: <?php echo $url?>
|
---|
378 | <br> Title: <?php echo $title?>
|
---|
379 | <br> Email: <?php echo $email?>
|
---|
380 | <br> Description: <?php echo $description?>
|
---|
381 | <br> Category id: <?php echo $parent?><br>
|
---|
382 | <?php
|
---|
383 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=main");
|
---|
384 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
385 | }
|
---|
386 | }
|
---|
387 |
|
---|
388 | function odlinksadmin_edit_ban($id){
|
---|
389 | global $_GET, $_POST, $wpdb, $table_prefix;
|
---|
390 | $odlinkssettings=get_option('odlinksdata');
|
---|
391 |
|
---|
392 | if(isset($id)){
|
---|
393 | $id=$_POST['odlinksdata']['id'];
|
---|
394 | $url=$_POST['odlinksdata']['url'];
|
---|
395 | $sql="update {$table_prefix}odbanned set c_domain='".$url."' WHERE b_id=" .$id;
|
---|
396 | $wpdb->query($sql);
|
---|
397 | ?>
|
---|
398 | <p>Record updated successfully.</p>
|
---|
399 | <b>String: </b><?php echo $url?><br>
|
---|
400 | <?
|
---|
401 | $url_back = admin_url("admin.php?page=odlinksposts&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=bannedlinks");
|
---|
402 | echo '<p><form method="post" action="'.$url_back.'"><input type="submit" value="<< Back"></form></p>';
|
---|
403 | }
|
---|
404 | }
|
---|
405 |
|
---|
406 | function odlinksadmin_main_links($id, $action){
|
---|
407 | global $table_prefix, $wpdb, $_GET;
|
---|
408 | $linkb=$PHP_SELF."?page=odlinksposts&odlinks_admin_page_arg=odlinksposts";
|
---|
409 | if(isset($id) && $action){
|
---|
410 | switch($action){
|
---|
411 | case "delete":
|
---|
412 | if(isset($_POST['odlinksdata']['delete_link'])){
|
---|
413 | ?><h3>Deleted link...</h3><?
|
---|
414 | $sql="SELECT * FROM {$table_prefix}odlinks WHERE l_id=$id";
|
---|
415 | $results=$wpdb->get_results($sql);
|
---|
416 | for($i=0; $i<count($results); $i++){
|
---|
417 | $row=$results[$i];
|
---|
418 | echo "URL: ".$row->l_url."<br>";
|
---|
419 | echo "Title: ".$row->l_title."<br>";
|
---|
420 | echo "Description: ".$row->l_description."<br>";
|
---|
421 | echo "Email: ".$row->l_author_mail."<br>";
|
---|
422 | }
|
---|
423 | $sql="DELETE FROM {$table_prefix}odlinks WHERE l_id=$id";
|
---|
424 | $wpdb->query($sql);
|
---|
425 | }else{
|
---|
426 | ?><h3>Deleted link ....</h3><?
|
---|
427 | $sql="SELECT * FROM {$table_prefix}odlinks WHERE l_id=$id";
|
---|
428 | $results=$wpdb->get_results($sql);
|
---|
429 | for($i=0; $i<count($results); $i++){
|
---|
430 | $row=$results[$i];
|
---|
431 | ?>
|
---|
432 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=main&id=<?php echo $id; ?>&action=delete">
|
---|
433 | <p>Are you sure you want to delete the website <strong><?php echo $row->l_url?></strong>?</p>
|
---|
434 | <input type="submit" name="odlinksdata[delete_link]" value="Delete Link"> <input type=button value="Cancel" onclick="history.go(-1);"></form>
|
---|
435 | <?php
|
---|
436 | }
|
---|
437 | }
|
---|
438 | break;
|
---|
439 | }
|
---|
440 | } else{
|
---|
441 | $results=$wpdb->get_results("SELECT * FROM {$table_prefix}odlinks WHERE l_id='".$id."'");
|
---|
442 | if(!empty($results)) {
|
---|
443 | for($i=0; $i<count($results); $i++){
|
---|
444 | $row=$results[$i];
|
---|
445 | ?>
|
---|
446 | <P>
|
---|
447 | <style type="text/css">
|
---|
448 | fieldset {
|
---|
449 | padding: 1em;
|
---|
450 | font:12px;
|
---|
451 | font-weight:bold;
|
---|
452 | border:1px solid #ddd;
|
---|
453 | }
|
---|
454 | label {
|
---|
455 | float:left;
|
---|
456 | width:25%;
|
---|
457 | margin-right:0.5em;
|
---|
458 | padding-top:0.2em;
|
---|
459 | text-align:right;
|
---|
460 | font-weight:bold;}
|
---|
461 | </style>
|
---|
462 |
|
---|
463 | <form method="post" id="odl_form_post" name="odl_form_post" action="<?php echo $linkb ?>&odlinks_admin_action=editlinks&id=<?php echo $row->l_id; ?>">
|
---|
464 | <fieldset>
|
---|
465 | <legend>Edit Website</legend>
|
---|
466 | <input type="hidden" name="odlinksdata[id]" value="<?php echo $row->l_id; ?>">
|
---|
467 | <label>URL:</label>
|
---|
468 | <input type="text" name="odlinksdata[url]" value="<?php echo $row->l_url; ?>" size="80">
|
---|
469 | <br><label>Title:</label>
|
---|
470 | <input type="text" name="odlinksdata[title]" value="<?php echo $row->l_title; ?>" size="80">
|
---|
471 | <br><label>Email:</label>
|
---|
472 | <input type="text" name="odlinksdata[email]" value="<?php echo $row->l_author_mail; ?>" size="80">
|
---|
473 | <br><label>Description:</label>
|
---|
474 | <textarea rows="5" name="odlinksdata[description]" cols="60"><?php echo $row->l_description; ?></textarea>
|
---|
475 | <br><label>Visible?</label>
|
---|
476 | <select name="odlinksdata[visible]">
|
---|
477 | <?
|
---|
478 | if($row->l_hide == 'visible'){
|
---|
479 | $yes="SELECTED";
|
---|
480 | } else{
|
---|
481 | $no="SELECTED";
|
---|
482 | }
|
---|
483 | ?>
|
---|
484 | <option <?php $yes?> value="1">Yes</option>
|
---|
485 | <option <?php $no?> value="0">No</option>
|
---|
486 | </select>
|
---|
487 | <br><label>Category:</label><select name="odlinksdata[parent]"> <?php odl_list_cats(0,0,0,$row->l_c_id); ?> </select>
|
---|
488 | <P><label> </label>
|
---|
489 | <input type="submit" value="Save Link!"> <input type=button value="Cancel" onclick="history.go(-1);">
|
---|
490 | </fieldset>
|
---|
491 | </form>
|
---|
492 | <?
|
---|
493 | }
|
---|
494 | } else {
|
---|
495 | $sql="SELECT COUNT(l_id) as count FROM {$table_prefix}odlinks";
|
---|
496 | $result=$wpdb->get_row($sql, ARRAY_A);
|
---|
497 | $NumberOfResults=$result['count'];
|
---|
498 | $sql="SELECT * FROM {$table_prefix}odlinks";
|
---|
499 | $results=$wpdb->get_results($sql);
|
---|
500 | if(!empty($results)){
|
---|
501 | ?>
|
---|
502 | <p> </p>
|
---|
503 | <table width="100%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF"><tr>
|
---|
504 | <td>
|
---|
505 | <table width="100%" cellspacing="1" cellpadding="3" border="0">
|
---|
506 | <tr bgcolor="#CCCCCC">
|
---|
507 | <td>Edit</td>
|
---|
508 | <td>WebSite URL</td>
|
---|
509 | <td>Visible</td>
|
---|
510 | <td>Title</td>
|
---|
511 | <td nowrap>Date</td>
|
---|
512 | <td> </td>
|
---|
513 | <td>Delete</td> </tr>
|
---|
514 | <?
|
---|
515 | for($x=0; $x<count($results); $x++){
|
---|
516 | $row=$results[$x];
|
---|
517 | ?>
|
---|
518 | <tr bgcolor="#F4F4F4" onMouseOver="this.bgColor='#FFFFFF';" onMouseOut="this.bgColor='#F4F4F4';">
|
---|
519 | <td><a href="<?php echo $linkb ?>&odlinks_admin_action=main&id=<?php echo $row->l_id ?>">
|
---|
520 | <img border=0 src="<?php echo get_bloginfo('wpurl'); ?>/wp-content/plugins/odlinks/images/edit.gif"></td>
|
---|
521 | <td><?php echo $row->l_url ?></td>
|
---|
522 | <?
|
---|
523 | if($row->l_hide == "visible"){
|
---|
524 | $new_link="<font color=blue>Yes</font>";
|
---|
525 | } else{
|
---|
526 | $new_link="<font color=purple>No</font>";
|
---|
527 | }
|
---|
528 | echo "<td>".$new_link."</td>";
|
---|
529 | echo "<td><a target=\"_blank\" href=\"".$row->l_url."\">".$row->l_title."</a></td>"; print "<td nowrap>".$row->l_date."</td>"; print "<td>";
|
---|
530 | echo"</td>";
|
---|
531 | echo "<td><a href=\"". $linkb ."&odlinks_admin_action=main&action=delete&id=".$row->l_id ."\"><img border=0 src=\"" .get_bloginfo('wpurl'). "/wp-content/plugins/odlinks/images/delete.png\"</a>";
|
---|
532 | ?> </td></tr>
|
---|
533 | <?
|
---|
534 | } //for main links
|
---|
535 | ?>
|
---|
536 | </table></td></tr>
|
---|
537 | </table>
|
---|
538 | <?
|
---|
539 | } // for
|
---|
540 | } // else
|
---|
541 | }
|
---|
542 | return $msg;
|
---|
543 | }
|
---|
544 |
|
---|
545 |
|
---|
546 | ?>
|
---|