В Контроллере нашел вот такую красоту на PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public function query(){ $id=$_GET['vid']; $data=D('Danmu')->getAll($id); $content='['; foreach($data as $d){ if($content!='['){ $content.=','; } $content.=("'".$d['content']."'"); } $content.=']'; echo $content; } |
Когда реально очень нужен PHP язык
1 2 3 4 5 |
echo "<!DOCTYPE HTML>"; echo "<html>"; echo "<head>"; echo "<meta charset ='utf-8'>"; echo "<link rel='stylesheet' type='text/css' href='styles.css'>"; |
Мастер валидации на PHP 😁
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
if(!isset($ip) || !isset($port) || !isset($time) || !isset($method) || !isset($key) || !isset($customer)) { die('ERROR: Please fill in all fields'); } elseif(!filter_var($ip, FILTER_VALIDATE_IP) && $methodData['classification'] == 4) { die('ERROR: This is not a valid IP'); } elseif(!filter_var($ip, FILTER_VALIDATE_URL) && $methodData['classification'] == 7) { die('ERROR: This is not a valid layer 7 URL'); } elseif(!is_numeric($port) || !is_numeric($time)) { die('ERROR: Numeric Port / Time values only'); } elseif(!$server->allowedMethod($method)) { die('ERROR: This is not a valid method'); } elseif($time > $data['max_time']) { die('ERROR: You are exceeding your max boottime!'); } elseif($key != $data['accesskey']) { die(Config::Read('DENYMSG')); } elseif(!$user->freeSlot($admin)) { die('ERROR: You have the maximum amount of concurrent attacks running'); } else { print 'Attack has been sent on ' . htmlspecialchars($ip) . ':' . htmlspecialchars($port) . ' for ' . $time . ' seconds using ' . $method; $logs->insertLog($customer, $ip, $port, $time, $method); $server->sendAttack($ip, $port, $time, $method); } |
Шедевр на PHP который берет за душу 😗
1 2 3 4 5 6 7 |
if ($name==null && $item==null){ return self::$collection; } if ($name==null){ throw new Exception('Cannot save null list item'); } |
SQL injection в PHP реальный пример
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$title=$_POST['title']; $genre=$_POST['genre']; $actor=$_POST['actor']; mysqli_query($connect,"INSERT INTO movies(title,genre,actor) VALUES('$title','$genre','$actor')"); if(mysqli_affected_rows($connect) > 0){ echo "<p>Movie Added</p>"; echo "<a href='searchdisplay.php'>Search for movies!</a>"; } else { echo "Movie NOT Added<br />"; echo mysqli_error ($connect); } |