Example #1
0
 /**
  * @param $call
  * @param array $params
  * @param string $method
  * @return array|null|\stdClass|mixed
  * @throws \RuntimeException
  */
 protected function callApi($call, array $params = array(), $method = self::CALL_GET)
 {
     if (!isset($params['api_user'])) {
         $params['api_user'] = $this->config->getUser();
     }
     if (!isset($params['api_key'])) {
         $params['api_key'] = $this->config->getPass();
     }
     $options = array(\CURLOPT_RETURNTRANSFER => true, \CURLOPT_HEADER => false, \CURLOPT_ENCODING => '', \CURLOPT_SSL_VERIFYPEER => $this->config->getVerifySSL(), \CURLOPT_USERPWD => sprintf('%s:%s', $params['api_user'], $params['api_key']));
     $output = $this->config->getOutput();
     if (substr($call, -1 * strlen($output)) !== $output) {
         $call .= $output;
     }
     $url = $this->config->getBaseUrl() . $call;
     if ($method === self::CALL_GET) {
         $url .= '?' . http_build_query($params);
     } else {
         $options[\CURLOPT_HTTPHEADER] = array('expect:', 'user-agent: evodelavega-sendgrid/1.0;php');
         $options[\CURLOPT_POST] = true;
         $options[\CURLOPT_POSTFIELDS] = $params;
     }
     $ch = $this->initCurl($url, $options);
     //we've set CURL_RETURNTRANSFER, curl_exec returns the result, or false
     $response = curl_exec($ch);
     return $this->processResult($response, $ch);
 }
 public function __construct(Config $config)
 {
     $paths = [$config->getModelPath()];
     $isDevMode = $config->getDevMode();
     $dbParams = ['driver' => $config->getDriver(), 'user' => $config->getUser(), 'password' => $config->getPassword(), 'dbname' => $config->getDbname()];
     $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
     $this->entityManager = DoctrineEntityManager::create($dbParams, $config);
 }
 /**
  * @param Hypercharge\IUrl $url
  * @param Hypercharge\IRequest $request
  * @return Hypercharge\IResponse
  * @throws Hypercharge\Error
  */
 public function call(IUrl $url, IRequest $request)
 {
     $curl = Config::getFactory()->createHttpsClient(Config::getUser(), Config::getPassword());
     $serializer = new XmlSerializer();
     $responseStr = $curl->xmlPost($url->get(), $serializer->toXml($request));
     $responseDom = new \SimpleXMLElement($responseStr);
     return $request->createResponse(XmlSerializer::dom2hash($responseDom));
 }
Example #4
0
 /**
  * @param string $user
  * @param string $passw
  * @return Hypercharge\IHttpsClient
  */
 function createHttpsClient($user = null, $passw = null)
 {
     if ($user === null) {
         $user = Config::getUser();
     }
     if ($passw === null) {
         $passw = Config::getPassword();
     }
     return new Curl($user, $passw);
 }
Example #5
0
 function xml($xml, $name = 'operation')
 {
     $db = Database::singletone()->db();
     $session = Session::singletone();
     $op = $xml->createElement($name);
     $op->appendChild($xml->createElement('mode', $this->dbdata('moderation_mode')));
     $op->appendChild($xml->createElement('time', Utils::formatTime($this->dbdata('moderation_time'), Config::getUser($session->uid(), 'datetime-format'))));
     $op->appendChild($xml->createElement('note', $this->dbdata('moderation_note')));
     $op->appendChild($this->moderator()->xml($xml, 'moderator'));
     return $op;
 }
Example #6
0
 public function isLoggedIn()
 {
     session_start();
     if (isset($_SESSION['user']) and $_SESSION['user'] === Config::getUser()) {
         echo "true";
         return true;
     } else {
         echo "false";
         return false;
     }
     exit;
 }
Example #7
0
 function getSetting($name, $def, $glob = true)
 {
     return Config::getUser($this->_uid, $name, $def, $glob);
 }
 function getPhoto()
 {
     $session = Session::singletone();
     $db = Database::singletone()->db();
     $pid = Utils::pg("pid", 0);
     $w = Utils::pg('w', -1);
     $h = Utils::pg('h', -1);
     $this->_query->appendChild($this->_dom->createElement("photo-id", $pid));
     $this->_query->appendChild($this->_dom->createElement("width", $w));
     $this->_query->appendChild($this->_dom->createElement("height", $h));
     if ($pid <= 0) {
         $this->error("bad-arguments");
         return;
     }
     $photo = new Photo($pid);
     $this->_response->appendChild($this->_dom->createElement('photo-id', $photo->dbdata('photo_id')));
     $this->_response->appendChild($this->_dom->createElement('photo-title', $photo->dbdata('photo_title')));
     $this->_response->appendChild($this->_dom->createElement('photo-description', $photo->dbdata('photo_description')));
     $this->_response->appendChild($this->_dom->createElement('photo-added', Utils::formatTime($photo->dbdata('photo_added'), Config::getUser($session->uid(), 'datetime-format'))));
     if ($photo->dbdata('photo_approved', 0)) {
         $this->_response->appendChild($this->_dom->createElement('photo-approved', 1));
     }
     $img = $photo->get($w, $h);
     $file = $this->_dom->createElement('file', $img[0]);
     $file->setAttribute('width', $img[1]);
     $file->setAttribute('height', $img[2]);
     $this->_response->appendChild($file);
     $this->_response->appendChild($photo->author()->xml($this->_dom, 'author'));
     //if ($photo->dbdata('photo_approved', 0) > 0)
     //	$this->_response->appendChild($photo->moderator()->xml($this->_dom, 'moderator'));
     $this->_response->appendChild($photo->moderationXML($this->_dom));
     $this->_response->appendChild($photo->metaXML($this->_dom));
     $this->success();
 }
Example #9
0
 /**
  * @private
  * @param string $action
  * @param string $channelToken
  * @param string $unique_id
  * @return Hypercharge\Transaction
  */
 static function request($action, $channelToken, $unique_id)
 {
     $url = new TransactionUrl(Config::ENV_SANDBOX, $channelToken, $action);
     $url = $url->get() . '/' . $unique_id;
     $curl = new Curl(Config::getUser(), Config::getPassword());
     $responseStr = $curl->xmlPost($url, '');
     $responseDom = new \SimpleXMLElement($responseStr);
     // dummy
     $request = new TransactionRequest(array('transaction_type' => 'sale'));
     return $request->createResponse(XmlSerializer::dom2hash($responseDom));
 }