Advertisement
droidus

Untitled

Jun 9th, 2011
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.48 KB | None | 0 0
  1. <?php
  2. if (!isset($_SESSION))
  3.     {
  4.         session_start();
  5.     }
  6. ?>
  7. <?php require_once('../Connections/uploader.php'); ?>
  8. <?
  9. function loginFormErrorsCheck ($loginUsername, $loginPassword) {
  10.   if (empty($loginUsername) || empty($loginPassword)) {
  11.     return true;
  12.   } else {
  13.     return false;
  14.   }
  15. }
  16. ?>
  17.  
  18.  
  19.  
  20.  
  21.  
  22. <?php
  23. if (isset($_POST['login'])) {
  24.    
  25.     $loginUsername = $_POST['uname'];  
  26.     $loginPassword = $_POST['pword'];
  27.    
  28.     $errors = loginFormErrorsCheck ($loginUsername, $loginPassword);    
  29.    
  30.     if (!$errors) {
  31.        
  32.         mysql_select_db($database_uploader, $uploader);    
  33.         $query = "SELECT * FROM members WHERE uname='"
  34.         . mysql_real_escape_string($loginUsername) . "' AND pword='"
  35.         . mysql_real_escape_string($loginPassword) . "'";  
  36.         $result = mysql_query($query) or die(mysql_error());
  37.        
  38.         // make sure the username and password were found
  39.         if (mysql_num_rows($result) > 0) {
  40.             $row = mysql_fetch_array($result) or die(mysql_error());
  41.            
  42.             if ($loginUsername == "admin") { // Admin Login
  43.                 mysql_close($result);
  44.                 $_SESSION['admin'] = "Admin.";
  45.                 header('Location: admin.php');
  46.                 exit;
  47.             }
  48.            
  49.             if ($row['acntStatus'] == 0) {  // If account is OK
  50.                 mysql_close($result);
  51.             }
  52.             else // If account is in bad standing
  53.                 {
  54.                     $errors[0]="Your account has been temporarily/permanently disabled, or terminated. Please contact us for more details.";
  55.                 }
  56.            
  57.             if ($row['activated'] == 1) {
  58.                
  59.             }
  60.             else {$errors[1] = "Your account is not yet activated.";}
  61.            
  62.             if ($row['activated'] == 1 && $row['acntStatus'] == 0)
  63.             {
  64.                 mysql_close($result);
  65.                 $_SESSION[$user] = $loginUsername;
  66.                 header('Location: users/' . $row['uname'] . '/index.php');
  67.                 exit;
  68.             }
  69.         }
  70.     }
  71. }
  72. ?>
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.     <?
  86.     if (isset($_POST['register'])) {
  87.        
  88.     if (empty($name)) {
  89.         $name_error = 'Flagged';
  90.         $errors=1;
  91.     }
  92.     if (empty($new_username)) {
  93.         $newusername_error = 'Flagged';
  94.         $errors=1;
  95.     }
  96.     if (empty($new_password)) {
  97.         $newpassword_error = 'Flagged';
  98.         $errors=1;
  99.     }
  100.     $pattern = '/^[^@]+@[^\s\r\n\'";,@%]+$/';
  101. if (!preg_match($pattern, trim($new_email)) || empty($new_email))
  102. {
  103.     $newemail_error = 'Flagged';
  104.     $errors =1;
  105. }
  106.     if (($spamcheck != 7) || empty($spamcheck)) {
  107.         $errors=1;
  108.         $spamcheck_error = 'Flagged';
  109.     }
  110.             if (file_exists($new_username))
  111.     {
  112.         $errors = 1;
  113.         echo "<span class='error'>We are sorry, but the username, $new_username, is already taken.</span>";
  114.     }
  115.    
  116.         if (!file_exists($new_username) && !(empty($new_username)) && ($errors != 1))  // if the user is not registered....
  117.     {
  118.         echo "Please wait while we process your request and setup your user account...";
  119.    
  120.         $_SESSION['username'] = $new_username;
  121.        
  122.         mkdir('users/'.$new_username); // creates the user's profile
  123.        
  124.             /*if (isset($remember)) {
  125.     $_COOKIE['username'] = $_POST['new_username'];
  126.     $_COOKIE['password'] = $_POST['new_password']; }*/
  127.                    
  128.                 /* Accessing SQL-Server and querying table */
  129.  
  130.                
  131.                 mysql_query(sprintf("INSERT INTO members(name, uname, pword, email, activated) VALUES('%s','%s','%s','%s','%s')",mysql_real_escape_string($name),mysql_real_escape_string($new_username),mysql_real_escape_string($new_password),mysql_real_escape_string($new_email), mysql_real_escape_string($acntactivation)))
  132.            
  133.                 // ERROR MESSAGE??
  134.     or die(mysql_error());  
  135.     mysql_close($con);
  136.            
  137.            
  138.         $file2 = 'myaccount.php';
  139.         $newfile2 = 'users/'.$new_username.'/myaccount.php';
  140.         if (!copy($file2, $newfile2)) // Optional
  141.         {
  142.             echo "<br>Failed to copy $file2 to the location, $newfile2.";
  143.         }  
  144.         $file3 = 'upgrade.php';
  145.         $newfile3 = 'users/'.$new_username.'/upgrade.php';
  146.         if (!copy($file3, $newfile3)) // Optional
  147.         {
  148.             echo "<br>Failed to copy $file3 to the location, $newfile3.";
  149.         }  
  150.                             // copy all files to user's folder
  151.         $file = 'index.php';
  152.         $newfile = 'users/'.$new_username.'/index.php';
  153.         if (!copy($file, $newfile)) // Optional
  154.         {
  155.             echo "<br>Failed to copy $file to the location, $newfile.";
  156.         }
  157.         else
  158.         {
  159.             echo '<br>Your account has been successfully created.  It may take up to two weeks to activate your account.  We will e-mail you at the e-mail address you specified when your account is fully activated.';
  160.             // USE THIS WHEN SERVICE IS READY - echo '<br><a href="/VBS/' . $new_username . '/index.php">Your account has been successfully created.  It may take up to two weeks to activate your account.  We will e-mail you at the e-mail address you specified when you may start using your account.</a>';
  161.         }  
  162.     }
  163.     }
  164.     ?>
  165.    
  166.    
  167. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  168. <html xmlns="http://www.w3.org/1999/xhtml">
  169. <head>
  170. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  171. <title>Member's Area</title>
  172. <style type="text/css">
  173. .required { color:#F00;
  174. }
  175. body {
  176.     background-color: #FC9;
  177. }
  178. .errors {
  179.     color:#F00;
  180.     font-weight:bold;
  181. }
  182. </style>
  183. </head>
  184.  
  185. <body>
  186. <h1 align="center"><img src="../Images/user_logout.gif" width="40" height="40" /> Member's Area</h1>
  187. <p align="center">To access this restricted access area, please login if you are an existing member, or register.</p>
  188. <?php
  189. if (isset($errors) && !empty($errors)) {
  190.     for ($i=0; $i<2; $i++) {
  191.         echo "<p class='errors'>$errors[$i]<br></p>";
  192.     }
  193. }
  194. ?>
  195.  
  196. <table width="50%" border="1" align="center">
  197.   <tr>
  198.     <td><form action="" method="post" id="login" name="login" >
  199. <table border="1" align="center">
  200.   <tr>
  201.     <td colspan="2"><h3>Login</h3>
  202.       <p>Please enter a username to continue being uploading your files:</p></td>
  203.     </tr>
  204.   <tr>
  205.     <td>Username: </td>
  206.     <td><input type="text" name="uname" id="uname" value="<? if (isset($errors)) {echo $_POST['uname'];} ?>" /></td>
  207.   </tr>
  208.   <tr>
  209.     <td>Password: </td>
  210.     <td><input name='pword' type='password' value="<? if (isset($errors)) {echo $_POST['pword'];} ?>" /></td>
  211.   </tr>
  212.   <tr>
  213.     <td colspan="2">By clicking &quot;Submit&quot;, you have read agreed to the <a href="#">Terms and Conditions</a>. </td>
  214.   </tr>
  215.     <tr>
  216.       <td>&nbsp;</td>
  217.       <td><input type="submit" name="login" id="login" value="Submit" /></td>
  218.     </tr>
  219. </table>
  220. </form></td>
  221.     <td><strong><span style="padding:15px;">OR</span></strong></td>
  222.     <td><form id="register" name="register" method="post" action=""><table border="0" align="center">
  223.   <tr>
  224.     <td colspan="2"><h3>Register</h3>
  225.       <p>If you are not yet a member of this site, you must register to be able to use our services. Please fill out the following fields:</p></td>
  226.     </tr>
  227.   <tr>
  228.     <td align="right"><span class="required">*</span>Name:</td>
  229.     <td><input type="text" name="name" id="name" value="<? if (isset($errors)) {echo $_POST['name']; } ?>" /></td>
  230.   </tr>
  231.   <tr>
  232.     <td align="right"><label for="new_username"><span class="required">*</span>Username:</label></td>
  233.     <td><input type="text" name="new_username" id="new_username" value="<? if (isset($errors)) {echo $_POST['new_username']; } ?>" /></td>
  234.   </tr>
  235.   <tr>
  236.     <td align="right"><span class="required">*</span>Password:</td>
  237.     <td><input type="password" name="new_password" id="new_password" value="<? if (isset($errors)) {echo $_POST['new_password']; } ?>" /></td>
  238.   </tr>
  239.   <tr>
  240.     <td align="right"><span class="required">*</span>E-mail Address: </td>
  241.     <td><input type="text" name="new_email" id="new_email" value="<? if (isset($errors)) {echo $_POST['new_email']; } ?>" /></td>
  242.   </tr>
  243.   <tr>
  244.     <td>&nbsp;</td>
  245.     <td><span style="color:#999; font-size:12px;">*Please not that a max of 500mb is supported at this time.</span></td>
  246.   </tr>
  247.   <tr>
  248.     <td align="right">Remember me?:</td>
  249.     <td><input name="remember" type="checkbox" value="remember" disabled="disabled" /></td>
  250.   </tr>
  251.   <tr>
  252.     <td align="right"><span class="required">*</span>Human Verification - What is 5 + 2?: </td>
  253.     <td><input type="text" name="spamcheck" id="spamcheck" value="<? if (isset($errors)) {echo $_POST['spamcheck']; } ?>" /></td>
  254.   </tr>
  255.   <tr>
  256.     <td colspan="2">By clicking &quot;Submit&quot;, you have read agreed to the <a href="#">Terms and Conditions</a>. </td>
  257.     </tr>
  258.   <tr>
  259.     <td>&nbsp;</td>
  260.     <td><input type="submit" name="register" id="register" value="Submit" /></td>
  261.   </tr>
  262. </table>
  263. </form></td>
  264.   </tr>
  265.   <tr>
  266.   <td colspan="3" align="right";> v. 1.0 </td>
  267.   </tr>
  268. </table>
  269.  
  270.  
  271.  
  272. </div>
  273. </body>
  274. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement