Jump to content

The Little Guy

Members
  • Posts

    6,675
  • Joined

  • Last visited

Posts posted by The Little Guy

  1. I would use str_repeat for this:

     

    <?php
    function hide($string, $start = 11, $length = 3, $repeater = "*"){
    $front = str_repeat($repeater, $start);
    $letters = substr($string, $start, $length);
    $end = str_repeat($repeater, strlen($string)-($start+$length));
    return $front.$letters.$end;
    }
    
    $strings = array("http://www.google.com", "http://www.yahoo.com", "http://phpsnips.com/forums");
    foreach($strings as $string){
    echo hide($string)."<br>";
    }
    ?>

  2. I was using no-ip like 5+ years ago which I hear is a similar service. I am currently not on my computer to test this, but doesn't that still mask the URL doing it like that?

     

    found this:

    - Go to your DNS manager and create a DNS CNAME entry for your domain (abc.com) and make it go to your free no-ip subdomain (xyz.redirectme.net)

  3. I have a dynamic IP address, and port 80 blocked (So I use port 3333) and I was wondering if anyone had any solutions to use a domain with that. I would like to register a domain under godaddy. I have see some sites were it masks the urls, so if I go to:

    http://mysite.com

     

    Then click on a link that takes me to:

    http://mysite.com/somepage.php

     

    the URL then still displays:

    http://mysite.com

     

    I would like to have a way around this, does anyone know of any free solution?

  4. to help you build a better table here is my suggestion:

     

    1. Make a points table

    2. have 3 fields: member_id, create_date, points

    3. every time you give out points insert a value into the table

    4. every time you remove points insert a value into the table (as a negative point value)

    5. to get a total sum:

    select sum(points) as amount from myTable where member_id = 123;

    6. to get a total sum between 2 dates:

    select sum(points) as amount from myTable where create_date between '2011-01-01' and '2011-02-01 23:59:59' where member_id = 123;

     

    There is a basic way of what you could do.

  5. I would recommend using a database, but this is a non-database way (NOT TESTED!):

     

    function checkFolder(){
    $.ajax({
    	type: "GET",
    	url: "/process/checkfolder.php",
    	success: function(data){
    		$("#myDiv").append(data);
    	}
    });
    }
    setInterval("checkFolder()", 10000);  // Run checkFolder every 10 seconds
    

     

    session_start();
    if(!isset($_SESSION['last_check']))
    $_SESSION['last_check'] = 0;
    $last_check = $_SESSION['last_check'];
    $_SESSION['last_check'] = time();
    $newest_files = array();
    foreach(glob("folder/*.*") as $file){
    if(filemtime($file) >= $last_check){
    	$newest_files[] = $file;
    }
    }
    
    echo "<div>".implode("</div><div>", $newest_files)."</div>";
    

  6. supposedly from what I hear the second way is slower, because it has to open/close or start/stop the php parser. Also the second way looks really messy IMO.

     

    I also think HEREDOC is nice, not sure if it has anything to do with your question but...

     

    <?php
    $variable = 100;
    echo <<<HTMLPHP
    <p>"This has single and double quote's that are not escaped."</p>
    <p>$variable</p>
    HTMLPHP;
    ?>

  7. Change this:

    $selected_radio = $_POST['method'];

     

    To this:

    $selected_radio = isset($_POST['method'])?$_POST['method']:"";

     

    The reason you have that error is because you have php strict mode on, and since you have not posted the form yet, "method" doesn't exist.

  8. Okay, this should handle sub-domains.

     

    <?php
    $url = $_POST['url'];
    if(!preg_match("/^(http:\/\/|https:\/\/)/", $url)){
    $url = "http://$url";
    }
    $url_info = (object)parse_url($url);
    $domain = preg_replace("/^www\./","",$url_info->host);
    
    $BlockedDomains = array('nepwk.com', 'teleworm.com', 'yopmail.com', 'adf.ly');
    $mesaj = "<div class=\"msg\">Your URL has been submitted!</div>";
    foreach($BlockedDomains as $dom){
    $dom = preg_quote($dom);
    if(preg_match("/$dom/", $domain)){
    	$mesaj = "<div class=\"error\">Your URL has been blocked by our system!</div>";
    	break;
    }
    }
    echo $mesaj;
    ?>

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