| [ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/signup.php,v $ 14 | $Revision: 1.108 $ 15 | $Date: 2007/02/04 09:30:44 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 require_once ("class2.php"); 21 $qs = explode(".", e_QUERY); 22 if($qs[0] != "activate"){ // multi-language fix. 23 e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_signup.php"); 24 e107_include_once(e_LANGUAGEDIR."English/lan_signup.php"); 25 e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_usersettings.php"); 26 } 27 28 include_once(e_HANDLER."user_extended_class.php"); 29 $usere = new e107_user_extended; 30 require_once(e_HANDLER."calendar/calendar_class.php"); 31 $cal = new DHTML_Calendar(true); 32 33 if (is_readable(THEME."signup_template.php")) { 34 require_once(THEME."signup_template.php"); 35 } else { 36 require_once(e_THEME."templates/signup_template.php"); 37 } 38 39 include_once(e_FILE."shortcode/batch/signup_shortcodes.php"); 40 41 $signup_imagecode = ($pref['signcode'] && extension_loaded("gd")); 42 43 // Resend Activation Email -------------------------------------------> 44 if(e_QUERY == "resend" && !USER && ($pref['user_reg_veri'] == 1)) 45 { 46 e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_".e_PAGE); 47 e107_include_once(e_LANGUAGEDIR."English/lan_".e_PAGE); 48 require_once(HEADERF); 49 50 if(!$clean_email = check_email($tp -> toDB($_POST['resend_email']))) 51 { 52 $clean_email = "xxx"; 53 } 54 55 if(!$new_email = check_email($tp -> toDB($_POST['resend_newemail']))) 56 { 57 $new_email = FALSE; 58 } 59 60 if($_POST['submit_resend']) 61 { 62 if($_POST['resend_email'] && !$new_email && $sql->db_Select_gen("SELECT * FROM #user WHERE user_ban=0 AND user_sess='' AND (user_loginname= \"".$tp->toDB($_POST['resend_email'])."\" OR user_name = \"".$tp->toDB($_POST['resend_email'])."\" OR user_email = \"".$clean_email."\" ) ")) 63 { 64 $ns -> tablerender(LAN_SIGNUP_40,LAN_SIGNUP_41."<br />"); 65 require_once(FOOTERF); 66 exit; 67 } 68 69 if(trim($_POST['resend_password']) !="" && $new_email) 70 { 71 if($sql->db_Select("user", "user_id", "user_password = \"".md5($_POST['resend_password'])."\" AND user_ban=2 AND user_sess !='' LIMIT 1")) 72 { 73 $row = $sql -> db_Fetch(); 74 if($sql->db_Update("user", "user_email='".$new_email."' WHERE user_id = '".$row['user_id']."' LIMIT 1 ")) 75 { 76 $clean_email = $new_email; 77 } 78 } 79 else 80 { 81 require_once(e_HANDLER."message_handler.php"); 82 message_handler("ALERT",LAN_SIGNUP_52); // Incorrect Password. 83 } 84 } 85 86 87 if($sql->db_Select("user", "*", "(user_loginname = \"".$tp->toDB($_POST['resend_email'])."\" OR user_name = \"".$tp->toDB($_POST['resend_email'])."\" OR user_email = \"".$clean_email."\" ) AND user_ban=2 AND user_sess !='' LIMIT 1")) 88 { 89 $row = $sql -> db_Fetch(); 90 91 $_POST['password1'] = "xxxxxxxxx"; 92 $_POST['loginname'] = $row['user_loginname']; 93 $_POST['name'] = $row['user_name']; 94 $nid = $row['user_id']; 95 $u_key = $row['user_sess']; 96 97 $eml = render_email(); 98 $mailheader_e107id = $nid; 99 require_once(e_HANDLER."mail.php"); 100 101 /* 102 echo "Sending to: ".$row['user_email']; 103 require_once(FOOTERF); 104 exit; 105 */ 106 107 if(!sendemail($row['user_email'], $eml['subject'], $eml['message'], $row['user_name'], "", "", $eml['attachments'], $eml['cc'], $eml['bcc'], $returnpath, $returnreceipt,$eml['inline-images'])) 108 { 109 $ns -> tablerender(LAN_ERROR,LAN_SIGNUP_42); 110 require_once(FOOTERF); 111 exit; 112 } 113 else 114 { 115 $ns -> tablerender(LAN_SIGNUP_43,LAN_SIGNUP_44." ".$row['user_email']." - ".LAN_SIGNUP_45."<br /><br />"); 116 require_once(FOOTERF); 117 exit; 118 } 119 } 120 121 require_once(e_HANDLER."message_handler.php"); 122 message_handler("ALERT",LAN_106); // email not valid. 123 exit; 124 } 125 elseif(!$_POST['submit_resend']) 126 { 127 128 $text .= "<div style='text-align:center'> 129 <form method='post' action='".e_SELF."?resend' name='resend_form'> 130 <table style='".USER_WIDTH."' class='fborder'> 131 <tr> 132 <td class='forumheader3' style='text-align:right'>".LAN_SIGNUP_48."</td> 133 <td class='forumheader3'> 134 <input type='text' name='resend_email' class='tbox' size='50' style='max-width:80%' value='' maxlength='80' /> 135 </td> 136 </tr> 137 138 <tr> 139 <td class='forumheader3' colspan='2'>".LAN_SIGNUP_49."</td> 140 </tr> 141 <tr> 142 <td class='forumheader3' style='text-align:right;width:30%'>".LAN_SIGNUP_50."</td> 143 <td class='forumheader3'><input type='text' name='resend_newemail' class='tbox' size='50' style='max-width:80%' value='' maxlength='80' /> 144 </tr> 145 <tr> 146 <td class='forumheader3' style='text-align:right'>".LAN_SIGNUP_51."</td> 147 <td class='forumheader3'><input type='text' name='resend_password' class='tbox' size='50' style='max-width:80%' value='' maxlength='80' /> 148 149 </td> 150 </tr> 151 152 "; 153 154 $text .="<tr style='vertical-align:top'> 155 <td colspan='2' style='text-align:center' class='forumheader'>"; 156 $text .= "<input class='button' type='submit' name='submit_resend' value=\"".LAN_SIGNUP_47."\" />"; // resend activation email. 157 $text .= "</td> 158 </tr> 159 </table> 160 </form> 161 </div>"; 162 163 $ns -> tablerender(LAN_SIGNUP_47, $text); 164 require_once(FOOTERF); 165 exit; 166 } 167 168 exit; 169 } 170 171 // ------------------------------------------------------------------ 172 173 if(!$_POST) // Notice Removal. 174 { 175 176 $error = ""; 177 $text = " "; 178 $password1 = ""; 179 $password2 = ""; 180 $email = ""; 181 $loginname = ""; 182 $realname = ""; 183 $user_timezone = ""; 184 $image = ""; 185 $avatar_upload = ""; 186 $photo_upload = ""; 187 $_POST['ue'] = ""; 188 $signature = ""; 189 } 190 191 if(ADMIN && (e_QUERY == "preview" || e_QUERY == "test" || e_QUERY == "preview.aftersignup")) 192 { 193 e107_include_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_".e_PAGE); 194 e107_include_once(e_LANGUAGEDIR."English/lan_".e_PAGE); 195 if(e_QUERY == "preview.aftersignup") 196 { 197 require_once(HEADERF); 198 if(trim($pref['signup_text_after'])) 199 { 200 $text = $tp->toHTML($pref['signup_text_after'], TRUE, 'parse_sc,defs')."<br />"; 201 } 202 else 203 { 204 if ($pref['user_reg_veri'] == 2) 205 { 206 $text = LAN_SIGNUP_37; 207 } 208 else 209 { 210 $text = LAN_405; 211 } 212 } 213 $ns->tablerender(LAN_406, $text); 214 require_once(FOOTERF); 215 exit; 216 } 217 218 $eml = render_email(TRUE); 219 echo $eml['preview']; 220 221 if(e_QUERY == "test") 222 { 223 require_once(e_HANDLER."mail.php"); 224 $message = $eml['message']; 225 $subj = $eml['subject']; 226 $inline = $eml['inline-images']; 227 $Cc = $eml['cc']; 228 $Bcc = $eml['bcc']; 229 $attachments = $eml['attachments']; 230 231 if(!sendemail(USEREMAIL, $subj, $message, USERNAME, "", "", $attachments, $Cc, $Bcc, $returnpath, $returnreceipt,$inline)) 232 { 233 echo "<br /><br /><br /><br > >> ".LAN_SIGNUP_42; // there was a problem. 234 } 235 else 236 { 237 echo "<br /><br /> >> ".LAN_SIGNUP_43." [ ".USEREMAIL." ] - ".LAN_SIGNUP_45; 238 } 239 } 240 exit; 241 } 242 243 if ($pref['membersonly_enabled']) 244 { 245 $HEADER = "<div style='text-align:center; width:100%;margin-left:auto;margin-right:auto;text-align:center'><div style='width:70%;text-align:center;margin-left:auto;margin-right:auto'><br />"; 246 if (file_exists(THEME."images/login_logo.png")) 247 { 248 $HEADER .= "<img src='".THEME."images/login_logo.png' alt='' />\n"; 249 } 250 else 251 { 252 $HEADER .= "<img src='".e_IMAGE."logo.png' alt='' />\n"; 253 } 254 $HEADER .= "<br />"; 255 $FOOTER = "</div></div>"; 256 } 257 258 if($signup_imagecode) 259 { 260 require_once(e_HANDLER."secure_img_handler.php"); 261 $sec_img = new secure_image; 262 } 263 264 if($pref['user_reg'] == 0) 265 { 266 header("location: ".e_HTTP."index.php"); 267 exit; 268 } 269 270 if(USER) 271 { 272 header("location: ".e_HTTP."index.php"); 273 exit; 274 } 275 276 // After clicking the activation link ------------------------- 277 if (e_QUERY) 278 { 279 $qs = explode(".", e_QUERY); 280 if ($qs[0] == "activate" && (count($qs) == 3 || count($qs) == 4) && $qs[2]) 281 { 282 // return the message in the correct language. 283 if($qs[3] && strlen($qs[3]) == 2 ) 284 { 285 require_once(e_HANDLER."language_class.php"); 286 $lng = new language; 287 $the_language = $lng->convert($qs[3]); 288 if(is_readable(e_LANGUAGEDIR.$the_language."/lan_signup.php")) 289 { 290 include(e_LANGUAGEDIR.$the_language."/lan_signup.php"); 291 } 292 else 293 { 294 require_once(e_LANGUAGEDIR.e_LANGUAGE."/lan_signup.php"); 295 } 296 } 297 else 298 { 299 include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_signup.php"); 300 } 301 302 303 $e107cache->clear("online_menu_totals"); 304 if ($sql->db_Select("user", "*", "user_sess='".$tp -> toDB($qs[2], true)."' ")) 305 { 306 if ($row = $sql->db_Fetch()) 307 { 308 $sql->db_Update("user", "user_ban='0', user_sess='' WHERE user_sess='".$tp -> toDB($qs[2], true)."' "); 309 $e_event->trigger("userveri", $row); 310 require_once(HEADERF); 311 $text = LAN_401." <a href='index.php'>".LAN_SIGNUP_22."</a> ".LAN_SIGNUP_23."<br />".LAN_SIGNUP_24." ".SITENAME; 312 $ns->tablerender(LAN_402, $text); 313 require_once(FOOTERF); 314 exit; 315 } 316 } 317 else 318 { 319 header("location: ".e_BASE."index.php"); 320 exit; 321 } 322 } 323 } 324 325 326 if (isset($_POST['register'])) 327 { 328 $e107cache->clear("online_menu_totals"); 329 $error_message = ""; 330 require_once(e_HANDLER."message_handler.php"); 331 if ($signup_imagecode && !isset($_POST['xupexist'])) 332 { 333 if (!$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify'])) 334 { 335 $error_message .= LAN_SIGNUP_3."\\n"; 336 $error = TRUE; 337 } 338 } 339 340 if($_POST['xupexist']) 341 { 342 require_once(e_HANDLER."xml_class.php"); 343 $xml = new parseXml; 344 if(!$rawData = $xml -> getRemoteXmlFile($_POST['xupexist'])) 345 { 346 echo "Error: Unable to open remote XUP file"; 347 } 348 preg_match_all("#\<meta name=\"(.*?)\" content=\"(.*?)\" \/\>#si", $rawData, $match); 349 $count = 0; 350 foreach($match[1] as $value) 351 { 352 $xup[$value] = $match[2][$count]; 353 $count++; 354 } 355 356 $_POST['name'] = $xup['NICKNAME']; 357 $_POST['email'] = $xup['EMAIL']; 358 $_POST['signature'] = $xup['SIG']; 359 $_POST['hideemail'] = $xup['EMAILHIDE']; 360 $_POST['timezone'] = $xup['TZ']; 361 $_POST['realname'] = $xup['FN']; 362 $_POST['image'] = $xup['AV']; 363 364 $_POST['ue']['user_homepage'] = $xup['URL']; 365 $_POST['ue']['user_icq'] = $xup['ICQ']; 366 $_POST['ue']['user_aim'] = $xup['AIM']; 367 $_POST['ue']['user_msn'] = $xup['MSN']; 368 $_POST['ue']['user_yahoo'] = $xup['YAHOO']; 369 $_POST['ue']['user_location'] = $xup['GEO']; 370 $_POST['ue']['user_birthday'] = $xup['BDAY']; 371 372 unset($xup); 373 } 374 if($_POST['loginnamexup']) $_POST['loginname'] = $_POST['loginnamexup']; 375 if($_POST['password1xup']) $_POST['password1'] = $_POST['password1xup']; 376 if($_POST['password2xup']) $_POST['password2'] = $_POST['password2xup']; 377 378 // Strip most invalid characters now 379 $temp_name = trim(preg_replace('/ |\#|\=|\$/', "", strip_tags($_POST['loginname']))); 380 if ($temp_name != $_POST['loginname']) 381 { 382 $error_message .= LAN_409."\\n"; 383 $error = TRUE; 384 } 385 $_POST['loginname'] = $temp_name; 386 387 if ($_POST['loginname'] == "Anonymous") 388 { 389 $error_message .= LAN_103."\\n"; 390 $error = TRUE; 391 } 392 393 // Use LoginName for DisplayName if restricted **** MOVED FORWARD **** 394 if (!check_class($pref['displayname_class'])) 395 { 396 $_POST['name'] = $_POST['loginname']; 397 } 398 399 // Impose a minimum length on display name 400 $_POST['name'] = trim($_POST['name']); 401 if (strlen($_POST['name']) < 2) 402 { 403 $error_message .= LAN_SIGNUP_56."\\n"; 404 $error = TRUE; 405 } 406 407 global $db_debug; 408 // Check for disallowed names. 409 if(varsettrue($pref['signup_disallow_text'])) 410 { 411 $tmp = explode(",", $pref['signup_disallow_text']); 412 if (E107_DEBUG_LEVEL) $db_debug->log('disallowed ('.count($tmp).'), like "'.$tmp[0].'"'); 413 foreach($tmp as $disallow) 414 { 415 if( strstr($_POST['name'], $disallow) || strstr($_POST['loginname'], $disallow) ){ 416 $error_message .= LAN_103."\\n"; 417 $error = TRUE; 418 } 419 } 420 } 421 422 // Check if form maxlength has been bypassed 423 if ( strlen($_POST['name']) > 30 || strlen($_POST['loginname']) > 30) 424 { 425 exit; 426 } 427 428 // Check if display name exceeds maximum allowed length 429 if (isset($pref['displayname_maxlength']) && (strlen($_POST['name']) > $pref['displayname_maxlength'])) 430 { 431 $error_message .= LAN_SIGNUP_55."\\n"; 432 $error = TRUE; 433 } 434 435 // Display Name exists. 436 if ($sql->db_Select("user", "*", "user_name='".$tp -> toDB($_POST['name'])."'")) 437 { 438 $error_message .= LAN_411.": ".$tp -> toDB($_POST['name'])."\\n"; 439 $error = TRUE; 440 } 441 // Login Name exists 442 if ($sql->db_Select("user", "*", "user_loginname='".$tp -> toDB($_POST['loginname'])."' ")) 443 { 444 $error_message .= LAN_104.": ".$tp -> toDB($_POST['loginname'])."\\n"; 445 $error = TRUE; 446 } 447 448 // check for multiple signups from the same IP address. 449 if($ipcount = $sql->db_Select("user", "*", "user_ip='".$e107->getip()."' and user_ban !='2' ")) 450 { 451 if($ipcount >= $pref['signup_maxip'] && trim($pref['signup_maxip']) != "") 452 { 453 $error_message .= LAN_202."\\n"; 454 $error = TRUE; 455 } 456 } 457 458 // Check password fields are matching. 459 if ($_POST['password1'] != $_POST['password2']) 460 { 461 $error_message .= LAN_105."\\n"; 462 $error = TRUE; 463 $password1 = ""; 464 $password2 = ""; 465 } 466 467 // Email address confirmation. 468 if ($_POST['email'] != $_POST['email_confirm']) 469 { 470 $error_message .= LAN_SIGNUP_38."\\n"; 471 $error = TRUE; 472 $email = ""; 473 $email_confirm = ""; 474 } 475 476 // Password length check. 477 if (trim(strlen($_POST['password1'])) < $pref['signup_pass_len']) 478 { 479 $error_message .= LAN_SIGNUP_4.$pref['signup_pass_len'].LAN_SIGNUP_5."\\n"; 480 $error = TRUE; 481 $password1 = ""; 482 $password2 = ""; 483 } 484 485 // Check for emtpy fields 486 if (trim($_POST['name']) == "" || trim($_POST['loginname']) == "" || trim($_POST['password1']) == "" || trim($_POST['password2']) == "") 487 { 488 $error_message .= LAN_185."\\n"; 489 $error = TRUE; 490 } 491 492 // ========== Verify Custom Signup options if selected ======================== 493 494 $signup_option_title = array(LAN_308, LAN_120, LAN_121, LAN_122, LAN_SIGNUP_28); 495 $signup_option_names = array("realname", "signature", "image", "timezone", "class"); 496 497 foreach($signup_option_names as $key => $value) 498 { 499 if ($pref['signup_option_'.$value] == 2 && !$_POST[$value]) 500 { 501 $error_message .= LAN_SIGNUP_6.$signup_option_title[$key].LAN_SIGNUP_7."\\n"; 502 $error = TRUE; 503 } 504 } 505 506 // Check for Duplicate Email address. 507 if ($sql->db_Select("user", "user_email, user_ban, user_sess", "user_email='".$tp -> toDB($_POST['email'])."' ")) 508 { 509 $chk = $sql -> db_Fetch(); 510 if($chk['user_ban']== 2 && $chk['user_sess']){ 511 // duplicate because unactivated 512 $error = TRUE; 513 header("Location: ".e_BASE."signup.php?resend"); 514 exit; 515 }else{ 516 $error_message .= LAN_408."\\n"; 517 $error = TRUE; 518 } 519 } 520 521 // Extended Field validation 522 $extList = $usere->user_extended_get_fieldList(); 523 524 foreach($extList as $ext) 525 { 526 if(isset($_POST['ue']['user_'.$ext['user_extended_struct_name']])) 527 { 528 529 $newval = trim($_POST['ue']['user_'.$ext['user_extended_struct_name']]); 530 if($ext['user_extended_struct_required'] == 1 && $newval == "" ) 531 { 532 $_ftext = (defined($ext['user_extended_struct_text']) ? constant($ext['user_extended_struct_text']) : $ext['user_extended_struct_text']); 533 $error_message .= LAN_SIGNUP_6.$_ftext.LAN_SIGNUP_7."\\n"; 534 $error = TRUE; 535 } 536 $parms = explode("^,^", $ext['user_extended_struct_parms']); 537 $regex = (isset($parms[1]) ? $tp->toText($parms[1]) : ""); 538 $regexfail = (isset($parms[2]) ? trim($tp->toText($parms[2])) : ""); 539 540 if($regexfail == "") 541 { 542 $regexfail = $ext['user_extended_struct_name']." ".LAN_SIGNUP_53; 543 } 544 545 if(defined($regexfail)) {$regexfail = constant($regexfail);} 546 547 if($regex != "" && $newval != "") 548 { 549 if(!preg_match($regex, $newval)) 550 { 551 $error_message .= $regexfail."\\n"; 552 $error = TRUE; 553 } 554 } 555 } 556 } 557 558 // Email syntax validation. 559 if (!check_email($_POST['email'])) 560 { 561 message_handler("P_ALERT", LAN_106); 562 $error_message .= LAN_106."\\n"; 563 $error = TRUE; 564 } 565 566 // Check Email against banlist. 567 $wc = $tp -> toDB("*".trim(substr($_POST['email'], strpos($_POST['email'], "@")))); 568 if ($sql->db_Select("banlist", "*", "banlist_ip='".$tp -> toDB($_POST['email'])."' OR banlist_ip='{$wc}'")) 569 { 570 $brow = $sql -> db_Fetch(); 571 $error = TRUE; 572 if($brow['banlist_reason']) 573 { 574 $repl = array("\n","\r","<br />"); 575 $error_message = str_replace($repl,"\\n",$tp->toHTML($brow['banlist_reason'],"","nobreak, defs"))."\\n"; 576 $email = ""; 577 } 578 else 579 { 580 exit; 581 } 582 } 583 584 // Check email address on remote server (if enabled). 585 if (varsettrue($pref['signup_remote_emailcheck']) && $error != TRUE) 586 { 587 require_once(e_HANDLER."mail_validation_class.php"); 588 list($adminuser,$adminhost) = split ("@", SITEADMINEMAIL); 589 $validator = new email_validation_class; 590 $validator->localuser= $adminuser; 591 $validator->localhost= $adminhost; 592 $validator->timeout=3; 593 // $validator->debug=1; 594 // $validator->html_debug=1; 595 if($validator->ValidateEmailBox(trim($_POST['email'])) != 1) 596 { 597 $error_message .= LAN_106."\\n"; 598 $error = TRUE; 599 $email = ""; 600 $email_confirm = ""; 601 } 602 603 } 604 605 if($error_message) 606 { 607 message_handler("P_ALERT", $error_message); 608 } 609 610 // ========== End of verification.. ==================================================== 611 612 if (!$error) 613 { 614 $fp = new floodprotect; 615 if ($fp->flood("user", "user_join") == FALSE) 616 { 617 header("location:".e_BASE."index.php"); 618 exit; 619 } 620 621 if ($sql->db_Select("user", "*", "user_email='".$tp -> toDB($_POST['email'])."' AND user_ban='1'")) { 622 exit; 623 } 624 625 $username = $tp -> toDB(strip_tags($_POST['name'])); 626 $loginname = $tp -> toDB(strip_tags($_POST['loginname'])); 627 $time = time(); 628 $ip = $e107->getip(); 629 630 $ue_fields = ""; 631 foreach($_POST['ue'] as $key => $val) 632 { 633 $key = $tp->toDB($key); 634 $val = $tp->toDB($val); 635 $ue_fields .= ($ue_fields) ? ", " : ""; 636 $ue_fields .= $key."='".$val."'"; 637 } 638 639 $u_key = md5(uniqid(rand(), 1)); 640 $nid = $sql->db_Insert("user", "0, '{$username}', '{$loginname}', '', '".md5($_POST['password1'])."', '{$u_key}', '".$tp -> toDB($_POST['email'])."', '".$tp -> toDB($_POST['signature'])."', '".$tp -> toDB($_POST['image'])."', '".$tp -> toDB($_POST['timezone'])."', '".$tp -> toDB($_POST['hideemail'])."', '".$time."', '0', '".$time."', '0', '0', '0', '0', '".$ip."', '2', '0', '', '', '0', '0', '".$tp -> toDB($_POST['realname'])."', '', '', '', '0', '".$tp -> toDB($_POST['xupexist'])."' "); 641 if(!$nid) 642 { 643 require_once(HEADERF); 644 $ns->tablerender("", LAN_SIGNUP_36); 645 require_once(FOOTERF); 646 } 647 648 if ($pref['user_reg_veri']) 649 { 650 // ==== Update Userclass =======> 651 652 if ($_POST['class']) 653 { 654 unset($insert_class); 655 sort($_POST['class']); 656 $insert_class = implode(",",$_POST['class']); 657 $sql->db_Update("user", "user_class='".$tp -> toDB($insert_class)."' WHERE user_id='".$nid."' "); 658 } 659 660 // ========= save extended fields into db table. ===== 661 662 if($ue_fields) 663 { 664 $sql->db_Select_gen("INSERT INTO #user_extended (user_extended_id) values ('{$nid}')"); 665 $sql->db_Update("user_extended", $ue_fields." WHERE user_extended_id = '{$nid}'"); 666 } 667 668 // ========== Send Email =========> 669 670 if ($pref['user_reg_veri'] != 2) 671 { 672 $eml = render_email(); 673 $mailheader_e107id = $eml['userid']; 674 require_once(e_HANDLER."mail.php"); 675 676 677 if(!sendemail($_POST['email'], $eml['subject'], $eml['message'], "", "", "", $eml['attachments'], $eml['cc'], $eml['bcc'], "", "", $eml['inline-images'])) 678 { 679 $error_message = LAN_SIGNUP_42; // There was a problem, the registration mail was not sent, please contact the website administrator. 680 } 681 } 682 683 $_POST['ip'] = $ip; 684 $e_event->trigger("usersup", $_POST); // send everything in the template, including extended fields. 685 686 require_once(HEADERF); 687 if($pref['signup_text_after']) 688 { 689 $text = $tp->toHTML($pref['signup_text_after'], TRUE, 'parse_sc,defs')."<br />"; 690 } 691 else 692 { 693 if ($pref['user_reg_veri'] == 2) 694 { 695 $text = LAN_SIGNUP_37; 696 } 697 else 698 { 699 $text = LAN_405; 700 } 701 } 702 if(isset($error_message)) 703 { 704 $text .= "<br /><b>".$error_message."</b><br />"; 705 } 706 $ns->tablerender(LAN_406, $text); 707 require_once(FOOTERF); 708 exit; 709 } 710 else 711 { 712 require_once(HEADERF); 713 714 if(!$sql -> db_Select("user", "user_id", "user_name='{$username}' AND user_password='".md5($_POST['password1'])."'")) 715 { 716 $ns->tablerender("", LAN_SIGNUP_36); 717 require_once(FOOTERF); 718 exit; 719 } 720 $sql->db_Update("user", "user_ban = '0' WHERE user_id = '{$nid}'"); 721 722 // ==== Update Userclass ======= 723 if ($_POST['class']) 724 { 725 unset($insert_class); 726 sort($_POST['class']); 727 $insert_class = implode(",",$_POST['class']); 728 $sql->db_Update("user", "user_class='".$tp -> toDB($insert_class)."' WHERE user_id='".$nid."' "); 729 } 730 // ======== save extended fields to DB table. 731 732 if($ue_fields) 733 { 734 $sql->db_Select_gen("INSERT INTO #user_extended (user_extended_id) values ('{$nid}')"); 735 $sql->db_Update("user_extended", $ue_fields." WHERE user_extended_id = '{$nid}'"); 736 } 737 738 // ========================================================== 739 $_POST['ip'] = $ip; 740 $e_event->trigger("usersup", $_POST); // send everything in the template, including extended fields. 741 742 if($pref['signup_text_after']) 743 { 744 $text = $tp->toHTML($pref['signup_text_after'], TRUE, 'parse_sc,defs')."<br />"; 745 } 746 else 747 { 748 $text = LAN_107." ".SITENAME.", ".LAN_SIGNUP_12."<br /><br />".LAN_SIGNUP_13; 749 } 750 $ns->tablerender(LAN_SIGNUP_8,$text); 751 require_once(FOOTERF); 752 exit; 753 } 754 } 755 756 } 757 require_once(HEADERF); 758 759 $qs = ($error ? "stage" : e_QUERY); 760 if ($pref['use_coppa'] == 1 && strpos($qs, "stage") === FALSE) 761 { 762 $text = $tp->parseTemplate($COPPA_TEMPLATE, TRUE, $signup_shortcodes); 763 $ns->tablerender(LAN_110, $text); 764 require_once(FOOTERF); 765 exit; 766 } 767 768 if (!$website) 769 { 770 $website = "http://"; 771 } 772 773 if (strpos(LAN_109, "stage") === FALSE) 774 { 775 if (isset($_POST['newver'])) 776 { 777 if (!$_POST['coppa']) 778 { 779 $text = $tp->parseTemplate($COPPA_FAIL); 780 $ns->tablerender(LAN_110, $text); 781 require_once(FOOTERF); 782 exit; 783 } 784 } 785 } 786 787 require_once(e_HANDLER."form_handler.php"); 788 $rs = new form; 789 790 791 $text = $tp->parseTemplate($SIGNUP_BEGIN.$SIGNUP_BODY.$SIGNUP_END, TRUE, $signup_shortcodes); 792 $ns->tablerender(LAN_123, $text); 793 require_once(FOOTERF); 794 exit; 795 796 // Default Signup Form -----> 797 798 $ns->tablerender(LAN_123, $text); 799 800 require_once(FOOTERF); 801 802 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 803 804 function req($field) 805 { 806 return ($field == 2 ? REQUIRED_FIELD_MARKER : ""); 807 } 808 //------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// 809 810 function headerjs() 811 { 812 $script_txt = " 813 <script type=\"text/javascript\"> 814 function addtext3(sc){ 815 document.getElementById('signupform').image.value = sc; 816 } 817 818 function addsig(sc){ 819 document.getElementById('signupform').signature.value += sc; 820 } 821 function help(help){ 822 document.getElementById('signupform').helpb.value = help; 823 } 824 </script>\n"; 825 826 global $cal; 827 $script_txt .= $cal->load_files(); 828 return $script_txt; 829 } 830 831 832 function render_email($preview = FALSE) 833 { 834 // 1 = Body 835 // 2 = Subject 836 837 global $pref,$nid,$u_key,$_POST,$SIGNUPEMAIL_LINKSTYLE,$SIGNUPEMAIL_SUBJECT,$SIGNUPEMAIL_TEMPLATE; 838 839 if($preview == TRUE) 840 { 841 $_POST['password1'] = "test-password"; 842 $_POST['loginname'] = "test-loginname"; 843 $_POST['name'] = "test-username"; 844 $_POST['website'] = "www.test-site.com"; 845 $nid = 0; 846 $u_key = "1234567890ABCDEFGHIJKLMNOP"; 847 } 848 849 define("RETURNADDRESS", (substr(SITEURL, -1) == "/" ? SITEURL."signup.php?activate.".$nid.".".$u_key : SITEURL."/signup.php?activate.".$nid.".".$u_key.".".e_LAN)); 850 $pass_show = ($pref['user_reg_secureveri'])? "*******" : $_POST['password1']; 851 852 if (file_exists(THEME."email_template.php")) 853 { 854 require_once(THEME."email_template.php"); 855 } 856 else 857 { 858 require_once(e_THEME."templates/email_template.php"); 859 } 860 861 $inline_images = explode(",",$SIGNUPEMAIL_IMAGES); 862 if($SIGNUPEMAIL_BACKGROUNDIMAGE) 863 { 864 $inline_images[] = $SIGNUPEMAIL_BACKGROUNDIMAGE; 865 } 866 867 $ret['userid'] = $nid; 868 $ret['cc'] = $SIGNUPEMAIL_CC; 869 $ret['bcc'] = $SIGNUPEMAIL_BCC; 870 $ret['attachments'] = $SIGNUPEMAIL_ATTACHMENTS; 871 $ret['inline-images'] = implode(",",$inline_images); 872 873 $style = ($SIGNUPEMAIL_LINKSTYLE) ? "style='$SIGNUPEMAIL_LINKSTYLE'" : ""; 874 875 $search[0] = "{LOGINNAME}"; 876 $replace[0] = $_POST['loginname']; 877 878 $search[1] = "{PASSWORD}"; 879 $replace[1] = $pass_show; 880 881 $search[2] = "{ACTIVATION_LINK}"; 882 $replace[2] = "<a href='".RETURNADDRESS."' $style>".RETURNADDRESS."</a>"; 883 884 $search[3] = "{SITENAME}"; 885 $replace[3] = SITENAME; 886 887 $search[4] = "{SITEURL}"; 888 $replace[4] = "<a href='".SITEURL."' $style>".SITEURL."</a>"; 889 890 $search[5] = "{USERNAME}"; 891 $replace[5] = $_POST['name']; 892 893 $search[6] = "{USERURL}"; 894 $replace[6] = ($_POST['website']) ? $_POST['website'] : ""; 895 896 $cnt=1; 897 898 foreach($inline_images as $img) 899 { 900 if(is_readable($inline_images[$cnt-1])) 901 { 902 $cid_search[] = "{IMAGE".$cnt."}"; 903 $cid_replace[] = "<img alt=\"".SITENAME."\" src='cid:".md5($inline_images[$cnt-1])."' />\n"; 904 $path_search[] = "{IMAGE".$cnt."}"; 905 $path_replace[] = "<img alt=\"".SITENAME."\" src=\"".$inline_images[$cnt-1]."\" />\n"; 906 } 907 $cnt++; 908 } 909 910 $subject = str_replace($search,$replace,$SIGNUPEMAIL_SUBJECT); 911 $ret['subject'] = $subject; 912 913 $HEAD = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"; 914 $HEAD .= "<html xmlns='http://www.w3.org/1999/xhtml' >\n"; 915 $HEAD .= "<head><meta http-equiv='content-type' content='text/html; charset=utf-8' />\n"; 916 $HEAD .= ($SIGNUPEMAIL_USETHEME == 1) ? "<link rel=\"stylesheet\" href=\"".SITEURL.THEME."style.css\" type=\"text/css\" />\n" : ""; 917 $HEAD .= ($preview) ? "<title>Signup Preview</title>\n" : ""; 918 if($SIGNUPEMAIL_USETHEME == 2) 919 { 920 $CSS = file_get_contents(THEME."style.css"); 921 $HEAD .= "<style>\n".$CSS."\n</style>"; 922 } 923 924 $HEAD .= "</head>\n"; 925 if($SIGNUPEMAIL_BACKGROUNDIMAGE) 926 { 927 $HEAD .= "<body background=\"cid:".md5($SIGNUPEMAIL_BACKGROUNDIMAGE)."\" >\n"; 928 } 929 else 930 { 931 $HEAD .= "<body>\n"; 932 } 933 $FOOT = "\n</body>\n</html>\n"; 934 935 $SIGNUPEMAIL_TEMPLATE = $HEAD.$SIGNUPEMAIL_TEMPLATE.$FOOT; 936 $message = str_replace($search,$replace,$SIGNUPEMAIL_TEMPLATE); 937 938 $ret['message'] = str_replace($cid_search,$cid_replace,$message); 939 $ret['preview'] = str_replace($path_search,$path_replace,$message); 940 941 return $ret; 942 } 943 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |