|
1
|
|
|
<?php |
|
2
|
|
|
namespace app\controllers; |
|
3
|
|
|
|
|
4
|
|
|
use Kotori\Core\Controller; |
|
5
|
|
|
|
|
6
|
|
|
class Hello extends Controller |
|
7
|
|
|
{ |
|
8
|
|
|
public function __construct() |
|
9
|
|
|
{ |
|
10
|
|
|
parent::__construct(); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
public function index() |
|
14
|
|
|
{ |
|
15
|
|
|
$news_list = $this->model->News->getNewsList(); |
|
16
|
|
|
$this->view->assign('news_list', $news_list) |
|
17
|
|
|
->assign('title', 'Welcome to Kotori.php') |
|
18
|
|
|
->assign('logo', 'https://raw.githubusercontent.com/kokororin/Kotori.php/master/src/Kotori.gif') |
|
19
|
|
|
->display(); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function showNews($id) |
|
23
|
|
|
{ |
|
24
|
|
|
echo 'This is news No.' . $id; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
public function addNews() |
|
28
|
|
|
{ |
|
29
|
|
|
$this->view->display(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function insertNews() |
|
33
|
|
|
{ |
|
34
|
|
|
print_r($this->request->post()); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function pager() |
|
38
|
|
|
{ |
|
39
|
|
|
header('Content-Type: text/html;charset=utf-8'); |
|
40
|
|
|
$count = $this->db->count("test", "title"); |
|
41
|
|
|
$Page = new \app\libraries\Page($count, 20); |
|
42
|
|
|
$show = $Page->show(); |
|
43
|
|
|
$data = $this->db->select("test", "title", array( |
|
44
|
|
|
"LIMIT" => array($Page->firstRow, $Page->listRows), |
|
45
|
|
|
)); |
|
46
|
|
|
print_r($data); |
|
47
|
|
|
echo '<br/>' . $show; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function captcha() |
|
51
|
|
|
{ |
|
52
|
|
|
$captcha = new \app\libraries\Captcha(); |
|
53
|
|
|
$captcha->getImg(); |
|
54
|
|
|
$_SESSION['verify'] = md5($vc->getCode()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function memcache() |
|
58
|
|
|
{ |
|
59
|
|
|
$this->cache->set('testvalue', 'TESTVALUE'); |
|
60
|
|
|
var_dump($this->cache->get('testvalue')); |
|
61
|
|
|
$this->cache->set('testarray', array( |
|
62
|
|
|
'id' => 1, |
|
63
|
|
|
'name' => 'abc', |
|
64
|
|
|
)); |
|
65
|
|
|
var_dump($this->cache->get('testarray')); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
public function cli($to = 'World') |
|
69
|
|
|
{ |
|
70
|
|
|
echo "Hello {$to}!" . PHP_EOL; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
} |
|
74
|
|
|
|