- 1
 - 2
 - 3
 - 4
 - 5
 - 6
 
$stringPath = dirname(__FILE__);
if (strstr($stringPath,":")) $stringExplode = "\\";
  else $stringExplode = "/";
       
$paths = explode($stringExplode,$stringPath);
                                    Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+169
$stringPath = dirname(__FILE__);
if (strstr($stringPath,":")) $stringExplode = "\\";
  else $stringExplode = "/";
       
$paths = explode($stringExplode,$stringPath);
                                    
            Источник: http://www.php.net/manual/en/function.require.php#70463
Автору срочно найти в том-же мануале: DIRECTORY_SEPARATOR
        
+173
if(!file_exists(getenv('SCRIPT_FILENAME'))) die('File not found)';
                                    Нет, ну а вдруг?!
+165
for ($i = $bstart; $i < $bend; $i++) 
{
	// ГЛАВНАЯ BASE НЕТУ
	
	if (empty($_REQUEST['base']) && $i == 1) 
	{
		$pagin .= '<strong><font color=#980101>' . $i . '</font></strong>  ';
	}
	if (empty($_REQUEST['base']) && $i != 1) 
	{	
		$b_start = (ARTICLE_VIEW * $i) - ARTICLE_VIEW;
		$query_news = $sn . record_lanuage($page) . $ot . $b_start . ", " . ARTICLE_VIEW;
		$res = mysql_query($query_news) or die(error($query_news));		
		
		if ($db->nr($res))
		{
			$pagin .= '<a href="http://' . $config['server_name'] . '/article.php?page=' . $_REQUEST['page'] . '&base=' . $i . $base_mmt . '">' . $i . '</a>  ';
		}
		else
		{
			$pagin .= '<font>' . $i . '</font>  ';
		}
		if ($i == $bend - 1 && $db->nr($res) != 0)
		{
			$pagin .= '<a href="http://' . $config['server_name'] . '/article.php?page=' . $_REQUEST['page'] . '&base=' . ($i + 1) . $base_mmt . '">></a>';
		}
	}
	
	// ГЛАВНАЯ BASE ЕСТЬ
	
	if (!empty($_REQUEST['base']) && $i < $_REQUEST['base']) 
	{	
		$pagin .= '<a href="http://' . $config['server_name'] . '/article.php?page=' . $_REQUEST['page'] . '&base=' . $i . $base_mmt . '">' . $i . '</a>  ';
	}
	if (!empty($_REQUEST['base']) && $i >= $_REQUEST['base']) 
	{			
		$b_start = (ARTICLE_VIEW * $i) - ARTICLE_VIEW;
		$query_news = $sn . $q . $ot . $b_start . ", " . ARTICLE_VIEW;
		
		$res = mysql_query($query_news) or trigger_error($sql);
		
		if ($_REQUEST['base'] == $i) 
		{
			$pagin .= '<strong><font color=#980101>' . $i . '</font></strong>  ';
		}
		if ($_REQUEST['base'] < $i) 
		{
			if ($db->nr($res) != 0) 
			{
				$pagin .= '<a href="http://' . $config['server_name'] . '/article.php?page=' . $_REQUEST['page'] . '&base=' . $i . $base_mmt . '">' . $i . '</a>  ';
			}
			else
			{
				$pagin .= '<font>' . $i . '</font>  ';
			}
		}
		if ($db->nr($res) != 0 && substr($i, strlen($i) - 1) == 0)
		{
			$pagin .= '<a href="http://' . $config['server_name'] . '/article.php?page=' . $_REQUEST['page'] . '&base=' . ($i + 1) . $base_mmt . '">></a>';
		}
	}
}
                                    пагинация длиной в 130 строк и даже не функция, выложил только основную EPIC часть, которая существовала в отдельном файле!
+81
public static void createShotAndSend() {
        Toolkit tool = Toolkit.getDefaultToolkit();
        Dimension screen = tool.getScreenSize();
        int w = screen.width;
        int h = screen.height;
        
        int x = MouseInfo.getPointerInfo().getLocation().x-W/2;
        int y = MouseInfo.getPointerInfo().getLocation().y-H/2;
        if(x == ox && y == oy) {
            return;
        }
        ox = x;
        oy = y;
        int sx = Math.min(Math.max(x, 0), w-W);
        int sy = Math.min(Math.max(y, 0), h-H);
        BufferedImage capture;
        try {
            capture = (new Robot()).createScreenCapture(new Rectangle(sx, sy, W, H));
        } catch (AWTException ex) {
            System.err.println("Failed screen capturing!");
            return;
        }
        ByteArrayOutputStream data = new ByteArrayOutputStream();
        try {
            ImageIO.write(capture, "JPG", data);
        } catch (IOException ex) {
            System.err.println("Failed writing capture!");
            return;
        }
        byte[] toSend = data.toByteArray();
        int l = data.size();
        byte[] size = itob(l);
        //pool - Client[]
        for(int i = 0; i < pool.length; i++) {
            if(pool[i] == null) continue;
            if(!pool[i].isActive()) continue;
            pool[i].send(size, 0, 4);
            pool[i].send(toSend, 0, l);
        }
    }
                                    делаем скриншот. квадратом в 100 пикселей (курсор в центре).
+165
function passgen( $length )
{
    if( $_SERVER['REQUEST_METHOD'] == 'POST' )
    {
        $length = (int) $length;   
        $pass = "";
        for( $i = 0; $i < $length; $i ++ ) {
            if( isset( $_POST['uc'] ) ) {
                $j = mt_rand( 1, 10 );
                    if( $j % 3 )
                        $pass .= chr( mt_rand( 97, 122 ) ) ;
                    else
                        $pass .= chr( mt_rand( 65, 90 ) ) ;
            } else 
                $pass .= chr( mt_rand( 97, 122 ) ) ;    
        }   
        return $pass;
    }
}
                                    
−91
import sys
from ru.hastel.gameserver.model.quest import State
from ru.hastel.gameserver.model.quest import QuestState
from ru.hastel.gameserver.model.quest.jython import QuestJython as JQuest
qn = "2008_christmas"
class Quest (JQuest) :
 def __init__(self,id,name,descr): JQuest.__init__(self,id,name,descr)
 def onEvent (self,event,st) :
    htmltext = event
    if event == "1":
        if st.getQuestItemsCount(5556) >= 4 and st.getQuestItemsCount(5557) >= 4 and st.getQuestItemsCount(5558) >= 10 and st.getQuestItemsCount(5559) >= 1:
            st.takeItems(5556,4)
            st.takeItems(5557,4)
            st.takeItems(5558,10)
            st.takeItems(5559,1)
            st.giveItems(5560,1)
            htmltext = "<html><body>Merry Christmas.</body></html>"
        else:
             htmltext = "31863-2.htm"
    elif event == "2":
        if st.getQuestItemsCount(5560) >= 10 :
            st.takeItems(5560,10)
            st.giveItems(5561,1)
            htmltext = "<html><body>Merry Christmas.</body></html>"
        else:
             htmltext = "31863-3.htm"
    if htmltext != event:
      st.setState(COMPLETED)
      st.exitQuest(1)
    return htmltext
 def onTalk (self,npc,player):
    st = player.getQuestState(qn)
    if not st : return 
    npcId = npc.getNpcId()
    if npcId == 31863 :
       htmltext = "31863-1.htm"
       st.setState(STARTED)
    return htmltext
QUEST       = Quest(2008,qn,"custom")
CREATED     = State('Start', QUEST)
STARTED     = State('Started', QUEST)
COMPLETED   = State('Completed', QUEST)
QUEST.setInitialState(CREATED)
QUEST.addStartNpc(31863)
QUEST.addTalkId(31863)
                                    Вот простенький эвент на Питоне , как улучшить подскажите
+128
<?xml version='1.0' encoding='utf-8'?>
<list>
	<item id="8190" skillId="3603" name="Demonic Sword Zariche">
		<dropRate val="1" /> <!-- 100000 for 100% -->
		<duration val="300" /> <!-- in minutes -->
		<durationLost val="3" /> <!-- in minutes -->
		<disapearChance val="50" /> <!-- in % -->
		<stageKills val="10" /> <!-- Integer -->
	</item>
	<item id="8689" skillId="3629" name="Blood Sword Akamanah">
		<dropRate val="1" /> <!-- 100000 for 100% -->
		<duration val="300" /> <!-- in minutes -->
		<durationLost val="3" /> <!-- in minutes -->
		<disapearChance val="50" /> <!-- in % -->
		<stageKills val="10" /> <!-- Integer -->
	</item>
</list>
                                    Вот ХМЛ код , задроты Л2 поймут))
−115
#!/usr/bin/ruby1.8
require 'mysql'
$KCODE = 'UTF8'
class Country
  @@country = Array.new
  @@insert_query = String.new
  @@db = Mysql
  def initialize(filename)
    file = File.open(filename)
    while !file.eof?
      value, index = file.readline.split(/\s+/u)
      @@country[index.to_i] = value.to_s
    end
    file.close
  end
  def database_connect
    @@db = Mysql.new('localhost','username','userpass','userdatabase')
    begin
      @@db.query("SET NAMES utf8")
    rescue
      puts @@db.error
    end
  end
  def create_query
    begin
      result = @@db.query("SELECT * FROM table")
    rescue
      puts @@db.error
    end
    result.each_hash do |field|
      @@country.each_index do |index|
      @@insert_query += "UPDATE table SET position = #{index} WHERE caption = '#{field['caption']}';" if @@country[index] == field['caption']
      end
    end
  end
  def execute_query
    begin
      @@insert_query.split(/;/u).each { |query| @@db.query(query) }
      puts "result: #{@@db.errno}" if @@db.errno
    rescue
      puts @@db.error
    end
  end
  def database_disconnect
    @@db.close
  end
end
cnt = Country.new('country.txt')
# connect to DB
cnt.database_connect
# construct query
cnt.create_query
# execute constructed query
cnt.execute_query
# close connect
cnt.database_disconnect
                                    Ну можно же как-то сделать лучше?
+171
class note
{
public:
char name[10];
int telnumb;
int date[3];
};
int main()
{
system("echo Введите фамилию");
cin>>a[c].name;
system("echo Введите номер телефона");
cin>>a[c].telnumb;
system("echo Введите дату рождения");
cin>>a[c].date[1];
cin>>a[c].date[2];
cin>>a[c].date[3];
...
                                    Да, школокод, однако такой оригинальный способ вывода текста мне ещё не попадался...
−854
SELECT FROM `girls` WHERE (Age>=18)) AND (Tits size BETWEEN '2' AND '4') AND (Hair color = Blond));
                                    Вот лазил по Базе Мира решил похимичить ;)