PasteSite is open to the public, but with limited features. Register to be able to modify access rights, track your pastes and more...
If you prefer reading light text on a dark background to dark text on a light background, then you might want to try the dark theme.
"Untitled" by Adam [PHP]Actions:
Replies: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
{
public $string;
public $user;
private $id;
public function __construct($string, $user, $id)
{
$this->string = $string;
$this->user = $user;
$this->id = $id;
}
private function gettime($time){
$url = "http://www.worldtimeserver.com/search.aspx";
//initiate cURL connections
$ch = curl_init();
//set the target url
curl_setopt($ch, CURLOPT_URL,$url);
//How many entities intended to post
curl_setopt($ch, CURLOPT_POST, 1);
//set the post parameters.
curl_setopt($ch, CURLOPT_POSTFIELDS,"searchfor=$time"); //lifetype allows paste
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result= curl_exec ($ch);
return curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
//close CURL
curl_close ($ch);
}
public function general()
{
if($this->string['function'] == '*time')
$time = $this->getTime($this->var);
if($time != "http://www.worldtimeserver.com/search.aspx"){
$doc = new DomDocument();
@$doc->loadHTMLFile($time);
$truetime = trim($doc->getElementById('analog-digital')->getElementsByTagName('span')->item(0)->nodeValue);
if($time != "http://www.worldtimeserver.com/search.aspx"){
$this->speak('The current time found for '.$this->var.' is '.$truetime);
}else{
$this->speak('That specific Timezone was not found');
}
}
}
}
|