daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Apr 29th, 2017 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require_once 'engine/init.php';
  3. logged_in_redirect();
  4. include 'layout/overall/header.php';
  5.  
  6. if (empty($_POST) === false) {
  7.     // $_POST['']
  8.     $required_fields = array('username', 'password', 'password_again', 'email', 'selected');
  9.     foreach($_POST as $key=>$value) {
  10.         if (empty($value) && in_array($key, $required_fields) === true) {
  11.             $errors[] = 'You need to fill in all fields.';
  12.             break 1;
  13.         }
  14.     }
  15.    
  16.     // check errors (= user exist, pass long enough
  17.     if (empty($errors) === true) {
  18.         /* Token used for cross site scripting security */
  19.         if (!Token::isValid($_POST['token'])) {
  20.             $errors[] = 'Token is invalid.';
  21.         }
  22.  
  23.         if ($config['use_captcha']) {
  24.             $captcha = (isset($_POST['g-recaptcha-response'])) ? $_POST['g-recaptcha-response'] : false;
  25.             if(!$captcha) {
  26.                 $errors[] = 'Please check the the captcha form.';
  27.             } else {
  28.                 $secretKey = $config['captcha_secret_key'];
  29.                 $ip = $_SERVER['REMOTE_ADDR'];
  30.                 // curl start
  31.                 $curl_connection = curl_init("https://www.google.com/recaptcha/api/siteverify");
  32.                 $post_string = "secret=".$secretKey."&response=".$captcha."&remoteip=".$ip;
  33.                 curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 5);
  34.                 curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
  35.                 curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
  36.                 curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
  37.                 curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
  38.                 $response = curl_exec($curl_connection);
  39.                 curl_close($curl_connection);
  40.                 // Curl end
  41.                 $responseKeys = json_decode($response,true);
  42.                 if(intval($responseKeys["success"]) !== 1) {
  43.                     $errors[] = 'Captcha failed.';
  44.                 }
  45.             }
  46.         }
  47.        
  48.         if (user_exist($_POST['username']) === true) {
  49.             $errors[] = 'Sorry, that username already exist.';
  50.         }
  51.        
  52.         // Don't allow "default admin names in config.php" access to register.
  53.         $isNoob = in_array(strtolower($_POST['username']), $config['page_admin_access']) ? true : false;
  54.         if ($isNoob) {
  55.             $errors[] = 'This account name is blocked for registration.';
  56.         }
  57.         if (preg_match("/^[a-zA-Z*]+$/", $_POST['username']) == false) {
  58.             $errors[] = 'Your username can only contain characters a-z, A-Z.';
  59.         }
  60.         // name restriction
  61.         $resname = explode(" ", $_POST['username']);
  62.         foreach($resname as $res) {
  63.             if(in_array(strtolower($res), $config['invalidNameTags'])) {
  64.                 $errors[] = 'Your username contains a restricted word.';
  65.             }
  66.             else if(strlen($res) == 1) {
  67.                 $errors[] = 'Too short words in your name.';
  68.             }
  69.         }
  70.         if (strlen($_POST['username']) > 32) {
  71.             $errors[] = 'Your account name must be less than 33 characters.';
  72.         }
  73.         // end name restriction
  74.         if (strlen($_POST['password']) < 6) {
  75.             $errors[] = 'Your password must be at least 6 characters.';
  76.         }
  77.         if (strlen($_POST['password']) > 100) {
  78.             $errors[] = 'Your password must be less than 100 characters.';
  79.         }
  80.         if ($_POST['password'] !== $_POST['password_again']) {
  81.             $errors[] = 'Your passwords do not match.';
  82.         }
  83.         if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false) {
  84.             $errors[] = 'A valid email address is required.';
  85.         }
  86.         if (user_email_exist($_POST['email']) === true) {
  87.             $errors[] = 'That email address is already in use.';
  88.         }
  89.         if ($_POST['selected'] != 1) {
  90.             $errors[] = 'You are only allowed to have an account if you accept the rules.';
  91.         }
  92.         if (validate_ip(getIP()) === false && $config['validate_IP'] === true) {
  93.             $errors[] = 'Failed to recognize your IP address. (Not a valid IPv4 address).';
  94.         }
  95.             if (strlen($_POST['flag']) < 1) {
  96.                         $errors[] = 'Please choose country.';
  97.                 }
  98. $request = new HttpRequest();
  99. $request->setUrl('http://lordaeron.se/forum/api/core/members/');
  100. $request->setMethod(HTTP_METH_POST);
  101.  
  102. $request->setHeaders(array(
  103.   'authorization' => 'Basic ZGYwZGY5N2RkZTMwMjA1YTY4MmY2OGRiZGYzNmNiOTA',
  104.   'content-type' => 'application/x-www-form-urlencoded'
  105. ));
  106.  
  107. $request->setContentType('application/x-www-form-urlencoded');
  108. $request->setPostFields(array(
  109.   'name' => ($_POST['username']),
  110.   'email' => ($_POST['email']),
  111.   'password' => ($_POST['password']),
  112.   'group' => '3'
  113. ));
  114.  
  115. try {
  116.   $response = $request->send();
  117.  
  118.   echo $response->getBody();
  119. } catch (HttpException $ex) {
  120.   echo $ex;
  121. }
  122.     }
  123. }
  124.  
  125. ?>
  126. <h1>Register Account</h1>
  127. <?php
  128. if (isset($_GET['success']) && empty($_GET['success'])) {
  129.     if ($config['mailserver']['register']) {
  130.         ?>
  131.         <h3>Email authentication required</h3><hr>
  132.         <p>We have sent you an email with an activation link to your submitted email address.</p>
  133.         <p>If you can't find the email within 5 minutes, check your <strong>junk/trash inbox (spam filter)</strong> as it may be mislocated there.</p>
  134.         <?php
  135.     } else echo 'Congratulations! Your account has been created. You may now login to create a character.';
  136. } elseif (isset($_GET['authenticate']) && empty($_GET['authenticate'])) {
  137.     // Authenticate user, fetch user id and activation key
  138.     $auid = (isset($_GET['u']) && (int)$_GET['u'] > 0) ? (int)$_GET['u'] : false;
  139.     $akey = (isset($_GET['k']) && (int)$_GET['k'] > 0) ? (int)$_GET['k'] : false;
  140.     // Find a match
  141.     $user = mysql_select_single("SELECT `id`, `active` FROM `znote_accounts` WHERE `account_id`='$auid' AND `activekey`='$akey' LIMIT 1;");
  142.     if ($user !== false) {
  143.         $user = $user['id'];
  144.         $active = $user['active'];
  145.         // Enable the account to login
  146.         if ($active == 0) {
  147.             mysql_update("UPDATE `znote_accounts` SET `active`='1' WHERE `id`='$user' LIMIT 1;");
  148.         }
  149.         echo '<h3>Congratulations!</h3> <hr> <p>Your account has been created. You may now login to create a character.</p>';
  150.     } else {
  151.         echo '<h3>Authentication failed</h3> <hr> <p>Either the activation link is wrong, or your account is already activated.</p>';
  152.     }
  153. } else {
  154.     if (empty($_POST) === false && empty($errors) === true) {
  155.         if ($config['log_ip']) {
  156.             znote_visitor_insert_detailed_data(1);
  157.         }
  158.        
  159.         //Register
  160.         $register_data = array(
  161.             'name'      =>  $_POST['username'],
  162.             'password'  =>  $_POST['password'],
  163.             'email'     =>  $_POST['email'],
  164.             'created'   =>  time(),
  165.             'ip'        =>  getIPLong(),
  166.             'flag'      =>  $_POST['flag']
  167.         );
  168.        
  169.         user_create_account($register_data, $config['mailserver']);
  170.         if (!$config['mailserver']['debug']) header('Location: register.php?success');
  171.         exit();
  172.         //End register
  173.        
  174.     } else if (empty($errors) === false){
  175.         echo '<font color="red"><b>';
  176.         echo output_errors($errors);
  177.         echo '</b></font>';
  178.     }
  179. ?>
  180.     <form action="" method="post">
  181.         <ul>
  182.             <li>
  183.                 Username:<br>
  184.                 <input type="text" name="username">
  185.             </li>
  186.             <li>
  187.                 Password:<br>
  188.                 <input type="password" name="password">
  189.             </li>
  190.             <li>
  191.                 Password again:<br>
  192.                 <input type="password" name="password_again">
  193.             </li>
  194.             <li>
  195.                 Email:<br>
  196.                 <input type="text" name="email">
  197.             </li>
  198.             <li>
  199.                 Country:<br>
  200.                 <select name="flag">
  201.                     <option value="">(Please choose)</option><option value="af"> Afghanistan </option><option value="al"> Albania </option><option value="dz"> Algeria </option><option value="as"> American Samoa </option><option value="ad"> Andorra </option><option value="ao"> Angola </option><option value="ai"> Anguilla </option><option value="aq"> Antarctica </option><option value="ag"> Antigua and Barbuda </option><option value="ar"> Argentina </option>
  202.                     <option value="am"> Armenia </option><option value="aw"> Aruba </option><option value="au"> Australia </option><option value="at"> Austria </option><option value="az"> Azerbaijan </option><option value="bs"> Bahamas </option><option value="bh"> Bahrain </option><option value="bd"> Bangladesh </option><option value="bb"> Barbados </option><option value="by"> Belarus </option><option value="be"> Belgium </option><option value="bz"> Belize </option><option value="bj"> Benin </option><option value="bm"> Bermuda </option><option value="bt"> Bhutan </option><option value="bo"> Bolivia </option><option value="ba"> Bosnia and Herzegowina </option><option value="bw"> Botswana </option><option value="bv"> Bouvet Island </option><option value="br"> Brazil </option><option value="io"> British Indian Ocean Territory </option><option value="bn"> Brunei Darussalam </option><option value="bg"> Bulgaria </option><option value="bf"> Burkina Faso </option><option value="bi"> Burundi </option>
  203.                     <option value="kh"> Cambodia </option><option value="cm"> Cameroon </option><option value="ca"> Canada </option><option value="cv"> Cape Verde </option><option value="ky"> Cayman Islands </option><option value="cf"> Central African Republic </option><option value="td"> Chad </option><option value="cl"> Chile </option><option value="cn"> China </option><option value="cx"> Christmas Island </option><option value="cc"> Cocos Islands </option><option value="co"> Colombia </option><option value="km"> Comoros </option><option value="cd"> Congo </option><option value="cg"> Congo </option><option value="ck"> Cook Islands </option><option value="cr"> Costa Rica </option><option value="ci"> Cote DIvoire </option><option value="hr"> Croatia </option><option value="cu"> Cuba </option><option value="cy"> Cyprus </option><option value="cz"> Czech Republic </option><option value="dk"> Denmark </option><option value="dj"> Djibouti </option><option value="dm"> Dominica </option>
  204.                     <option value="do"> Dominican Republic </option><option value="tp"> East Timor </option><option value="ec"> Ecuador </option><option value="eg"> Egypt </option><option value="sv"> El Salvador </option><option value="gq"> Equatorial Guinea </option><option value="er"> Eritrea </option><option value="ee"> Estonia </option><option value="et"> Ethiopia </option><option value="fk"> Falkland Islands </option><option value="fo"> Faroe Islands </option><option value="fj"> Fiji </option><option value="fi"> Finland </option><option value="fr"> France </option><option value="gf"> French Guiana </option><option value="pf"> French Polynesia </option><option value="tf"> French Southern Territories </option><option value="ga"> Gabon </option><option value="gm"> Gambia </option><option value="ge"> Georgia </option><option value="de"> Germany </option><option value="gh"> Ghana </option><option value="gi"> Gibraltar </option><option value="gr"> Greece </option>
  205.                     <option value="gl"> Greenland </option><option value="gd"> Grenada </option><option value="gp"> Guadeloupe </option><option value="gu"> Guam </option><option value="gt"> Guatemala </option><option value="gn"> Guinea </option><option value="gw"> Guinea-Bissau </option><option value="gy"> Guyana </option><option value="ht"> Haiti </option><option value="hm"> Heard and Mc Donald Islands </option><option value="hn"> Honduras </option><option value="hk"> Hong Kong </option><option value="hu"> Hungary </option><option value="is"> Iceland </option><option value="in"> India </option><option value="id"> Indonesia </option><option value="ir"> Iran </option><option value="iq"> Iraq </option><option value="ie"> Ireland </option><option value="il"> Israel </option><option value="it"> Italy </option><option value="jm"> Jamaica </option><option value="jp"> Japan </option><option value="jo"> Jordan </option><option value="kz"> Kazakhstan </option><option value="ke"> Kenya </option>
  206.                     <option value="ki"> Kiribati </option><option value="kr"> Korea </option><option value="kp"> Korea </option><option value="kw"> Kuwait </option><option value="kg"> Kyrgyzstan </option><option value="la"> Lao Peoples Democratic Republic </option><option value="lv"> Latvia </option><option value="lb"> Lebanon </option><option value="ls"> Lesotho </option><option value="lr"> Liberia </option><option value="ly"> Libyan Arab Jamahiriya </option><option value="li"> Liechtenstein </option><option value="lt"> Lithuania </option><option value="lu"> Luxembourg </option><option value="mo"> Macau </option><option value="mk"> Macedonia </option><option value="mg"> Madagascar </option><option value="mw"> Malawi </option><option value="my"> Malaysia </option><option value="mv"> Maldives </option><option value="ml"> Mali </option><option value="mt"> Malta </option><option value="mh"> Marshall Islands </option><option value="mq"> Martinique </option>
  207.                     <option value="mr"> Mauritania </option><option value="mu"> Mauritius </option><option value="yt"> Mayotte </option><option value="mx"> Mexico </option><option value="fm"> Micronesia </option><option value="md"> Moldova </option><option value="mc"> Monaco </option><option value="mn"> Mongolia </option><option value="ms"> Montserrat </option><option value="ma"> Morocco </option><option value="mz"> Mozambique </option><option value="mm"> Myanmar </option><option value="na"> Namibia </option><option value="nr"> Nauru </option><option value="np"> Nepal </option><option value="nl"> Netherlands </option><option value="an"> Netherlands Antilles </option><option value="nc"> New Caledonia </option><option value="nz"> New Zealand </option><option value="ni"> Nicaragua </option><option value="ne"> Niger </option><option value="ng"> Nigeria </option><option value="nu"> Niue </option><option value="nf"> Norfolk Island </option><option value="mp"> Northern Mariana Islands </option>
  208.                     <option value="no"> Norway </option><option value="om"> Oman </option><option value="pk"> Pakistan </option><option value="pw"> Palau </option><option value="pa"> Panama </option><option value="pg"> Papua New Guinea </option><option value="py"> Paraguay </option><option value="pe"> Peru </option><option value="ph"> Philippines </option><option value="pn"> Pitcairn </option><option value="pl"> Poland </option><option value="pt"> Portugal </option><option value="pr"> Puerto Rico </option><option value="qa"> Qatar </option><option value="re"> Reunion </option><option value="ro"> Romania </option><option value="ru"> Russian Federation </option><option value="rw"> Rwanda </option><option value="kn"> Saint Kitts and Nevis </option><option value="lc"> Saint Lucia </option><option value="ws"> Samoa </option><option value="sm"> San Marino </option><option value="st"> Sao Tome and Principe </option><option value="sa"> Saudi Arabia </option><option value="sn"> Senegal </option>
  209.                     <option value="sc"> Seychelles </option><option value="sl"> Sierra Leone </option><option value="sg"> Singapore </option><option value="sk"> Slovakia </option><option value="si"> Slovenia </option><option value="sb"> Solomon Islands </option><option value="so"> Somalia </option><option value="za"> South Africa </option><option value="es"> Spain </option><option value="lk"> Sri Lanka </option><option value="sh"> St. Helena </option><option value="pm"> St. Pierre and Miquelon </option><option value="sd"> Sudan </option><option value="sr"> Suriname </option><option value="sj"> Svalbard and Jan Mayen Islands </option><option value="sz"> Swaziland </option><option value="se"> Sweden </option><option value="ch"> Switzerland </option><option value="sy"> Syrian Arab Republic </option><option value="tw"> Taiwan </option><option value="tj"> Tajikistan </option><option value="tz"> Tanzania </option>
  210.                     <option value="th"> Thailand </option><option value="tg"> Togo </option><option value="tk"> Tokelau </option><option value="to"> Tonga </option><option value="tt"> Trinidad and Tobago </option><option value="tn"> Tunisia </option><option value="tr"> Turkey </option><option value="tm"> Turkmenistan </option><option value="tc"> Turks and Caicos Islands </option><option value="tv"> Tuvalu </option><option value="ug"> Uganda </option><option value="ua"> Ukraine </option><option value="ae"> United Arab Emirates </option><option value="gb"> United Kingdom </option><option value="us"> United States </option><option value="uy"> Uruguay </option><option value="uz"> Uzbekistan </option><option value="vu"> Vanuatu </option><option value="va"> Vatican </option><option value="ve"> Venezuela </option><option value="vn"> Viet Nam </option><option value="vg"> Virgin Islands (British) </option><option value="vi"> Virgin Islands (US) </option>
  211.                     <option value="wf"> Wallis and Futuna Islands </option><option value="eh"> Western Sahara </option><option value="ye"> Yemen </option><option value="yu"> Yugoslavia </option><option value="zm"> Zambia </option><option value="zw"> Zimbabwe </option>
  212.                 </select>
  213.             </li>
  214.             <?php
  215.             if ($config['use_captcha']) {
  216.                 ?>
  217.                 <li>
  218.                      <div class="g-recaptcha" data-sitekey="<?php echo $config['captcha_site_key']; ?>"></div>
  219.                 </li>
  220.                 <?php
  221.             }
  222.             ?>
  223.             <li>
  224.                 <h2>Server Rules</h2>
  225.                 <p>The golden rule: Have fun.</p>
  226.                 <p>If you get pwn3d, don't hate the game.</p>
  227.                 <p>No <a href='http://en.wikipedia.org/wiki/Cheating_in_video_games' target="_blank">cheating</a> allowed.</p>
  228.                 <p>No <a href='http://en.wikipedia.org/wiki/Video_game_bot' target="_blank">botting</a> allowed.</p>
  229.                 <p>The staff can delete, ban, do whatever they want with your account and your <br>
  230.                     submitted information. (Including exposing and logging your IP).</p>
  231.             </li>
  232.             <li>
  233.                 Do you agree to follow the server rules?<br>
  234.                 <select name="selected">
  235.                   <option value="0">Umh...</option>
  236.                   <option value="1">Yes.</option>
  237.                   <option value="2">No.</option>
  238.                 </select>
  239.             </li>
  240.             <?php
  241.                 /* Form file */
  242.                 Token::create();
  243.             ?>
  244.             <li>
  245.                 <input type="submit" value="Create Account">
  246.             </li>
  247.         </ul>
  248.     </form>
  249. <?php
  250. }
  251. include 'layout/overall/footer.php';
  252. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top