示例#1
1
文件: demo.php 项目: aikeay/sandbox
function d($arg)
{
    $declared = 'variable';
    ChromePhp::log('xdebug_get_declared_vars', xdebug_get_declared_vars());
    ChromePhp::groupCollapsed('backtrace');
    ChromePhp::log(debug_backtrace());
    ChromePhp::groupEnd();
    ChromePhp::info('Triggered notice.');
    trigger_error('Custom notice', E_USER_NOTICE);
    ChromePhp::warn('Triggered warning.');
    trigger_error('Custom warning', E_USER_WARNING);
    ChromePhp::error('Triggered error.');
    trigger_error('Custom error', E_USER_ERROR);
}
 /**
  * Write the data
  *
  * @param array $event Event Data
  */
 public function _write($event)
 {
     $event = Mage::helper('firegento_logger')->getEventObjectFromArray($event);
     $priority = $event->getPriority();
     $message = $this->_formatter->format($event);
     if ($priority !== false) {
         switch ($priority) {
             case Zend_Log::EMERG:
             case Zend_Log::ALERT:
             case Zend_Log::CRIT:
             case Zend_Log::ERR:
                 ChromePhp::error($message);
                 break;
             case Zend_Log::WARN:
                 ChromePhp::warn($message);
                 break;
             case Zend_Log::NOTICE:
             case Zend_Log::INFO:
             case Zend_Log::DEBUG:
                 ChromePhp::info($message);
                 break;
             default:
                 Mage::log('Unknown loglevel at ' . __CLASS__);
                 break;
         }
     } else {
         Mage::log('Attached message event has no priority - skipping !');
     }
 }
示例#3
0
 function deleteRoom($name)
 {
     $idusuario = $this->usuario->getUsuarioId();
     $sql = "DELETE FROM `habitaciones` WHERE descripcion=\"" . $name . " \"and id_usuario=" . $idusuario;
     ChromePhp::log($sql);
     $consulta = $this->db->prepare($sql);
     $consulta->execute();
 }
 public function followers(Request $request, User $user)
 {
     if (!($followers = $user->followers) or $followers->isEmpty()) {
         throw new HttpException('404', $user->name . " does not have any followers yet.");
     }
     \ChromePhp::log($followers);
     $this->authorize("viewFollowedUsers", $user);
     return $followers;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, Setting $setting)
 {
     $this->validate($request, ['who_can_see_my_skills' => 'required|in:' . join(",", Setting::$options), 'who_can_see_who_i_am_following' => 'required|in:' . join(",", Setting::$options)]);
     \ChromePhp::log($setting->getTable());
     $this->authorize('owns', $setting);
     $setting->who_can_see_my_skills = $request->who_can_see_my_skills;
     $setting->who_can_see_who_i_am_following = $request->who_can_see_who_i_am_following;
     $setting->save();
     return "Settings updated.";
 }
 public function canFollow(User $user, Connection $connection)
 {
     if ($user->id == $connection->follows) {
         throw new HttpException('403', "You can not follow yourself");
     }
     $alreadyFollowing = Connection::where("follower", $user->id)->where("follows", $connection->follows)->first();
     \ChromePhp::log($alreadyFollowing);
     if ($alreadyFollowing) {
         throw new HttpException('403', "You are already following this user.");
     }
     return true;
 }
示例#7
0
 /**
  * Renvoie un type machine
  * 
  * @param type $id
  * @return type
  * @throws Exception
  */
 public function getTypemachine($id)
 {
     $sql = "select ID_type_machine as id, code_type_machine as nom, libelle_type_machine\n                from type_machines where ID_type_machine=?";
     $typemachine = $this->executerRequete($sql, array($id));
     ChromePhp::log('$id : ', $id);
     if ($typemachine->rowCount() == 1) {
         return $typemachine->fetch();
         // Accès à la première ligne de résultat
     } else {
         throw new Exception("Aucun type machine ne correspond à l'identifiant '{$id}'");
     }
 }
示例#8
0
 function connect()
 {
     try {
         //$connection = new PDO( "sqlsrv:Server=". self::SERVER . " ; Database =". self::DATABASE , self::USER, self::PASSWORD);
         $connection = new PDO("mysql:host=localhost;dbname=harvpren_magicCards;charset=utf8", self::USER, self::PASSWORD);
         $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         return $connection;
     } catch (Exception $e) {
         ChromePhp::log($e);
         return $e->getMessage();
     }
 }
