示例#1
0
 /**
  * Get Upload Signature
  * @static
  * @param null $redirectUrl In case if you are using redirection after your upload, specify redirect URL
  * @param false $multipart Initiate a multipart upload
  * @return array
  */
 public static function getUploadSignature($redirectUrl = null, $path, $multipart = false, $filename = null, $filesize = null)
 {
     if ($path == null) {
         throw new VzaarException('path/url could not be null');
     }
     if (!preg_match('/^(https?:\\/\\/+[\\w\\-]+\\.[\\w\\-]+)/i', $path)) {
         $_url = "path=" . $path;
         if ($filename != null) {
             $_url .= "&filename=" . $filename;
         }
         if ($filesize != null) {
             $_url .= "&filesize=" . $filesize;
         }
     } else {
         $_url .= "url=" . $path;
     }
     if (Vzaar::$enableFlashSupport) {
         $_url .= "&flash_request=true";
     }
     if ($redirectUrl != null) {
         $_url .= "&success_action_redirect=" . $redirectUrl;
     }
     if ($multipart) {
         $_url .= "&multipart=true";
         $_url .= "&uploader=" . Constants::Uploader;
     }
     $_base_url = self::$url . "api/v1.1/videos/signature?";
     $_auth_url = $_base_url . $_url;
     $_http_url = $_base_url . str_replace(' ', '+', $_url);
     $req = Vzaar::setAuth($_auth_url, 'GET');
     $req->verbose = Vzaar::$enableHttpVerbose;
     $c = new HttpRequest($_http_url);
     $c->method = 'GET';
     array_push($c->headers, $req->to_header());
     array_push($c->headers, 'User-Agent: Vzaar OAuth Client');
     $data = $c->send();
     return UploadSignature::fromXml($data);
 }
示例#2
0
 /**
  * Get Upload Signature
  * @static
  * @param null $redirectUrl In case if you are using redirection after your upload, specify redirect URL
  * @return array
  */
 public static function getUploadSignature($redirectUrl = null)
 {
     $_url = self::$url . "api/videos/signature";
     if (Vzaar::$enableFlashSupport) {
         $_url .= '?flash_request=true';
     }
     if ($redirectUrl != null) {
         if (Vzaar::$enableFlashSupport) {
             $_url .= '&success_action_redirect=' . $redirectUrl;
         } else {
             $_url .= '?success_action_redirect=' . $redirectUrl;
         }
     }
     $req = Vzaar::setAuth($_url, 'GET');
     $req->verbose = Vzaar::$enableHttpVerbose;
     $c = new HttpRequest($_url);
     $c->method = 'GET';
     array_push($c->headers, $req->to_header());
     array_push($c->headers, 'User-Agent: Vzaar OAuth Client');
     return UploadSignature::fromXml($c->send());
 }
                    $this->signatory_model->updateSignature($this->signatoryID, $imagepath);
                    $this->template->assign('signatureImage', $imagepath);
                    $this->template->assign('hasImageSet', '1');
                    $this->template->setAlert('Signature image has been successfully uploaded.', Template::ALERT_SUCCESS);
                } else {
                    $this->template->setAlert('An error occured while uploading the image.' . $image_upload->error, Template::ALERT_INFO);
                }
            } else {
                $this->template->setAlert('An error occured while uploading the image.', Template::ALERT_INFO);
            }
        } else {
            $this->template->setAlert('Invalid image! The image must be of valid file type (jpg, png, or gif), has exactly 200x35 size, and is less than 1 MB.', Template::ALERT_ERROR, 'alert');
            //return;
        }
    }
    public function reset()
    {
        $sigIm = $this->signatory_model->getSignature($this->signatoryID);
        $sigIm = parse_url($sigIm, PHP_URL_PATH);
        $sigIm = substr($sigIm, strrpos($sigIm, "/") + 1);
        $sigIm = PATH . "photos/signatures/" . $sigIm;
        unlink($sigIm);
        $this->signatory_model->resetSignature($this->signatoryID);
        $this->template->assign('signatureImage', HOST . "/photos/default_signature.jpg");
        $this->template->assign('hasImageSet', '0');
        $this->template->setAlert('Signature image has been removed.', Template::ALERT_SUCCESS);
    }
}
$controller = new UploadSignature();
$controller->perform_actions();
$controller->display();