示例#1
0
 /**
  * Dispatch post actions
  *
  * @param array $segments Method segments indicate action and resource
  *
  * @return void
  */
 public function restPost($segments)
 {
     $action_id = $segments[0];
     switch ($action_id) {
         case 'login':
             $validate_login_username = LMValidateHelper::validateNoEmpty($_POST['login_username']);
             $validate_login_password = LMValidateHelper::validateNoEmpty($_POST['login_password']);
             if (!$validate_login_username || !$validate_login_password) {
                 $type = 'not_exist_value';
                 $parameter = array("none" => "none");
                 $error_messanger = new IndievoxErrorMessenger($type, $parameter);
                 $error_messanger->printErrorJSON();
                 unset($error_messanger);
             } else {
                 $login_username = $_POST['login_username'];
                 $login_password = $_POST['login_password'];
                 $user_god = new LMUserGod();
                 $user_id = $user_god->checkUserPassword($login_username, $login_password);
                 if (!empty($user_id)) {
                     LMAuthHelper::login($user_id);
                     $type = 'success';
                     $parameter = array("none" => "none");
                     $error_messanger = new LMErrorMessenger($type, $parameter);
                     $error_messanger->printErrorJSON();
                     unset($error_messanger);
                 } else {
                     $type = 'login_fail';
                     $parameter = array("none" => "none");
                     $error_messanger = new LMErrorMessenger($type, $parameter);
                     $error_messanger->printErrorJSON();
                     unset($error_messanger);
                 }
                 // end if (!empty($user_id))
             }
             // end if (!$validate_login_username|| $validate_login_password)
             break;
         case 'logout':
             LMAuthHelper::logout();
             $type = 'success';
             $parameter = array("none" => "none");
             $error_messanger = new LMErrorMessenger($type, $parameter);
             $error_messanger->printErrorJSON();
             unset($error_messanger);
             break;
         default:
             $type = 'page_not_found';
             $parameter = array("none" => "none");
             $error_messanger = new LMErrorMessenger($type, $parameter);
             $error_messanger->printErrorJSON();
             unset($error_messanger);
             break;
             // end default
     }
     // end switch ($action_id)
 }
示例#2
0
 /**
  * Method permitAccess check access permission
  *
  * @param string $page_path # the page path
  *
  * @return void
  */
 public static function permitAccess($page_path)
 {
     $backyard_pattern = "/^\\/b\\/*/";
     if (preg_match($backyard_pattern, $page_path)) {
         if (!LMAuthHelper::isLogin()) {
             header("Location: " . SITE_HOST . "/403.php");
             exit;
         }
         // end if
     }
     // end if
 }
示例#3
0
/**
 * index.php is the /music/index.php content
 *
 * PHP version 5
 *
 * @category PHP
 * @package  /music/
 * @author   Fukuball Lin <*****@*****.**>
 * @license  No Licence
 * @version  Release: <1.0>
 * @link     http://sarasti.cs.nccu.edu.tw
 */
?>
<div id='song-list-block'>
   <?php
   if (LMAuthHelper::isLogin()) {
   ?>
   <table width="1000px" class="table table-bordered table-striped">
      <thead width="1000px">
         <tr width="1000px">
            <th width="50px">
               id
            </th>
            <th width="50px">
               藝人
            </th>
            <th width="100px">
               歌名
            </th>
            <th width="400px">
               歌詞