SitePoint Sponsor

User Tag List

Page 1 of 3 123 LastLast
Results 1 to 25 of 54

Hybrid View

  1. #1
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking Useless code snippets

    Hey folks!!

    During the time we spend in front of the keyboard, whacking away like lunatics we tend to work hours on end on some of the most useless code snippets.

    Anyways, just to display what we all mostly just waste our time with why don't we throw in a bit of useless code for everybody to see.

    Doesn't have to have any particular pretty effect - just as long as it does something. Doesn't have to be long codes or terribly complicated codes, just as long as we know that it's a one time use only. Some client who's been asking for something totally nutty and un-explainable.

    Well, here's my bid on it, lets see how much time we can wrestle down and claim to have wasted. Ok and before i forget - it doesn't have to be the absolute best way of doing things, just as long as we don't go out of our way to actually create mumbo jumbo.

    PHP Code:
    <?
    setlocale 
    (LC_TIME"C"); //set locale time
    $num = (strftime("%u")); //getting the number of the day for the week ie. Monday=1, Tuesday=2 etc
    $month date("m"); //getting month in number ie. January=01, February=02 etc
    $year date("Y"); //getting full year ei. 2002
        
    if (($num != 6) || ($num != 7)) //if number of the day isn't 6 or 7 (saturday and sunday)
     
    {
     
    $day date("d")-$num//subtract day number from date
        
    if ($day 0//if date is less than 0
        
    {
        while (
    checkdate($month$day$year) == False) { $day $day-1;} //check date is valid ie date not 31-02-2002 subtract 1 from day till it is
        
    $update1 "$day-".str_replace("0"""$month)."-$year"//create valid date
        
    }
        else 
    //if day is less than 0
          
    {
          
    $month1 $month//get month
          
    $month1 $month1-1//subtract 1 from month 
          
    $day = (31 $day); //subtract negative day from 31
           
    if (checkdate($month1$day$year) == False//another date validation
          
    {
    while (
    checkdate($month1$day$year) == False):
     
    $day $day-1;} // subtract 1 from date till it's valid
     
    $update1 "$day-".str_replace("0"""$month1)."-$year"//create valid date
    endwhile;
        }
         else
          { 
    $update1 date("d/m/Y"); } //if day is 6 or 7 create date
     
    }
    ?>
    Part of a large script of course, but this particular little snippet was to insert the past weekend's sunday/saturday date regardless of when the script was run.

    I'll probably never have any use for it in my entire life so i'd dare say this is my most (to date) useless code snippet.

    Well, who knows, there might be somebody out there that's looking for just exactly something like this but since you mostly find instructions/tutorials/articles on the most common things when searching online for help, it might even prove that we get some info collected here which will (when all added together) prove to be less than useless.
    Last edited by EvilDoppler; Jun 7, 2002 at 21:06.
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  2. #2
    That's Right. notepad_coder's Avatar
    Join Date
    Apr 2002
    Location
    Colorado
    Posts
    835
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, heres an useless script I made yesterday when I got bored. It was made just to make someone mad ( my brother ) and I probably will never use it again unless I get really bored some day.
    PHP Code:
    <?
    if ($_POST) {
        
    $msg $_POST['message'];
        for (
    $i=0$i<=strlen($msg)-1$i++) {
            
    mail($_POST['email'], $_POST['subject'], $msg[$i]);
        }
    } else {
    ?>
    <form action="<?= $PHP_SELF?>" method="post">
      <input type="text" name="email"><br>
      <input type="text" name="subject"><br>
      <textarea name="message"></textarea><br>
      <input type="submit">
    </form>
    <? ?>
    Nothing fancy, all it does is email someone a message one letter at a time. It kinda sucks when you send over 200 words but who cares.
    Last edited by notepad_coder; Jun 7, 2002 at 03:06.
    - the lid is off the maple syrup again!

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe, i made something exactly like that, and my mate used it to send someone 2500 emails lol.

    PHP Code:
    <?
      $dbHost 
    'localhost';       // your host
      
    $dbUser '';                // mySQL database username
      
    $dbPass '';                // mySQL database password
      
    $dbSel  'webdev';          // mySQL database name
      
    $dbTable'articles';        // mySQL database table

     
    class connect
     
    {

       function 
    connect()  // connects to mySQL database
       
    {
         Global 
    $dbHost$dbUser$dbPass$dbSel$dbTable;

         
    $dbConnect = @mysql_connect($dbHost$dbUser$dbPass);

         if(!
    $dbConnect)
         {
           die(
    "<!-- connection failed -->\n\n"); 
         }
         else
         {
           echo 
    '<!-- db Connected -->';
         }

         
    mysql_select_db($dbSel) or die("<!-- select db failed -->\n\n"); echo "<!-- selected  -->\n\n";
       }

       function 
    databases()  // displays all databases in mySQL database
       
    {
         
    $result mysql_list_dbs();

         echo 
    "<table border=\"0\" cellpadding=\"1\">\n";
         echo 
    "  <tr style=\"background-color:gray; color:white; font-size:10pt\">\n";
         echo 
    "    <td>databases</td>\n";
         echo 
    "  </tr>\n";

         while (
    $row mysql_fetch_row($result))
         {
             echo 
    "  <tr style=\"background-color:gray;font-size:10pt; cursor:hand;\" onmouseover=\"this.style.backgroundColor='white';\"  onmouseout=\"this.style.backgroundColor='gray';\">\n    <td>$row[0]</td>\n  </tr>\n";
         }

         echo 
    "</table>\n";
         
    mysql_free_result($result);
       }

       function 
    tables()  // displays all tables in mySQL database
       
    {
         Global 
    $dbSel;

         
    $result mysql_list_tables($dbSel);

         echo 
    "<table border=\"0\" cellpadding=\"1\">\n";
         echo 
    "  <tr style=\"background-color:gray; color:white; font-size:10pt\">\n";
         echo 
    "    <td>tables</td>\n";
         echo 
    "  </tr>\n";

         while (
    $row mysql_fetch_row($result))
         {
             echo 
    "  <tr style=\"background-color:gray;font-size:10pt; cursor:hand;\" onmouseover=\"this.style.backgroundColor='white';\"  onmouseout=\"this.style.backgroundColor='gray';\">\n    <td>$row[0]</td>\n  </tr>\n";
         }

         echo 
    "</table>\n";
         
    mysql_free_result($result);
       }

       function 
    fields()  // displays all fields in a table in mySQL database
       
    {
         Global 
    $dbTable;

         
    $result mysql_query("select * fom $dbTable");

         echo 
    'function fields()s to be completed';

       }

       function 
    select()  // displays all data inside a table in mySQL database
       
    {
        Global 
    $dbTable;

        
    $result mysql_query("select * from $dbTable") or die("<!-- wrong value in $dbTable -->\n\n");

        echo 
    "<table border=\"0\" cellpadding=\"1\">\n  <tr style=\"background-color:gray; color:white; font-size:10pt\">\n";
        
    $i=0;

        while (
    $i mysql_num_fields($result))
        {
          echo 
    '    <td>' mysql_field_name($result$i) . "</td>\n";
          
    $i++;
        }

        echo 
    "  </tr>";

        while (
    $row mysql_fetch_array($resultMYSQL_BOTH))
        {
          echo 
    "  <tr style=\"background-color:gray;font-size:10pt; cursor:hand;\" onmouseover=\"this.style.backgroundColor='white';\"  onmouseout=\"this.style.backgroundColor='gray';\">\n";
          for (
    $i 0$i <= (mysql_num_fields($result)-1); $i++)
          {
            echo (
    "    <td>$row[$i]</td>\n");
          }
          echo 
    "  </tr>\n";

        }
          echo 
    "</table>\n";
        
        
    mysql_free_result($result);

       }
     }

    $connect = new connect();
    $connect->tables();       echo '<br />';
    $connect->databases();    echo '<br />';
    $connect->select();

    ?>
    this just displays your databases, tables, and data in the tables depending on what info you put into it

  4. #4
    Gone!
    Join Date
    Aug 2001
    Location
    Witty Location Parody
    Posts
    3,889
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great idea Evil, but any chance of everybody commenting each line. I hate using things where I do not know exactly what each line/block does and I am sure others will find it useful too.

    Cheers

  5. #5
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This script has to be up there for uselessness. HarryF aka "Drunken Dominator"

  6. #6
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up Superb!

    Excellent Notepad, Andrew and Harry (harry please just display the code in here, we want to see the uselessness of it in all it's glory).

    glenplake, sure, commenting the lines will probably both show how much crap we put together and also help out if somebody (gawd help them) should actually find a use for any of it.

    Cheers and we're off to a good start.
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  7. #7
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK;

    Main script
    PHP Code:
    <html> 
    <head> 
      <title>Generate Your Wu-Name</title> 
    </head> 
    <body bgcolor="#FFFFFF"> 

    <h2>Generate Your Wu-Name</h2> 
    <p><hr size=1 noshade></p> 

      <form action="<?=$SCRIPT_NAME?>" method="POST"> 
        <p><b>Enter your Name: </b><br> 
        <input type="text" name="realname" size=25> &nbsp; &nbsp; 
        <input type="submit" value="Submit"> 
        </p> 
      </form> 

    <p><hr size=1 noshade></p> 

    <? 
    if ($REQUEST_METHOD == "POST")  

        
    $displayname $realname
        
    $realname strtolower($realname); 

        
    /*== generate seed number from name submitted ==*/ 
        
    $len strlen($realname); 
        
    $seed 0$s 0

        for (
    $e=1$e<=$len$e++)  
        { 
          
    $chr substr($realname,$s,$e); 
          
    $seed $seed ord($chr)*$e

          
    $s=$e
        } 

        
    /*== read in the two files into the arrays ==*/ 
        
    $adj_array file("wu_adjs"); 
        
    $noun_array file("wu_nouns"); 

        
    /*== set random seed ==*/ 
        
    srand($seed); 

        
    /*== get the random numbers for each name first/last or adj/noun ==*/ 
        
    $arnd rand(0,sizeof($adj_array)-1); 
        
    $nrnd rand(0,sizeof($noun_array)-1); 

        
    /*== create name from random numbers ==*/ 
        
    $wuname "$adj_array[$arnd] $noun_array[$nrnd]"

        print 
    "<p><font size=4><b>$displayname</b> from this day forward you <br>you will also be known as "
        print 
    "<font size='+1'><b> $wuname </b></font></font></p>"

      } 

    ?>
    The adjectives file

    Code:
    Bitter
    Friendly
    Mad
    Master
    Dynamic
    Erratic
    Merry
    Fearless
    Misunderstood
    Quiet
    Pesty
    Gentlemen
    Profound
    Respected
    Amateur
    Shrieking
    Lucky
    Phantom
    Smiling
    Thunderous
    Tough
    Ungrateful
    Drunken
    Excessive
    Expert
    Fanatical
    Happy
    Intellectual
    Unlucky
    Visual
    Foolish
    Midnight
    Mighty
    Violent
    Vulgar
    Crazy
    Annoying
    Arrogant
    Beloved
    Sarcastic
    Insane
    Irate
    Jolly
    Lazy-assed
    Amazing
    The nouns file

    Code:
    Enchanter
    Genius
    Hunter
    Killer
    Professional
    Artist
    Dreamer
    Observer
    *******
    Wizard
    Swami
    Wanderer
    Assassin
    Bandit
    Leader
    Ambassador
    Warrior
    Menace
    Worlock
    Conqueror
    Lover
    Magician
    Desperado
    Specialist
    Mercenary
    Ninja
    Contender
    Mastermind
    Demon
    Watcher
    Destroyer
    Beggar
    Commander
    Dominator
    Overlord
    Samurai
    Knight
    Pupil
    Prophet
    Scholar
    Some put a fair amount of work into that.

  8. #8
    K, Dan K Dan_K's Avatar
    Join Date
    Jun 2001
    Location
    Perth - Western Australia
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I got Thunderous Knight.
    -Daniel Kerton,
    Humor

  9. #9
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My useless script I picked up from here:


    PHP Code:
    <?
    while (true) {}
    ?>


    It'll only crash your browser

  10. #10
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A nice on with a little PHP and mainly Javascript is;

    PHP Code:
    <html>
    <head>

    <script type="text/javascript">
    function openwindow()
    {
    window.open("<?php echo ( $_SERVER['PHP_SELF'] );?>","_blank","width=20,height=20")
    }
    </script>

    </head>
    <body onload="openwindow()">
    <h1 align="center">No STOP!!!!!</h1>
    </body>
    </html>
    Dont try that one at home folks.

  11. #11
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i made a nasty one a while back like that, my mate stuck it on his site and said it was a cheat in a mirc chat lol, and it crashed nearly everyone that was online lol.

    there is a way round this script tho, however it can be hard to pull off whilst using alt ctrl del and somthing like esc (can't remember exactly). Or just use a popup killer program

  12. #12
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post your script?

  13. #13
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Edit: okay, now it has PHP.

    Definately the most irritating thing I've ever assembled.

    Save this file as hell.html

    PHP Code:
    <html>

    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Page from Hell</title>

    <script language="JavaScript"><!--
    function reSpawn() {
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    open("<?php echo ( $_SERVER['PHP_SELF'] );?>")
    };
    window.onunload=reSpawn;
    //--></script>

    <script language="JavaScript">
    function noRightClick(evnt) {
    errMsg="Not enough system memory to display source/perform graphics save, repeat right-click to delete systems files and free resou
    rces for display. Click OK to abort file deletion."
    if (navigator.appName.toUpperCase().match(/NETSCAPE/) != null) {
    if (evnt.which == 3){alert(errMsg);return false;}}else
    if (event.button==2)alert(errMsg);}
    document.onmousedown=noRightClick;
    </script>

    <SCRIPT language=Javascript>

    <!---Hide
    var xOff = 100;
    var yOff = 100;
    var xPos = 100;
    var yPos = 100;
    var flagRun = 1;
    function newXlt(){
            xOff = Math.ceil( 0 - 5 * Math.random()) * 5 ;
            window.focus()}
    function newXrt(){
            xOff = Math.ceil(5 * Math.random())  * 5 ;
            }
    function newYup(){
            yOff = Math.ceil( 0 - 5 * Math.random())  * 5 ;
            }
    function newYdn(){
            yOff = Math.ceil( 5 * Math.random())  * 5  ;
            }
    function playBall(){
            xPos += xOff;
            yPos += yOff;
            if (xPos > 600){
            newXlt();
            }
            if (xPos < -240){
            newXrt();
            }
            if (yPos > 470){
            newYup();
            }
            if (yPos < -110){
            newYdn();
            }
            if (flagRun == 1){
            window.moveTo(xPos,yPos);
            setTimeout('playBall()',10);
            }
            }
    //Done hiding --->
    </SCRIPT>
    </head>

    <body onload="flagRun = 1; playBall(); return true">
    <h1>Page from Hell!</h1>

    I take no responsibility<P>
    </body>

    </html>
    Last edited by Owen; Jun 9, 2002 at 00:54.

  14. #14
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok...

    That had NO php in it, but that's ok...

    Thanks,
    ~someonewhois

  15. #15
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rocking!!!

    superb - we're getting a nice influx of malicious scripts assembled here (i wonder what you guys do to pass the time without a computer nearby!!!! )

    We just need some more comments in the code (as glenplake requested earlier on) but we're getting an excellent selection happening.

    Let's keep 'em rolling
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  16. #16
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually i could always do a bit of vb and create 10,000 files on your hard drive in about 5 secs, now we would have a nice variety .

  17. #17
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Useless code snippets

    Originally posted by EvilDoppler
    ... During the time we spend in front of the keyboard, whacking away...
    You've got that right, pal
    Pants.
    Join the NYFlava Fashions Contest

  18. #18
    SitePoint Evangelist AlexC's Avatar
    Join Date
    Oct 2000
    Location
    Sheffield, UK
    Posts
    437
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just a side note - a great script we put on our school network (me and someone else) is a simple batch file that is called 1.bat containing the single line

    Code:
    START 1.bat
    :-D
    Nearly 7 years old!

  19. #19
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Isaac,

    ... During the time we spend in front of the keyboard, whacking away like lunatics...
    Felt your quote was missing something, you bad man.

  20. #20
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink quote

    Darn....and here i was trying to convince myself that I wasn't turning into a slobbering, light sensitive, perverted *******...guess that idea didn't last long enough!!

    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  21. #21
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    btw..got a quick question...

    how do i get more
    ???

    ok..i'm an ignorant hick (well not really a hick, just a saying), but i want more...do i have to post more messages or do i have to do some serious brownie point gathering around here ???
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  22. #22
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to post more 20 more posts and you get another one!

  23. #23
    SitePoint Addict EvilDoppler's Avatar
    Join Date
    Dec 2001
    Location
    Perth, Australia
    Posts
    217
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking 20 more to go and i wont look like a newbie

    excellent...only 20 more to go...

    cheers n' thanks
    * Due to the last tax raise our prices has risen
    * - answers w/o thought $1 - answers w/ thought $3
    * - correct answers $10
    * - Dumb stares are still free

  24. #24
    SitePoint Addict IsaacV's Avatar
    Join Date
    Jan 2002
    Location
    Saint Petersburg
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by HarryF
    Hey Isaac,



    Felt your quote was missing something, you bad man.
    Hey now, . Let's not point fingers here. I now see that my message could have been misinterpreted into something dirty. Well you should blame yourself for thinking that way! Pig!
    Pants.
    Join the NYFlava Fashions Contest

  25. #25
    SitePoint Wizard gold trophysilver trophy
    Join Date
    Nov 2000
    Location
    Switzerland
    Posts
    2,479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Of course - you had no idea

    Here's something useless I've never tried (and don't really want to risk trying). Put these files in the same directory

    PHP Code:
    <?php
    /* include_me.php */
    include ( "no_include_me.php" );
    header "Location: no_include_me.php" );
    ?>
    PHP Code:
    <?php
    /* no_include_me.php */
    include ( "include_me.php" );
    header "Location: include_me.php" );
    ?>
    God knows what happens if you run this. Perhaps anything from crashing your PC to the webserver itself. Not nice.

    YOU HAVE BEEN WARNED!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •