Ejemplo n.º 1
0
 public static function sendPasswordResetLink(\Member $member)
 {
     $email = $member->getEmail();
     $locale = Localizer::get('mail.password_reset');
     $num = $member->getNum();
     $now = time();
     $email = $member->getEmail();
     $href = Router::toModule('manage', 'do_reset_password', ['num' => $num, 'exp' => time(), 'hash' => Cryption::getPasswordResetToken($num, $now, $email)]);
     return self::send($email, \Tbmt\view\Factory::buildMemberFullNameString($member), $locale['subject'], Localizer::insert($locale['body'], ['link' => $href], false));
 }
Ejemplo n.º 2
0
 public static function login($num, $pwd)
 {
     $member = \MemberQuery::create()->filterByDeletionDate(null, \Criteria::ISNULL)->findOneByNum($num);
     if (!$member) {
         return false;
     }
     if (!Cryption::verifyPassword($pwd, $member->getPassword())) {
         return false;
     }
     self::$user = $member;
     self::set(self::KEY_USER_ID, $member->getId());
     return $member;
 }
Ejemplo n.º 3
0
 public static function login($num, $pwd)
 {
     $member = \MemberQuery::create()->filterByDeletionDate(null, \Criteria::ISNULL)->filterByNum($num)->filterByIsExtended(Config::get('extended.marketing.member', TYPE_BOOL, false))->findOne();
     if (!$member) {
         return false;
     }
     if (!Cryption::verifyPassword($pwd, $member->getPassword())) {
         return false;
     }
     self::$user = $member;
     self::set(self::KEY_USER_ID, $member->getId());
     return $member;
 }
Ejemplo n.º 4
0
 public function action_do_reset_password()
 {
     $data = \Tbmt\Arr::initMulti($_REQUEST, ['num' => TYPE_STRING, 'exp' => TYPE_STRING, 'hash' => TYPE_STRING]);
     $newPassword = false;
     if (!empty($data['num']) || !empty($data['exp']) || !empty($data['hash'])) {
         $member = \Member::getByNum($data['num']);
         if ($member && Cryption::validatePasswordResetToken($data['num'], $data['exp'], $member->getEmail(), $data['hash']) && intval($data['exp']) + 3600 * 24 >= time()) {
             $newPassword = bin2hex(mcrypt_create_iv(8, MCRYPT_DEV_URANDOM));
             $member->setPassword($newPassword);
             $member->save();
         }
     }
     return ControllerDispatcher::renderModuleView(self::MODULE_NAME, CURRENT_MODULE_ACTION, ['newPassword' => $newPassword]);
 }
Ejemplo n.º 5
0
 public function request($params = null, $url = null, $method = null, $contenttype = 'text/plain')
 {
     $this->responseHeaders = array();
     if (!is_array($params)) {
         $params = [];
     }
     $params['token'] = Cryption::getApiToken();
     // Initialize parameters
     $url = parse_url($url === null ? $this->url : $url);
     $query = isset($url['query']) ? $url['query'] : null;
     $method = strtoupper($method === null ? $this->method : $method);
     if ($contenttype) {
         // Only set content type if is given
         $this->appendHeader('Content-Type: ' . $contenttype);
     }
     // Perform the request
     if (empty($this->methods[$method])) {
         throw new \Exception('Invalid HTTP method: ' . $method);
     }
     // Add this to your script if you ever encounter an
     // "417 - Expectation Failed" error message.
     //$this->appendHeader('Expect:');
     $ctxHttpParams = ['method' => $method, 'ignore_errors' => true];
     if ($this->protocol_version) {
         $ctxHttpParams['protocol_version'] = $this->protocol_version;
     }
     if ($this->additionHttpContextParams) {
         $ctxHttpParams = array_merge($ctxHttpParams, $this->additionHttpContextParams);
     }
     $strUrl = $url['scheme'] . '://' . $url['host'] . (isset($url['port']) ? ':' . $url['port'] : '');
     if (isset($url['path'])) {
         $strUrl .= $url['path'];
     }
     $contentLength = 0;
     if (!empty($params)) {
         if ($method === 'GET') {
             if (is_array($params)) {
                 $query = ($query === null ? '' : '&') . http_build_query($params, null, '&');
             } else {
                 $query = ($query === null ? '' : '&') . $params;
             }
         } else {
             if (strpos($contenttype, 'application/json') === 0) {
                 $ctxHttpParams['content'] = is_string($params) ? $params : json_encode($params);
                 $contentLength = strlen($ctxHttpParams['content']);
             } else {
                 $ctxHttpParams['content'] = http_build_query($params, null, '&');
                 $contentLength = strlen($ctxHttpParams['content']);
             }
         }
     }
     if ($query) {
         $strUrl .= '?' . $query;
     }
     $this->appendHeader('Content-Length: ' . $contentLength);
     $ctxHttpParams['header'] = $this->getHeader();
     if (isset($url['fragment'])) {
         $strUrl .= '#' . $url['fragment'];
     }
     $arrContentOptions = ['http' => $ctxHttpParams];
     $ctx = stream_context_create($arrContentOptions);
     $contents = file_get_contents($strUrl, false, $ctx);
     $this->responseHeaders = isset($http_response_header) ? $http_response_header : array();
     return new RestResult($contents, $http_response_header);
 }