示例#9
0
 /**
  * Renvoie un fournisseur
  * 
  * @param type $id
  * @return type
  * @throws Exception
  */
 public function getMarque($id)
 {
     $sql = "select ID_marque as id, libelle_court_marque as nom, libelle_long_marque, ad_1, ad_2, ad_num, ad_rue, ad_cp, ad_ville,\n        \t\t ad_pays, ad_website, contact1, contact2, phone1, phone2, ad_mail1, ad_mail2\n                from marques where ID_marque=?";
     $marque = $this->executerRequete($sql, array($id));
     ChromePhp::log('$id : ', $id);
     if ($marque->rowCount() == 1) {
         return $marque->fetch();
         // Accès à la première ligne de résultat
     } else {
         throw new Exception("Aucune marque ne correspond à l'identifiant '{$id}'");
     }
 }
示例#10
0
 public static function init()
 {
     // \Template::instance()->extend('img',function($node){
     //     var_dump($node);
     //      array(1) {
     //       ["@attrib"]=>
     //       array(1) {
     //         ["src"]=>
     //         string(25) "{{'ui/images/'.@article.image}}"
     //       }
     //     }
     // });
     \ChromePhp::log('INIT');
 }
示例#11
0
文件: Menu.php 项目: Dacendi/timelab
 /**
  * Renvoie les infos sur un menu
  * 
  * @param type $id
  * @return type
  * @throws Exception
  */
 public function getMenu($id)
 {
     //  $sql = "select ID_menu as id, libelle_menu from menus where ID_menu=?";
     $sql = "select code_menu, libelle_menu from menus where code_menu=?";
     $menu = $this->executerRequete($sql, array($id));
     //  $menu = $this->executerRequete($sql, array($codeMenu));
     ChromePhp::log('$menu : ', $menu);
     ChromePhp::log('$id : ', $id);
     if ($menu->rowCount() == 1) {
         return $menu->fetch();
         // Accés à la première ligne de résultat
     } else {
         throw new Exception("La page '{$id}' est introuvable !");
     }
 }
示例#12
0
 private function __construct()
 {
     // Handles debugging. If TRUE, displays all errors and enables FirePHP logging
     if (ACTIVATE_DEBUG_MODE === TRUE) {
         ini_set("display_errors", 1);
         ERROR_REPORTING(E_ALL);
         FB::setEnabled(TRUE);
         FB::warn("FirePHP logging is enabled! Sensitive data may be exposed.");
         ChromePhp::warn("ChromePHP logging is enabled! Sensitive data may be exposed.");
     } else {
         ini_set("display_errors", 0);
         error_reporting(0);
         FB::setEnabled(FALSE);
     }
 }
示例#13
0
 public function mergeClientes($clientes)
 {
     global $cnx;
     $idClientesAdd = array();
     $idClientes = array();
     $ind = 0;
     foreach ($clientes as $cliente) {
         $idCliente = $cliente[0];
         $cveCliente = $cliente[1];
         $nomCliente = utf8_decode($cliente[2]);
         $apCliente = utf8_decode($cliente[3]);
         $amCliente = utf8_decode($cliente[4]);
         $direccion = utf8_decode($cliente[5]);
         $fechaNacimiento = $cliente[6];
         $telefono = $cliente[7];
         $correo = $cliente[8];
         $idTipCliente = $cliente[9];
         $ind = $cliente[13];
         if ($idCliente == "") {
             // NUEVO REGRISTRO
             $query = "INSERT INTO cliente(cveCliente,nombreCliente,apCliente,amCliente,direccionCliente,telefonoCliente,mailCliente,fechaNCliente,idTipoCliente) VALUES('{$cveCliente}','{$nomCliente}','{$apCliente}','{$amCliente}','{$direccion}',{$telefono},'{$correo}','{$fechaNacimiento}',{$idTipCliente})";
             //                ChromePhp::log($query);
             try {
                 $rs = $cnx->Execute($query);
                 array_push($idClientes, array($cnx->Insert_ID(), $ind));
                 $idClientesAdd['mesaje'] = "ok";
             } catch (Exception $exc) {
                 $idClientesAdd['mesaje'] = $exc->getTraceAsString();
                 return $idClientesAdd;
             }
         } else {
             //ACTUALIZACION DE PRODUCTO
             $query = "UPDATE cliente set cveCliente ='{$cveCliente}', nombreCliente = '{$nomCliente}', apCliente='{$apCliente}',amCliente = '{$amCliente}',direccionCliente='{$direccion}',telefonoCliente={$telefono},mailCliente='{$correo}',fechaNCliente='{$fechaNacimiento}' ,idTipoCliente={$idTipCliente} WHERE idCliente = {$idCliente}";
             ChromePhp::log($query);
             try {
                 $rs = $cnx->Execute($query);
                 $idClientesAdd['mesaje'] = "ok";
             } catch (Exception $exc) {
                 $idClientesAdd['mesaje'] = $exc->getTraceAsString();
                 return $idClientesAdd;
             }
         }
     }
     $idClientesAdd['nuevosIds'] = $idClientes;
     //        print_r($idProductosAdd);
     //
     return $idClientesAdd;
 }
示例#14
0
 public function ejecutar($valor)
 {
     /*$data = array("value" => $valor);                                                                    
     		$data_string = json_encode($data);                                                                                   
                                                                                                                          
     		$ch = curl_init($this->propiedades['apideejecucion']);                                                                      
     		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
     		curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
     		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                      
     		curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
     			'Content-Type: application/json',                                                                                
     			'Content-Length: ' . strlen($data_string))                                                                       
     		);                                                                                                                                                                                                                                       
     		$result = curl_exec($ch);*/
     ChromePhp::Log("cambio a " . $valor);
 }
示例#15
0
    public function ajouterReservation()
    {
        // on crée une nouvelle machine
        ChromePhp::log('$machineToAdd (Machines) : ', $machineToAdd);
        $error = false;
        $sql = 'insert into machines(code_machine,libelle_machine,image_machine, id_type_machine,id_sous_type_machine, id_marque,
		serial, date_entree, commentaire, lien_consigne
    	) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
        try {
            $this->executerRequete($sql, array($machineToAdd['code_machine'], $machineToAdd['libelle_machine'], $machineToAdd['image_machine'], $machineToAdd['id_type_machine'], $machineToAdd['id_sous_type_machine'], $machineToAdd['id_marque'], $machineToAdd['serial'], $machineToAdd['date_entree'], $machineToAdd['commentaire'], $machineToAdd['lien_consigne']));
        } catch (Exception $e) {
            $error = true;
            ChromePhp::log('$machineToAdd (erreur) : ', $e);
        }
        return $error;
    }
示例#16
0
 /**
  * log to console directly with this method passing only the first required parameter and to change
  * the log type the third parameter according to allowed log types. pass a lable for second parameter
  * to describe the message send to console.
  *
  * @error 10908
  * @param null|mixed $mixed expects the message of any type to send to console
  * @param null|string $label expects the optional label to describe the first parameter
  * @param string $type expects the log type - see log type array
  * @param array $options expects optional parameters
  * @return void
  * @throws Xapp_Error
  */
 public function log($mixed = null, $label = null, $type = 'info', array $options = array())
 {
     $type = strtolower((string) $type);
     if (array_key_exists($type, self::$_typeMap)) {
         if ($type === 'ini') {
             $this->ini($mixed, $label, $options);
         }
         if ($label !== null) {
             $label = trim(trim($label), ':') . ':';
         }
         switch ($this->_driver) {
             case 'chromephp':
                 switch ($type) {
                     case $type === 'ungroup' || $mixed === null:
                         $this->console->groupEnd();
                         break;
                     case 'group':
                         $this->console->group($mixed);
                         break;
                     case 'trace':
                         $this->console->log((string) $label, $mixed, 'info');
                         break;
                     default:
                         $this->console->log((string) $label, $mixed, self::$_typeMap[$type]);
                 }
                 break;
             case 'firephp':
                 switch ($type) {
                     case $type === 'ungroup' || $mixed === null:
                         $this->console->groupEnd();
                         break;
                     case 'group':
                         $this->console->group($mixed, $options);
                         break;
                     case 'trace':
                         $this->console->trace($label);
                         break;
                     default:
                         $this->console->{$type}($mixed, (string) $label, $options);
                 }
                 break;
         }
     } else {
         throw new Xapp_Error(xapp_sprintf(_("xapp console log type: %s not supported"), $type), 1090801);
     }
 }
