1. Список говнокодов пользователя xXx_totalwar

    Всего: 24

  2. PHP / Говнокод #5564

    +163

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    <?
    class Thread {
    <...>
    	function Thread($proc_id) {
    		$this->db=new ezSQL_mssql(s_login, s_password, s_db_name_threads, s_host);
    		$this->proc_id=$proc_id;
    		$this->timeout=500;
    		$this->last_busy=0;
    		$this->notactive_num=0;
    		$query="INSERT INTO threads(proc_id, last_beat) VALUES('".$this->proc_id."','".(time()+60)."');";
    		$this->db->query($query);
    	}
    	static function Create($url,$proc_id) {
    		$t = new Thread($proc_id);
    		
    		//### execute thread
    		//NB!!!
    		//BE CAREFUL WITH LOG PATHS, IF YOU MISS OR MISSPEL THE PATH, IT IS HARDLY POSSIBLE TO DEBUG
    		//IF YOU MISSPELL THE PATH YOU CAN FACE THE PROBLEM OF THREADS SIMPLY DO NOT START OR DO NOT LOG WITHOUT ANY NOTIFICATION
    		//USE YOUR OWN PATHS FOR PHP, LOGS AND COMMAND LINE COMMANDS AD PARAMETERS FOR YOUR SPECIFIC OS, WINDOWS EXAMPLE IS BELOW
    		//start /B will execute background process in windows, > symbol will store the output of current process into log file
    		//you can call threads from another server via http request etc.
    		pclose(popen("start /B \"$proc_id\" C:\php\php.exe D:\wwwroot\\newimport\elko\import_ignitor_thread.php > D:\globalimport\logs\\".$proc_id.".txt $proc_id","r"));		
    		
    		//give some time to start the thread
    		Sleeper(1000);
    		return $t;
    	}
    	
    	//check is Thread active or not
    	//check active, busy, last beat etc.
    	//you can put here your own business logic how thread should be checked for statused etc.
    	function isActive () {
        if($this->state==3){
    			return false;
    		}elseif ($this->last_busy==1){
    			return true;
    		}
    		$cur_time=time();
    		if($cur_time>$this->last_beat){
    			$result=$this->db->get_var("SELECT last_beat FROM threads WHERE proc_id=".$this->proc_id);
    			$this->state=$this->db->get_var("SELECT state FROM threads WHERE proc_id=".$this->proc_id);
    			if($cur_time<$result){
    				return true;
    			}
    		}else{
    			return true;
    		}
    		return true;
    	}
    	
    	//check is Thread is busy or not, in order to give a new task/job
    	//it is similat to the previous procedure
    	function isBusy() {
    		//$this->tell("ping"); - this could be implemented in the future
    		$cur_time=time();
    		if($cur_time>$this->last_beat or $this->last_busy==0){
    			$result=$this->db->get_var("SELECT busy FROM threads WHERE proc_id=".$this->proc_id);
    			$this->last_busy=$result;
    			if($result==1){
    				return true;
    			}else{
    				return false;
    			}
    		}else{
    			return false;
    		}
    	}
    	
    	//tells a command to the thread
    	function tell($thought, $params = NULL) {
    		$param=base64_encode(serialize($params));
    		$query="INSERT INTO cmd(proc_id, cmd, param) VALUES('".$this->proc_id."','".$thought."','".$param."');";
    		$this->db->query($query);
    	}
    }

    'многопоточность'

    xXx_totalwar, 07 Февраля 2011

    Комментарии (5)
  3. PHP / Говнокод #5563

    +157

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    <?php
    function Sleeper($mSec)
    {
    	//    For dummies like me who spent 5 minutes
    	//    wondering why socket_create wasn't defined
    	if(!function_exists('socket_create')){
    		die("Please enable extension php_sockets.dll");
    	}
    	//    So the socket is only created once
    	static $socket=false;
    	if($socket===false){
    		$socket=array(socket_create(AF_INET,SOCK_RAW,0));
    	}
    	$pSock=$socket;
    	//    Calc time
    	$uSex = $mSec * 1000;
    	//    Do the waiting
    	socket_select($read=NULL,$write=NULL,$pSock,0,$uSex);
    	//    OCD
    	return true;
    }

    что бы гк делал без этого чудесного языка..

    xXx_totalwar, 07 Февраля 2011

    Комментарии (5)
  4. Куча / Говнокод #5555

    +74

    Pony!

    xXx_totalwar, 06 Февраля 2011

    Комментарии (36)
  5. Java / Говнокод #5498

    +84

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    /*
     * Copyright 2003-2009 the original author or authors.
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *     http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */
    package org.codehaus.groovy.runtime;
    
    
    public class ArrayUtil {
        private static final Object[] EMPTY = new Object[0]
                ;
    
        public static Object[] createArray() {
            return EMPTY;
        }
    
        public static Object[] createArray(Object arg0) {
            return new Object[]{
                    arg0};
        }
    
        public static Object[] createArray(Object arg0, Object arg1) {
            return new Object[]{
                    arg0, arg1};
        }
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2) {
            return new Object[]{
                    arg0, arg1, arg2};
        }
    .......................................................
    
        public static Object[] createArray(Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6, Object arg7, Object arg8, Object arg9, Object arg10, Object arg11, Object arg12, Object arg13, Object arg14, Object arg15, Object arg16, Object arg17, Object arg18, Object arg19, Object arg20, Object arg21, Object arg22, Object arg23, Object arg24, Object arg25, Object arg26, Object arg27, Object arg28, Object arg29, Object arg30, Object arg31, Object arg32, Object arg33, Object arg34, Object arg35, Object arg36, Object arg37, Object arg38, Object arg39, Object arg40, Object arg41, Object arg42, Object arg43, Object arg44, Object arg45, Object arg46, Object arg47, Object arg48, Object arg49, Object arg50, Object arg51, Object arg52, Object arg53, Object arg54, Object arg55, Object arg56, Object arg57, Object arg58, Object arg59, Object arg60, Object arg61, Object arg62, Object arg63, Object arg64, Object arg65, Object arg66, Object arg67, Object arg68, Object arg69, Object arg70, Object arg71, Object arg72, Object arg73, Object arg74, Object arg75, Object arg76, Object arg77, Object arg78, Object arg79, Object arg80, Object arg81, Object arg82, Object arg83, Object arg84, Object arg85, Object arg86, Object arg87, Object arg88, Object arg89, Object arg90, Object arg91, Object arg92, Object arg93, Object arg94, Object arg95, Object arg96, Object arg97, Object arg98, Object arg99, Object arg100) {
            return new Object[]{
                    arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23, arg24, arg25, arg26, arg27, arg28, arg29, arg30, arg31, arg32, arg33, arg34, arg35, arg36, arg37, arg38, arg39, arg40, arg41, arg42, arg43, arg44, arg45, arg46, arg47, arg48, arg49, arg50, arg51, arg52, arg53, arg54, arg55, arg56, arg57, arg58, arg59, arg60, arg61, arg62, arg63, arg64, arg65, arg66, arg67, arg68, arg69, arg70, arg71, arg72, arg73, arg74, arg75, arg76, arg77, arg78, arg79, arg80, arg81, arg82, arg83, arg84, arg85, arg86, arg87, arg88, arg89, arg90, arg91, arg92, arg93, arg94, arg95, arg96, arg97, arg98, arg99, arg100};
        }

    вот такой он - groovy

    xXx_totalwar, 02 Февраля 2011

    Комментарии (11)
  6. C++ / Говнокод #5277

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    // Licensed to Green Energy Corp (www.greenenergycorp.com) under one
    // or more contributor license agreements. See the NOTICE file
    // distributed with this work for additional information
    // regarding copyright ownership. Green Enery Corp licenses this file
    // to you under the Apache License, Version 2.0 (the
    // "License"); you may not use this file except in compliance
    // with the License. You may obtain a copy of the License at
    // http://www.apache.org/licenses/LICENSE-2.0
    // Unless required by applicable law or agreed to in writing,
    // software distributed under the License is distributed on an
    // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    // KIND, either express or implied. See the License for the
    // specific language governing permissions and limitations
    // under the License.
    //
    #include "Objects.h"
    
    #define MACRO_STATIC_INSTANCE(group, var) Group##group##Var##var Group##group##Var##var::mInstance;
    
    namespace apl { namespace dnp {
    
    MACRO_STATIC_INSTANCE(1,0)
    MACRO_STATIC_INSTANCE(1,1)
    MACRO_STATIC_INSTANCE(1,2)
    MACRO_STATIC_INSTANCE(2,0)
    MACRO_STATIC_INSTANCE(2,1)
    MACRO_STATIC_INSTANCE(2,2)
    MACRO_STATIC_INSTANCE(2,3)
    
    <... 100500 строк ...>
    
    MACRO_STATIC_INSTANCE(60,1)
    MACRO_STATIC_INSTANCE(60,2)
    MACRO_STATIC_INSTANCE(60,3)
    MACRO_STATIC_INSTANCE(60,4)
    
    MACRO_STATIC_INSTANCE(80,1)
    
    MACRO_STATIC_INSTANCE(110,0)
    MACRO_STATIC_INSTANCE(111,0)
    MACRO_STATIC_INSTANCE(112,0)
    MACRO_STATIC_INSTANCE(113,0)
    
    //////////////////////////////////////////////
    // Binary Input Types
    //////////////////////////////////////////////
    
    void Group1Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group1Var2::Inst(), v); }
    void Group2Var1::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQ(p, Group2Var1::Inst(), v); }
    void Group2Var2::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var2::Inst(), v); }
    void Group2Var3::Write(apl::byte_t* p, const apl::Binary& v) const { DNPToStream::WriteQT(p, Group2Var3::Inst(), v); }
    
    Binary Group1Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group1Var2::Inst()); }
    Binary Group2Var1::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var1::Inst()); }
    Binary Group2Var2::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQV(p, Group2Var2::Inst()); }
    Binary Group2Var3::Read(const apl::byte_t* p) const { return DNPFromStream::ReadBinaryQVT(p, Group2Var3::Inst()); }

    "We provide world-class engineering services to companies leading the smart energy revolution."
    посредством копипасты. малаца.

    xXx_totalwar, 14 Января 2011

    Комментарии (9)
  7. PHP / Говнокод #4356

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    <?
    // регистрационная информация (пароль #1)
    // registration info (password #1)
    $mrh_pass1 = "Morbid11";
    
    // чтение параметров
    // read parameters
    $out_summ = $_REQUEST["OutSum"];
    $inv_id = $_REQUEST["InvId"];
    $shp_item = $_REQUEST["Shp_item"];
    $crc = $_REQUEST["SignatureValue"];
    
    $crc = strtoupper($crc);
    
    $my_crc = strtoupper(md5("$out_summ:$inv_id:$mrh_pass1:Shp_item=$shp_item"));
    
    // проверка корректности подписи
    // check signature
    if ($my_crc != $crc)
    {
      echo "bad sign\n";
      exit();
    }
    
    // проверка наличия номера счета в истории операций
    // check of number of the order info in history of operations
    $f=@fopen("order.txt","r+") or die("error");
    
    while(!feof($f))
    {
      $str=fgets($f);
    
      $str_exp = explode(";", $str);
      if ($str_exp[0]=="order_num :$inv_id")
      { 
    	echo "Операция прошла успешно\n";
    	echo "Operation of payment is successfully completed\n";
      }
    }
    fclose($f);
    ?>

    учитесь, как надо с онлайн-наличкой работать
    http://www.robokassa.ru/Doc/demo_php.zip

    xXx_totalwar, 12 Октября 2010

    Комментарии (12)
  8. JavaScript / Говнокод #4302

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function tv_cat(iz){
    if (iz%2==0)
    {
    	document.getElementById("cat_tv_header3").innerHTML=
    		"<a href='#'  onclick=' javascript: tv_cat(1);'><img src='/img2/but_tv.gif' width='142' height='30' border='0'>";
    }
    else
    {
    	document.getElementById("cat_tv_header3").innerHTML=
    		"<a href='#'  onclick= javascript: tv_cat(2);'><img src='/img2/but_catalog.gif' width='142' height='30' border='0'>";
    }
    }

    "рекурсия", епт

    xXx_totalwar, 07 Октября 2010

    Комментарии (2)
  9. C++ / Говнокод #3463

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    #include <math.h>
    #include <stdio.h>
    double zero = 0, three = 3, four = 4;
    class Complex
         {
            public:
            double &x, &y;
            Complex() : x(zero), y(zero) { }
            Complex( double &z ) : x(y), y(z) { }
            Complex( double &_x, double &_y ) : x(_x), y(_y) { }
         };
         double square( double const &x ) { return x * x; }
         double absValue( Complex &c ) { return sqrt( square(c.x)+square(c.y) ); }
         int main()
         {
             Complex c(four);
             printf( "absolute value is %g\n", absValue( c ) );
             return 0;
         }

    говно отсюда http://www.gimpel.com/html/bugs.htm

    xXx_totalwar, 13 Июня 2010

    Комментарии (13)
  10. C++ / Говнокод #3093

    +908

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    for (int i = ((x-1)>=0)?(x-1):0; i<=((x+1<=9)?(x+1):9); ++i)
    	for (int j = ((y-1)>=0)?(y-1):0; j<=((y+d<=9)?(y+d):9); ++j)
    		if (isplayer)
    		{
    			if (Board[i][j]->Alive)
    				return false;
    		}
    		else
    		{
    			if (EnBoard[i][j]->Alive)
    				return false;
    		}

    с++ такой с++

    xXx_totalwar, 23 Апреля 2010

    Комментарии (8)
  11. C# / Говнокод #2880

    +116.2

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    SendMessage("PRIVMSG " + channel + " :Name: " + ObjectManager.Me.Name + " Health: " + ObjectManager.Me.CurrentHealth + "/" + ObjectManager.Me.MaxHealth + " Mana: " + ObjectManager.Me.CurrentMana + "/" + ObjectManager.Me.MaxMana + " Level: " + ObjectManager.Me.Level + " Race: " + ObjectManager.Me.Race + " Class: " + ObjectManager.Me.Class + " Xp to LeveL: " + ObjectManager.Me.XP + "/" + ObjectManager.Me.NextLevelXP + " Combat: " + ObjectManager.Me.Combat + " Time to level: " + hours + " Hours " + minutes + " Minutes");                   
    
    /* немного дальше */
                        if (CommandUsed("!zone", messageLine))
                        {
                            SendMessage("PRIVMSG " + channel + " :Zone: " +ObjectManager.Me.RealZoneText);
                            SendMessage("PRIVMSG " + channel + " :SubZone: "+ ObjectManager.Me.SubZoneText);
                        }
                        if (CommandUsed("!free", messageLine))
                        {
                            SendMessage("PRIVMSG " + channel + " : i have "+ Global.FreeSlots + " free slots");
                        }
    /* и тд */
                        if (CommandUsed("!guild", messageLine))
                        {
                            if (accCheck.CanUseCommand(loginCheckLine))
                            {
                                SendGuild(messageLine);
                            }
                        }

    вот как надо шпарить ботов для irc
    http://pastebin.org/126516

    xXx_totalwar, 28 Марта 2010

    Комментарии (4)