|
1 | | -<?php namespace App\Controllers; |
2 | | - |
3 | | -use CodeIgniter\API\ResponseTrait; |
4 | | -use CodeIgniter\Config\Services; |
5 | | -use CodeIgniter\Controller; |
6 | | -use CodeIgniter\I18n\Time; |
7 | | -use CodeIgniter\Model; |
8 | | -use Config\Database; |
9 | | -use Tests\Support\Models\JobModel; |
10 | | - |
11 | | -class Checks extends Controller |
12 | | -{ |
13 | | - use ResponseTrait; |
14 | | - |
15 | | - public function index() |
16 | | - { |
17 | | - session()->start(); |
18 | | - } |
19 | | - |
20 | | - |
21 | | - public function escape() |
22 | | - { |
23 | | - $db = Database::connect(); |
24 | | - $db->initialize(); |
25 | | - |
26 | | - $jobs = $db->table('job') |
27 | | - ->whereNotIn('name', ['Politician', 'Accountant']) |
28 | | - ->get() |
29 | | - ->getResult(); |
30 | | - |
31 | | - die(var_dump($jobs)); |
32 | | - } |
33 | | - |
34 | | - public function password() |
35 | | - { |
36 | | - $db = Database::connect(); |
37 | | - $db->initialize(); |
38 | | - |
39 | | - $result = $db->table('misc') |
40 | | - ->insert([ |
41 | | - 'key' => 'password', |
42 | | - 'value' => '$2y$10$ErQlCj/Mo10il.FthAm0WOjYdf3chZEGPFqaPzjqOX2aj2uYf5Ihq' |
43 | | - ]); |
44 | | - |
45 | | - die(var_dump($result)); |
46 | | - } |
47 | | - |
48 | | - |
49 | | - public function forms() |
50 | | - { |
51 | | - helper('form'); |
52 | | - |
53 | | - var_dump(form_open()); |
54 | | - } |
55 | | - |
56 | | - public function api() |
57 | | - { |
58 | | - $data = array( |
59 | | - "total_users" => 3, |
60 | | - "users" => array( |
61 | | - array( |
62 | | - "id" => 1, |
63 | | - "name" => "Nitya", |
64 | | - "address" => array( |
65 | | - "country" => "India", |
66 | | - "city" => "Kolkata", |
67 | | - "zip" => 700102, |
68 | | - ) |
69 | | - ), |
70 | | - array( |
71 | | - "id" => 2, |
72 | | - "name" => "John", |
73 | | - "address" => array( |
74 | | - "country" => "USA", |
75 | | - "city" => "Newyork", |
76 | | - "zip" => "NY1234", |
77 | | - ) |
78 | | - ), |
79 | | - array( |
80 | | - "id" => 3, |
81 | | - "name" => "Viktor", |
82 | | - "address" => array( |
83 | | - "country" => "Australia", |
84 | | - "city" => "Sydney", |
85 | | - "zip" => 123456, |
86 | | - ) |
87 | | - ), |
88 | | - ) |
89 | | - ); |
90 | | - |
91 | | - return $this->respond($data); |
92 | | - } |
93 | | - |
94 | | - public function db() |
95 | | - { |
96 | | - $db = Database::connect(); |
97 | | - $db->initialize(); |
98 | | - |
99 | | - $query = $db->prepare(function($db){ |
100 | | - return $db->table('user')->insert([ |
101 | | - 'name' => 'a', |
102 | | - 'email' => 'b@example.com', |
103 | | - 'country' => 'x' |
104 | | - ]); |
105 | | - }); |
106 | | - |
107 | | - $query->execute('foo', 'foo@example.com', 'US'); |
108 | | - } |
109 | | - |
110 | | - public function format() |
111 | | - { |
112 | | - echo '<pre>'; |
113 | | - var_dump($this->response->getHeaderLine('content-type')); |
114 | | - } |
115 | | - |
116 | | - public function model() |
117 | | - { |
118 | | - $model = new class() extends Model { |
119 | | - protected $table = 'job'; |
120 | | - }; |
121 | | - |
122 | | - $results = $model->findAll(); |
123 | | - |
124 | | - $developer = $model->findWhere('name', 'Developer'); |
125 | | - |
126 | | - $politician = $model->find(3); |
127 | | - |
128 | | - } |
129 | | - |
130 | | - public function curl() |
131 | | - { |
132 | | - $client = Services::curlrequest([ |
133 | | - 'debug' => true, |
134 | | - 'follow_redirects' => true, |
135 | | - 'json' => ['foo' => 'bar'] |
136 | | - ]); |
137 | | - |
138 | | - echo '<pre>'; |
139 | | - $response = $client->request('PUT', 'http://ci4.dev/checks/catch'); |
140 | | - echo $response->getBody(); |
141 | | - } |
142 | | - |
143 | | - // Simply echos back what's given in the body. |
144 | | - public function catch() |
145 | | - { |
146 | | - $body = print_r($this->request->getRawInput(), true); |
147 | | - echo $body; |
148 | | - } |
149 | | - |
150 | | - public function redirect() |
151 | | - { |
152 | | - redirect('/checks/model'); |
153 | | - } |
154 | | - |
155 | | - public function image() |
156 | | - { |
157 | | - $info = Services::image('imagick') |
158 | | - ->withFile("/Users/kilishan/Documents/BobHeader.jpg") |
159 | | - ->getFile() |
160 | | - ->getProperties(true); |
161 | | - |
162 | | - dd(ENVIRONMENT); |
163 | | - |
164 | | - $images = Services::image('imagick') |
165 | | - ->getVersion(); |
166 | | -// ->withFile("/Users/kilishan/Documents/BobHeader.jpg") |
167 | | -// ->resize(500, 100, true) |
168 | | -// ->crop(200, 75, 20, 0, false) |
169 | | -// ->rotate(90) |
170 | | -// ->save('/Users/kilishan/temp.jpg'); |
171 | | - |
172 | | -// $images = Services::image('imagick') |
173 | | -// ->withFile("/Users/kilishan/Documents/BobHeader.jpg") |
174 | | -// ->fit(500, 100, 'bottom-left') |
175 | | -// ->text('Bob is Back!', [ |
176 | | -// 'fontPath' => '/Users/kilishan/Downloads/Calibri.ttf', |
177 | | -// 'fontSize' => 40, |
178 | | -// 'padding' => 0, |
179 | | -// 'opacity' => 0.5, |
180 | | -// 'vAlign' => 'top', |
181 | | -// 'hAlign' => 'right', |
182 | | -// 'withShadow' => true, |
183 | | -// ]) |
184 | | -// ->save('/Users/kilishan/temp.jpg', 100); |
185 | | - |
186 | | - |
187 | | - ddd($images); |
188 | | - } |
189 | | - |
190 | | - public function time() |
191 | | - { |
192 | | - $time = new Time(); |
193 | | - |
194 | | - echo($time); |
195 | | - echo '<br/>'; |
196 | | - echo Time::now(); |
197 | | - echo '<br/>'; |
198 | | - echo Time::parse('First Monday of December'); |
199 | | - echo '<br/>'; |
200 | | - |
201 | | - $time = new Time('Next Monday'); |
202 | | - die($time); |
203 | | - } |
204 | | - |
205 | | - public function csp() |
206 | | - { |
207 | | -// $this->response->CSP->reportOnly(true); |
208 | | - $this->response->CSP->setDefaultSrc(base_url()); |
209 | | - $this->response->CSP->addStyleSrc('unsafe-inline'); |
210 | | - $this->response->CSP->addStyleSrc('https://maxcdn.bootstrapcdn.com'); |
211 | | - |
212 | | - echo <<<EOF |
213 | | -<!doctype html> |
214 | | -<html> |
215 | | -<head> |
216 | | - <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> |
217 | | -</head> |
218 | | -<body> |
219 | | -<style {csp-style-nonce}> |
220 | | - body { background: #efefef; } |
221 | | -</style> |
222 | | -
|
223 | | -</body> |
224 | | -</html> |
225 | | -EOF; |
226 | | - |
227 | | - } |
228 | | - |
229 | | - public function upload() |
230 | | - { |
231 | | - if ($this->request->getMethod() == 'post') |
232 | | - { |
233 | | - $this->validate([ |
234 | | - 'avatar' => 'uploaded[avatar]|ext_in[avatar,png,jpg,jpeg,gif]' |
235 | | - ]); |
236 | | - |
237 | | - /** |
238 | | - * @var \CodeIgniter\HTTP\Files\UploadedFile |
239 | | - */ |
240 | | - $file = $this->request->getFile('avatar'); |
241 | | - |
242 | | - echo "Name: {$file->getName()}<br/>"; |
243 | | - echo "Temp Name: {$file->getTempName()}<br/>"; |
244 | | - echo "Original Name: {$file->getClientName()}<br/>"; |
245 | | - echo "Random Name: {$file->getRandomName()}<br/>"; |
246 | | - echo "Extension: {$file->getExtension()}<br/>"; |
247 | | - echo "Client Extension: {$file->getClientExtension()}<br/>"; |
248 | | - echo "Guessed Extension: {$file->guessExtension()}<br/>"; |
249 | | - echo "MimeType: {$file->getMimeType()}<br/>"; |
250 | | - echo "IsValid: {$file->isValid()}<br/>"; |
251 | | - echo "Size (b): {$file->getSize()}<br/>"; |
252 | | - echo "Size (kb): {$file->getSize('kb')}<br/>"; |
253 | | - echo "Size (mb): {$file->getSize('mb')}<br/>"; |
254 | | - echo "Size (mb): {$file->getSize('mb')}<br/>"; |
255 | | - echo "Path: {$file->getPath()}<br/>"; |
256 | | - echo "RealPath: {$file->getRealPath()}<br/>"; |
257 | | - echo "Filename: {$file->getFilename()}<br/>"; |
258 | | - echo "Basename: {$file->getBasename()}<br/>"; |
259 | | - echo "Pathname: {$file->getPathname()}<br/>"; |
260 | | - echo "Permissions: {$file->getPerms()}<br/>"; |
261 | | - echo "Inode: {$file->getInode()}<br/>"; |
262 | | - echo "Owner: {$file->getOwner()}<br/>"; |
263 | | - echo "Group: {$file->getGroup()}<br/>"; |
264 | | - echo "ATime: {$file->getATime()}<br/>"; |
265 | | - echo "MTime: {$file->getMTime()}<br/>"; |
266 | | - echo "CTime: {$file->getCTime()}<br/>"; |
267 | | - |
268 | | - dd($file); |
269 | | - } |
270 | | - |
271 | | - echo <<<EOF |
272 | | -<!doctype html> |
273 | | -<html> |
274 | | -<body> |
275 | | -
|
276 | | -<form action="" method="post" enctype="multipart/form-data"> |
277 | | -
|
278 | | - <input type="file" name="avatar"> |
279 | | -
|
280 | | - <input type="submit" value="Upload"> |
281 | | - |
282 | | -</form> |
283 | | -
|
284 | | -</body> |
285 | | -</html> |
286 | | -
|
287 | | -EOF; |
288 | | -; |
289 | | - } |
290 | | - |
291 | | - |
292 | | -} |
| 1 | +<?php |
| 2 | + echo 'Hi there ...<br/>'; |
| 3 | + echo extension_loaded('openssl'); |
0 commit comments