示例#17
0
 /**
  * Using ChromePhp, log the message
  */
 public function handle(PteLogMessage $message)
 {
     switch ($message->getType()) {
         case PteLogMessage::$ERROR:
             ChromePhp::error($message->getMessage());
             break;
         case PteLogMessage::$WARN:
             ChromePhp::warn($message->getMessage());
             break;
         case PteLogMessage::$INFO:
             ChromePhp::info($message->getMessage());
             break;
         case PteLogMessage::$DEBUG:
         default:
             ChromePhp::log($message->getMessage());
             break;
     }
 }
示例#18
0
 public function Add()
 {
     \ChromePhp::log("Subscr CRUD Add");
     if ($subscriber = $this->getSubscriber()) {
         $this->user = \CUser::GetByID($subscriber)->Fetch();
         \CUser::Authorize($this->user["ID"]);
         if ($subscribe = \CSubscription::GetList(False, array("ACTIVE" => "Y", "USER_ID" => $this->user["ID"]))->Fetch()) {
             return $subscribe["ID"];
         } else {
             try {
                 return $this->addSubscribe();
             } catch (SubscribeException $e) {
                 prentExpection($e->getMessage());
             }
         }
     } else {
         throw new SubscribeUserException("No user for add to subscribers" . ". Line: " . __LINE__);
     }
 }
示例#19
0
文件: Firelog.php 项目: bixev/firelog
 /**
  * @param null $obj
  * @param null $label
  * @param string $type
  */
 public static function log($obj = null, $label = null, $type = LoggerLevel::LEVEL_LOG)
 {
     if (!static::$_enabled) {
         return;
     }
     if ($type == LoggerLevel::LEVEL_TRACE) {
         $e = new \Exception();
         $obj = explode("\n", $e->getTraceAsString());
         $label = empty($label) ? 'TRACE' : $label . ' | TRACE';
         $type = null;
     }
     $type = strtoupper($type);
     $delay = static::getTimer();
     $label = $delay . ' :: ' . $label;
     \ChromePhp::log($type, $label);
     \ChromePhp::log($type, $obj);
     $instance = \FirePHP::getInstance(true);
     $instance->fb($obj, $label, $type);
 }
示例#20
0
 function registrarse($email, $nombre, $pass)
 {
     if (!empty($nombre)) {
         // comprobamos que el campo nombre no esté vacío
         if (!empty($pass)) {
             if (preg_match('/^[A-Za-z0-9-_.+%]+@[A-Za-z0-9-.]+\\.[A-Za-z]{2,4}$/', $email)) {
                 $email = $this->db->quote($email);
                 $pass = $this->db->quote($pass);
                 $nombre = $this->db->quote($nombre);
                 $consulta = 'SELECT usuario_email FROM usuarios WHERE usuario_email =' . $email . '';
                 $consulta = $this->db->prepare($consulta);
                 $consulta->execute();
                 if ($row = $consulta->fetch()) {
                     return "existe usuario";
                 } else {
                     $pass = md5($pass);
                     $consulta = "SELECT MAX(usuario_id) AS id FROM usuarios";
                     $consulta = $this->db->prepare($consulta);
                     $consulta->execute();
                     if ($row = $consulta->fetch()) {
                         $id = trim($row[0]);
                     } else {
                         $id = 0;
                     }
                     $id = $id + 1;
                     ChromePhp::log($id);
                     $consulta = 'INSERT INTO usuarios (usuario_id, usuario_nombre, usuario_clave, usuario_email, usuario_freg) VALUES (\'' . $id . '\', ' . $nombre . ', \'' . $pass . '\', ' . $email . ', NOW())';
                     ChromePhp::log($consulta);
                     $consulta = $this->db->prepare($consulta);
                     $consulta->execute();
                     return "Registrado";
                 }
             } else {
                 return "Email incorrecto";
             }
         } else {
             return "Password vacio";
         }
     } else {
         return "Nombre vacio";
     }
 }
