Exemplo n.º 1
0
 public function __construct()
 {
     if (!self::$_db_data) {
         self::$_db_data = DB::GetInstance();
         self::$_connect_data = self::$_db_data->GetConnection();
     }
 }
Exemplo n.º 2
0
         if (isset($_SESSION['loggedin'])) {
             $_SESSION['username'] = $_POST['username'];
             $message = msgSignedIn($_POST['username']);
             include_once 'views/list.php';
         } else {
             $error = "Username or password is not correct";
             include_once 'views/login.php';
         }
         exit;
     }
     break;
 case 'logout':
     session_destroy();
     session_start();
     $db = new PDO(DB_INFO, DB_USER, DB_PASS);
     $dreams = new Dreams($db);
     $d = $dreams->getDreams();
     // Send the user back to their last location
     $message = msgSignedOut();
     include_once 'views/list.php';
     break;
 case 'addcomment':
     if (!empty($_POST['content'])) {
         // Include database connection
         $db = new PDO(DB_INFO, DB_USER, DB_PASS);
         $comments = new Comments($db);
         $comments->addcomment($_POST);
         header('location: ' . $loc);
         exit;
     }
     break;
Exemplo n.º 3
0
        $params[$key] = $value;
    }
} else {
    foreach ($_GET as $key => $value) {
        $params[$key] = $value;
    }
}
if (empty($params['api_uid'])) {
    $output = array('data' => null, 'msg' => "没有接口名!", 'result' => 201);
    exit(json_encode($output));
}
//file_put_contents("dreams.txt", $params);
switch ($params['api_uid']) {
    case "users":
        //登录校验
        $usersApi = new Users();
        $ret = $usersApi->chooseType($params);
        exit($ret);
        break;
    case "dreams":
        $dreamApi = new Dreams();
        $ret = $dreamApi->chooseType($params);
        exit($ret);
        break;
    case "comments":
        $commentApi = new Comments();
        $ret = $commentApi->chooseType($params);
        exit($ret);
    default:
        break;
}