Paramètres de l'agenda -> Adresse URL privée, et copiez l'adresse XML. Sinon, laissez vide pour que ce message soit dans l'agenda principal par défaut: $feedxmlprive = ""; /* Class: MyCurl Author: Skakunov Alex (i1t2b3@gmail.com) Date: 26.11.06 Description: provides a simple tool to GET/POST data with help of CURL library http://a4.users.phpclasses.org/browse/package/3547.html */ class MyCurl { public $getHeaders = true;//headers will be added to output public $getContent = true; //contens will be added to output public $followRedirects = true; //should the class go to another URL, if the current is "HTTP/1.1 302 Moved Temporarily" private $fCookieFile; private $fSocket; function MyCurl() { $this->fCookieFile = tempnam("/tmp", "g_"); } function init() { return $this->fSocket = curl_init(); } function setopt($opt, $value) { return curl_setopt($this->fSocket, $opt, $value); } function load_defaults() { $this->setopt(CURLOPT_RETURNTRANSFER, 1); $this->setopt(CURLOPT_FOLLOWLOCATION, $this->followRedirects); $this->setopt(CURLOPT_REFERER, "http://google.com"); $this->setopt(CURLOPT_VERBOSE, false); $this->setopt(CURLOPT_SSL_VERIFYPEER, false); $this->setopt(CURLOPT_SSL_VERIFYHOST, false); $this->setopt(CURLOPT_HEADER, $this->getHeaders); $this->setopt(CURLOPT_NOBODY, !$this->getContent); $this->setopt(CURLOPT_COOKIEJAR, $this->fCookieFile); $this->setopt(CURLOPT_COOKIEFILE, $this->fCookieFile); $this->setopt(CURLOPT_USERAGENT, "MyCurl"); $this->setopt(CURLOPT_POST, 1); $this->setopt(CURLOPT_CUSTOMREQUEST,'POST'); $fp = fopen("curl.log", "a"); if($fp) $this->setopt(CURLOPT_STDERR, $fp); } function destroy() { return curl_close($this->fSocket); } function head($url) { $this->init(); if($this->fSocket) { $this->getHeaders = true; $this->getContent = false; $this->load_defaults(); $this->setopt(CURLOPT_POST, 0); $this->setopt(CURLOPT_CUSTOMREQUEST,'HEAD'); $this->setopt(CURLOPT_URL, $url); $result = curl_exec($this->fSocket); $this->destroy(); return $result; } return 0; } function get($url) { $this->init(); if($this->fSocket) { $this->load_defaults(); $this->setopt(CURLOPT_POST, 0); $this->setopt(CURLOPT_CUSTOMREQUEST,'GET'); $this->setopt(CURLOPT_URL, $url); $result = curl_exec($this->fSocket); $this->destroy(); return $result; } return 0; } function post($url, $post_data, $arr_headers=array(), &$http_code) { $this->init(); if($this->fSocket) { $post_data = $this->compile_post_data($post_data); $this->load_defaults(); if(!empty($post_data)) $this->setopt(CURLOPT_POSTFIELDS, $post_data); if(!empty($arr_headers)) $this->setopt(CURLOPT_HTTPHEADER, $arr_headers); $this->setopt(CURLOPT_URL, $url); $result = curl_exec($this->fSocket); $http_code = curl_getinfo($this->fSocket, CURLINFO_HTTP_CODE); $this->destroy(); return $result; } return 0; } function compile_post_data($post_data) { $o=""; if(!empty($post_data)) foreach ($post_data as $k=>$v) $o.= $k."=".urlencode($v)."&"; return substr($o,0,-1); } function get_parsed($result, $bef, $aft="") { $line=1; $len = strlen($bef); $pos_bef = strpos($result, $bef); if($pos_bef===false) return ""; $pos_bef+=$len; if(empty($aft)) { //try to search up to the end of line $pos_aft = strpos($result, "\n", $pos_bef); if($pos_aft===false) $pos_aft = strpos($result, "\r\n", $pos_bef); } else $pos_aft = strpos($result, $aft, $pos_bef); if($pos_aft!==false) $rez = substr($result, $pos_bef, $pos_aft-$pos_bef); else $rez = substr($result, $pos_bef); return $rez; } } /* Class: GoogleCalendarWrapper Author: Skakunov Alex (i1t2b3@gmail.com) Date: 26.11.06 Description: provides a simple tool to work with Google Calendar (add events currenly) You must define login and password. Class adds events into your main calendar by default. If you want to add events in other calendar, write its XML URL into "feed_url" property like this: $gc = new GoogleCalendarWrapper("email@gmail.com", "password"); $gc->feed_url = "http://www.google.com/calendar/feeds/pcafiuntiuro1rs%40group.calendar.google.com/private-586fa023b6a7151779f99b/basic"; Feel free to provide "basic" URL, it will be automatically converted to "full" one (prepare_feed_url() method).. How to get the XML URL: http://code.google.com/apis/gdata/calendar.html#get_feed */ class GoogleCalendarWrapper extends MyCurl { public $email; public $password; public $feed_url = "http://www.google.com/calendar/feeds/default/private/full"; private $fAuth; private $isLogged = false; private $feed_url_prepared; function GoogleCalendarWrapper($email, $password) { $this->email = $email; $this->password = $password; $this->feed_url_prepared = $this->feed_url; parent::MyCurl(); } //login with Google's technology of "ClientLogin" //check here: http://code.google.com/apis/accounts/AuthForInstalledApps.html function login() { $post_data = array(); $post_data['Email'] = $this->email; $post_data['Passwd'] = $this->password; $post_data['source'] = "exampleCo-exampleApp-1"; $post_data['service'] = "cl"; $post_data['accountType'] = "GOOGLE"; $this->getHeaders = true; $this->getContent = true; $response = $this->post("https://www.google.com/accounts/ClientLogin", $post_data, null, $http_code); if(200==$http_code) { $this->fAuth = parent::get_parsed($response, "Auth="); $this->isLogged = true; return 1; } $this->isLogged = false; return 0; } //to make the feed URL writable, it should be ended with "private/full" //check this: http://code.google.com/apis/gdata/calendar.html#get_feed function prepare_feed_url() { $url = parse_url($this->feed_url); $path = explode("/", $url["path"]); $size = sizeof($path); if($size>4) { $path[$size-1] = "full"; $path[$size-2] = "private"; $path = implode("/", $path); } $this->feed_url_prepared = $url["scheme"]."://".$url["host"].$path; } //adds new event into calendar //filled $settings array should be provided function add_event($settings) { if(!$this->isLogged) $this->login(); if($this->isLogged) { $_entry = " ".$settings["title"]." ".$settings["content"]." ".$this->email." ".$this->email." "; $this->prepare_feed_url(); $header = array(); $header[] = "Host: www.google.com"; $header[] = "MIME-Version: 1.0"; $header[] = "Accept: text/xml"; $header[] = "Authorization: GoogleLogin auth=".$this->fAuth; $header[] = "Content-length: ".strlen($_entry); $header[] = "Content-type: application/atom+xml"; $header[] = "Cache-Control: no-cache"; $header[] = "Connection: close \r\n"; $header[] = $_entry; $this->post($this->feed_url_prepared, null, $header, $http_code); if(201==$http_code) return true; } else echo "cannot login with '".$this->email."' email and '".$this->password."' password
"; return false; } } /* interface web et envoi du message */ $gc = new GoogleCalendarWrapper("$emailgoogle", "$passgoogle"); // mettre adresse e-mail et mot de passe Google Calendar Agenda if ($feedxmlprive){ $gc->feed_url = "$feedxmlprive"; } ?> Envoi d'un SMS
Votre nom :

Votre message :

Il vous reste 113 caractères

$val) { $val = trim(stripslashes(htmlentities($val))); $_REQUEST[$key] = $val; } $titre = 0; $titre = preg_replace("/[^a-zA-Z0-9éÉèÈçÇàÀùÙâÂêÊîÎôÔûÛäÄëËïÏöÖüÜÿŸœŒæÆ@€\,\.\!\? \'\’\(\)\/\-\:\+]/i",'', $_POST["gijhuyw"]); $titre = preg_replace("/[\']/i",'’', $titre); $message = 0; $message = preg_replace("/[^a-zA-Z0-9éÉèÈçÇàÀùÙâÂêÊîÎôÔûÛäÄëËïÏöÖüÜÿŸœŒæÆ@€\,\.\!\? \'\’\(\)\/\-\:\+]/i",'', $_POST["trkxxw"]); $message = preg_replace("/[\']/i",'’', $message); /* Dans la partie Description de l'événement inscrit dans l'agenda, on enregistre les date et heure ainsi que l'adresse IP. Ces données ne sont pas visibles dans le SMS. */ /* fonction recuperation IP */ 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; } /* enregistrement ip et de son host */ $ip = get_ip(); $nomhote = gethostbyaddr($ip); /* date et heure réelles */ @setlocale(LC_TIME, 'fr_FR.utf-8'); $jour = strftime("%A %d %B %Y"); $heure = date("H:i"); $contenu = 0; $contenu = "Demande faite le $jour, $heure. \n"; $contenu .= "Adresse internet: $nomhote - $ip \n"; /* on fixe la date et l'heure à include dans l'agenda Google */ $localtime_assoc = localtime(time(), true); if ($localtime_assoc[tm_isdst] = 1) { // si heure d'été; Je retire une heure. Si on a 10h, google mets 11h // On capture le temps actuel $heure = time() - 6870; // -2 heures + 5 minutes + 30 secondes $now = date('H:i:s', $heure); // On lui ajoute 15 sec $heure15sec = time() - 6435; // -2 heures + 15 minutes + 15 secondes $now15sec = date('H:i:s', $heure15sec); } else { // On capture le temps actuel $heure = time() - 3270; // -1 heures + 5 minutes + 30 secondes $now = date('H:i:s', $heure); // On lui ajoute 15 sec $heure15sec = time() - 2835; // -1 heures + 15 minutes + 15 secondes $now15sec = date('H:i:s', $heure15sec); } $s = array(); $s["title"] = $titre; $s["content"] = $contenu; $s["where"] = $message; $s["startDay"] = date('Y-m-d', $heure); $s["startTime"] = $now; $s["endDay"] = date('Y-m-d', $heure15sec); $s["endTime"] = $now15sec; if ($message){ if($gc->add_event($s)) { echo "Envoi SMS [ OK ]
Heure: ".$now." (".$s['startDay'].")
Nom: ".$titre."
Message: ".$message."
".$contenu."\n"; } else{ echo "Erreur Envoi Message ".$s['startTime']." ".$s['startDay']." \n"; } } ?>