示例#21
0
 function _log($data, $label = null, $backtrace = false)
 {
     // Stop execution and log to ChromePhp if the class exists
     if (class_exists('ChromePhp')) {
         if ($label) {
             $r = array('label' => $label, 'data' => $data);
             return ChromePhp::log($r);
         }
         return ChromePhp::log($data);
     }
     $output = '';
     switch (gettype($data)) {
         case "array":
         case "object":
             $output .= print_r($data, TRUE);
             if ($label !== null) {
                 $output .= "\n\n---^^^^^^^ END {$label} ^^^^^^^---";
             }
             break;
         case "integer":
         case "float":
         case "string":
             $output .= $data;
             break;
         case "boolean":
             $converted_data = $data ? 'true' : 'false';
             $output .= $converted_data;
             break;
         default:
             $output .= "ERROR: tried to log bad type [" . gettype($data) . "]";
             break;
     }
     if ($backtrace) {
         _backtrace($label);
     }
     if (!empty($label)) {
         $output = "\t--- [ {$label} ] ---\n\n" . $output . "\n";
     }
     error_log($output);
 }
 public function mergePromociones($promociones)
 {
     global $cnx;
     $idProductosAdd = array();
     $idProductos = array();
     $ind = 0;
     $idPromocion = $promociones['idPromocion'];
     $idProducto = $promociones['idProducto'];
     $precioPromocion = $promociones['precioPromocion'];
     $fechaInicio = $promociones['fechaInicial'];
     $fechaFinal = $promociones['fechaFinal'];
     if ($idPromocion == "") {
         // NUEVO REGRISTRO
         $query = "INSERT INTO promocion(idProducto,precioPromocion,fechaInicio,fechaFinal) VALUES({$idProducto},{$precioPromocion},STR_TO_DATE('{$fechaInicio}','%d/%m/%Y'),STR_TO_DATE('{$fechaFinal}','%d/%m/%Y'))";
         ChromePhp::log($query);
         try {
             $rs = $cnx->Execute($query);
             //                array_push($idProductos, array($cnx->Insert_ID(), $ind));
             $idProductosAdd['mesaje'] = "ok";
         } catch (Exception $exc) {
             $idProductosAdd['mesaje'] = $exc->getTraceAsString();
             return $idProductosAdd;
         }
     } else {
         //ACTUALIZACION DE PRODUCTO
         $query = "UPDATE promocion set idProducto = {$idProducto}, precioPromocion={$precioPromocion},fechaInicio = STR_TO_DATE('{$fechaInicio}','%d/%m/%Y'),fechaFinal=STR_TO_DATE('{$fechaFinal}','%d/%m/%Y') WHERE idPromocion = {$idPromocion}";
         try {
             $rs = $cnx->Execute($query);
             $idProductosAdd['mesaje'] = "ok";
         } catch (Exception $exc) {
             $idProductosAdd['mesaje'] = $exc->getTraceAsString();
             return $idProductosAdd;
         }
     }
     //        print_r($idProductosAdd);
     //
     return $idProductosAdd;
 }
示例#23
0
 public static function init()
 {
     return function ($info) {
         switch ($info['level']) {
             case \Analog\Analog::DEBUG:
                 \ChromePhp::log($info['message']);
                 break;
             case \Analog\Analog::INFO:
             case \Analog\Analog::NOTICE:
                 \ChromePhp::info($info['message']);
                 break;
             case \Analog\Analog::WARNING:
                 \ChromePhp::warn($info['message']);
                 break;
             case \Analog\Analog::ERROR:
             case \Analog\Analog::CRITICAL:
             case \Analog\Analog::ALERT:
             case \Analog\Analog::URGENT:
                 \ChromePhp::error($info['message']);
                 break;
         }
     };
 }
示例#24
0
    try {
        $stmt = $db->exec("TRUNCATE TABLE experiment");
        ChromePhp::log($stmt);
        echo json_encode($stmt);
    } catch (Exception $ex) {
        ChromePhp::log($ex->getMessage());
    }
} else {
    //user is presumed not admin therefore a check on owner of experiment.
    if ($userCheck == 1) {
        //user check is required, checks if user is the owner of experiments
        try {
            $stmt = $db->exec("DELETE FROM experiment WHERE date < DATE_SUB(NOW(), INTERVAL '" . $interval . "' ) AND person = '" . $userId . "'");
            echo json_encode($stmt);
            ChromePhp::log("Update complete");
            //for logging purposes
        } catch (Exception $ex) {
            ChromePhp::log($ex->getMessage());
        }
    } elseif ($access == 1) {
        //user is admin, deletes all experiments from chosen interval.
        try {
            $stmt = $db->exec("DELETE FROM experiment WHERE date < DATE_SUB(NOW(), INTERVAL '" . $interval . "' )");
            echo json_encode($stmt);
            ChromePhp::log("Update complete");
            //for logging purposes
        } catch (Exception $ex) {
            ChromePhp::log($ex->getMessage());
        }
    }
}
示例#25
0
    $oUserInfo = json_decode($oRes);
    ChromePhp::info($oUserInfo);
    ChromePhp::info("GetUserInfo success");
    if (isset($oCreds->Users)) {
        foreach ($oCreds->Users as $sEmail) {
            if ($sEmail == $oUserInfo->email) {
                $_SESSION['loggedin'] = True;
                ChromePhp::info("Login success");
                break;
            }
        }
        if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == True) {
            foreach ($oCreds->Admins as $sEmail) {
                if ($sEmail == $oUserInfo->email) {
                    $_SESSION['isAdmin'] = True;
                    ChromePhp::info("Admin Login success");
                    break;
                }
            }
        } else {
            $oApp->render('error.phtml');
        }
    }
    $oApp->redirect('/');
});
/***
 * Inner functions
***/
function getUserType()
{
    if (isset($_SESSION['loggedin']) && $_SESSION['loggedin'] == True) {
 /**
  * Check the BotSmasher API 
  * 
  * @param \string $ip				IP address
  * @param \string $email			Email address
  * @param \string $name				Name
  * @param \boolean $debug			Debug cUrl communication
  * @param \int						BotSmasher status
  * @throws \Tollwerk\TwAntibot\Utility\BotSmasher\Exception		If an invalid IP address is provided
  */
 public function check($ip = null, $email = null, $name = null, $debug = false)
 {
     $status = self::STATUS_INVALID;
     $checks = array();
     $errors = new BotSmasher\Exception();
     // IP address check
     if (strlen(trim($ip))) {
         // If the IP address is invalid
         if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
             $errors->addMessage(sprintf('Invalid IP address "%s"', $ip), self::IP_INVALID);
             // Else if the IP address is private
         } elseif (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) === false) {
             $errors->addMessage(sprintf('Private IP address "%s"', $ip), self::IP_PRIVATE);
             // Else
         } else {
             $checks['ip'] = trim($ip);
         }
     }
     // Email address check
     if (strlen(trim($email))) {
         if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
             $errors->addMessage(sprintf('Invalid email address "%s"', $email), self::EMAIL_INVALID);
         } else {
             $checks['email'] = trim($email);
         }
     }
     // Name check
     if (strlen(trim($name))) {
         $checks['name'] = trim($name);
     }
     // If no checks are requested: Error
     if (!count($checks)) {
         if (count($errors)) {
             throw $errors;
         } else {
             return $status;
         }
     }
     $checks['key'] = $this->_apiKey;
     $checks['action'] = self::ACTION_CHECK;
     if ($debug) {
         \ChromePhp::log($checks);
     }
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->_apiUrl);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, TRUE);
     curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $checks);
     // Execute post and get results
     $result = curl_exec($ch);
     $info = curl_getinfo($ch);
     curl_close($ch);
     // 		$result = '{"response":{"summary":{"badguys":"false","requesttype":"check","code":"success","description":"Your request was successful - "},"request":{"email":{"submitted":"*****@*****.**","flaggedbyyou":"false","found":"false","count":"0"}}}}';
     // 		$info = array(
     // 			'url' => 'https://www.botsmasher.com/api/',
     // 			'content_type' => 'text/html; charset=utf-8',
     // 			'http_code' => 200,
     // 			'header_size' => 261,
     // 			'request_size' => 191,
     // 			'filetime' => -1,
     // 			'ssl_verify_result' => 10,
     // 			'redirect_count' => 0,
     // 			'total_time' => 1.4916369999999999,
     // 			'namelookup_time' => 0.0038340000000000002,
     // 			'connect_time' => 0.122919,
     // 			'pretransfer_time' => 0.37947500000000001,
     // 			'size_upload' => 414,
     // 			'size_download' => 236,
     // 			'speed_download' => 158,
     // 			'speed_upload' => 277,
     // 			'download_content_length' => 236,
     // 			'upload_content_length' => 414,
     // 			'starttransfer_time' => 0.49339500000000003,
     // 			'redirect_time' => 0,
     // 			'redirect_url' => '',
     // 			'primary_ip' => '65.181.127.31',
     // 			'certinfo' => array(),
     // 			'primary_port' => 443,
     // 			'local_ip' => '192.168.123.18',
     // 			'local_port' => 34043
     // 		);
     // 		$result = '{"response":{"summary":{"badguys":"true","requesttype":"check","code":"success","description":"Your request was successful - "},"request":{"email":{"submitted":"*****@*****.**","flaggedbyyou":"false","found":"true","count":"6","lastseen":"2015-08-08 10:10:04"}}}}';
     // 		$info = array(
     // 			'url' => 'https://www.botsmasher.com/api/',
     // 			'content_type' => 'text/html; charset=utf-8',
     // 			'http_code' => 200,
     // 			'header_size' => 261,
     // 			'request_size' => 191,
     // 			'filetime' => -1,
     // 			'ssl_verify_result' => 10,
     // 			'redirect_count' => 0,
     // 			'total_time' => 0.70769400000000005,
     // 			'namelookup_time' => 3.4999999999999997E-5,
     // 			'connect_time' => 0.113187,
     // 			'pretransfer_time' => 0.36741499999999999,
     // 			'size_upload' => 409,
     // 			'size_download' => 262,
     // 			'speed_download' => 370,
     // 			'speed_upload' => 577,
     // 			'download_content_length' => 262,
     // 			'upload_content_length' => 409,
     // 			'starttransfer_time' => 0.47937000000000002,
     // 			'redirect_time' => 0,
     // 			'redirect_url' => '',
     // 			'primary_ip' => '65.181.127.31',
     // 			'certinfo' => array(),
     // 			'primary_port' => 443,
     // 			'local_ip' => '192.168.123.18',
     // 			'local_port' => 39524
     // 		);
     if ($debug) {
         echo curl_error($ch) . PHP_EOL;
         var_export($info);
         print_r($result);
     }
     if ($info['http_code'] == 200 && strlen($result)) {
         $response = @json_decode($result);
         if (is_object($response) && isset($response->response) && is_object($response->response)) {
             $response = $response->response;
             $summary = isset($response->summary) && is_object($response->summary) ? $response->summary : null;
             $request = isset($response->request) && is_object($response->request) ? $response->request : null;
             if ($summary && $request) {
                 if (!empty($summary->code) && strtolower($summary->code) == 'success') {
                     if (!empty($summary->badguys) && strtolower($summary->badguys) == 'true') {
                         // Run through all check results
                         foreach ($request as $check => $checkResult) {
                             if (is_object($checkResult) && isset($checkResult->found) && strtolower($checkResult->found) == 'true') {
                                 $status |= self::$_checks[$check];
                             }
                         }
                     } else {
                         $status = self::STATUS_VALID;
                     }
                 }
             }
         }
     }
     return $status;
 }
