- 1
- 2
- 3
function pop3_dele($connection,$message) {
return(imap_delete($connection,$message));
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+159
function pop3_dele($connection,$message) {
return(imap_delete($connection,$message));
}
Настоятельно рекомендуют не использовать wrapper'ы... М да... [http://www.php.net/manual/en/intro.imap.php]
+159
$one = $_POST["one"];
$two = $_POST["two"];
$three = $_POST["three"];
$total = $_POST["total"];
$total = $_POST["total1"];
function Action($a, $b, $act)
{
switch($act)
{
case "add":
return $a+$b;
case "sub":
return $a-$b;
case "mult":
return $a*$b;
case "div":
return $a/$b;
}
}
/*Это проверка на то, какое действие выполняется первое
total или total1(Если total равен умножению или делению то он и первый.
А все остальное его не интересует)*/
if ($total == "mult" || $total == "div")
{
$result = Action($one, $two, $total);
$result = Action($result, $three, $total1);
}
else
{
$result = Action($two, $three, $total1);
$result = Action($result, $one, $total);
}
echo $result;
+159
SetClipboardData(CF_TEXT, hMems);
SetClipboardData(RegisterClipboardData(CFSTR_SHELLURL), hMems);
+159
int** ppi = new int*;
+159
<?php
session_start();
define('_JEXEC', 1);
$host = $_SERVER['DOCUMENT_ROOT'];
include $host.'/admin/function.php';
include $host.'/data/conf.php';
include $host.'/data/settings.php';
$templates = $system['templates'];
$content = file_get_contents($host.'/design/'.$templates.'/index.tpl');
$result = mysql_query(" SELECT * FROM news WHERE section='index' ");
$myrow = mysql_fetch_array($result);
$result2 = mysql_query(" SELECT * FROM slogan ");
$myrow2 = mysql_fetch_array($result2);
$index_news = $myrow['news'];
$title = $myrow['title'];
$description = $myrow['description'];
$keywords = $myrow['keywords'];
$menu='';
function callback($s) {$GLOBALS['menu'].=$s; }
ob_start('callback');
include $host.'/data/site_content/menu.php';
ob_end_flush();
$menu="$menu";
$content=str_replace('{templates}', $templates, $content);
$content=str_replace('{menu}', $menu, $content);
$content=str_replace('{content}', $index_news, $content);
$content=str_replace('{slogan_name}', $myrow2['slogan_name'], $content);
$content=str_replace('{slogan}',$myrow2['slogan'], $content);
$content=str_replace('{title}', $title, $content);
$content=str_replace('{description}', $description, $content);
$content=str_replace('{keywords}', $keywords, $content);
echo $content;
?>
+159
public static function encode($value, $cycleCheck = false, $options = array())
{
$encoder = new self(($cycleCheck) ? true : false, $options);
return $encoder->_encodeValue($value);
}
Zend Framework, Zend_Json_Encoder
+159
// TODO: use Virtual memory instead of heap!
#ifndef __CHUNK_H__
#define __CHUNK_H__
#include <windows.h>
#include "../JuceLibraryCode/JuceHeader.h"
class Chunk {
public:
enum CHUNK_DIRECTION {CHUNK_UNKNOWN = 0, CHUNK_IN, CHUNK_OUT};
Chunk (DWORD ChunkSize, WORD id, CHUNK_DIRECTION chunkDirection);
~Chunk ();
// override
virtual void eventChunkIsEmpty () {
Logger::outputDebugString(T("empty"));
}
virtual void eventChunkIsFull () {
Logger::outputDebugString(T("full"));
}
virtual void eventChunkOverrun () {
Logger::outputDebugString(T("overrun"));
}
DWORD getData (WORD *data, DWORD size) {
if (data == 0) return 0;
if (cs.tryEnter ()) { // if it's true, we locked.. (TODO: check, i'm not sure about that)
if (((size + nReadCounter) > nWriteCounter) || size == 0) { cs.exit(); return 0; }
memcpy (data, pBuffer + nReadCounter, size*sizeof(WORD));
nReadCounter += size;
if (nReadCounter == nWriteCounter) { eventChunkIsEmpty() ; nWriteCounter = 0; nReadCounter = 0; }
cs.exit ();
return size;
}
return 0;
}
DWORD putData (WORD *data, DWORD size) {
if (data == 0) return 0;
if (cs.tryEnter ()) { // if it's true, we locked.. (TODO: check, i'm not sure about that)
if ((size + nWriteCounter) > nSize) { eventChunkOverrun(); cs.exit (); return 0; }
memcpy (pBuffer + nWriteCounter, data, size*sizeof(WORD));
nWriteCounter += size;
if (nWriteCounter == nSize ) eventChunkIsFull();
cs.exit ();
return size;
}
return 0;
}
inline DWORD getSize () {
return nSize;
}
// TODO: add check for nWriteCounter?
inline bool setSize (DWORD ChunkSize) {
if (bExchangeIsActive) return false;
nSize = ChunkSize;
// TODO: add result check.
pBuffer = (WORD*) realloc ((void*)pBuffer, ChunkSize*sizeof(WORD));
if (pBuffer) return true;
return false;
}
inline DWORD getReadCounter () { return nReadCounter; }
inline DWORD getWriteCounter () { return nWriteCounter; }
juce_UseDebuggingNewOperator
protected:
bool bExchangeIsActive;
CHUNK_DIRECTION cdDirection;
DWORD nSize;
DWORD nWriteCounter;
DWORD nReadCounter;
WORD nChunkId;
WORD *pBuffer;
CriticalSection cs;
};
#endif
// EOF
#include "Chunk.h"
Chunk::Chunk (DWORD ChunkSize, WORD id, CHUNK_DIRECTION chunkDirection) {
bExchangeIsActive = false;
cdDirection = chunkDirection;
nSize = ChunkSize;
nWriteCounter = 0;
nReadCounter = 0;
nChunkId = id;
pBuffer = (WORD*) malloc (ChunkSize*sizeof(WORD));
zeromem (pBuffer, ChunkSize*sizeof(WORD));
}
Chunk::~Chunk () {
if (pBuffer) free (pBuffer);
}
// EOF
Посвящается всем изобретателям велосипедов и просто неудачникам.. :(
+159
function get_existing_boxes () {
global $wp_meta_boxes, $more_fields;
$data = $wp_meta_boxes;
$boxes = array();
foreach ((array) $data as $data1) {
foreach ((array) $data1 as $data2) {
foreach ((array) $data2 as $data3) {
foreach ((array) $data3 as $box) {
if ($title = $box['title']) {
$boxes[$box['id']] = $box;
}
}
}
}
}
//if (is_object($more_fields)) {
// $mfs = $more_fields->get_objects(array('_plugin_saved', '_plugin'));
// foreach ($mfs as $mf_key => $mf) $boxes[$mf_key] = $mf;
// }
//__d($wp_meta_boxes);
return $boxes;
}
Из плагина "more-post-types" для WP
+159
Сколько говна уже придумано было...:
$lasthour = date("Y-m-d H:i:s", mktime(date("H")-1, date("i"), date("s"), date("m"), date("d"), date("Y")));
$query = "
UPDATE user_sid
SET online = 0
WHERE date_action < '{$lasthour}'
";
$sql->query($query);
Вместо простого и понятного:
$query = "
UPDATE user_sid
SET online = 0
WHERE date_action < DATE_FORMAT( NOW( ) - INTERVAL 1 HOUR , '%Y-%m-%d %H:%i:%s' )
";
$sql->query($query);
Печаль... :'(
+159
<?php
//debug($item[$modelname]);
if($item[$modelname]['has_rooms_furniture']){
__('has_rooms_furniture');
} else {
echo 'без ';
__('has_rooms_furniture');
}
echo'<br>';
if($item[$modelname]['has_kitchen_furniture']){
__('has_kitchen_furniture');
}
else {
echo 'без ';
__('has_kitchen_furniture');
}
echo'<br>';
if($item[$modelname]['has_phone']){
__('has_phone');
}else {
echo 'без ';
__('has_phone');
}
echo'<br>';
if($item[$modelname]['has_tv']){
__('has_tv');
echo'<br>';
}
if($item[$modelname]['has_fridge']){
__('has_fridge');
echo'<br>';
}
if($item[$modelname]['has_washer']){
__('has_washer');
echo'<br>';
}
if($item[$modelname]['has_balcon']){
__('has_washer');
echo'<br>';
}
if($item[$modelname]['may_children']){
__('may_children');
echo'<br>';
}
if($item[$modelname]['may_animals']){
__('may_animals');
echo'<br>';
}
echo " ";
?>
Код из проекта на CakePHP
__() - функция для локализации термина