Membership is FREE, giving all registered users unlimited access to every Acorn Domains feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

Code Snippet PHP Calculate Drop Date.

Status
Not open for further replies.
Joined
Nov 12, 2005
Posts
278
Reaction score
5
Been refactoring a lot of our code this week and will be sharing snippets if anyone is interested. Let Me Know and I will post more.

PHP:
function getDropDate ($date)
{
    $newdate = strtotime('+92 day', strtotime($date));
    $newdate = date('Y-m-d', $newdate);
    return $newdate;
}
Usage:
PHP:
$date = '2011-08-21';
$dropdate = getDropDate($date);
echo $dropdate;
Nice and Simple I think..
 
Cheers

Can you please combine it with domainmonster.com's A+to E ratings based on previous drops :) - that would be awesome in php.

Just out of interest, how did you do it before refactoring - seems like the logical way to calculate drops?
 
Last edited:
We dont like to use others work (domainmonster) I am sure they have invested enough time and effort over the years to warrant them keeping all that to themselves.

Before we never had this as a function, which seems obvious now, but sometimes when coding you mean to change it but if it works, dont fix sort of thing.. but we have 30k lines of code in our domain analysis system and its time to refactor and put into classes and functions where we can.
 
In php5.2+

Code:
function getDropDate ($date) {
    $dt = new DateTime($date);
    $dt->modify('+92 days');
    return $dt->format('Y-m-d');
}
date passed as standards complient format e.g Y-m-d
 
I was more thinking.. for people to add into their own scripts.

Perhaps a Code Section would be an interesting addition where people can share other such snippets.
 
Would be good if had a Web Developer Section.. for coding requests and snippets..

Here is another:

PHP:
function getalexarank ($domain)
{
    $data_url = "http://data.alexa.com/data?cli=10&dat=s&url=$domain";
    $data = simplexml_load_file($data_url) or die("Could not load data");
    $rank = $data->SD->POPULARITY['TEXT'];
    if ($rank > 0) {
        $alexa = $rank;
    } else {
        $alexa = "none";
    }
    return $alexa;
}
 
Get a real IP address from those Spammers hiding behind proxies.

PHP:
    function get_ip() {
        if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
            $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
        } elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
            $ip = $_SERVER['HTTP_CLIENT_IP'];
        } else {
            $ip = $_SERVER['REMOTE_ADDR'];
        }

        return $ip;
    }
 
Really Useful for Getting Meta Keywords from a single keyword or phrase

PHP:
function getmetakeywords($keyword) {
    $q = urlencode($keyword);
    $url = "http://suggestqueries.google.com/complete/search?qu=" . $q;
    $text = file_get_contents($url); //Get content from Google suggest
    $keywords = array();
    $text = str_ireplace("window.google.ac.h([", "", $text); //Remove unwanted portion
    $arr_items = explode("],[", $text); //Split and put it in arrary

    foreach ($arr_items as $items) {
        $arr_item = explode(",", $items);
        $key = $arr_item[0]; //Get the keyword, the arrary will have other details such as no.of resutls also.
        $key = trim($key, "\""); //Use to remove quotes
        array_push($keywords, $key);
    }
    $keywords = implode(",", $keywords); //Convert Array into Comma Seperated values
    return $keywords;
}
 
Status
Not open for further replies.

The Rule #1

Do not insult any other member. Be polite and do business. Thank you!

Members online

Premium Members

Latest Comments

New Threads

Domain Forum Friends

Our Mods' Businesses

*the exceptional businesses of our esteemed moderators
General chit-chat
Help Users
  • No one is chatting at the moment.
      There are no messages in the current room.
      Top Bottom