Ejemplo n.º 6
0
                    
                    <span id="rightbar-toggle" class="hidden-lg sidebar-toggle">
                         <i class="fa fa-angle-left"></i>
                    </span>
               </aside>

            <!-- Content -->
            <section id="content" class="container">
                <header class="p-header">
                    <h2 class="p-title">Student List</h2>
                </header>
                
                <div class="row">
                    <?php 
if (Token::check(Input::get('tid')) && Input::get('sid')) {
    $id = Cryption::decryt64(Input::get('sid'));
} else {
    ?>
                    <div class="col-lg-12 col-xs-12 search-div" style="margin-bottom:10px">
                      <div class="col-xs-12 form-inline">
                        <input type="text" data-column="0" id="search-person" class="form-control col-xs-12" style="max-width:400px" placeholder='Search Student....'>
                      </div>
                    </div>
                    <div class="col-lg-6">
                      <div class="col-xs-12 search-dis">
                        <div class="block">
                            <h2 style="margin:0px" class="resultc">Result Found:</h2>
                            <div class="config">
                              View By:
                              <a id="show-list" data-toggle="tooltip" data-original-title="List" class="ttips active">
                                  <i class="fa fa-list"></i>
Ejemplo n.º 7
0
Archivo: test.php Proyecto: riidt/rest
<?php

if (!defined('REST')) {
    exit('Access Denied');
}
include_once "class_cryption.php";
$c = new Cryption();
$s = "ri.idt@163.com && riidt0807";
$k = "riidt0807";
$en = $c->en($s, $k);
$de = $c->de($en, $k);
echo $de . "<br>";
echo $en . "<br>";
echo $s . "<br>";
Ejemplo n.º 8
0
 /**
  * The authentication method specifies if an API task may be executed or not.
  * This method may be different in subordinate classes
  *
  * @return bool
  */
 public function auth()
 {
     if (isset($_REQUEST['token'])) {
         return Cryption::validateApiToken($_REQUEST['token']);
     }
     return false;
 }
Ejemplo n.º 9
0
 public function check($source, $item = array())
 {
     foreach ($item as $itm => $rules) {
         foreach ($rules as $rule => $rule_values) {
             $value = trim($source[$itm]);
             $itm = escape($itm);
             if ($rule === 'name') {
                 $name = $rule_values;
             }
             if ($rule === 'required' && empty($value)) {
                 $this->addError("{$name} is required");
             } else {
                 if (!empty($value)) {
                     switch ($rule) {
                         case 'min':
                             if (strlen($value) < $rule_values) {
                                 $this->addError("{$name} must be minimum of {$rule_values} characters");
                             }
                             break;
                         case 'max':
                             if (strlen($value) > $rule_values) {
                                 $this->addError("{$name} must be maximum of {$rule_values} characters");
                             }
                             break;
                         case 'matches':
                             if ($value != $source[$rule_values]) {
                                 $this->addError("{$rule_values} must match {$name}");
                             }
                             break;
                         case 'unique':
                             $check = $this->db->get($rule_values, array($itm, '=', $value));
                             if ($check->count()) {
                                 $this->addError("{$name} already exist");
                             }
                             break;
                         case 'samepassword':
                             $check = $this->db->get($rule_values, array(substr($itm, 1), '=', Cryption::generatehash($value)));
                             if (!$check->count()) {
                                 $this->addError("Wrong entered {$name}");
                             }
                             break;
                         case 'phone':
                             if (!preg_match("/^([\\+][0-9]{1,3}[\\ \\.\\-])?([\\(]{1}[0-9]{2,6}[\\)])?([0-9\\ \\.\\-\\/]{3,20})((x|ext|extension)[\\ ]?[0-9]{1,4})?\$/", $value)) {
                                 $this->addError("{$name} is Invalid Phone");
                             }
                             break;
                         case 'number':
                             if (!is_numeric($value)) {
                                 $this->addError("{$name} must be numeric number only");
                             }
                             break;
                         case 'letter':
                             if (!preg_match("/^[a-zA-Z\\ \\']+\$/", $value)) {
                                 $this->addError("{$name} must be all letter only");
                             }
                             break;
                         case 'letterNumber':
                             if (!preg_match("/^[0-9a-zA-Z]+\$/", $value)) {
                                 $this->addError("{$name} must be all letter or number only");
                             }
                             break;
                         case 'icNumber':
                             if (!preg_match("/^[0-9]{6}[0-9]{2}[0-9]{4}\$/", $value)) {
                                 $this->addError("{$name} not valid IC number");
                             }
                             break;
                         case 'email':
                             if (!filter_var($value, FILTER_VALIDATE_EMAIL)) {
                                 $this->addError("{$name} must be valid email");
                             }
                             break;
                     }
                 }
             }
         }
     }
     if (empty($this->errors)) {
         $this->passed = true;
     }
     return $this;
 }
Ejemplo n.º 10
0
<?php

require "control/core/init.php";
$current_url = Cryption::encryt64($url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
Session::put('current_url', $current_url);
$total = 0;
$total_item = 0;
?>
<!DOCTYPE html>
<html>
    <head>
        <title></title>
         <meta name="viewport" content="width=device-width, initial-scale=1.0">
         <meta name="description" content="">
         <meta name="keywords" content="">
         <meta charset="UTF-8">
         
         <!-- CSS -->
         <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
         <link href="css/calendar.min.css" rel="stylesheet">
         <link href="css/media-player.min.css" rel="stylesheet">
         <link href="css/form.min.css" rel="stylesheet">
         <link href="css/style.min.css" rel="stylesheet">
         <!-- CSS font -->
         <link href="css/icomoon.min.css" rel="stylesheet">
         <link href="fonts/font-awesome-4.3.0/css/font-awesome.min.css" rel="stylesheet">
         

         <link rel="stylesheet" type="text/css" href="css/sales.css">

          <style type="text/css">
Ejemplo n.º 11
0
                                                        echo '</div>';
                                                        $unpaid = DB::getInstance()->query("Select SUM(total) as sum_total from history_tbl where stud_id = ? and status = 'unpaid'", array($val->stud_id));
                                                        $opid = $unpaid->result();
                                                        if ($opid[0]->sum_total != NULL) {
                                                            echo '<div class="block attrs attrs-red">';
                                                            echo 'Total Unpaid: RM ' . $opid[0]->sum_total;
                                                            echo '</div>';
                                                        }
                                                        echo '</div>';
                                                        echo '<div class="list-options">';
                                                        echo '<button class="btn btn-danger btn-sm">Delete</button>';
                                                        echo '<button class="btn btn-primary btn-sm viewdiv" view="' . $val->stud_id . '">View</button>';
                                                        echo '</div>';
                                                        echo '</div>';
                                                    }
                                                }
                                            } else {
                                                $current_url = Cryption::decryt64(Session::get("current_url"));
                                                Redirect::to($current_url);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}