Нашел вот такой код Пагинации на PHP 😁
1 2 3 4 5 6 7 8 9 10 11 |
///pagination $page=$_GET['page']; if($page=="" || $page=="1") { $page1=0; } else { $page1=($page*10)-10; } |
Интересная проверка авторизации на PHP. Мне кажется некоторый дупликат проверок. 😚
1 2 3 4 5 6 7 8 9 |
if (isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login']) || isset( $HTTP_POST_VARS['logout']) || isset($HTTP_GET_VARS['logout'])) { if ((isset($HTTP_POST_VARS['login']) || isset($HTTP_GET_VARS['login'])) && (!$userdata ['session_logged_in'] || isset($HTTP_POST_VARS['admin']))) { $username = isset($HTTP_POST_VARS['username']) ? phpbb_clean_username($HTTP_POST_VARS ['username']) : ''; $password = isset($HTTP_POST_VARS['password']) ? $HTTP_POST_VARS['password'] : ''; } } |
Слайд Шоу (SlideShow) на 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
function StartPartnerSlideshow() { if(endPartnerDiv == "Partner2") { startPartnerDiv = "Partner2"; endPartnerDiv = "Partner3"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } else if(endPartnerDiv == "Partner3") { startPartnerDiv = "Partner3"; endPartnerDiv = "Partner4"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } else if(endPartnerDiv == "Partner4") { startPartnerDiv = "Partner4"; endPartnerDiv = "Partner5"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } else if(endPartnerDiv == "Partner5") { startPartnerDiv = "Partner5"; endPartnerDiv = "Partner6"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } else if(endPartnerDiv == "Partner6") { startPartnerDiv = "Partner6"; endPartnerDiv = "Partner7"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } else if (endPartnerDiv == "Partner7") { startPartnerDiv = "Partner7"; endPartnerDiv = "Partner8"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)", partnerspeed); } else if (endPartnerDiv == "Partner8") { startPartnerDiv = "Partner8"; endPartnerDiv = "Partner9"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)", partnerspeed); } else if (endPartnerDiv == "Partner9") { startPartnerDiv = "Partner9"; endPartnerDiv = "Partner10"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)", partnerspeed); } else if (endPartnerDiv == "Partner10") { startPartnerDiv = "Partner10"; endPartnerDiv = "Partner11"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)", partnerspeed); } else if (endPartnerDiv == "Partner11") { startPartnerDiv = "Partner11"; endPartnerDiv = "Partner1"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)", partnerspeed); } else { startPartnerDiv = "Partner1"; endPartnerDiv = "Partner2"; setTimeout("GetNextPartner('" + startPartnerDiv + "', '" + endPartnerDiv + "', 10, 0)",partnerspeed); } } |
Когда реально очень нужен 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 |
function toinv($input){ return intval($input); } |
Проверка доступа на странице в PHP 😁
1 2 3 4 |
if (!defined("IN_SCRIPT") || !isset($_SESSION['admin_user_id']) || !$_SESSION['admin_user_id'] || !isset($_SESSION['admin_username']) || !$_SESSION['admin_username']){ header("Location: login.php?menu=$menu"); die(); } |
Начать и тут же закончить сессию в PHP
1 2 3 |
session_start(); session_destroy(); header('Location: login.php'); |
Мастер валидации на 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); } |
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); } |