Guest User

Untitled

a guest
Jun 5th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.51 KB | None | 0 0
  1. <?php
  2.  
  3. error_reporting(E_ALL);
  4. ini_set("display_errors", 1);
  5.  
  6. //single file registration script!
  7. session_start();
  8. //requires
  9. require("simple-php-captcha.php");
  10.  
  11. //uncomment to Disable registration.
  12. //die("<br><br><center>Registration is currently disabled due to closed beta testing. Please try again in a couple days! :D</center><br><center><p>Right now, beta testing is invite only.</p></center>");
  13.  
  14. //Config (You really only need to change domain, m, & p. But anything in the config array can be changed how you want :)
  15. $config = array(
  16.     "domain"    => "clemail.me",
  17.     "m"         => escapeshellcmd("[email protected]"),
  18.     "p"         => escapeshellcmd("xxxxx"),
  19.     "captcha" => array( //Configure Captcha settings for registration.
  20.         'min_length' => 8,
  21.         'max_length' => 10,
  22.         'backgrounds' => array('backgrounds/45-degree-fabric.png','backgrounds/45-degree-fabric.png','backgrounds/45-degree-fabric.png','backgrounds/45-degree-fabric.png'),
  23.         'fonts' => array('fonts/times_new_yorker.ttf'),
  24.         'characters' => 'ABCDEFGHJKLMNPRSTUVWXYZabcdefghjkmnprstuvwxyz23456789',
  25.         'min_font_size' => 15,
  26.         'max_font_size' => 20,
  27.         'color' => '#666',
  28.         'angle_min' => 0,
  29.         'angle_max' => 20,
  30.         'shadow' => true,
  31.         'shadow_color' => '#fff',
  32.         'shadow_offset_x' => -1,
  33.         'shadow_offset_y' => 1
  34.         )
  35.     );
  36. //Check for POST
  37. head();
  38. if(isset($_SESSION['email']) && isset($_POST['username'])){
  39.     //body();
  40.     $_SESSION['message'] = '<p style="color:DarkRed">You already created an email. Get outta here!</p>';
  41.    
  42. }
  43. if(isset($_POST['username']) && isset($_POST['password']) && isset($_POST['captcha'])){
  44.     //Process a registration.
  45.     if($_POST['captcha'] == $_SESSION['captcha']['code']){
  46.         if(!isset($_SESSION['email'])){
  47.             $ret = register($_POST['username'], $_POST['password']);
  48.             if($ret === true){
  49.                 $_SESSION['message'] = '<text><p style="color:green">E-mail '.$_POST['username'].'@'.$config['domain'].' successfully created! You may login to that email using the following settings:</p>
  50.                     <br>
  51.                     Server: <b>'.$config['domain'].'</b><br>
  52.                     Username: <b>'.$_POST['username'].'@'.$config['domain'].'</b><br>
  53.                     Password: Duh?<br>
  54.                     Type: <b>IMAP/SMTP</b><br>
  55.                     Ports: <b>993/587</b><br>
  56.                     SSL/TLS: <b>Yes</b><br>
  57.                     </text>';
  58.                     $_SESSION['email'] = $username."@".$config['domain'];
  59.             } else {
  60.                 $_SESSION['message'] = '<text style="color:darkred">There was an error creating the email, please try again or contact the systems administrator!<br>'.$ret.'</text>';
  61.             }  
  62.         }
  63.        
  64.     } else {
  65.         $_SESSION['message'] = '<text style="color:darkred">The captcha was invalid, please try again!</text>';
  66.     }
  67.  
  68. }
  69. bodyLogin();
  70. function head(){
  71.     echo '';
  72.     ?>
  73. <html>
  74.     <head>
  75.         <title><?php echo $config['domain']; ?> Registration</title>
  76.         <meta charset="utf-8">
  77.         <meta http-equiv="X-UA-Compatible" content="IE=edge">
  78.         <meta name="viewport" content="width=device-width, initial-scale=1">
  79.         <meta name="description" content="">
  80.         <meta name="author" content="">
  81.         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  82.         <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
  83.         <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  84.         <style>
  85.         .frame {
  86.           display: block;
  87.           width: 100vw;
  88.           height: 80vh;
  89.           max-width: 100%;
  90.           margin: 0;
  91.           padding: 0;
  92.           border: 0 none;
  93.           box-sizing: border-box;
  94.         }
  95.         </style>
  96.     </head>
  97.  
  98.     <?php
  99. }
  100.  
  101. if (class_exists('mysqli')) {
  102.     echo "MySQLi Class Exists";
  103. }
  104. else
  105. {
  106.  echo "MySQLi Class Does Not Exist";
  107. }
  108.  
  109.  
  110. function bodyLogin(){
  111.     global $config;
  112.     $_SESSION['captcha'] = simple_php_captcha($config['captcha']);
  113.     echo '';
  114.     ?>
  115.     <body>
  116.     <div class="container">
  117.         <div class="page-header">
  118.             <h1><?php echo $config['domain']; ?> Registration Form</h1>
  119.         </div>
  120.     <div class="row">
  121.         <div class="col-md-6">
  122.             <iframe src="eula.html" class="frame"></iframe><br />
  123.         </div>
  124.         <div class="col-md-6">
  125.             <form action="index.php" method="POST">
  126.                 <div class="form-group">
  127.                 <label for="user">Username:</label>
  128.                 <div class="row">
  129.                     <div class="col-md-6">
  130.                         <input type="username" class="form-control" id="username" name="username">
  131.                     </div>
  132.                     <div class="col-md-6">
  133.                         <p>@<?php echo $config['domain']; ?></p>
  134.                     </div>
  135.                 </div>
  136.               </div>
  137.               <div class="form-group">
  138.                 <label for="pass">Password:</label>
  139.                 <input type="password" class="form-control" id="password" name="password">
  140.               </div>
  141.                 <div class="form-group">
  142.                     <label for="cap">Captcha Request:</label><br />
  143.                     <img src="<?php echo $_SESSION['captcha']['image_src']; ?>">&nbsp;&nbsp;<input type="text" name="captcha" id="captcha" rows="12">
  144.                 </div>
  145.               <small>By clicking "Submit" you are agreeing to the Terms and Conditions found to the left of this form.</small><button type="submit" class="btn btn-primary pull-right">Submit</button>
  146.             </form><br>
  147.             <?php
  148.             if(isset($_SESSION['message']) && $_SESSION['message'] !== ""){
  149.                 echo $_SESSION['message'];
  150.                 $_SESSION['message'] = "";
  151.             }
  152.             ?>
  153.         </div>
  154.     </div>
  155.     </div>
  156.     </body>
  157.     <?php
  158. }
  159. function register($username, $password){
  160.     global $config;
  161.     //first make sure this shit is safe.
  162.     $username = clean($username);
  163.     $password = escapeshellcmd($password);
  164.     $return = shell_exec('curl -X POST -k --insecure --user '.$config['m'].':'.$config['p'].' -d "email='.$username.'@'.$config['domain'].'" -d "password='.$password.'" https://localhost/admin/mail/users/add');
  165.     $bool = false;
  166.     if(strpos($return, 'mail user added') !== false){
  167.         $bool = true;
  168.     } else if(strpos($return, 'User already exists.') !== false){
  169.         $bool = "User account already exists, please use a different name.";
  170.     } else {
  171.         $bool = false;
  172.     }
  173.     return $bool;
  174. }
  175. function clean($string) {
  176.    $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
  177.    $string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
  178.  
  179.    return preg_replace('/-+/', '-', $string); // Replaces multiple hyphens with single one.
  180. }
  181. ?>
Add Comment
Please, Sign In to add comment