Jump to content

benphelps

Members
  • Posts

    61
  • Joined

  • Last visited

    Never

About benphelps

  • Birthday 08/23/1990

Contact Methods

  • AIM
    bphelpsen
  • MSN
    bphelpsen@gmail.com
  • Website URL
    http://benphelps.me/
  • Yahoo
    bphelpsen

Profile Information

  • Gender
    Male
  • Location
    127.0.0.1

benphelps's Achievements

Member

Member (2/5)

0

Reputation

  1. THANK YOU! Here is the function I wrote to make it easy. I'm sure this can be compressed down to a smaller function, but it does the job for me. function cmdColor($text, $color = "32"){ $color = strtolower($color); switch($color){ case "30": case "black": $prefx = "\033[30m"; break; case "31": case "red": $prefx = "\033[31m"; break; case "32": case "green": $prefx = "\033[32m"; break; case "33": case "yellow": $prefx = "\033[33m"; break; case "34": case "blue": $prefx = "\033[34m"; break; case "35": case "magenta": $prefx = "\033[35m"; break; case "36": case "cyan": $prefx = "\033[36m"; break; case "37": case "white": $prefx = "\033[37m"; break; } print $prefx.$text."\33[0m"; } I added "\33[0m" to the end so it sets the color back to default, this way, if the script terms, your not stuck in a colored cmd line.
  2. Isn't that your part? You tell us whats wrong with it, then we tell you how to fix it.
  3. I'm not sure how I could explain it any better. Instead of plain white text in the command line, color the output. I start a php script from the command line that prints out some text, I would like to color that text. I have done this before with a simple function, maybe 15 lines of code max. I have just lost my snippets folder, so in that, I lost the function. I found the function on the a blog, which I found via. StumbleUpon. I have tried (for days now) to find this snippet, or any other snippet that might work with no luck.
  4. Check it against the domain and the domain only, if it still gets added, then its happening in other parts of the code.
  5. Here is how I changed it up, not sure if it will work for your database scheme. <?php $reciprocal = (isset($_POST['r_url'])?$_POST['r_url']:''); function Domain($reciprocal){ $nowww = ereg_replace('www.','',$reciprocal); $domain = parse_url($nowww); if(!empty($domain["host"])){ return $domain["host"]; }else{ return $domain["path"]; } } $sql1 = "SELECT r_url FROM exchange_links WHERE domain = '$reciprocal'"; $result1 = mysql_query($sql1) or die("Could not get link information."); $count = mysql_num_rows($result1); if($count != 0){ echo "This domain name is already listed"; } else { } ?>
  6. This cannot be done in PHP. Only the value is sent to PHP.
  7. When you say, console apps, I think you have a misunderstanding of how it works. PHP is not a compile and distribute language like C. PHP requires an interpreter before it can do anything. To run a PHP script in the command line, you can start it via "php script.php". When in the CMD line you loose most Superglobals and gain a few you dont have access to while not in the CMD line. I know you gain "$argv" and "$argc". You loose $_SERVER $_GET $_POST $_COOKIE $_FILES as those are set all by Apache or w/e server software is being used. Now, there are some tools you can use that CAN compile PHP with the PHP interpreter. The one i use is called Bambalam, a little old (PHP4) but it does the job. http://www.bambalam.se/bamcompile/ As far as what you can do while in the CMD line, I have personally coded a VERY basic, but functioning HTTP server. I have also coded an IRC bot in PHP. There are some very fun projects you can do with sockets and PHP. Hope this all helps a little.
  8. I'm 100% sure there is a better way to do this, I just don't know how. $array = shuffle(mysql_fetch_array(mysql_query("SELECT * FROM table"))); $save = serialize($array); $open = unserialize($save); You could save the array in a database and tag it to the session for the user, that way the user has the same, but random, results. You can treat the array you get from $open just like you would if it was never changed. The only thing you loose the the "LIMIT" from the SQL, which is how most pagination scripts work if I'm not mistaken.
  9. I don't usually bump things, but I really really need this function. With limited knowledge of the Linux CMD line, I have no idea where to start. If someone could help me, I can offer (good) hosting (Web or VPS) in exchange. (if me offering something in return is out of the TOS for this forum category, feel free to move it)
  10. I have checked everywhere I know on the interwebs looking for a function to color the CMD line output. I know it can be done, I have done it before, but I lost my snippets folder and now I need the function. Does anyone here on PHPFreaks have this function, or know how it can be done? It wasn't alot of code, maybe 15 lines in total.
  11. I'm trying to pull data from a table between certain hours of a day. Here is the SQL i have now: SELECT sum(bytes) FROM traffic WHERE ip = '${ip}' AND measuringtime > ( NOW() - INTERVAL ${hour} HOUR) GROUP BY ip This sends the data back for the past hour. I need to modify it to send the data for one hour of a day. Here is how to do it in a sentence form. I just dont know how to get that to MySQL. Select the sum of bytes from traffic where IP is equal to A and measuringtime is between hours 2 and 3 of the past day. This is the format of the "measuringtime" column: 2009-08-03 20:23:01
  12. Simulated cron jobs: http://cronless.com/ I'm up to about 6,000 jobs (about 6,500 users) and I'm noticing a performance drop and looking to speed it up.
  13. \r also simulates the pressing of the return key (Enter)
  14. The server is on a 100/100mb/s connection and most of the pages are blank or have little output, the server might peak at about .5-1mB/s when the batch runs. I'm just trying to improve the performance of the system.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.