[44] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | /*
|
---|
| 4 | * odl_posts.php
|
---|
| 5 | * wordpress plugin website 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 |
|
---|
| 14 | $odlinkssettings=get_option('odlinksdata');
|
---|
| 15 |
|
---|
| 16 | function odlinkspost_link(){
|
---|
| 17 | global $_GET, $_POST, $table_prefix, $wpdb;
|
---|
| 18 |
|
---|
| 19 | $odlinkssettings=get_option('odlinksdata');
|
---|
| 20 | $parent=$_GET['parent'];
|
---|
| 21 | if (!$parent) $parent=0;
|
---|
| 22 |
|
---|
| 23 | $displayform=true;
|
---|
| 24 | $tpl=new ODLTemplate();
|
---|
| 25 |
|
---|
| 26 | $tpl->assign('odl_images', get_bloginfo('wpurl')."/wp-content/plugins/odlinks");
|
---|
| 27 | //$odl_search_link= get_bloginfo('url')."&odlinksaction=searchlink";
|
---|
| 28 | //$odl_advanced=odlinkscreate_link("searchlink", array("name"=>'Advanced'));
|
---|
| 29 | //$tpl->assign('odl_advanced', $odl_advanced);
|
---|
| 30 | $odl_search_link=odlinkscreate_link("searchform", array());
|
---|
| 31 | $tpl->assign('odl_search_link', $odl_search_link);
|
---|
| 32 | $odl_main_link=odlinkscreate_link("index", array("name"=>"Main"));
|
---|
| 33 | $odl_top_link=odlinkscreate_link("index", array("name"=>$odlinkssettings['page_link_title']));
|
---|
| 34 | $tpl->assign('odl_top_link', $odl_top_link);
|
---|
| 35 | $tpl->assign('odl_main_link', $odl_main_link);
|
---|
| 36 | $tpl->assign('odl_wpurl', get_bloginfo('url'));
|
---|
| 37 |
|
---|
| 38 | $url=$_POST['odlinksdata']['url'];
|
---|
| 39 | $email=$_POST['odlinksdata']['email'];
|
---|
| 40 | $title=$_POST['odlinksdata']['title'];
|
---|
| 41 | $category=$_POST['odlinksdata']['category'];
|
---|
| 42 | $description=$_POST['odlinksdata']['description'];
|
---|
| 43 |
|
---|
| 44 | if ($_POST['odlinkspost_topic']=='yes'){
|
---|
| 45 | $makepost=true;
|
---|
| 46 | if (str_replace(" ", "", $email)==''){
|
---|
| 47 | $msg ="You need to enter email address!";
|
---|
| 48 | $makepost=false;
|
---|
| 49 | }
|
---|
| 50 | if (str_replace(" ", "", $url)==''){
|
---|
| 51 | $msg ="You must provide an url!";
|
---|
| 52 | $makepost=false;
|
---|
| 53 | } else {
|
---|
| 54 | $sql="SELECT c_domain FROM {$table_prefix}odbanned";
|
---|
| 55 | $results=$wpdb->get_results($sql);
|
---|
| 56 | for($i=0; $i<count($results); $i++){
|
---|
| 57 | $row=$results[$i];
|
---|
| 58 | if(eregi($row->c_domain,$url)){
|
---|
| 59 | $msg = "This address that is banned from our directory, please contact administration to resolve this issue: " .get_option('admin_email');
|
---|
| 60 | $makepost=false;
|
---|
| 61 | }
|
---|
| 62 | }
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | if (str_replace(" ", "", $title)==''){
|
---|
| 66 | $msg ="You must to enter a title!";
|
---|
| 67 | $makepost=false;
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | if (!$category || str_replace(" ", "", $category)==''){
|
---|
| 71 | $msg ="You need to select at least one category!";
|
---|
| 72 | $makepost=false;
|
---|
| 73 | }
|
---|
| 74 |
|
---|
| 75 | if (str_replace(" ", "", $description)==''){
|
---|
| 76 | $msg ="You must provide a description!";
|
---|
| 77 | $makepost=false;
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | if($odlinkssettings['confirmation_code']=='y'){
|
---|
| 81 | if (! _odl_captcha::Validate($_POST['odlinksdata']['odl_captcha'])) {
|
---|
| 82 | $msg="The confirmation code didn't matched.";
|
---|
| 83 | $makepost=false;
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | if($url && !eregi("http://",$url)){
|
---|
| 88 | $url='http://'.$url;
|
---|
| 89 | }
|
---|
| 90 |
|
---|
| 91 | if ($makepost==true){
|
---|
| 92 | $sql="SELECT * FROM {$table_prefix}odnew_links";
|
---|
| 93 | $results=$wpdb->get_results($sql);
|
---|
| 94 | if (!empty($results))
|
---|
| 95 | foreach ($results as $result) {
|
---|
| 96 | if($result->n_url == $url){
|
---|
| 97 | $msg="This URL was already submitted. We will check it as soon as possible.";
|
---|
| 98 | $makepost=false;
|
---|
| 99 | }
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | $sql="SELECT * FROM {$table_prefix}odlinks";
|
---|
| 103 | $results=$wpdb->get_results($sql);
|
---|
| 104 | if (!empty($results)) {
|
---|
| 105 | // check Double Post
|
---|
| 106 | foreach ($results as $result) {
|
---|
| 107 | if($result->l_url == $url){
|
---|
| 108 | $msg="This URL is already listed in our directory.";
|
---|
| 109 | $makepost=false;
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | if ($makepost==true){
|
---|
| 114 | mysql_query("INSERT INTO {$table_prefix}odnew_links (n_url, n_title, n_description, n_email, n_category) VALUES ('$url', '$title', '$description', '$email', $category)");
|
---|
| 115 | $msg="<font color=\"green\">Your URL was sucessfully submitted for editor review!<p>Feel free to submit another URL.</font><p> </p>";
|
---|
| 116 | $out=_odl_email_notifications($url, $title, $description, $email, $category);
|
---|
| 117 | $displayform=false;
|
---|
| 118 | } else {
|
---|
| 119 | $displayform=true;
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | if ($displayform==true){
|
---|
| 125 | $space="";
|
---|
| 126 | if($odlinkssettings['confirmation_code']=='y'){
|
---|
| 127 | $aFonts=array(ABSPATH."wp-content/plugins/odlinks/includes/fonts/arial.ttf");
|
---|
| 128 | $oVisualCaptcha=new _odl_captcha($aFonts);
|
---|
| 129 | $captcha=rand(1, 50).".png";
|
---|
| 130 | $oVisualCaptcha->create(ABSPATH."wp-content/plugins/odlinks/includes/Smarty/cache/".$captcha);
|
---|
| 131 | $confirm='<tr><td class="odl_label_right">Confirm: </td><td><img src="'.get_bloginfo('wpurl').'/wp-content/plugins/odlinks/includes/Smarty/cache/' .$captcha.'" alt="ConfirmCode" align="middle"/></td></tr>';
|
---|
| 132 |
|
---|
| 133 | $confirm .= '<tr><td></td><td><input type="text" name="odlinksdata[odl_captcha]" id="odlinksdata[odl_captcha]" size="10"></td></tr>';
|
---|
| 134 |
|
---|
| 135 | $tpl->assign('confirm',$confirm);
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | for ($x=0; $x < $lev; $x++) {
|
---|
| 139 | $space .= " ";
|
---|
| 140 | }
|
---|
| 141 |
|
---|
| 142 | $sql="SELECT * FROM {$table_prefix}odcategories WHERE c_parent='$parent' ORDER BY c_title ASC";
|
---|
| 143 | $categories=$wpdb->get_results($sql);
|
---|
| 144 | for ($i=0; $i<count($categories); $i++){
|
---|
| 145 | $row=$categories[$i];
|
---|
| 146 | $sql="SELECT COUNT(l_id) as count FROM {$table_prefix}odlinks WHERE l_hide='visible' AND l_c_id='".$row->c_id."'";
|
---|
| 147 | $result=$wpdb->get_row($sql, ARRAY_A);
|
---|
| 148 | $links_num=$result['count'];
|
---|
| 149 | $id=intval($row->c_id);
|
---|
| 150 | $title=$row->c_title;
|
---|
| 151 | $option .= "<option value=\"$id\">$space$title ($links_num)</option>\n";
|
---|
| 152 | }
|
---|
| 153 |
|
---|
| 154 | $tpl->assign('categories',$option);
|
---|
| 155 | $tpl->assign('error','<font color="red">'.$msg.'</font>');
|
---|
| 156 | $tpl->assign('url',$url);
|
---|
| 157 | $tpl->assign('title',$title);
|
---|
| 158 | $tpl->assign('description',$description);
|
---|
| 159 | $tpl->assign('email',$email);
|
---|
| 160 |
|
---|
| 161 | } else {
|
---|
| 162 | odlinksdisplay_index($msg);
|
---|
| 163 | }
|
---|
| 164 | if ($odlinkssettings[odlinksshow_credits] == 'y') {
|
---|
| 165 | $credit='Open Directory Links Powered By <a href="http://www.forgani.com/" target="_blank">4gani</a> Version '.$odlinksversion;
|
---|
| 166 | $tpl->assign('odl_credit_line', $credit);
|
---|
| 167 | }
|
---|
| 168 |
|
---|
| 169 | list($gAd, $top, $btn)=get_odl_GADlink();
|
---|
| 170 | if ($gAd) {
|
---|
| 171 | $code='<div class="odl_googleAd">'.$gAd.'</div>';
|
---|
| 172 | $tpl->assign('googletop',$top);
|
---|
| 173 | $tpl->assign('googlebtn',$btn);
|
---|
| 174 | $tpl->assign('googleAd',$code);
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | odlinks_footer($tpl);
|
---|
| 178 | $tpl->display('addurl.tpl');
|
---|
| 179 | } //odlinkspost_link
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | function odlinkssend_link(){
|
---|
| 183 | global $_GET, $_POST, $table_prefix, $wpdb;
|
---|
| 184 |
|
---|
| 185 | $odlinkssettings=get_option('odlinksdata');
|
---|
| 186 | $id=$_GET['id'];
|
---|
| 187 | $sql="SELECT * FROM {$table_prefix}odlinks WHERE l_id=".$id;
|
---|
| 188 | $results=$wpdb->get_results($sql);
|
---|
| 189 | if (!empty($results)) {
|
---|
| 190 | foreach ($results as $result) {
|
---|
| 191 | $description=$result->l_description;
|
---|
| 192 | $name=$result->l_name;
|
---|
| 193 | $title=$result->l_title;
|
---|
| 194 | $url=$result->l_url;
|
---|
| 195 | }
|
---|
| 196 | }
|
---|
| 197 | $displayform=true;
|
---|
| 198 | $tpl=new ODLTemplate();
|
---|
| 199 | $tpl->assign('title', $title);
|
---|
| 200 | $tpl->assign('description', $description);
|
---|
| 201 | $tpl->assign('odl_images', get_bloginfo('wpurl')."/wp-content/plugins/odlinks");
|
---|
| 202 | //$odl_advanced=odlinkscreate_link("searchlink", array("name"=>'Advanced'));
|
---|
| 203 | //$tpl->assign('odl_advanced', $odl_advanced);
|
---|
| 204 | $odl_search_link=odlinkscreate_link("searchform", array());
|
---|
| 205 | $tpl->assign('odl_search_link', $odl_search_link);
|
---|
| 206 | $odl_main_link=odlinkscreate_link("index", array("name"=>"Main"));
|
---|
| 207 | $odl_top_link=odlinkscreate_link("index", array("name"=>$odlinkssettings['page_link_title']));
|
---|
| 208 | $tpl->assign('odl_top_link', $odl_top_link);
|
---|
| 209 | $tpl->assign('odl_main_link', $odl_main_link);
|
---|
| 210 | $tpl->assign('odl_wpurl', get_bloginfo('url'));
|
---|
| 211 |
|
---|
| 212 | if ($_POST['odlinks_send_link']=='yes'){
|
---|
| 213 | $sendAd=true;
|
---|
| 214 | $yourname=$_POST['odlinksdata'][yourname];
|
---|
| 215 | $mailfrom=$_POST['odlinksdata'][mailfrom];
|
---|
| 216 | $mailto=$_POST['odlinksdata'][mailto];
|
---|
| 217 | if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}$", $_POST['odlinksdata'][mailto])){
|
---|
| 218 | $msg='_INVALIDEMAIL2';
|
---|
| 219 | $sendAd=false;
|
---|
| 220 | }
|
---|
| 221 | if($odlinkssettings['confirmation_code']=='y'){
|
---|
| 222 | if (! _odl_captcha::Validate($_POST['odlinksdata']['odl_captcha'])) {
|
---|
| 223 | $msg="The confirmation code didn't matched.";
|
---|
| 224 | $sendAd=false;
|
---|
| 225 | }
|
---|
| 226 | }
|
---|
| 227 | if ($sendAd == true) {
|
---|
| 228 | $displayform=false;
|
---|
| 229 | $message="Dear ".$_POST['odlinksdata'][fname]."<br>";
|
---|
| 230 | $message .= "Your friend ".$yourname." send you this interesting website about <b>".$title."</b><br><br>";
|
---|
| 231 | $message .= 'links detail: '.$description."<BR>";
|
---|
| 232 | $message .= 'link: '.$url;
|
---|
| 233 | $message .= '<BR><BR><HR>Link Directory Sites '.get_bloginfo('wpurl')."/?page_id=".$pageinfo["ID"].' and Service';
|
---|
| 234 | $txt=odl_html2text($message);
|
---|
| 235 | $from="From: ".$yourname."<" .$mailfrom.">";
|
---|
| 236 | $from .= "Content-Type: text/html";
|
---|
| 237 | $sub="your friend ".$yourname." sent you an interesting website ;-)";
|
---|
| 238 | $email_status=_odl_send_email($mailto, $sub, $txt, $from); //, $from
|
---|
| 239 | if ($email_status[0] == false) {
|
---|
| 240 | $msg=$email_status[1];
|
---|
| 241 | $sendAd=false;
|
---|
| 242 | } else {
|
---|
| 243 | odlinksdisplay_index($email_status[1]);
|
---|
| 244 | }
|
---|
| 245 | }
|
---|
| 246 | } else {
|
---|
| 247 | $displayform=true;
|
---|
| 248 | }
|
---|
| 249 |
|
---|
| 250 | if ($displayform==true){
|
---|
| 251 | if($odlinkssettings['confirmation_code']=='y'){
|
---|
| 252 | $aFonts=array(ABSPATH."wp-content/plugins/odlinks/includes/fonts/arial.ttf");
|
---|
| 253 | $oVisualCaptcha=new _odl_captcha($aFonts);
|
---|
| 254 | $captcha=rand(1, 50).".png";
|
---|
| 255 | $oVisualCaptcha->create(ABSPATH."wp-content/plugins/odlinks/includes/Smarty/cache/".$captcha);
|
---|
| 256 | $confirm='<tr><td class="odl_label_right">Confirm: </td><td><img src="'.get_bloginfo('wpurl').'/wp-content/plugins/odlinks/includes/Smarty/cache/' .$captcha.'" alt="ConfirmCode" align="middle"/></td></tr>';
|
---|
| 257 |
|
---|
| 258 | $confirm .= '<tr><td></td><td><input type="text" name="odlinksdata[odl_captcha]" id="odlinksdata[odl_captcha]" size="10"></td></tr>';
|
---|
| 259 |
|
---|
| 260 | $tpl->assign('confirm',$confirm);
|
---|
| 261 | }
|
---|
| 262 | $tpl->assign('error','<font color="red">'.$msg.'</font>');
|
---|
| 263 | $tpl->assign('yourname',$yourname);
|
---|
| 264 | $tpl->assign('mailfrom',$mailfrom);
|
---|
| 265 | $tpl->assign('mailto',$mailto);
|
---|
| 266 | $tpl->assign('fname',$fname);
|
---|
| 267 | } else {
|
---|
| 268 | odlinksdisplay_index($msg);
|
---|
| 269 | }
|
---|
| 270 | if ($odlinkssettings[odlinksshow_credits] == 'y') {
|
---|
| 271 | $credit='Open Directory Links Powered By <a href="http://www.forgani.com/" target="_blank">4gani</a> Version '.$odlinksversion;
|
---|
| 272 | $tpl->assign('odl_credit_line', $credit);
|
---|
| 273 | }
|
---|
| 274 |
|
---|
| 275 | list($gAd, $top, $btn)=get_odl_GADlink();
|
---|
| 276 | if ($gAd) {
|
---|
| 277 | $code='<div class="odl_googleAd">'.$gAd.'</div>';
|
---|
| 278 | $tpl->assign('googletop',$top);
|
---|
| 279 | $tpl->assign('googlebtn',$btn);
|
---|
| 280 | $tpl->assign('googleAd',$code);
|
---|
| 281 | }
|
---|
| 282 |
|
---|
| 283 | odlinks_footer($tpl);
|
---|
| 284 | $tpl->display('sendurl.tpl');
|
---|
| 285 | }
|
---|
| 286 |
|
---|
| 287 |
|
---|
| 288 |
|
---|
| 289 | # EMAIL ROUTINE
|
---|
| 290 | function _odl_send_email($mailto, $mailsubject, $mailtext, $from) {
|
---|
| 291 | global $lang;
|
---|
| 292 | $email_status=array();
|
---|
| 293 | $email=wp_mail($mailto, $mailsubject, $mailtext, $from);
|
---|
| 294 | if ($email == false) {
|
---|
| 295 | $email_status[0]=false;
|
---|
| 296 | $email_status[1]="The email could not be sent!";
|
---|
| 297 | } else {
|
---|
| 298 | $email_status[0]=true;
|
---|
| 299 | $email_status[1]="The email sent successfully!";
|
---|
| 300 | }
|
---|
| 301 | return $email_status;
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 |
|
---|
| 305 |
|
---|
| 306 | # NOTIFICATION EMAILS
|
---|
| 307 | function _odl_email_notifications($url, $title, $description, $email, $category){
|
---|
| 308 | global $lang, $PHP_SELF;
|
---|
| 309 |
|
---|
| 310 | $odlinkssettings=get_option('odlinksdata');
|
---|
| 311 | $out='';
|
---|
| 312 | $eol="\r\n";
|
---|
| 313 |
|
---|
| 314 | # notify admin?
|
---|
| 315 | $msg='';
|
---|
| 316 |
|
---|
| 317 | $msg.= sprintf(__('New Post, '.date("j-M-Y, l").' and is waiting for your Approval on your site %s:'), get_option('blogname')).$eol;
|
---|
| 318 | $msg.= " Please visit the admin panel";
|
---|
| 319 | $msg .= $eol."WebSite: ".$url;
|
---|
| 320 | $msg .= $eol."Title: ".$title;
|
---|
| 321 | $msg .= $eol."Description: ".$description;
|
---|
| 322 | $msg .= $eol."Email: ".$email;
|
---|
| 323 | $msg .= $eol."Category: ".$category.$eol;
|
---|
| 324 | # admin message
|
---|
| 325 | $url = admin_url("admin.php?page=odlinks&odlinks_admin_page_arg=odlinksposts&odlinks_admin_action=approvelinks");
|
---|
| 326 | $msg .= $eol."Approve or delete it: ".$url.$eol;
|
---|
| 327 | //$msg.= $lang['_FROM'].': '.$subject.$eol;
|
---|
| 328 | $adminStruct=get_userdata($ADMINID);
|
---|
| 329 | $email_status=_odl_send_email(get_option('admin_email'), get_bloginfo('name').': '.'A new (ODL)post is waiting for your Approval', $msg, '');
|
---|
| 330 | return $email_status;
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 |
|
---|
| 334 | ?>
|
---|