public function connect() { if (!self::$connected) { if (!$this->sftp->login('root', 'WEB2B7eMsiJ43')) { die("Failed to connect to img.theberrics.com"); } else { self::$connected = true; } } }
public function reject_file($id) { $file = $this->MediahuntMediaItem->find("first", array("conditions" => array("MediahuntMediaItem.id" => $id), "contain" => array("MediahuntTask"))); $this->MediahuntMediaItem->delete($id); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $i = ImgServer::instance(); $i->delete_file("mediahunt-media/" . $file['MediahuntMediaItem']['file_name']); $cb = "/mediahunt_events/view/" . $file['MediahuntTask']['mediahunt_event_id']; if (isset($this->request->params['callback'])) { $cb = base64_decode($this->request->params['callback']); } $this->redirect($cb); }
public function handle_upload() { $file = $_FILES['Filedata']; if (is_uploaded_file($file['tmp_name'])) { $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $fileName = md5(time()) . mt_rand(100, 999) . "." . $ext; move_uploaded_file($file['tmp_name'], TMP . $fileName); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); ImgServer::instance()->upload_bangyoself_entry($fileName, TMP . $fileName); unlink(TMP . $fileName); //insert the entry $this->BangyoselfEntry->create(); $this->BangyoselfEntry->save(array("user_id" => $this->user_id_scope, "file_name" => $fileName, "bangyoself_event_id" => $this->event_id)); die("1"); } else { die("0"); } }
private function handleIconUpload() { $file = $this->request->data['CanteenPromoCode']['icon_file']; if (!is_uploaded_file($file['tmp_name'])) { unset($this->request->data['CanteenPromoCode']['icon_file']); return; } $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $fileName = md5(microtime() . mt_rand(99, 999)) . "." . $ext; if (move_uploaded_file($file['tmp_name'], TMP . $fileName)) { App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); ImgServer::instance()->upload_canteen_promo_icon($fileName, TMP . $fileName); $this->request->data['CanteenPromoCode']['icon_file'] = $fileName; unlink(TMP . $fileName); } else { unset($this->request->data['CanteenPromoCode']['icon_file']); } }
public function uploadImage($file) { if (!isset($file['tmp_name'])) { return ''; } //save to tmp $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $name = md5(time() . mt_rand(999, 9999)) . "." . $ext; $tmp_path = TMP . $name; if (move_uploaded_file($file['tmp_name'], $tmp_path)) { App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $img = ImgServer::instance(); $img->upload_unified_employee($name, $tmp_path); unlink($tmp_path); return $name; } return ''; }
public function handle_upload() { $file = $this->request->data['AssetFile']['asset-file']; $valid = array("js", "css"); $ext = pathinfo($file['name'], PATHINFO_EXTENSION); if (!is_uploaded_file($file['tmp_name']) || !in_array($ext, $valid)) { $this->Session->setFlash("Invalid Upload"); $this->redirect("/cdn/upload_fb_assets"); return; } else { //move the file to tmp move_uploaded_file($file['tmp_name'], TMP . "uploads/" . $file['name']); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $img = ImgServer::instance(); $img->upload_fb_tab_assets($file['name'], TMP . "uploads/" . $file['name']); //unlink(TMP."uploads/".$file['name']); } $this->Session->setFlash("File has been uploaded and processed"); $this->redirect("/cdn/upload_fb_assets"); }
private function uploadHeading($data, $file) { if (!is_uploaded_file($file['tmp_name'])) { return false; } $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $fileName = md5(mt_rand(999, 99999) . time()) . "." . $ext; move_uploaded_file($file['tmp_name'], TMP . "uploads/" . $fileName); ImgServer::instance()->upload_section_heading($fileName, TMP . "uploads/" . $fileName); unlink(TMP . "upload/" . $fileName); return $fileName; }
public function brightcove_file_migration() { set_time_limit(0); $conds = array("MediaFile.media_type" => "bcove", "MediaFile.file_video_still" => NULL); //get 100 brightcove posts that do not have any file_video_still populated $files = $this->MediaFile->find("all", array("conditions" => $conds, "limit" => 500, "contain" => array())); $cwd = getcwd(); chdir("/home/sites/berrics/img.theberrics.com/public_html/video/stills"); //brightcove API App::import("Vendor", "BCAPI", array("file" => "bc_api.php")); $bc = BCAPI::instance()->bc; foreach ($files as $file) { $m = $file['MediaFile']; if ($m['brightcove_id'] > 0) { $bc_info = $bc->find("videobyid", array("video_id" => $m['brightcove_id'])); $image = $bc_info->videoStillURL; //save the image // die("wget $image -O ".$m['id'].".jpg"); exec("wget {$image} -O " . $m['id'] . ".jpg"); ImgServer::instance()->upload_video_still($m['id'] . ".jpg", "/home/sites/berrics/img.theberrics.com/public_html/video/stills/" . $m['id'] . ".jpg"); //save the info $this->MediaFile->create(); $this->MediaFile->id = $m['id']; $this->MediaFile->save(array("file_video_still" => $m['id'] . ".jpg", "brightcove_url" => $bc_info->FLVURL)); $this->out("Saved: " . $m['id']); } } }
private function uploadBackImage() { $file = $this->request->data['OndemandTitle']['image_back']; if (is_uploaded_file($file['tmp_name'])) { App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $fileName = md5(microtime()) . "." . $ext; //move file to the tmp directory move_uploaded_file($file['tmp_name'], TMP . "upload/" . $fileName); ImgServer::instance()->upload_ondemand_cover($fileName, TMP . "upload/" . $fileName); unlink(TMP . "upload/" . $fileName); $this->request->data['OndemandTitle']['image_back'] = $fileName; } else { unset($this->request->data['OndemandTitle']['image_back']); } }
public function sftp() { App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $srv = ImgServer::instance(); $srv->connect(); $srv->sftp->chdir("/home/sites/berrics/theberrics.com/public_html/app/controllers"); pr($srv->sftp->nlist()); $srv->close(); }
public function commit_pending_image() { if ($this->request->is("post")) { if (!empty($this->request->data['MediaFile']['tags'])) { $this->request->data['Tag'] = $this->MediaFile->Tag->parseTags($this->request->data['MediaFile']['tags']); } else { $this->request->data['Tag'] = array(); } $ext = pathinfo($this->request->data['MediaFile']['tmp_image'], PATHINFO_EXTENSION); $file_name = md5(time() . mt_rand(999, 9999)) . "." . $ext; $tmp_file = TMP . "uploads/" . $this->request->data['MediaFile']['tmp_image']; App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $img = ImgServer::instance(); $img->upload_image_file($file_name, $tmp_file); $this->request->data['MediaFile']['media_type'] = "img"; $this->request->data['MediaFile']['file'] = $file_name; $this->MediaFile->create(); if ($this->MediaFile->saveAll($this->request->data)) { unlink($tmp_file); } die(json_encode($this->request->data)); } die; }
private function handleProfileImageUpload() { $file = $this->request->data['User']['profile_image']; $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $name = md5(microtime()) . "." . $ext; //move to temp folder $tmp_path = TMP . $name; move_uploaded_file($file['tmp_name'], $tmp_path); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $i = ImgServer::instance(); //upload file to server $i->upload_profile_image($name, $tmp_path); //$this->request->data['User']['profile_img_file'] = $name; //insert a new profile image row $this->loadModel("UserProfileImage"); $this->UserProfileImage->create(); $this->UserProfileImage->save(array("file_name" => $name, "user_id" => $this->request->data['User']['id'])); }
private function uploadStyleCodeImage() { $file = $this->request->data['CanteenProduct']['style_code_image']; $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION)); if (!is_uploaded_file($file['tmp_name']) || !in_array($ext, array("jpg", "jpeg", "png", "gif"))) { return false; } $fileName = md5(time() . uniqid()) . "." . $ext; //move the file over to the temp dir if (move_uploaded_file($file['tmp_name'], TMP . $fileName)) { App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); ImgServer::instance()->upload_product_image($fileName, TMP . $fileName); unlink(TMP . $fileName); $this->request->data['CanteenProduct']['style_code_image'] = $fileName; return true; } return false; }
public function process_usps_label($label = false, $record_id = false) { //save the label to a tmp folder $tmp_name = microtime() . ".tif"; $img_str = base64_decode($label); $touch = TMP . $tmp_name; echo `touch {$touch}`; file_put_contents(TMP . $tmp_name, $img_str); //convert the label to a png $magic = new Imagick(TMP . $tmp_name); $magic->setImageFormat('png'); $new_img = $record_id . ".png"; $magic->writeImage(TMP . $new_img); //move the image to the static server App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $srv = ImgServer::instance(); $srv->upload_shipping_label($new_img, TMP . $new_img); unlink(TMP . $new_img); unlink(TMP . $tmp_name); return $new_img; }
private function uploadImageLogo() { if (is_uploaded_file($this->request->data['UnifiedStore']['image_logo']['tmp_name'])) { $ext = pathInfo($this->request->data['UnifiedStore']['image_logo']['name'], PATHINFO_EXTENSION); $fileName = md5(time()) . "." . $ext; move_uploaded_file($this->request->data['UnifiedStore']['image_logo']['tmp_name'], TMP . "upload/" . $fileName); ImgServer::instance()->upload_unified_logo($fileName, TMP . "upload/" . $fileName); unlink(TMP . "upload/" . $fileName); $this->request->data['UnifiedStore']['image_logo'] = $fileName; } }
public function handleCanteenLogoUpload() { $file = $this->request->data['Brand']['new_canteen_logo']; if (!is_uploaded_file($file['tmp_name'])) { return false; } $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $fileName = md5(time() . mt_rand(1, 100)) . "." . $ext; move_uploaded_file($file['tmp_name'], TMP . "upload/" . $fileName); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); ImgServer::instance()->upload_canteen_brand_logo($fileName, TMP . "upload/" . $fileName); $this->request->data['Brand']['canteen_logo'] = $fileName; unlink(TMP . "upload/" . $fileName); }
public function attach_instagram($id = false) { $data = array("status" => false); $instagram_token = $this->Auth->user("instagram_oauth_token"); if (empty($instagram_token) || !$id) { die(json_encode($data)); } App::import("Vendor", "InstagramApi", array("file" => "instagram/instagram_api.php")); $i = InstagramApi::userInstance($instagram_token); $image = $i->instagram->getMedia($id); $image = json_decode($image, true); //get the image $f_image = file_get_contents($image['data']['images']['standard_resolution']['url']); $image_name = md5(time() . mt_rand(999, 9999)) . ".jpg"; file_put_contents(TMP . $image_name, $f_image); App::import("Vendor", "ImgServer", array("file" => "ImgServer.php")); $imgs = ImgServer::instance(); $imgs->upload_tmp_file($image_name, TMP . $image_name); $data['status'] = true; $data['image'] = $image; $data['file_name'] = $image_name; die(json_encode($data)); }