Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Posts posted by The Little Guy

  1. For the service I am providing, I think what I posted would be fine. As I am not providing a service to check if you page renders correctly, but if it responds to requests that come into the server.

     

    But I still don't know, but.. I do believe that sending a cURL request to the server is the best way to check if a website is up/down, and sending pings to test if a server is up/down. Is there a better way to check, maybe something like http://canyouseeme.org and test port 80?

  2. That could return a 403, 404, 500, etc. return code which means your user doesn't have access to the page. That could be because of the page IS a 404 page or whatever, but it could also mean that you have an error with the server setup.

     

    At the least, you should be checking a normal page (non-404 nor authorization required) for a HTTP 200 code. Dan's solution is more robust in making sure your page actually outputs something worthwhile (although if you have dynamic pages you'd have to select something more general like <html)

     

    But the web service still responded, which is all I am really after. I don't really care if a page works or not, but whether or not the web service is working.

  3. I don't think you need to do regexp, I'm sure this would work:

     

    <?php
    $domains = array("http://asdfasdfaassafaf.com", "http://google.com", "123.123.123.123");
    foreach($domains as $domain){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $domain);
    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_exec($ch);
    $info = curl_getinfo($ch);
    curl_close($ch);
    if($info['http_code'] == 0)
    	echo "Page not served from $domain";
    else
    	echo "$domain Responded: ".$info['http_code'];
    echo "<br>";
    }
    ?>

  4. what would be the best way to test a websites up/downtime?

     

    I have a program that pings a website every 5 minutes, would that be a good way to test if the site is up or down, or would it be better to do a cURL request to the domain?

     

    OR... is there an even better way to test if a domain is up or down?

     

    Thanks!

  5. I was wondering, for someone who has 2+ data centers, say one in California, and one in New York and they share the same domain name like "superawesomewebsite.com", how does traffic get directed to each data center? I believe you just use the ip of data center 1 and 2 in your dns and it will send you there, but isn't the second ip for connecting only if the first one isn't reachable?

     

    So basically how does having 2+ data centers work while utilizing both of them?

  6. Okay, so I figured out it is this:

     

    shell_exec("php ./pingDomain.php $domain $domain_id $date > NUL");

     

    Now any ideas how to make it so it doesn't wait for the script to finish executing before it continues?

  7. Using Windows, how do you redirect the output, something similar to /dev/null?

     

    I tried this:

    shell_exec("php ./myScript.php arg1 arg2 arg3 >/dev/null");

     

    but I am getting this error:

    The system cannot find the path specified.

     

    So, how do I redirect the output in Windows?

  8. I am using AJAX to access this file on my domain (weblyize.com), from my subdomain (ping.weblyize.com), and it keeps going into the if statement, logged is set on the domain, because I can see it when I go to a page that displays it. Anyone know why it is going into the if? If I go to the page directly, it works fine.

     

    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Methods: POST, GET");
    header("Access-Control-Allow-Headers: NCZ");
    header("Access-Control-Max-Age: 1728000");
    session_set_cookie_params(0, "/", ".weblyize.com", false); 
    session_start();
    if(!isset($_SESSION['logged']) || !$_SESSION['logged']){
    header("HTTP/1.0 400 Bad Request");
    header("Status: 400 Bad Request");
    exit;
    }

  9. Actually I think the PDF thing is built into Open Office, but for MS Word, you can download:

    http://www.cutepdf.com/

     

    For MS Word: download it install it, make your file within word. To save it, File->print->Cute PDF (instead of the printer)

     

    For Open Office: make your file. To save it, File->export->PDF

  10. myFunc($p1, $p2, $p3){
    $p1 = (bool)call_user_func($p1);
    if($p1)
    	retrun "Smoosh Smoosh";
    if($p2 == "cat")
    	return "Meow!";
    else
    	return "Error";
    }
    
    echo myFunc(function(){
    $num = $_POST['number'];
    for($i=$num;$i > 0;$i--){ 
    	$v = $num / $i; 
    	if(!is_float($v)){ 
    		if($v != $num && $v != 1) 
    			return false; 
    	} 
    } 
    return true; 
    }, ("cat"==$animal?("red"==$color?(12=="age"?("mamal"==$type?"cat":false):"dragon"):"monkey bars"):false), preg_replace("/[0-9]/", "123", round(($upper+$lower)/2+0.5)));

     

    nuf said!

  11. Give this a try:

     

    SELECT p.orderid, p.updated, p.origsalesman, p.salesman, p.status, p.profit, p.product, p.orderdate, o.price
    FROM printersales p LEFT JOIN orderdetail o ON(p.orderid = o.orderid)
    LEFT JOIN printers pr ON(o.productid = pr.productid)
    WHERE p.updated > '2011-08-5 00:00:01';

  12. Auth: http://tests.phpsnips.com/phpfreaks.txt

     

    For the past year or so, I have been working on a library to help people program. It is a fairly easy to use library (In My Opinion), my site has documentation on a fair amount of the library, but the documentation is still not complete.

     

    So, I have 2 questions to ask of you:

     

    1. What do you think of the documentation that is there, was it helpful?

    2. What do you think of the library its self? What could be improved and what did/din't you like?

     

    Some powerful/Useful features in my opinion are:

     

    - Easily send mail with 1+ attachments

    $to = array("Billy Bob", "billybob@example.com");
    $from = array("Jimmy", "jimmy@example.com");
    $subject = "Hello Billy Bob!";
    $message = "Just cheking up on you!";
    $files = array("/files/file1.png", "/files/file2.jpg");
    $live->mail($to, $from, $subject, $message, MAIL_ATTACHMENT, $files);
    

     

    - Easily zip up some files and download them on the fly

    $files = array(
        "/path/to/file1.php" => "file1.php",
        "/path/to/text/license.txt" => "docs/license.txt",
        "extensions/"
    );
    $live->zip($files)->download(PHP_TMPFILE, "myFiles.zip");
    exit;

     

    - Grab all the links from a webpage:

    print_r($live->getHttp("http://somesite.com")->getLinks()->list);

     

    - Some methods have a callback function, such as each(), where the following code can convert a handful links into full URLS (following method format requires php 5.3.x or higher. You could place the function in another function and call the function for php 5.2.x and lower)

    print_r($live->getHttp("http://phplive.org")->getLinks()->each(function($link){
        global $live;
        $url_info = (object)parse_url($live->endingUrl);
        $domain = $url_info->scheme."://".$url_info->host;
        if(preg_match("/^\//", $link)){
            return $domain.$link;
        }elseif(!preg_match("/^http/", $link)){
            return $live->endingUrl."/".$link;
        }
        return $link;
    }));

     

    There are many other things, such as database methods, threading, mobile device check, operating system check, etc.

     

    Here are the related links:

    Docs: http://tests.phpsnips.com/docs

    Download: http://tests.phpsnips.com/download.php

     

    Thank you for your help!

  13. Australia doesn't make the list? We invented the boomerang! makes hunting so much easier while riding our kangaroos.

     

     

    Didn't you guys invent the rotary washing line too? Where would we be without those, eh?

     

    That we did, but I think our contributions to medicine are probably the most significant.

     

    - Penicillin

    - Bionic Ear

    - Aspro

    - Spray on Skin

    - Zinc Cream

    - Ultrasound

    - Latex Gloves

    - Flu Vaccine

    - Night and Day contact lenses

    - Heart Pacemaker

    - Anthrax Vaccine

     

    to name a few, and we pioneered microsurgery.

     

    Some of other inventions/discoveries/innovations include...

     

    - Combine Harvester

    - The Sarich Engine

    - Wave Piercing Catamaran

    - Differential Gears

    - The 'Ute' (which is different to the 'pickup truck' developed in the USA)

    - Black Box Flight Recorder

    - Variable Ratio Rack and Pinion Steering

    - Hyshot Scramjet Engine

    - Electric Drill

    - Two Stroke Lawn Mower

    - Notepad

    - Telephane (yes Telephane, not Telephone)

    - Garage Roller Door

    - Salt Water Chlorination of Swimming Pools

    - Pre-paid Postage

    - Xerox Photocopying

    - Polymer Bank Notes

    - Blast Glass

    - Refrigeration

    - Vegemite (controversial topic as of late since the iSnack 2.0 incident)

    - Wine Cask

    - CETO Wave Energy System

    - Calyx Drill

    - Uniloc Software Protection (which after Microsoft copied, lost approx half a billion for stealing the technology)

    - Wireless LAN IEEE 802.11

    - Samba Software

    - Google Maps (developed by a couple of Danish-Australian brothers in Sydney, believe it or not)

    - Feature Films (The Story of the Kelly Gang, 1906, ran for more than an hour)

    - The Australian Crawl

    - Race Cam

    - Speedo Swimwear

    - The Mills Cross

    - Gene Shears

    - SILEX

    - Synroc

    - The Stobie Pole

     

     

    we all invented our own language individually, with the exceptions of USA and Australia which stole ours.  :o  lol

    I can't speak for the USA, but we improved it :P

     

     

    Well I'm rooting for you, oh wait, that means something else in Aus lol

     

    Yes lets keep quoting full posts instead of trimming them, I like it!

     

    I dunno...it seems like a good idea but it's also kinda annoying...

     

     

    I invented that, +1 UK ;) lol

     

    How can I quote all three pages?

     

    Here are some "10 Dumb Inventions That Made People Stupidly Rich":

    http://www.asylum.com/2010/01/11/9-dumb-inventions-that-made-people-stupidly-rich/

×
×
  • 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.