예제 #1
0
파일: UserModel.php 프로젝트: nabble/ajde
 private function saveFileFromWeb($fieldName)
 {
     if ($this->has($fieldName) && (substr(strtolower($this->get($fieldName)), 0, 7) === 'http://' || substr(strtolower($this->get($fieldName)), 0, 8) === 'https://')) {
         // load file from web
         $image = Ajde_Http_Curl::get($this->get($fieldName));
         // extract filename (without extension)
         $basename = basename(parse_url($this->get($fieldName), PHP_URL_PATH));
         $filename = preg_replace('/[^A-Za-z0-9_\\-]/', '_', $this->get($this->usernameField)) . '_' . pathinfo($basename, PATHINFO_FILENAME);
         // save to tmp directory
         $tmp_path = TMP_DIR . $filename;
         $fh = fopen($tmp_path, 'wb');
         fwrite($fh, $image);
         fclose($fh);
         // get mime type
         $mimeType = Ajde_Fs_File::getMimeType($tmp_path);
         // unlink tmp file
         unlink($tmp_path);
         // get default extension
         $extension = Ajde_Fs_File::getExtensionFromMime($mimeType);
         // don't overwrite previous files that were uploaded
         while (is_file(LOCAL_ROOT . AVATAR_DIR . $filename . '.' . $extension)) {
             $filename .= rand(10, 99);
         }
         // save to avatar directory
         $path = AVATAR_DIR . $filename . '.' . $extension;
         $fh = fopen($path, 'wb');
         fwrite($fh, $image);
         fclose($fh);
         $this->set($fieldName, $filename . '.' . $extension);
     }
 }
예제 #2
0
파일: Dialect.php 프로젝트: nabble/ajde
 /**
  * @param string $html
  *
  * @return mixed
  */
 public static function inlineCss($html)
 {
     $url = 'http://premailer.dialect.ca/api/0.1/documents';
     $data = ['html' => $html, 'preserve_styles' => 'false'];
     $json = Ajde_Http_Curl::post($url, $data);
     $result = @json_decode($json);
     if (is_object($result) && isset($result->documents)) {
         $url = $result->documents->html;
         return Ajde_Http_Curl::get($url);
     }
     return $html;
 }
예제 #3
0
파일: Vimeo.php 프로젝트: nabble/ajde
 public function getThumbnail()
 {
     $vmid = $this->_getVimeoId();
     if ($vmid) {
         $response = Ajde_Http_Curl::get("http://vimeo.com/api/v2/video/{$vmid}.php");
         try {
             $hash = unserialize($response);
         } catch (Exception $e) {
             Ajde_Exception_Log::logException(new Ajde_Exception('Could not parse result from Vimeo'));
             return;
         }
         return $hash[0]['thumbnail_large'];
     }
 }
예제 #4
0
파일: Mixcloud.php 프로젝트: nabble/ajde
 public function getThumbnail()
 {
     $url = $this->_getMixcloudUrl();
     if ($url) {
         $html = Ajde_Http_Curl::get($url);
         $matches = [];
         preg_match('%og:image\\" content=\\"(.+?)\\"%', $html, $matches);
         // we get .png, we want .jpg
         if (isset($matches[1])) {
             return $matches[1];
         }
         return;
     }
 }
예제 #5
0
파일: Soundcloud.php 프로젝트: nabble/ajde
 public function getThumbnail()
 {
     if (substr($this->_code, 0, 7) == 'http://' || substr($this->_code, 0, 8) == 'https://') {
         $apiUrl = 'http://api.soundcloud.com/resolve.json?url=' . urlencode($this->_code) . '&client_id=' . $this->_key();
         $hash = json_decode(Ajde_Http_Curl::get($apiUrl));
         return str_replace('large.jpg', 't300x300.jpg', $hash->artwork_url);
     } else {
         $url = $this->_getSoundcloudUrl();
         if ($url) {
             $apiUrl = $url . '.json?client_id=' . $this->_key();
             $hash = json_decode(Ajde_Http_Curl::get($apiUrl));
             return str_replace('large.jpg', 't300x300.jpg', $hash->artwork_url);
         }
     }
 }
예제 #6
0
#!/usr/bin/php
<?php 
include 'private/lib/Ajde/Http/Curl.php';
$e = Ajde_Http_Curl::get('http://updatemybrowser.org/admin/cron.html');
echo $e;
예제 #7
0
파일: Torchbox.php 프로젝트: nabble/ajde
 /**
  * @param string $html
  *
  * @return mixed
  */
 public static function inlineCss($html)
 {
     $url = 'https://inlinestyler.torchbox.com:443/styler/convert/';
     $data = ['returnraw' => '1', 'source' => $html];
     return Ajde_Http_Curl::post($url, $data);
 }
예제 #8
0
파일: MediaModel.php 프로젝트: nabble/ajde
 public function saveFileFromDrive($filename, $oauthToken)
 {
     if ($filename && $oauthToken && $this->has('pointer') && substr(strtolower($this->pointer), 0, 24) === 'https://drive.google.com') {
         $basename = basename(parse_url($filename, PHP_URL_PATH));
         $filename = pathinfo($basename, PATHINFO_FILENAME);
         $ext = pathinfo($basename, PATHINFO_EXTENSION);
         if (strtolower($ext) === 'jpeg') {
             $ext = 'jpg';
         }
         if (!$this->replaceOldFile) {
             // don't overwrite previous files that were uploaded
             while (is_file(LOCAL_ROOT . $this->uploadDirectory . $filename . '.' . $ext)) {
                 $filename .= rand(10, 99);
             }
         }
         $path = $this->uploadDirectory . $filename . '.' . $ext;
         $curlResult = Ajde_Http_Curl::get($this->pointer, $path, ['Authorization: Bearer ' . $oauthToken]);
         //            $curlResult = Ajde_Http_Curl::get($this->pointer, $path);
         if (!$curlResult) {
             return 'error';
         }
         $this->name = $filename;
         $this->pointer = $filename . '.' . $ext;
         $this->thumbnail = $this->pointer;
         return true;
     }
     return false;
 }
예제 #9
0
 /**
  * {@inheritdoc}
  */
 public function update()
 {
     $url = 'https://raw.githubusercontent.com/Fyrd/caniuse/master/fulldata-json/data-2.0.json';
     $this->browsers = @json_decode(Ajde_Http_Curl::get($url));
 }
예제 #10
0
파일: Pdf.php 프로젝트: nabble/ajde
 private function web2pdf($url, $filename = null)
 {
     $web2pdfRoot = config('misc.pdf.web2PdfApi');
     $api = $web2pdfRoot . '?url=' . urlencode($url) . '&filename=' . urlencode($filename);
     return Ajde_Http_Curl::get($api);
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function update()
 {
     $url = 'http://fresh-browsers.com/export/browsers.serialized';
     $this->browsers = unserialize(Ajde_Http_Curl::get($url));
 }