Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Active and deactivate user

Jatinder BediJatinder Bedi indiaPosts: 2

Active and deactivate is working in database ie it is becoming 0 and 1 in column status. Now i am unable to change LS or config file so that after login it should check in database table user column status whether it is 0 or 1 , If it is 1 (user active) it should go to home page otherwise it should go to error page (user not activated). how to create public function for this, and needed modifications in config file
LS File to control all functions is

  /**
   * Get the current page URL
  */
  public static function curPageURL() {
    $pageURL = 'http';
    if(isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"){$pageURL .= "s";}
    $pageURL .= "://";
    if($_SERVER["SERVER_PORT"] != "80") {
      $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    }else{
      $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $pageURL;
  }

  /**
   * Generate a Random String
         */
  public static function rand_string($length, $int = false) {
    $random_str = "";
    $chars = $int ? "0516243741506927589" : "subinsblogabcdefghijklmanopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    $size = strlen($chars) - 1;
    for($i = 0;$i < $length;$i++) {
      $random_str .= $chars[rand(0, $size)];
    }
    return $random_str;
  }

  /**
   * Get the current page path.
          */
  public static function curPage(){
    $parts = parse_url(self::curPageURL());
    return $parts["path"];
  }

  /**
   * Do a redirect
 */
  public static function redirect($url, $status = 302){
    header("Location: $url", true, $status);
    exit;
  }


      }
    }
  }

 }

Config file is

<?php
   ini_set("display_errors", "on");

require __DIR__ . "/src/LS.php";
$config = array(
  "basic" => array(
    "company" => "******",
    "email" => "******"
  ),
  "db" => array(
    "host" => "********",
    "port" => 3306,
    "username" => "**********",
    "password" => "***333",
    "name" => "*******",
    "table" => "users"
  ),
  "features" => array(
    "auto_init" => true,
    "two_step_login" => true
  ),
  /**
   * These are my localhost paths, change it to yours
   */
  "pages" => array(
    "no_login" => array(
      "/user/",
      "/user/reset.php",
      "/user/registercomember.php"
    ),
    "everyone" => array(
      "/user/status.php",
      "/tips/open.php"
    ),
    "login_page" => "/user/login.php",
    "home_page" => "/tips/all.php",

  ),
  "two_step_login" => array(
    "instruction" => "A token was sent to your E-Mail Address. Please see the mail in your inbox and paste the token found in the textbox below :",
    "send_callback" => function(&$LS, $userID, $token){
      $email = $LS->getUser("email", $userID);
      $LS->sendMail($email, "Verify Yourself", "Someone tried to login to your account. If it was you, then use the following token to complete logging in : <blockquote>". $token ."</blockquote>If it was not you, then ignore this email and please consider to change your account's password.");
    }
  )
);

$LS = new \Fr\LS($config);
Tagged:
Sign In or Register to comment.