- 1
- 2
- 3
- 4
- 5
- 6
$placeholder_id = !empty($_GET['id'])?$_GET['id']:null;
if ( !is_numeric($placeholder_id) )
{
die("ERROR-wrong access (ID)");
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+147
$placeholder_id = !empty($_GET['id'])?$_GET['id']:null;
if ( !is_numeric($placeholder_id) )
{
die("ERROR-wrong access (ID)");
}
Мдя... зачем проверки если дохним...
+151
<?php
$code = "<table> <tr><td>1</td></tr> <tr><td>2</td></tr> </table>";
$out_arr = array();
while($line = substr( ($code = substr($code, strpos($code, ($s = "<tr><td>")) + strlen($s))), 0,
($s = strpos($code, "</td></tr>"))) and $s and array_push($out_arr, $line) );
print_r($out_arr);
?>
лень было с регекспами заниматься ^_^
упрощеный вариант
+151.1
if(!preg_match('/<table border="0" width="48%" cellspacing="0" cellpadding="5" class="modelProperties">(.+)<\/div>/isU', $tovar_page, $test)){
preg_match('/<table border="0" width="50%" cellspacing="0" cellpadding="5" class="modelProperties">(.+)<\/div>/isU', $tovar_page, $test);
}
парсер я.маркета
+147
<?php
/***************************************************************************
* usercp_activate.php
* -------------------
* begin : Saturday, Feb 13, 2001
* copyright : (C) 2001 The phpBB Group
* email : [email protected]
*
* Id: usercp_activate.php,v 1.6.2.9 2005/09/14 18:14:30 acydburn Exp
*
*
***************************************************************************/
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
***************************************************************************/
if ( !defined('IN_PHPBB') )
{
die('Hacking attempt');
exit;
}
Рихиты что ж тут еще скажешь...
+148
if (row[0]["IsAdmin"].ToString() == "True")
{
return true;
}
else
{
return false;
}
+154
php_value error_reporting 7
AddDefaultCharset UTF-8
# CharsetDisable On
# CharsetDefault windows-1251
# CharsetSourceEnc windows-1251
# CharsetRecodeMultipartForms off
Options All -Indexes
RewriteEngine On
RewriteRule ^/?$ index.php [L]
RewriteRule ^rated/?$ index.php?act=rated_screen [L]
RewriteRule ^upload/?$ test.php?act=upload_screen [L]
RewriteRule ^settings/?$ index.php?act=settings_screen [L]
RewriteRule ^logout/?$ index.php?act=logout [L]
RewriteRule ^([0-9]+)?$ index.php?act=id_screen&id=$1 [L]
RewriteRule ^([0-9]+)/i.jpg?$ templates/direct.php?id=$1 [L]
Есть в .htaccess вот такое "RewriteRule ^upload/?$ index.php?act=upload_screen [L]" и при переходе по ссылке site.ru/upload в адресной строке появляется http://site.ru/upload/?act=upload_screen ... почему такое может быть?
+148
template<class T>
T from_string(const std::string &str)
{
std::istringstream iss(str);
T ret_val;
iss>>ret_val;
return ret_val;
}
template <class T>
std::string to_string(T val)
{
std::ostringstream oss;
oss<<val;
return oss.str();
}
template<> inline
double from_string<double>(const std::string &str)
{
return atof(str.c_str());
}
взято с http://forums.realcoding.net/lofiversion/index.php/t15556.html
конвертация строки в число/числа в строку
+152
$str.= "<div class=\"matchtour2\"><table class='maintable' align=right width=590 cellspacing=0><tr bgcolor=#56B945 style='color:white; margin:0;' class='header'><td align=center width=50><b>время</b></td><td align=center><b>событие</b></td><td width=50 align=center><b>победа<br>1</b></td><td width=50 align=center><b>ничья<br>X</b></td><td width=50 align=center><b>пoбеда<br>2</b></td><td width=50> </td></tr></table></div><br><br>";
Мечта верстальщика
+139.5
#include <iostream>
#include <deque>
#include <time.h>
using namespace std;
int arr[10][10] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 4, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
#define SHIPS 1
struct point{
int x, y;
};
int num = -1, count = 0;
deque<point> ship;
int way[] = {0, 0, 0, 0};
void step(){
for (int i = 0; i < 10; i++){
for (int j = 0; j < 10; j++)
cout << arr[i][j] << ' ' ;
cout << '\n';
}
cout << '\n';
if (num == ship.size()){
memset(way, 0, sizeof(way));
while(!ship.empty()){
arr[ship.front().x + 1][ship.front().y] = 7;
arr[ship.front().x + 1][ship.front().y + 1] = 7;
arr[ship.front().x][ship.front().y + 1] = 7;
arr[ship.front().x + 1][ship.front().y - 1] = 7;
arr[ship.front().x - 1][ship.front().y + 1] = 7;
arr[ship.front().x - 1][ship.front().y - 1] = 7;
arr[ship.front().x][ship.front().y - 1] = 7;
arr[ship.front().x - 1][ship.front().y] = 7;
ship.pop_front();
}
count++;
if (count == SHIPS) {
cout << "Win" << '\n';
exit(0);
}
cout << num << " was killed" << '\n';
num = -1;
}
int x, y;
point tmp;
if (ship.empty()){
x = rand()%10;
y = rand()%10;
while (arr[x][y] == 7){
x = rand()%10;
y = rand()%10;
}
if (arr[x][y] != 0 && arr[x][y] != 7){
num = arr[x][y];
tmp.x = x;
tmp.y = y;
ship.push_front(tmp);
arr[x][y] = 7;
if (x > 0) if (arr[x][y - 1] != 7) way[0] = 1;
if (y > 0) if (arr[x - 1][y] != 7) way[1] = 1;
if (x < 9) if (arr[x][y + 1] != 7) way[2] = 1;
if (y < 9) if (arr[x + 1][y] != 7) way[3] = 1;
step();
}else{
arr[x][y] = 7;
return;
}
}else{
int t = rand()%4;
while (way[t] == 0){
t = rand()%4;
}
switch(t){
case 0:
x = ship.back().x;
y = ship.back().y - 1;
if(arr[x][y] == num){
way[1] = 0;
way[3] = 0;
tmp.x = x;
tmp.y = y;
ship.push_back(tmp);
arr[x][y] = 7;
step();
}else{
arr[x][y] = 7;
way[0] = 0;
return;
}
Морской бой
+151
for($i=0; $i<count($a); $i++)
{
$b=explode("|",$a[$i]);
for($j=0; $j<count($b); $i++)
echo $b[$j] . "<hr>";
}
Часто бывает...