- 1
- 2
PHP + Java = JPHP
https://habr.com/post/425223/
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
−2
PHP + Java = JPHP
https://habr.com/post/425223/
Поэтому я за "JPHP".
−3
require_once $_SERVER['DOCUMENT_ROOT'] . '/models/core/class.Application.php';
require_once 'class.DatabaseConnect.php';
require_once 'class.DatabaseResult.php';
class DatabaseQuery extends Application {
private $m_db_connect = NULL; //Соединение с БД
private $m_query_statment = NULL; //Результат последнего запроса
private $m_construct_query = NULL; //Строка формирования запроса
public function __construct(DatabaseConnect $db_connect) {
$this->m_db_connect = $db_connect;
}
public function __destruct() {
$this->m_db_connect = null;
}
//Вставляет данные в таблицу
public function insert($data) {
if (count($data) === 0)
return false;
$query_list = [];
//Обход таблиц
foreach ($data as $t_name => $table) {
//Ассациативный массив даннвх, где ключ массива это имя колонки в БД
$column_list = [];
//Копируем данные в отдельный массив
foreach ($table as $c_name => $column)
$column_list[$c_name] = $column;
//Строка запроса
$query = "INSERT INTO {$t_name} (" . implode(', ', array_keys($column_list)) . ') VALUES ';
//Выпоняем обход
for ($i = 0; $i < count($column_list[array_keys($column_list)[0]]); $i++) {
$query_values = '(';
//
foreach ($column_list as $c_name => $column)
$query_values .= '\'' . $column_list[$c_name][$i] . '\',';
$query_values = chop($query_values, ',') . '),';
$query .= $query_values;
}
$query_list[] = chop($query, ',');
}
try {
for ($i = 0; $i < count($query_list); $i++) {
$result = $this->query($query_list[$i]);
}
} catch (PDOException $e) {
Application::handlerErrorDB($e);
return false;
}
return true;
}
public function setSelect($data = ['*']) {
$query = 'SELECT ';
foreach ($data as $v)
$query .= $v . ',';
$this->m_construct_query = chop($query, ',') . ' ';
return $this;
}
public function setDelete($tables = []) {
$query = 'DELETE ';
foreach ($tables as $v)
$query .= $v . ',';
$this->m_construct_query = chop($query, ',') . ' ';
return $this;
}
public function setUpdate($tables) {
$query = 'UPDATE ';
foreach ($tables as $v)
$query .= $v . ',';
$this->m_construct_query = chop($query, ',') . ' ';
return $this;
}
public function setSet($data) {
$query = 'SET ';
foreach ($data as $k => $v)
$query .= "$k = '$v',";
$this->m_construct_query .= chop($query, ',') . ' ';
return $this;
}
public function setFrom($tables) {
$query = 'FROM ';
foreach ($tables as $v)
$query .= $v . ',';
$this->m_construct_query .= chop($query, ',') . ' ';
return $this;
}
...
Вот что бывает когда у тебя юношеский максимализм - ты пытаешь написать свой фреймворк, и при этом это твой первый проект на PHP.
0
Страйкер удалил политоту, а какого хуя ты не удалил
http://govnokod.ru/user/25102/codes
http://govnokod.ru/user/21529
http://govnokod.ru/user/21528/codes
И другую гомосятину в разделе "VisualBasic"?
−2
$price = WC()->cart->get_product_price( $_product );
$price = str_replace('<span class="woocommerce-Price-amount amount">', '', $price);
$price = str_replace(' <span class="woocommerce-Price-currencySymbol"><span class="rur">р<span>уб.</span></span></span></span>', '', $price);
$price = str_replace(',', '', $price);
$price = str_replace(' ', '', $price);
$price = str_replace('.', '', $price);
$price_m2 = round($price/25.2);
echo '<span class="woocommerce-Price-amount amount">'.$price_m2.' <span class="woocommerce-Price-currencySymbol"><span class="rur">р<span>уб.</span></span></span></span><span class="awspn_price_note"> / м<sup>2</sup></span>';
Привет, меня зовут Вася!
Как-то раз на одном из сайтов с WooCommerce мне нужно было в корзине вывести цену листового товара за метр квадратный. Ну а че, листа размера не 25.2м2 не существует, а еще на php.net я прочитал про функцию str_replace. И так сойдет! :)
−4
<?php
--"";
PHP Parse error: syntax error, unexpected ';', expecting :: (T_PAAMAYIM_NEKUDOTAYIM) in /home/XQ5b1K/prog.php on line 3
https://ideone.com/vYLgSF
−1
class MyBigClass
{
var $allocatedSize;
var $allMyOtherStuff;
}
function AllocateMyBigClass()
{
$before = memory_get_usage();
$ret = new MyBigClass;
$after = memory_get_usage();
$ret->allocatedSize = ($after - $before);
return $ret;
}
Зачем нам в языке адекватный sizeof, у нас нет времени, чтобы ебаться с ним!
Подробнее: https://stackoverflow.com/questions/1351855/getting-size-in-memory-of-an-object-in-php
+1
/**
* Cast an object into a different class.
*
* Currently this only supports casting DOWN the inheritance chain,
* that is, an object may only be cast into a class if that class
* is a descendant of the object's current class.
*
* This is mostly to avoid potentially losing data by casting across
* incompatable classes.
*
* @param object $object The object to cast.
* @param string $class The class to cast the object into.
* @return object
*/
function cast($object, $class) {
if( !is_object($object) )
throw new InvalidArgumentException('$object must be an object.');
if( !is_string($class) )
throw new InvalidArgumentException('$class must be a string.');
if( !class_exists($class) )
throw new InvalidArgumentException(sprintf('Unknown class: %s.', $class));
if( !is_subclass_of($class, get_class($object)) )
throw new InvalidArgumentException(sprintf(
'%s is not a descendant of $object class: %s.',
$class, get_class($object)
));
/**
* This is a beautifully ugly hack.
*
* First, we serialize our object, which turns it into a string, allowing
* us to muck about with it using standard string manipulation methods.
*
* Then, we use preg_replace to change it's defined type to the class
* we're casting it to, and then serialize the string back into an
* object.
*/
return unserialize(
preg_replace(
'/^O:\d+:"[^"]++"/',
'O:'.strlen($class).':"'.$class.'"',
serialize($object)
)
);
}
Это прекрасно.
0
// CVE-2012-5692
/* 4015. */ static public function get($name)
/* 4016. */ {
/* 4017. */ // Check internal data first
/* 4018. */ if ( isset( self::$_cookiesSet[ $name ] ) )
/* 4019. */ {
/* 4020. */ return self::$_cookiesSet[ $name ];
/* 4021. */ }
/* 4022. */ else if ( isset( $_COOKIE[ipsRegistry::$settings['cookie_id'].$name] ) )
/* 4023. */ {
/* 4024. */ $_value = $_COOKIE[ ipsRegistry::$settings['cookie_id'].$name ];
/* 4025. */
/* 4026. */ if ( substr( $_value, 0, 2 ) == 'a:' )
/* 4027. */ {
/* 4028. */ return unserialize( stripslashes( urldecode( $_value ) ) );
/* 4029. */ }
/*
The vulnerability is caused due to this method unserialize user input passed through cookies without a proper
sanitization. The only one check is done at line 4026, where is controlled that the serialized string starts
with 'a:', but this is not sufficient to prevent a "PHP Object Injection" because an attacker may send a
serialized string which represents an array of objects. This can be exploited to execute arbitrary PHP code
via the "__destruct()" method of the "dbMain" class, which calls the "writeDebugLog" method to write debug
info into a file. PHP code may be injected only through the $_SERVER['QUERY_STRING'] variable, for this
reason successful exploitation of this vulnerability requires short_open_tag to be enabled.
*/
Если вы думаете, что самое плохое, что ждёт ваш уютный сайт на «PHP» — это Роберт-брось-таблицу, то вы глубоко ошибаетесь.
CSRF verification passed.
−1
$data = new stdClass();
$data->receivers_list = [];
$data->receivers_list[0] = new stdClass();
$data->receivers_list[0]->address = $user_wallet;
$data->receivers_list[0]->amount = $amount;
Кусок кода, от проекта, который мне теперь надо поддерживать.
−6
Name:
<input type="text" name=
"name"
value="<?php echo $name;?>">
E-mail: <
input type="text"
name="email" value="<?php
echo $email;?>">
Website: <input type="text" name="website" value="
<?php echo $website;?>"
>
Comment: <textarea name="comment" rows="5" cols="40"><?php echo $comment;?></textarea>
Gender:
<input type="radio" name="gender"
<
?
php
if (isset($gender) && $gender=="female") echo "checked";
?> value="female">Female
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="male") echo "checked";?>
value="male">
Male
<input type="radio" name="gender"
<?php if (isset($gender) && $gender=="other") echo "checked";?>value="other">Other
PHP говно