예제 #1
0
function get_images_url($css_str)
{
    preg_match_all('/url\\(([\\s])?([\\"|\'])?(.*?)([\\"|\'])?([\\s])?\\)/i', $css_str, $matches, PREG_PATTERN_ORDER);
    if ($matches) {
        foreach ($matches[3] as $key => $match) {
            if (!is_image_url($match)) {
                unset($matches[3][$key]);
            }
        }
    }
    return $matches[3];
}
예제 #2
0
파일: api.php 프로젝트: JJaicmkmy/Chevereto
        case 'json':
        default:
            json_output($ERROR_AUTH_API, $callback);
            break;
        case 'xml':
            xml_output($ERROR_AUTH_API);
            break;
        case 'txt':
            echo $error_key_msg;
            break;
    }
    exit;
    // Shout the door
}
/*** Observe the image request ***/
if (is_image_url($to_upload)) {
    $api_remote_upload = true;
} else {
    if (check_value($to_upload) or check_value($_FILES['upload'])) {
        // Creates the temp image
        $api_temp_name = __CHV_PATH_IMAGES__ . generateRandomString(16) . '.temp';
        while (file_exists($api_temp_name)) {
            $api_temp_name = __CHV_PATH_IMAGES__ . generateRandomString(16) . '.temp';
        }
        if (check_value($_FILES['upload']['tmp_name'])) {
            $to_upload = $_FILES['upload'];
        } else {
            // The base64 comes from POST?
            if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                // Handles the stream
                $fh = fopen($api_temp_name, 'w');
예제 #3
0
 /**
  * valid_data
  * Validate the whole data before do the thing.
  *
  * @param	string
  * @return	mixed
  */
 private function valid_data()
 {
     // Sourced?
     if (!check_value($this->source)) {
         $this->error = 'empty source';
     } else {
         // it's sourced.. But is valid?
         if ($this->is_remote) {
             // URL Check...
             if (!is_image_url($this->source)) {
                 $this->error = 'invalid image url';
             }
         } else {
             // $_FILES Check...
             if (count($this->source) < 5 and !is_numeric($this->source['size'])) {
                 $this->error = 'invalid source';
             }
         }
     }
     // Valid thumb size?
     if (!is_numeric($this->thumb_width) or !is_numeric($this->thumb_height)) {
         $this->error = 'invalid thumb size';
     }
     // Setted and valid resize?
     if ($this->seted_value($this->resize_width) and !is_numeric($this->resize_width)) {
         $this->error = 'invalid resize size';
     }
     // No errors... Process the thing
     if (!check_value($this->error) and $this->fetch_image()) {
         $this->info = get_info($this->working);
         if (!check_value($this->info)) {
             unlink($this->working);
             $this->error = 'invalid image';
             return false;
         } else {
             // The image is valid... Check for valid MIME
             if (!$this->valid_mime($this->info['mime'])) {
                 unlink($this->working);
                 $this->error = 'invalid mime';
                 return false;
             } else {
                 $this->mime = $this->info['mime'];
                 // The MIME is valid... Check for valid size (bytes)
                 if (filesize($this->working) > $this->max_size) {
                     unlink($this->working);
                     $this->error = 'too big';
                     return false;
                 } else {
                     return true;
                     // All valid!
                 }
             }
         }
     } else {
         return false;
         // errors = false
     }
 }