示例#27
0
if (mysql_num_rows($dupquery) > 0) {
    ChromePhp::log('User already exists.');
    ?>
        <script type="text/javascript">
            alert("This username is already registered.");
        </script>
        <?php 
} else {
    if (!isset($username)) {
        echo "Please provide a username";
        ChromePhp::log('No username');
    } else {
        if (!isset($name)) {
            echo "Please provide a name";
            ChromePhp::log('No username');
        } else {
            if (strlen($password) < 6) {
                echo "Password must be 6 characters.";
                ChromePhp::log('password < 6');
            } else {
                if ($password != $confirm) {
                    echo "Password does not match confirmation.";
                    ChromePhp::log('password != confirm');
                } else {
                    ChromePhp::log('password > 6');
                    mysql_query("INSERT INTO users\n            (username, name, password) VALUES('{$username}', '{$name}', '{$password}')") or die(mysql_error());
                }
            }
        }
    }
}
示例#28
0
 public static function log($var = '', $force = 0)
 {
     $debugroot = DISCUSS_HELPERS . '/debug';
     $firephp = false;
     $chromephp = false;
     if (JFile::exists($debugroot . '/fb.php') && JFile::exists($debugroot . '/FirePHP.class.php')) {
         include_once $debugroot . '/fb.php';
         fb($var);
     }
     if (JFile::exists($debugroot . '/chromephp.php')) {
         include_once $debugroot . '/chromephp.php';
         ChromePhp::log($var);
     }
 }
示例#29
0
 /**
  * gets instance of this class
  *
  * @return ChromePhp
  */
 public static function getInstance()
 {
     if (self::$_instance === null) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#30
0
<?php

$app->group('/wb', function () use($app, $wb_oauth) {
    //callback
    $app->get('/callback/:code', function ($code) use($wb_oauth) {
        ChromePhp::log($code);
    });
    //go to auth
    $app->get('/go', function () use($app, $wb_oauth) {
        $url = $wb_oauth->getAuthorizeURL(WB_CALLBACK_URL);
        //$url = 'http://www.phpgao.com';
        $app->redirect($url, 301);
    });
});