update
This commit is contained in:
parent
c8aa241511
commit
0e99eb711e
10 changed files with 191 additions and 54 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
session_start();
|
||||
define('IN_SYS', true);
|
||||
require_once("core.php");
|
||||
require_once "core.php";
|
||||
|
||||
include_once "{$ROOT}/library/email.class.php";
|
||||
$section = empty($_GET["s"]) ? "main" : $_GET["s"];
|
||||
|
@ -12,6 +12,9 @@ if (!is_file($section_page)) {
|
|||
}
|
||||
|
||||
$objDB = objDB();
|
||||
|
||||
$dbpdo = DBPDO::getInstance($dbconfig);
|
||||
|
||||
$user = get_userinfo();
|
||||
|
||||
$controller = "{$ROOT}/clientarea/controllers/{$section}.php";
|
||||
|
|
|
@ -7,6 +7,5 @@ if (!defined('IN_SYS')) {
|
|||
}
|
||||
|
||||
if (!isUserLoggedIn()) {
|
||||
setMsg("msg_notify", "You need to login before accessing the Client Area.", "warning");
|
||||
redirect("clientarea", "login");
|
||||
}
|
||||
|
|
|
@ -14,6 +14,33 @@ if (!isUserLoggedIn()) {
|
|||
$err = getMsg("errors");
|
||||
$data = getMsg("form_data");
|
||||
|
||||
function getTickets()
|
||||
{
|
||||
// DB_HOST, DB_USER, DB_PASSWORD, DB_NAME
|
||||
echo "getTickets()";
|
||||
$stmt = $dbpdo->prepare(
|
||||
"SELECT * FROM tickets"
|
||||
);
|
||||
$sql = 'SELECT * FROM `tickets`';
|
||||
$rs = $pdo->query($sql);
|
||||
$data = $rs->fetchAll(); //取出所有结果
|
||||
print_r($data);
|
||||
// $sql = 'UPDATE t1 SET t1.`id1`=11 WHERE t1.`id1`=1';
|
||||
// $rs = $pdo->query($sql);
|
||||
// // $stmt->bind_param("s", $email);
|
||||
// $stmt->execute();
|
||||
// // $stmt->store_result();
|
||||
// // return $stmt->num_rows;
|
||||
// $result = $stmt->get_result();
|
||||
|
||||
// // while ($row = $result->fetch_assoc()) {
|
||||
// // // do something with $row
|
||||
// // }
|
||||
// return $result;
|
||||
}
|
||||
|
||||
print_r(getTickets());
|
||||
|
||||
$tickets = [
|
||||
"total" => 10,
|
||||
"pages" => 4,
|
||||
|
@ -24,21 +51,21 @@ $tickets = [
|
|||
"department" => "Saturday, August 11th, 2018 (04:50)",
|
||||
"subject" => "Invoice Payment Confirmation",
|
||||
"status" => "",
|
||||
"lastupdated" => ""
|
||||
"lastupdated" => "",
|
||||
],
|
||||
[
|
||||
"date" => "Friday, August 10th, 2018 (12:00)",
|
||||
"department" => "Friday, August 10th, 2018 (12:00)",
|
||||
"subject" => "Customer Invoice",
|
||||
"status" => "",
|
||||
"lastupdated" => ""
|
||||
"lastupdated" => "",
|
||||
],
|
||||
[
|
||||
"date" => "Tuesday, April 3rd, 2018 (00:51)",
|
||||
"department" => "Tuesday, April 3rd, 2018 (00:51)",
|
||||
"subject" => "Your password has been reset",
|
||||
"status" => "",
|
||||
"lastupdated" => ""
|
||||
]
|
||||
]
|
||||
"lastupdated" => "",
|
||||
],
|
||||
],
|
||||
];
|
||||
|
|
19
clientarea/controllers/tickets_add.php
Normal file
19
clientarea/controllers/tickets_add.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
if (!defined('IN_SYS')) {
|
||||
// exit('禁止访问');
|
||||
header("Location: ../../clientarea.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isUserLoggedIn()) {
|
||||
setMsg("msg_notify", "You need to login before accessing the Tickets Add page.", "warning");
|
||||
redirect("clientarea", "login");
|
||||
}
|
||||
|
||||
$err = getMsg("errors");
|
||||
$data = getMsg("form_data");
|
||||
|
||||
$ticket_types = [
|
||||
"技术支持","销售财务","管理员信箱"
|
||||
];
|
|
@ -13,7 +13,7 @@ if (!defined('IN_SYS')) {
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Support Tickets</span>
|
||||
<a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets'); ?>">New Ticket</a>
|
||||
<a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets_add'); ?>">Add Ticket</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="table-responsive">
|
||||
|
|
48
clientarea/views/tickets_add.php
Normal file
48
clientarea/views/tickets_add.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
if (!defined('IN_SYS')) {
|
||||
// exit('禁止访问');
|
||||
header("Location: ../../clientarea.php");
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<?php echo (getMsg("msg_notify")); ?>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Tickets Add</span>
|
||||
<a class="btn btn-default btn-xs pull-right" href="<?php echo setRouter('clientarea', 'tickets'); ?>">Tickets List</a>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form action="" method="POST">
|
||||
<div class="form-group">
|
||||
<label for="ticket-type">Type: <sup>*</sup></label>
|
||||
<select name="ticket-type" id="ticket-title" class="form-control <?php echo (isset($err['ticket_type_err'])) ? 'is-invalid' : ''; ?>">
|
||||
<?php foreach ($ticket_types as $key => $value) {?>
|
||||
<option value="<?php echo $key; ?>"><?php echo $value; ?></option>
|
||||
<?php }?>
|
||||
</select>
|
||||
<span class="text-warning"><?php echo isset($err["ticket_type_err"]) ? $err["ticket_type_err"] : ""; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="ticket-title">Title: <sup>*</sup></label>
|
||||
<input type="text" name="title" id="ticket-title" value="<?php echo ($data['title']); ?>" class="form-control <?php echo (isset($err['content_err'])) ? 'is-invalid' : ''; ?>" placeholder="Title">
|
||||
<span class="text-warning"><?php echo isset($err["title_err"]) ? $err["title_err"] : ""; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="password">Content: <sup>*</sup></label>
|
||||
<textarea name="content" id="ticket-content" value="<?php echo ($data['content']); ?>" class="form-control <?php echo (isset($err['content_err'])) ? 'is-invalid' : ''; ?>" rows="10" maxlength="5000" placeholder="Content"></textarea>
|
||||
<span class="text-warning"><?php echo isset($err["content_err"]) ? $err["content_err"] : ""; ?></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" name="do_add_tickets" class="btn btn-primary">Add</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="panel-footer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
1
core.php
1
core.php
|
@ -8,6 +8,7 @@ $ROOT = __DIR__;
|
|||
include_once "{$ROOT}/data/config.php";
|
||||
include_once "{$ROOT}/library/language.php";
|
||||
include_once "{$ROOT}/library/functions.php";
|
||||
include_once "{$ROOT}/library/dbpdo.php";
|
||||
|
||||
$rooturl = $_SERVER['HTTP_HOST'];
|
||||
$domain = preg_replace('/^www\./', '', $rooturl);
|
||||
|
|
|
@ -34,6 +34,15 @@ $admin = [
|
|||
"password" => "admin",
|
||||
];
|
||||
|
||||
$dbconfig = [
|
||||
'host' => 'bv2g0ksp.hk1027lan.dnstoo.com',
|
||||
'username' => 'gcop2h_f',
|
||||
'password' => 'gdwst6ob',
|
||||
'dbname' => 'gcop2h',
|
||||
'charset' => 'utf8',
|
||||
'port' => '3306',
|
||||
];
|
||||
|
||||
$config = [
|
||||
"apiUsername" => "1",
|
||||
"apiPassword" => "1",
|
||||
|
|
|
@ -5,56 +5,52 @@ START TRANSACTION;
|
|||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `users` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`email` varchar(255) NOT NULL,
|
||||
`username` varchar(255) NOT NULL,
|
||||
`password` varchar(255) NOT NULL,
|
||||
`website` varchar(255) NOT NULL,
|
||||
`image` varchar(255) NOT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`reset_code` char(32) NOT NULL,
|
||||
`is_active` tinyint(4) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `users`(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`name` VARCHAR(255) NOT NULL,
|
||||
`email` VARCHAR(255) NOT NULL,
|
||||
`username` VARCHAR(255) NOT NULL,
|
||||
`password` VARCHAR(255) NOT NULL,
|
||||
`website` VARCHAR(255) NOT NULL,
|
||||
`image` VARCHAR(255) NOT NULL,
|
||||
`created_at` INT(11) NOT NULL,
|
||||
`reset_code` CHAR(32) NOT NULL,
|
||||
`is_active` TINYINT(4) NOT NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;
|
||||
|
||||
INSERT INTO `users` (`id`, `name`, `email`, `username`, `password`, `website`, `image`, `created_at`, `reset_code`, `is_active`) VALUES
|
||||
(1, 'Administrator', 'support@uiisc.com', 'admin', '$2y$10$g6SsReRUJDV0IANO7ZBamOGNQ7sE7zayFiXOC6sgU0lPjxq1b4yuu', 'http://uiisc.com', '5de69dbb55cc3623871b98adc74628081558340869.png', 1550143252, '', 1)
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `emails`(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` VARCHAR(255) NOT NULL,
|
||||
`subject` VARCHAR(255) NOT NULL,
|
||||
`body` VARCHAR(255) NOT NULL,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`is_active` TINYINT(4) NOT NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `emails` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` varchar(255) NOT NULL,
|
||||
`subject` varchar(255) NOT NULL,
|
||||
`body` varchar(255) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
`is_active` tinyint(4) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
|
||||
CREATE TABLE IF NOT EXISTS `tickets`(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` VARCHAR(255) NOT NULL,
|
||||
`department` VARCHAR(255) NOT NULL,
|
||||
`subject` VARCHAR(255) NOT NULL,
|
||||
`status` TINYINT(4) NOT NULL,
|
||||
`lastupdated` VARCHAR(255) NOT NULL,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tickets` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` varchar(255) NOT NULL,
|
||||
`department` varchar(255) NOT NULL,
|
||||
`subject` varchar(255) NOT NULL,
|
||||
`status` tinyint(4) NOT NULL,
|
||||
`lastupdated` varchar(255) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=100;
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `products` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` varchar(255) NOT NULL,
|
||||
`department` varchar(255) NOT NULL,
|
||||
`subject` varchar(255) NOT NULL,
|
||||
`status` tinyint(4) NOT NULL,
|
||||
`lastupdated` varchar(255) NOT NULL,
|
||||
`user_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
CREATE TABLE IF NOT EXISTS `products`(
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`date` VARCHAR(255) NOT NULL,
|
||||
`department` VARCHAR(255) NOT NULL,
|
||||
`subject` VARCHAR(255) NOT NULL,
|
||||
`status` TINYINT(4) NOT NULL,
|
||||
`lastupdated` VARCHAR(255) NOT NULL,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
PRIMARY KEY(`id`)
|
||||
) ENGINE = MyISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT = 100;
|
||||
|
||||
|
|
35
library/dbpdo.php
Normal file
35
library/dbpdo.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* 数据库pdo连接
|
||||
*/
|
||||
class DBPDO
|
||||
{
|
||||
private static $pdo;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
//code
|
||||
}
|
||||
private function __clone()
|
||||
{
|
||||
//code
|
||||
}
|
||||
/**
|
||||
* 获取实例化的PDO,单例模式
|
||||
* @return PDO
|
||||
*/
|
||||
public static function getInstance($dbConf)
|
||||
{
|
||||
if (!(self::$pdo instanceof PDO)) {
|
||||
$dsn = "mysql:host=" . $dbConf['host'] . ";port=" . $dbConf['port'] . ";dbname=" . $dbConf['dbname'] . ";charset=" . $dbConf['charset'];
|
||||
try {
|
||||
self::$pdo = new PDO($dsn, $dbConf['username'], $dbConf['password']); // , array(PDO::ATTR_PERSISTENT => true, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); // 保持长连接
|
||||
self::$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
||||
} catch (PDOException $e) {
|
||||
print "Error:" . $e->getMessage() . "<br/>";
|
||||
die();
|
||||
}
|
||||
}
|
||||
return self::$pdo;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue