Exemplo n.º 1
0
 function getAll($year)
 {
     $r = array();
     /**
     * Boucle version procédurale
     *
             $date = strtotime($year.'-01-01');
             while(date('Y',$date) <= $year){
        // Ce que je veux => $r[ANEEE][MOIS][JOUR] = JOUR DE LA SEMAINE
        $y = date('Y',$date);
        $m = date('n',$date);
        $d = date('j',$date);
        $w = str_replace('0','7',date('w',$date));
        $r[$y][$m][$d] = $w;
        $date = strtotime(date('Y-m-d',$date).' +1 DAY');
             }
             *
     *
     */
     // $month = date('n');
     // $day = date('j');
     $date = new DateTime($year . '-01-01');
     //$date = new DateTime($year.'-'.$month.'-01');
     while ($date->format('Y') <= $year) {
         // Ce que je veux => $r[ANEEE][MOIS][JOUR] = JOUR DE LA SEMAINE
         $y = $date->format('Y');
         $m = $date->format('n');
         $d = $date->format('j');
         $w = str_replace('0', '7', $date->format('w'));
         $r[$y][$m][$d] = $w;
         $date->add(new DateInterval('P1D'));
     }
     _DEBUG(0, P, $r);
     return $r;
 }
Exemplo n.º 2
0
 public function query($sQuery, $sClass = null)
 {
     _DEBUG('[mysql] Query (' . $sClass . ') : ' . $sQuery);
     $oRes = mysql_query($sQuery);
     if ($oRes === false) {
         throw new Exception('Failed ' . mysql_error());
     }
     return new MySQLDBResult($oRes, $sClass);
 }
Exemplo n.º 3
0
 public function query($sQuery, $sClass = null)
 {
     _DEBUG('[sqlite] Query ' . $sQuery);
     $oRes = sqlite_query($this->db, $sQuery, SQLITE_ASSOC, $sError);
     if ($oRes === false) {
         _ERROR('[sqlite] failed ' . $sError);
         throw new Exception($sError);
     }
     return new SQLiteDBResult($oRes, $sClass);
 }
Exemplo n.º 4
0
 public static function url($sURL, $iDepth = 0, $bFollow = false)
 {
     if (self::$bDebug) {
         _DEBUG('-> ' . $sURL . ' (attempt #' . $iDepth . ')');
     }
     $oCurl = curl_init();
     curl_setopt($oCurl, CURLOPT_URL, $sURL);
     curl_setopt($oCurl, CURLOPT_HTTPHEADER, array('Connection: close'));
     curl_setopt($oCurl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/419 (KHTML, like Gecko) Safari/419.3');
     curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($oCurl, CURLOPT_HEADER, 1);
     curl_setopt($oCurl, CURLOPT_VERBOSE, 0);
     if ($bFollow) {
         curl_setopt($oCurl, CURLOPT_FOLLOWLOCATION, 1);
     }
     curl_setopt($oCurl, CURLOPT_TIMEOUT, 10);
     $sResult = curl_exec($oCurl);
     if (!$sResult) {
         if (self::$bDebug) {
             _DEBUG('Timed out');
         }
         return null;
     }
     $iCode = curl_getinfo($oCurl, CURLINFO_HTTP_CODE);
     $aHeaders = array();
     $iHeaderSize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE);
     $sHeaders = substr($sResult, 0, $iHeaderSize - 4);
     $aHeaders = explode("\r\n", $sHeaders);
     $sResult = substr($sResult, $iHeaderSize);
     curl_close($oCurl);
     if (self::$bDebug) {
         _DEBUG('<- ' . $iCode);
     }
     if ($iCode == 302 || $iCode == 301) {
         foreach ($aHeaders as $sLine) {
             $aParts = explode(':', $sLine);
             if (strtolower($aParts[0]) == 'location') {
                 $sNew = trim(substr($sLine, strpos($sLine, ':') + 1));
                 if ($iDepth < 5) {
                     return Untiny::url($sNew, $iDepth + 1);
                 } else {
                     return array('url' => $sNew);
                 }
             }
         }
     } else {
         foreach ($aHeaders as $sLine) {
             $aParts = explode(':', $sLine);
             if (strtolower($aParts[0]) == 'content-type') {
                 if (stripos($sLine, 'text/html') !== false) {
                     // Find title in HTML
                     if (stripos($sResult, '</title>') !== false) {
                         $sPref = substr($sResult, 0, stripos($sResult, '</title>'));
                         $sTitle = trim(substr($sPref, strripos($sResult, '<title>') + 7));
                     }
                     if (stripos($sResult, '<meta name="description" content="') !== false) {
                         $sPref = substr($sResult, stripos($sResult, '<meta name="description" content="') + 34);
                         if (strpos($sPref, 'digg_url') !== false) {
                             $sPref = substr($sPref, strpos($sPref, ';') + 1);
                         }
                         if (strpos($sPref, 'digg_skin') !== false) {
                             $sPref = substr($sPref, strpos($sPref, ';') + 1);
                         }
                         $sPref = trim($sPref);
                         $sDescription = substr($sPref, 0, strpos($sPref, '"'));
                     }
                 }
                 $sMime = trim(substr($sLine, strpos($sLine, ':') + 1));
                 break;
             }
         }
         $hResult = array();
         $hResult['url'] = $sURL;
         if (!empty($sTitle)) {
             $hResult['title'] = $sTitle;
         }
         if (!empty($sDescription)) {
             $hResult['description'] = $sDescription;
         }
         if (!empty($sMime)) {
             $hResult['mime'] = $sMime;
         }
         return $hResult;
     }
 }
Exemplo n.º 5
0
                          $_SESSION["user"]['nick'] = $result[DB_TABLE_MEMBERS.'_nick'];
                          $_SESSION["user"]['nick'] = $result[DB_TABLE_MEMBERS.'_nick'];*/
                        // Si le mot de passe n'est pas valide
                    } else {
                        $err = "Connexion impossible !";
                    }
                }
            } else {
                $err = "Veuillez remplir tous les champs !";
            }
        }
    }
    //if (isset($_POST["registerbutton"])) { // PAS GOOD
    //}
} catch (PDOException $ex) {
    _DEBUG($DEBUG, E, $ex, ERR);
    // ====================================== DEBUG
}
// Si l'utilisateur est connecté alors on lui affiche ses infos de connexion
if (isset($_SESSION["user"]['nick'])) {
    echo '<div>' . (isset($_SESSION["user"]['nick']) ? 'Bonjour ' . $_SESSION["user"]['nick'] . ' !' : '') . '</div>';
    echo '<div><h1>AVATAR</h1></div>';
    echo '<div>' . $_SESSION["user"]['nick'] . '</div>';
    echo '<div>Vous avez x amis connecté</div>';
    echo '<div><a href="pages/logout.php"><button type="button">Me déconnecter</button></a></div>';
    echo '<div><a href="pages/profil.php"><button type="button">Mon profil</button></a></div>';
    echo '<div><a href="pages/privcal.php"><button type="button">Mon agenda</button></a></div>';
    // sinon, on lui propose de se loguer
} else {
    echo '<form method="post">';
    echo '<div><input type="text" name="loginname" placeholder="Pseudo"></div>';
Exemplo n.º 6
0
 public function run()
 {
     global $aAppConfig;
     $iStartTime = microtime(true);
     if (file_exists('app/lib/Helpers.php')) {
         include_once 'app/lib/Helpers.php';
     }
     // Retrieve the URL, remove the leading /
     if (isset($_SERVER['GATEWAY_INTERFACE']) && isset($_GET['path'])) {
         // FCGI MODE
         $sURL = isset($_GET['path']) ? $_GET['path'] : '/';
         $sURL = $sURL[0] == '/' ? substr($sURL, 1) : $sURL;
     } else {
         // MOD_PHP MODE
         $sURL = $_SERVER['REDIRECT_URL'];
         $sURL = substr($sURL, 1);
         if ($sURL == 'dispatch.php') {
             $sURL = $_SERVER['REQUEST_URI'];
             $sURL = substr($sURL, 1);
             // Remove query string
             if (strstr($sURL, '?')) {
                 $sURL = substr($sURL, 0, strpos($sURL, '?'));
             }
             if (strstr($sURL, '&')) {
                 $sURL = substr($sURL, 0, strpos($sURL, '&'));
             }
         }
     }
     // Clean up the URL from the path where the application actually is
     $sRoot = $_SERVER['DOCUMENT_ROOT'];
     $sScript = $_SERVER['SCRIPT_FILENAME'];
     $sIgnore = substr(str_replace($sRoot, '', $sScript), 1);
     $sIgnore = dirname($sIgnore) . '/';
     $sURL = str_replace($sIgnore, '', $sURL);
     // Ignore the extension
     if (strpos($sURL, '.')) {
         $sExt = substr($sURL, strrpos($sURL, '.') + 1);
         $sURL = substr($sURL, 0, strrpos($sURL, '.'));
     }
     $sExt = isset($sExt) ? $sExt : 'html';
     $sExt = strtolower($sExt);
     // Explode the URL to figure out the controller and method being called
     $aURLComponents = explode('/', $sURL);
     // Underscores and dashes are replaced by spaces, then camel case
     $sController = $aURLComponents[0] ? $aURLComponents[0] : 'Default';
     $sController = str_replace(array('_', '-'), ' ', $sController);
     $sController = ucwords($sController);
     $sController = str_replace(' ', '', $sController);
     // Underscores and dashes are replaced by spaces, periods are ignored
     // numbers will be preceded with n
     $sMethod = isset($aURLComponents[1]) ? $aURLComponents[1] : 'index';
     $sMethod = str_replace(array('_', '-'), ' ', $sMethod);
     $sMethod = ucwords($sMethod);
     $sMethod = str_replace(' ', '', $sMethod);
     $sMethod = str_replace('.', '', $sMethod);
     $sMethod = strtolower(substr($sMethod, 0, 1)) . substr($sMethod, 1);
     $sMethod = is_numeric($sMethod) ? 'n' . $sMethod : $sMethod;
     // Determine controller class and path
     $sControllerClass = $sController . 'Controller';
     $sControllerPath = 'app/controllers/' . $sControllerClass . '.php';
     if (!file_exists($sControllerPath)) {
         // Analyze routes
         // TODO improve routing
         if (isset($aAppConfig['MAPPING']) && is_array($aAppConfig['MAPPING'])) {
             foreach ($aAppConfig['MAPPING'] as $sPattern => $sController) {
                 if (preg_match($sPattern, $sURL)) {
                     $bFound = true;
                     break;
                 }
             }
         }
         $sController = ucwords($sController);
         $sMethod = 'index';
         $sControllerClass = $sController . 'Controller';
         $sControllerPath = 'app/controllers/' . $sControllerClass . '.php';
         if (!file_exists($sControllerPath)) {
             $this->notFound('controller ' . $sController . ' not found');
         }
     }
     $GLOBALS['controller'] = $sController;
     $GLOBALS['method'] = $sMethod;
     include_once $sControllerPath;
     if ($aAppConfig['TARGET'] == 'dev') {
         _DEBUG('---> ' . $sControllerClass . ' ' . $sMethod);
     }
     ob_start();
     $oController = new $sControllerClass();
     $__debug = ob_get_contents();
     ob_end_clean();
     if (!$oController->__early_exit) {
         if (!method_exists($oController, $sMethod)) {
             $this->notFound('method ' . $sMethod . ' not found');
         }
         $oController->set('controller', $sController);
         $oController->set('method', $sMethod);
         $oController->set('extension', $sExt);
         if (method_exists($oController, 'preExec')) {
             $oController->preExec();
         }
         $aArgs = array_slice($aURLComponents, 2);
         $oController->{$sMethod}($args);
     }
     if (method_exists($oController, 'postExec')) {
         $oController->postExec();
     }
     // TEMPLATE
     $sTemplate = $oController->getTemplate();
     $sTemplate = $sTemplate ? $sTemplate : strtolower($sController) . '.php';
     $sTemplatePath = 'app/templates/' . $sTemplate;
     if (!file_exists($sTemplatePath)) {
         $this->notFound('template ' . $sTemplate . ' not found');
     }
     $GLOBALS['_content_template'] = $sTemplate;
     $iEndTime = microtime(true);
     $iTotalTime = $iEndTime - $iStartTime;
     /*
     $oController->set('time_elapsed', $iTotalTime);
     $oController->set('__data', $oController->get()); 
     $oController->set('queries', DB::get_query_count());
     $oController->set('aQueries', DB::get_queries());
     $oController->set('__debug', $__debug);
     */
     // Rendering
     if (method_exists($oController, 'preRender')) {
         $oController->preRender();
     }
     ob_start();
     $oController->_render($sTemplatePath);
     $sContent = ob_get_contents();
     ob_end_clean();
     if (method_exists($oController, 'postRender')) {
         $sContent = $oController->postRender($sContent);
     }
     print $sContent;
 }
Exemplo n.º 7
0
<?php

session_start();
require_once 'connexionhdb.php';
$mail = '';
try {
    if (isset($_POST["submit"])) {
        //echo 'bouton de login appuyé';
        if (!empty($_POST["mail"])) {
            $mail = $_POST["mail"];
            $stmt = $h_db->query("SELECT * FROM " . DB_TABLE_MEMBERS . " WHERE " . DB_TABLE_MEMBERS . "_mail LIKE '" . $mail . "'");
            $result = $stmt->fetch();
            _DEBUG($DEBUG, P, $result);
            //=================================================================DEBUG
            echo "DEBUG SQL mail : " . $result[DB_TABLE_MEMBERS . '_mail'] . '<br />';
            if (!empty($result[DB_TABLE_MEMBERS . '_mail'])) {
                // $token = md5($result['mail'].$result['pseudo']); // -secure
                $token = utf8_encode(md5(uniqid(rand()), true));
                // +secure
                echo $token;
                mail($mail, 'Changez votre mot de passe', 'http://localhost/KLS_forum/_seb/Validation.php?token=' . $token);
                $_POST[""];
            }
        }
    }
} catch (PDOException $ex) {
    echo $ex->getMessage();
}
echo '<form method="post">';
echo '<div>Entrez votre e-mail : <input type="text" name="mail" placeholder="Votre e-mail" required></div>';
echo '<div><input type="submit" name="submit" value="Envoyer"></div>';
Exemplo n.º 8
0
/**
 * executes sql query in currently selected schema
 *
 * @param string $query sql query
 * @return int postgresql result
 */
function db_exec($query, $nodebug = false)
{
    global $ALINK, $SQL_EXEC, $SQL_EXEC_NUM;
    $rslt = pg_exec($ALINK, $query);
    $SQL_EXEC[++$SQL_EXEC_NUM] = $query;
    //print "$query<br>";
    if (DEBUG > 0) {
        global $DEBUG_OPT;
        if (isset($DEBUG_OPT["printsql"]) && $DEBUG_OPT["printsql"]) {
            print "{$query}<br />";
        }
    }
    if (!$nodebug && !$rslt) {
        _DEBUG($query, true);
    }
    return $rslt;
}
Exemplo n.º 9
0
        $stmt->execute(array('9', 'SuperAdmin'));
        // rouge bold
        //========= DB_TABLE_MEMBERS_EVENT =========
        $requete = "CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_TABLE_MEMBERS_EVENT . "` (\n\t\t\t\t`" . DB_TABLE_MEMBERS_EVENT . "_id` INT( 11 ) NOT NULL PRIMARY KEY ,\n\t\t\t\t`" . DB_TABLE_MEMBERS_EVENT . '_link_' . DB_TABLE_MEMBERS . "_id` INT( 11 ) NOT NULL ,\n\t\t\t\t`" . DB_TABLE_MEMBERS_EVENT . '_link_' . DB_TABLE_EVENT . "_id` INT( 11 ) NOT NULL ,\n\t\t\t\t`" . DB_TABLE_MEMBERS_EVENT . "_title` VARCHAR( 100 ) NOT NULL ,\n                `" . DB_TABLE_MEMBERS_EVENT . "_description` VARCHAR( 500 ) NOT NULL ,\n                `" . DB_TABLE_MEMBERS_EVENT . "_deb` DATETIME ,\n                `" . DB_TABLE_MEMBERS_EVENT . "_fin` DATETIME ,\n                `" . DB_TABLE_MEMBERS_EVENT . "_gps` VARCHAR( 50 )\n                ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;";
        $h_db->prepare($requete)->execute();
        //========= DB_TABLE_INSEE ========
        //https://www.data.gouv.fr/s/resources/base-officielle-des-codes-postaux/20151009-153255/base_officielle_codes_postaux_-_09102015.csv
        $requete = "CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_TABLE_INSEE . "` (\n                `" . DB_TABLE_INSEE . "_insee` INT( 5 ) NOT NULL PRIMARY KEY ,\n                `" . DB_TABLE_INSEE . "_city` VARCHAR( 40 ) NOT NULL ,\n\t\t\t\t`" . DB_TABLE_INSEE . "_zipcode` INT( 5 ) NOT NULL \n                ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;";
        $h_db->prepare($requete)->execute();
        //========= DB_TABLE_EVENT_CAT ========
        $requete = "CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_TABLE_EVENT_CAT . "` (\n                `" . DB_TABLE_EVENT_CAT . "_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t`" . DB_TABLE_EVENT_CAT . "_title` VARCHAR( 100 ) NOT NULL ,\n                `" . DB_TABLE_EVENT_CAT . "_description` VARCHAR( 500 ) NOT NULL ,\n                `" . DB_TABLE_EVENT_CAT . "_defcolor` VARCHAR( 7 ) NOT NULL ,\n                `" . DB_TABLE_EVENT_CAT . "_defimg` VARCHAR( 30 ) ,\n                `" . DB_TABLE_EVENT_CAT . "_ordre` INT( 2 ) \n                ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;";
        $h_db->prepare($requete)->execute();
        // Catégories d'évenements
        // On vérifie si les données ont déjà été inscrite
        $stmt = $h_db->query("SELECT * FROM " . DB_TABLE_EVENT_CAT);
        $result = $stmt->fetch();
        // if (!is_array($result)) {
        $stmt = $h_db->prepare("INSERT IGNORE INTO " . DB_TABLE_EVENT_CAT . "(" . DB_TABLE_EVENT_CAT . "_id, " . DB_TABLE_EVENT_CAT . "_title, " . DB_TABLE_EVENT_CAT . "_description, " . DB_TABLE_EVENT_CAT . "_defcolor, " . DB_TABLE_EVENT_CAT . "_defimg) VALUES (?, ?, ?, ?, ?)");
        $stmt->execute(array('4', 'Concert', 'Concerts blabla', 'RED', ''));
        $stmt->execute(array('1', 'Salon', 'Salons bla bla', 'GREEN', ''));
        $stmt->execute(array('2', 'Exposition', 'Expositions bla bla', 'BLUE', ''));
        $stmt->execute(array('3', 'Evenement Public', 'Evenement Public bla bla', 'YELLOW', ''));
        //  }
        //========= DB_TABLE_EVENT =========
        $requete = "CREATE TABLE IF NOT EXISTS `" . DB_NAME . "`.`" . DB_TABLE_EVENT . "` (\n\t\t\t\t`" . DB_TABLE_EVENT . "_id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,\n\t\t\t\t`" . DB_TABLE_EVENT . '_link_' . DB_TABLE_EVENT_CAT . "_id` INT( 11 ) NOT NULL ,\n\t\t\t\t`" . DB_TABLE_EVENT . "_title` VARCHAR( 100 ) NOT NULL ,\n                `" . DB_TABLE_EVENT . "_description` VARCHAR( 150 ) NOT NULL ,\n               `" . DB_TABLE_EVENT . "_datedeb` DATETIME ,\n               `" . DB_TABLE_EVENT . "_datefin` DATETIME ,\n               `" . DB_TABLE_EVENT . '_link_' . DB_TABLE_INSEE . "_zipcode` INT( 5 ) ,\n               `" . DB_TABLE_EVENT . "_coord_` VARCHAR( 20 ) ,\n               `" . DB_TABLE_EVENT . "_img` VARCHAR( 50 ) NOT NULL , \n               `" . DB_TABLE_EVENT . "_gps` VARCHAR( 50 ) NOT NULL \n                ) ENGINE = InnoDB CHARACTER SET utf8 COLLATE utf8_general_ci;";
        $h_db->prepare($requete)->execute();
    }
} catch (PDOException $ex) {
    _DEBUG($DEBUG, E, $ex, ERR_DB_CO);
}
//`FOREIGN KEY (".DB_TABLE_EVENT.'_link_'.DB_TABLE_EVENT_CAT."_id) REFERENCES ".DB_TABLE_EVENT."(".DB_TABLE_EVENT."_id)
Exemplo n.º 10
0
Arquivo: DB.php Projeto: poitch/dokin
 public function query($sQuery, $hParams = array(), $bDebug = false)
 {
     // ONLY TRY TO DO BINDING WHEN NEEDED
     if (is_array($hParams) && sizeof($hParams)) {
         $this->tmpValues = $hParams;
         $this->tmpBind = array();
         $sQuery = preg_replace_callback('/:([A-Za-z]+)/', array('self', 'bind'), $sQuery);
         $aKeys = array_keys($hParams);
         $aDiff = array_diff($this->tmpBind, $aKeys);
         $this->tmpBind = null;
         $this->tmpValues = null;
         if (sizeof($aDiff) > 0) {
             throw new Exception('bind failed ' . $sQuery . '<br>, no value for ' . print_r($aDiff, 1));
         }
     }
     if ($bDebug) {
         _DEBUG($sQuery);
     }
     $a = microtime(true);
     $oResult = mysql_query($sQuery, $this->db);
     $b = microtime(true);
     if (self::$bProfiling) {
         if (self::$bDeepProfiling) {
             $t = debug_backtrace();
             $n = sizeof($t) > 6 ? 6 : sizeof($t);
             $s = '';
             for ($i = 0; $i < $n; $i++) {
                 $s .= $t[$i]['class'] . '::' . $t[$i]['function'] . ':' . $t[$i]['line'] . '/';
             }
             DB::$aQueryStack[] = array('query' => $sQuery, 'time' => $b - $a, 'function' => $s);
         } else {
             DB::$aQueryStack[] = array('query' => $sQuery, 'time' => $b - $a);
         }
         DB::$aQueryStack['total'] += $b - $a;
     }
     if (!$oResult) {
         throw new Exception($sQuery . ' ***** ' . mysql_error());
     } else {
         return new DBResult($this->db, $oResult);
     }
 }
Exemplo n.º 11
0
 protected function doRequest($sURL, $hParams = array(), $bAuthenticate = false, $bPost = false)
 {
     $aParams = array();
     if ($hParams && is_array($hParams) && sizeof($hParams)) {
         foreach ($hParams as $sKey => $sValue) {
             $aParams[] = $sKey . '=' . urlencode($sValue);
         }
     }
     if (sizeof($aParams)) {
         $sParams = implode('&', $aParams);
     }
     if (!$bPost && strlen($sParams)) {
         $sURL .= '?' . $sParams;
     }
     _DEBUG('url = ' . $sURL);
     $oCurl = curl_init();
     curl_setopt($oCurl, CURLOPT_URL, $sURL);
     curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($oCurl, CURLOPT_HEADER, 1);
     if ($this->iTimeout > 0) {
         curl_setopt($oCurl, CURLOPT_TIMEOUT, $this->iTimeout);
     }
     if ($bPost) {
         curl_setopt($oCurl, CURLOPT_POST, 1);
         curl_setopt($oCurl, CURLOPT_POSTFIELDS, $sParams);
     }
     if ($bAuthenticate) {
         if (!$this->sLogin || !$this->sPassword) {
             throw new Exception('Authentication required');
         }
     }
     // Authenticate if required or if we have login/password
     if ($bAuthenticate || $this->sLogin && $this->sPassword) {
         curl_setopt($oCurl, CURLOPT_USERPWD, $this->sLogin . ':' . $this->sPassword);
     }
     $sResult = curl_exec($oCurl);
     if (!$sResult) {
         return null;
     }
     $iCode = curl_getinfo($oCurl, CURLINFO_HTTP_CODE);
     $iHeaderSize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE);
     curl_close($oCurl);
     $aHeaders = array();
     $sHeaders = substr($sResult, 0, $iHeaderSize - 4);
     $aLines = explode("\r\n", $sHeaders);
     foreach ($aLines as $sLine) {
         if (strpos($sLine, ':') !== false) {
             $sKey = substr($sLine, 0, strpos($sLine, ':'));
             $sValue = trim(substr($sLine, strpos($sLine, ':') + 1));
             $aHeaders[$sKey] = $sValue;
             if (strtolower($sKey) == 'x-ratelimit-limit') {
                 $this->iRateLimit = $sValue;
             } else {
                 if (strtolower($sKey) == 'x-ratelimit-remaining') {
                     $this->iRateRemaining = $sValue;
                 } else {
                     if (strtolower($sKey) == 'x-ratelimit-reset') {
                         $this->iRateReset = $sValue;
                     }
                 }
             }
         }
     }
     $sResult = substr($sResult, $iHeaderSize);
     return array('code' => $iCode, 'body' => $sResult, 'headers' => $aHeaders);
 }