Log in or register to post comments

how to delete cloud target image and metadata package using php code?

May 17, 2013 - 11:25am #1

Hi masters,

                    i newly work with vws , i am using client side cms for insert the target image and metadata package, and updated based on target id using php  with help of vuforia developer forums so i say thanks for that , then could you please tell me how to delete the cloud target image and metadata package using php code, give some code ....its very helpful to me

how to delete cloud target image and metadata package using php

June 1, 2013 - 9:23am #34

That was a temporary problem w/ the service that has been resolved. Try your app again and it should work.

how to delete cloud target image and metadata package using php

June 1, 2013 - 5:23am #33

Hi master,

                     When i run the application using iphone 3 , i scanning the image, before two days its working well, but yesterday i working with same process but i got some error messages, the error message is service unavailable the cloud recognition service is unavailable,please try again later, so cant scan the vuforia target images, so could you please help me.

how to delete cloud target image and metadata package using php

May 28, 2013 - 2:08pm #32

You'll need to use a PUT request and set the active_flag in the JSON body, as with the sample.

See: http://www.lornajane.net/posts/2011/posting-json-data-with-php-curl

how to delete cloud target image and metadata package using php

May 28, 2013 - 11:52am #31

Hi masters,

                          Using curl in php how to deactive the target id for delete purpose???. now i put target deactivate by manually.

how to delete cloud target image and metadata package using php

May 28, 2013 - 10:20am #30

Hi masters,

                          Thanks for your quick reply,

how to delete cloud target image and metadata package using php

May 28, 2013 - 10:18am #29

Take a look at the UpdateTarget sample..

	function UpdateTarget(){

		$this->requestPath = $this->requestPath . $this->targetId;
		
		$helloBase64 = base64_encode("hello world!");
		
		$this->jsonBody = json_encode( array( 'active_flag' => 0 ) );

		$this->execUpdateTarget();

	}

 

The above can be used to deactivate the target. You'll also want to check the target state using GetTarget. Examine the target_record object to ensure that the active_flag is false before attempting to Delete.

 

HTTP/1.1 200 OK
Content-Type: application/json
{
“result_code”:”Success”,
“transaction_id”:”e29b41550e8400d4a716446655440000”,
 “target_record”:{
      “target_id”:”550b41d4a7164466554e8400e2949364”,
      “active_flag”:true,
      “name”:”tarmac”,
      “width”:100.0,
      “tracking_rating”:4,
      “reco_rating”:””
},
“status”:”Success”
}

 

how to delete cloud target image and metadata package using php

May 28, 2013 - 10:12am #28

Hi masters,

                       i used the below line of code i deleted successfully the target image and meta data packages, but now i inactive the target id by manually, then how to put the target as inactive by php code in front end???

 

      

   public function createSignature($requestPath, $postType = "GET", $contentType = "", $content = ""){
                  $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
                  $serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
                  $serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
                  $vuforia_dateformat1 = Zend_Registry::get('config')->constants->vuforiadateformat;
                  $serveraccesskey = $serveraccess_key;
                  $serversecretkey = $serversecret_key;
                  $contentMD5 = md5($content);
                  $date = new DateTime("now", new DateTimeZone("GMT"));
                  $stringToSign = $postType . "\n" . $contentMD5 . "\n" . $contentType . "\n" . $date->format($vuforia_dateformat1) . " GMT\n" . $requestPath;
                  $signature = $this->hexToBase64(hash_hmac('sha1', $stringToSign, $serversecretkey));
                  $credentials = $serveraccesskey.":".$signature;
                  return $credentials;
        }//createSignature()

        public function getDeleteID($TargetID){
		$credentials = $this->createSignature("/targets/$TargetID", "DELETE", "application/json", $content);
		$target = "https://vws.vuforia.com/targets/$TargetID"; 
		return $this->delData($credentials, $target, $content);
	}//getDeleteID($TargetID)

	public function delData($credentials, $target ,$TargetID){
		$date = new DateTime("now", new DateTimeZone("GMT")); 
		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL, $target);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
		curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
		curl_setopt($ch, CURLOPT_HEADER, true);
		curl_setopt($ch, CURLOPT_VERBOSE, true); 
		curl_setopt($ch, CURLOPT_HTTPHEADER, array('Date: ' .$date->format("D, d M Y H:i:s"). " GMT", 'Content-Type: application/json', 'Authorization: VWS ' .$credentials));
		$json = curl_exec($ch);
		
		//$info = curl_getinfo($ch);
		//var_dump($info); die;
		
		curl_close($ch);
		return $json;
	}//delData($credentials, $target ,$TargetID)

 

how to delete cloud target image and metadata package using php

May 28, 2013 - 9:54am #27

Where are you deactivating the target in your code? It appears that it's only activating the target (

"active_flag" => 1 ) , the active_flag should be 0 to deactivate the target.

how to delete cloud target image and metadata package using php

May 27, 2013 - 12:23pm #26

Hi masters, i uploaded my code, and now i attached my code of page also

AttachmentSize
Plain text icon markermanagecontroller_php.txt44.24 KB

how to delete cloud target image and metadata package using php

May 27, 2013 - 12:04pm #25

Hi masters,

                      This part of code is i used for delete process, the target id is change to inactive and then the target id value is give as hot code.

require_once 'HTTP/Request2.php';

class MarkermanageController extends Zend_Controller_Action
{

public function deletemarkerAction(){
	   	$modelmarker = new Application_Model_DbTable_Markers();
		$this->_helper->layout->disableLayout();
		$markerid = $this->_getParam('delmarker_id'); 
		
		$targetId  = "698f5cfc6c9e492f8430541537f53f7d";
		$requestPath 	= "/targets/";
		
		$this->DeleteTarget($requestPath,$targetId);
		
		$resourceid = $modelmarker->getmarkerresourceid($markerid); 
		$lastimg = $resourceid[0]->ar_markerresource_mr_id; 
		  
		if($lastimg != ""){
			$deleteresourcewhere = 'mr_id='.$lastimg;
			//$modelmarker->delete('ar_markerresource',$deleteresourcewhere);
		 }
		  
		$delmarkerwhere =' marker_id='.$markerid;
		//$modelmarker->delete('ar_marker',$delmarkerwhere); 
		 
		$deldisplaymarkerwhere = 'marker_id='.$markerid;
		//$modelmarker->delete('ar_markerdisplay',$deldisplaymarkerwhere);
		
		$this->_redirect('/markermanage/index');
   }//deletemarkerAction()


function DeleteTarget($requestPath,$targetId){

		$requestPath = $requestPath . $targetId;
		
		$this->execDeleteTarget();

	}

	public function execDeleteTarget($requestPath){

		$url = "https://vws.vuforia.com";
		$request = new HTTP_Request2();
		$request->setMethod( HTTP_Request2::METHOD_DELETE );
		
		$request->setConfig(array(
				'ssl_verify_peer' => false
		));

		$request->setURL( $url . $requestPath );

		// Define the Date and Authentication headers
		$this->setHeaders($request);


		try {

			$response = $this->request->send();

			if (200 == $response->getStatus()) {
				echo $response->getBody();
			} else {
				echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
						$response->getReasonPhrase(). ' ' . $response->getBody();
			}
		} catch (HTTP_Request2_Exception $e) {
			echo 'Error: ' . $e->getMessage();
		}


	}

	private function setHeaders($request){
		$serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
		$serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
		$sb = 	new SignatureBuilder();
		$date = new DateTime("now", new DateTimeZone("GMT"));

		// Define the Date field using the proper GMT format
		$this->request->setHeader('Date', $date->format("D, d M Y H:i:s") . " GMT" );
		// Generate the Auth field value by concatenating the public server access key w/ the private query signature for this request
		$this->request->setHeader("Authorization" , "VWS " . $serveraccess_key . ":" . $sb->tmsSignature( $request , $serversecret_key ));

	}
	
	public function tmsSignature( $request , $secret_key ){
		
		$serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
		$serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
		
		$request = new HTTP_Request2();
		$request->setMethod( HTTP_Request2::METHOD_DELETE );
		
		$method = $request->getMethod();
		// The HTTP Header fields are used to authenticate the request
		$requestHeaders = $request->getHeaders();
		// note that header names are converted to lower case
		$dateValue = $requestHeaders['date'];
		
		$requestPath = $request->getURL()->getPath();
		
		// Not all requests will define a content-type
		if( isset( $requestHeaders['content-type'] ))
			$this->contentType = $requestHeaders['content-type'];
	
		if ( $method == 'GET' || $method == 'DELETE' ) {
			// Do nothing because the strings are already set correctly
		} else if ( $method == 'POST' || $method == 'PUT' ) {
			// If this is a POST or PUT the request should have a request body
			$this->hexDigest = md5( $request->getBody() , false );
			
		} else {
			print("ERROR: Invalid content type passed to Sig Builder");
		}
		


		$toDigest = $method . "\n" . $this->hexDigest . "\n" . $this->contentType . "\n" . $dateValue . "\n" . $requestPath ;

		echo $toDigest;
		
		$shaHashed = "";
		
		try {
			// the SHA1 hash needs to be transformed from hexidecimal to Base64
			$shaHashed = $this->shexToBase64( hash_hmac("sha1", $toDigest , $serversecret_key) );
			
		} catch ( Exception $e) {
			$e->getMessage();
		}

		return $shaHashed;	
	}
	
	private function shexToBase64($hex){
		$return = "";
		foreach(str_split($hex, 2) as $pair){
			$return .= chr(hexdec($pair));
		}
		return base64_encode($return);
	}





}

 

how to delete cloud target image and metadata package using php

May 27, 2013 - 10:57am #24

Hi masters,

                             i post my full code of page,

how to delete cloud target image and metadata package using php

May 27, 2013 - 10:45am #23

Hi masters,

                       this is my full code,

<?php
require_once 'HTTP/Request2.php';

class MarkermanageController extends Zend_Controller_Action
{
    private $allowedImgExtention = "";//Allowed Image extention.
    private $msgWrongImgFormat ="";//Error message for wrong image file format.
    
    
    private $contentType = '';
    private $hexDigest = 'd41d8cd98f00b204e9800998ecf8427e'; // Hex digest of an empty string
    
    
    public function init()
    {
        $this->allowedImgExtention = explode(",",Zend_Registry::get('config')->constants->allowedImgExtention);
        $this->msgWrongImgFormat = Zend_Registry::get('config')->constants->msgWrongImgFormat;
    }
    public function indexAction(){
        $modelclient = new Application_Model_DbTable_Clients();
        $modelmarker = new Application_Model_DbTable_Markers();
        $modelpublishers = new Application_Model_DbTable_Publishers();
        $modeluserdetails = new Application_Model_DbTable_Userdetails();
        $ns = new Zend_Session_Namespace('someaction');
        $users=$ns->data;
        $layout = Zend_Layout::getMvcInstance();
        $layout->setLayout('layout');
        $allclient = $modelclient->getclientname();
        $this->view->allclient = $allclient;
        foreach ($markerdetails as $mdetailsval){
            $mdetailid = $mdetailsval->marker_id;
            $this->view->markerid = $mdetailid;  
        }
        foreach($users  as $userstypeid){
             $this->view->userstype = $userstypeid;
        }
        /*current login user id*/
        $userid = $users['user_id']; //current login userid for created by
        if($userid == ""){
        unset( $users );
        session_destroy();
        $this->_redirect('/index/');
        }
        $curlogin_pid = $modeluserdetails->getpid($userid);
        foreach($curlogin_pid as $curlog_pid){
            $curloginpid = $curlog_pid->ar_publishers_pid;
        }
        $pid = $curloginpid;
        if($userstypeid == 1){
            $markerdetails = $modelmarker->getallmarkerdetails();
            $creditdetails = $modelmarker->getcreditdetails();
            $fullclientdetails = $modelclient->getallclientdetails();
        }
        else{
            $markerdetails = $modelmarker->getallmarkerdetails1($pid);
            $creditdetails = $modelmarker->getcreditdetails1($pid);
            $fullclientdetails = $modelclient->getallclientdetails1($pid);
        }
        $this->view->markerdetails = $markerdetails;
        $this->view->publisherdetails = $creditdetails;
        $this->view->fullclientdetails = $fullclientdetails;
        /*current login user id ends*/
        $newpubdetails = $modelpublishers->getpublishermarkerdeatils();
        $this->view->getnewmarkerdetails = $newpubdetails;

        $getpublisherall = $modelpublishers->getpublisherall();
        $this->view->getpublisherall = $getpublisherall;
        
        /*code for markermanagerment publisher filter*/
        
         $publishid = $this->_getParam('publisheridval');
        $this->view->publiid = $publishid;
        
        
        $publisherfilter = $this->_getParam('mpubid'); //for filter the gird values in index page
        $this->view->pubid_slct = $publisherfilter;
        if($publisherfilter){
            if($publisherfilter != "" && $publisherfilter != 0){
                $filter_pid = $modelmarker->getmarkerpublisherfilter($publisherfilter);
                $this->view->publist = $filter_pid;
                $paginator = Zend_Paginator::factory($filter_pid);
            }
            else{
                $paginator= Zend_Paginator::factory($markerdetails);
            }
        }
        else{
            $clientidfilter = $this->_getParam('clnid');
            $this->view->client_select = $clientidfilter;
            if($clientidfilter != "" && $clientidfilter != 0){
                $filter_cid = $modelmarker->getmarkerclientfilter($clientidfilter);
                $this->view->clientlist = $filter_cid;  
                $paginator = Zend_Paginator::factory($filter_cid);
            }
            else{
                $paginator = Zend_Paginator::factory($markerdetails);
            }
        /*code for markermanagement client filter ends*/
        }
        $page = $this->getRequest()->getParam('page', 1);
        //$paginator = Zend_Paginator::factory($markerdetails);
        $paginator->setItemCountPerPage(10);
        $paginator->setCurrentPageNumber($page);
        $this->view->paginator = $paginator;
        
    }//indexAction
    public function newmarkerAction(){
        $modelclient = new Application_Model_DbTable_Clients();
           $modelmarker = new Application_Model_DbTable_Markers();
        $modelpublishers = new Application_Model_DbTable_Publishers();
        $modeluserdetails = new Application_Model_DbTable_Userdetails();
        $ns = new Zend_Session_Namespace('someaction');
        $users=$ns->data;
        $layout = Zend_Layout::getMvcInstance();
        $layout->setLayout('blank');
        $allclient = $modelclient->getclientname();
        $this->view->allclient = $allclient;
        $markerresource = $modelmarker->getmarkerresourcedetails();
        $creditdetails = $modelmarker->getcreditdetails();
        $availabelcredits = $creditdetails[0]->cicredit;  
        $this->view->credits = $availabelcredits;
        foreach($users  as $userstypeid){
             $this->view->userstype = $userstypeid;
        }
        $userid = $users['user_id'];//current login userid for created by
        $curlogin_pid = $modeluserdetails->getpid($userid);
        foreach($curlogin_pid as $curlog_pid){
            $curloginpid = $curlog_pid->ar_publishers_pid;
        }
        $pid = $curloginpid;
        if($userstypeid == 1){
            $markerfulldetails = $modelmarker->getallmarkerdetails();
            $creditdfulletails = $modelmarker->getcreditdetails();
            $fullclientmarkerdetails = $modelclient->getallclientdetails();
        }
        else{
            $markerfulldetails = $modelmarker->getallmarkerdetails1($pid);
            $creditdfulletails = $modelmarker->getcreditdetails1($pid);
            $fullclientmarkerdetails = $modelclient->getallclientdetails1($pid);
        }
        $this->view->markerdetails = $markerfulldetails;
        $this->view->publisherdetails = $creditdfulletails;
        $this->view->fullclientdetails = $fullclientmarkerdetails;  
        /*current login user id ends*/
        $configvalue = $modelmarker->getconfigvalues();
        $this->view->configdetails = $configvalue;
        $getpublisherall = $modelpublishers->getpublisherall();
        $this->view->getpublisherall = $getpublisherall;
    
        if($this->_request->isPost()){
            $newmarkerpublisher = $this->_request->getpost('ddnewmarkerpublisher');
            $newmarkerclient = $this->_request->getpost('ddnewmarkerclient');
            $newmarkername = $this->_request->getpost('txtnewmarkername');
            $descnewmarker = $this->_request->getpost('descnewmarker');
            $newmarkerdisplayunit = $this->_request->getpost('newdisplay');
            $newmarkerdatepickerstart = $this->_request->getpost('hdndatepicker5startnew');
            $newmarkerdatepickerend = $this->_request->getpost('hdndatepicker5endnew');
            $newmarkerpubdatepicker = $this->_request->getpost('hdndatepicker7start');
            $newmarkeruseage = $this->_request->getpost('txtnewmarkusage');
            $newconfigusage = $this->_request->getpost('hdncredits');
            $this->view->configusagevalue = $newconfigusage;
            
            //file upload  value and width value for vuforia webservice start................
            $newmarkeruploadmarker = $this->_request->getpost('btnnewupload');
            $hdnddpubid = $this->_request->getpost('hdnddpubliserid');   //dropdown selct publishr id for foldername & dir create
            if($userstypeid == 1){
                $pid = $hdnddpubid;
            }
            $hdnclientid = $this->_request->getpost('hdnclientid');   //dropdown select client id for foldername and dir create
            $newmarkerwidth = $this->_request->getpost('txtmarkerwidth');
            
            //code for getting last marker id start
            $lastmarkerid = $modelmarker->getlastmarkerid();
            $last_markerid = $lastmarkerid[0];
            foreach($last_markerid as $lastmid => $lastmidval){
                 $lastmid =  $lastmidval;
            }
            $lastnewmarkerid = $lastmid+1;
            //code for getting last marker id end
            
            
            
            $mimage = $_FILES["btnnewupload"]["name"];
            if($mimage){
                $filename2 = $_FILES['btnnewupload']['name'];
                $mimname2 = explode('.',$filename2);
                $filename3 = strtolower($mimname2[1]);
            
                if(!in_array($filename3,$this->allowedImgExtention)){//checking files type code start
                    $this->_helper->flashMessenger->addMessage(array(
                            'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/newmarker');
                    header("Refresh: 0;");    
                }//checking file types code end        
            }
            
            $image = $_FILES["txtradioupload"]["name"];
               if($image){
                   $filename = $_FILES['txtradioupload']['name'];
                $imname = explode('.',$filename);
                $filename1 = strtolower($imname[1]);
                if(!in_array($filename1,$this->allowedImgExtention)){//checking upload file types code start
                    $this->_helper->flashMessenger->addMessage(array(
                        'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/newmarker');
                    header("Refresh: 0;");    
                } //checking upload file types code end
            }
            
            
            
            //code for creating directory for upload marker images
            $imageuploadpath = Zend_Registry::get('config')->constants->image_uploadpath;
            $pathdirectory = $imageuploadpath . $pid . "/" . $hdnclientid . "/" . $lastnewmarkerid;
            $filepermission = Zend_Registry::get('config')->constants->allowedfilepermission;
             mkdir($pathdirectory ,$filepermission,true);
            
            //code for creating directory for upload resource images or txt file
            $resourcesdir = Zend_Registry::get('config')->constants->resourcespath;
            $myfiledir = $pathdirectory . "/" . $resourcesdir;
            mkdir($myfiledir ,$filepermission,true);
            
            //file upload  value and width value for vuforia webservice end.................
            
            
            //radio description
            $editordesc = $this->_request->getpost('desceditor');
            $editorlink = $this->_request->getpost('txthypeditor');
            $uploadimage = $this->_request->getpost('txtradioupload');
            $capturelink = $this->_request->getpost('txtcapturelink');
            $videolink = $this->_request->getpost('txtvideolink1');
            $screenlink = $this->_request->getpost('txtvideolink2');
            $videodesc = $this->_request->getpost('descvideo');
            
            
            $markerresourceid  = "0";
            $ids = $this->_request->getParam('ids');
            $this->view->grid= $ids;
            $image = $_FILES["txtradioupload"]["name"];
               if($image){
                   $filename = $_FILES['txtradioupload']['name'];
                $imname = explode('.',$filename);
                $filename1 = strtolower($imname[1]);
                if(!in_array($filename1,$this->allowedImgExtention)){//checking upload file types code start
                    $this->_helper->flashMessenger->addMessage(array(
                        'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/newmarker');
                    header("Refresh: 0;");    
                } //checking upload file types code end
                 else{
                      $image_name = $filename;
                      $imname1    = explode('.',$image_name);
                      $extindex   = (count($imname1)-1);
                      $ext        = strtolower($imname1[$extindex]);
                      $resoureimgname = $pid . $hdnclientid . $lastnewmarkerid;
                      $destination = $myfiledir.'/'.$resoureimgname.'.'.$ext;
                    
                      if(move_uploaded_file($_FILES['txtradioupload']['tmp_name'], $destination))
                       {
                         $newmarkerresourcedata = array();
                         $mr_type = "Image";
                         $newmarkerresourcedata['mrname']         = $resoureimgname ;
                         $newmarkerresourcedata['mrextention']    = $ext;
                         $newmarkerresourcedata['mrtype']         = $newmarkerdisplayunit;
                         $newmarkerresourcedata['mrlastmodified'] = date('Y-m-d H:i:s');
                         $markerresourceid = $modelmarker->insertanywhere('ar_markerresource', $newmarkerresourcedata);
                      }//eof if(move_uploaded_file
                 }
            }//eof if($image)
            
            
            $newmarkerdata=array();
            $newmarkerdata['ar_clients_client_id'] = $newmarkerclient;
            if($userstypeid == 1){
              $newmarkerdata['p_id'] = $newmarkerpublisher;
            }
            else{
            $newmarkerdata['p_id'] = $curloginpid;
            }        
            $newmarkerdata['mname'] = $newmarkername;
            $newmarkerdata['mimgname'] = $mimage; //marker image name newly added
            $newmarkerdata['mimgwidth'] = $newmarkerwidth; //marker image width newly added
            $newmarkerdata['mdescription']= $descnewmarker;
            $newmarkerdata['ar_markerresource_mr_id']= $markerresourceid;
            $newmarkerdata['mdisplayunit']= $newmarkerdisplayunit;
            $newmarkerdata['mdurationfrom']= $newmarkerdatepickerstart;
            $newmarkerdata['mdurationto']= $newmarkerdatepickerend;
            $newmarkerdata['mpublishingdate']= $newmarkerpubdatepicker;
            $newmarkerdata['musagecount']= $newmarkeruseage;
            $newmarkerdata['mmodifieddate']= date('Y-m-d H:i:s');
            $newmarkerdata['mcreatedby']= $userid;
            $newmarkerdetails =  $modelmarker->insertanywhere('ar_marker',$newmarkerdata);
            
            $newmarkerdisplaydata=array();
            $newmarkerdisplaydata['marker_id'] = $newmarkerdetails;//marker_id value
            $newmarkerdisplaydata['mdisplayunit'] =  $newmarkerdisplayunit;//marker display type
            
            if($newmarkerdisplayunit == 1){
                $indexdisplay = "message";
                $indexvalue = $editordesc;
                $newmarkerdisplaydata['fieldindex'] = $indexdisplay;
                $newmarkerdisplaydata['fieldvalue'] =  $indexvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
                $linktext = "linktext";
                $linkvalue = $editorlink;
                $newmarkerdisplaydata['fieldindex'] = $linktext;
                $newmarkerdisplaydata['fieldvalue'] =  $linkvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
            }
            else if($newmarkerdisplayunit == 2){
                $imgindex = "uploadimage";
                $imgvalue = $uploadimage;
                $newmarkerdisplaydata['fieldindex'] = $imgindex;
                $newmarkerdisplaydata['fieldvalue'] = $image_name;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
                $cameralink = "capturelink";
                $cameraval = $capturelink;
                $newmarkerdisplaydata['fieldindex'] = $cameralink;
                $newmarkerdisplaydata['fieldvalue'] = $cameraval;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
            }
            else if($newmarkerdisplayunit == 3){
                $videodisplay = "videolink";
                $videovalue = $videolink;
                $newmarkerdisplaydata['fieldindex'] = $videodisplay;
                $newmarkerdisplaydata['fieldvalue'] =  $videovalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
                $screendisplay = "screenlink";
                $screenvalue = $screenlink;
                $newmarkerdisplaydata['fieldindex'] = $screendisplay;
                $newmarkerdisplaydata['fieldvalue'] =  $screenvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
                $videodescdisplay = "videodescription";
                $videodescvalue = $videodesc;
                $newmarkerdisplaydata['fieldindex'] = $videodescdisplay;
                $newmarkerdisplaydata['fieldvalue'] =  $videodescvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$newmarkerdisplaydata);
            }
            /*image uploader*/
            
            
            //working with vuforia webservices code start.....................
            if($editordesc != "" || $editorlink != ""){
                $metadata2 = $editordesc ."|".$editorlink;
                $metadata2 = "Text = " . $metadata2;
            }
            else if($uploadimage != "" || $capturelink != ""){
                $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
                $uploadimage = "Image = "."http://". $_SERVER['HTTP_HOST'] . $baseUrl ."/". $destination;
                $metadata2 = $uploadimage . "|" . $capturelink;
            }
            else if($videolink != "" || $screenlink != "" || $videodesc != ""){
                $metadata2 = $videolink . "|" . $screenlink . "|" . $videodesc;
                $metadata2 = "Video = " . "http://". $_SERVER['HTTP_HOST'] . $baseUrl ."/". $metadata2;
            }
            

            //$mypath = $txt_upload;                                
            
            $markerimgname = $pid . $hdnclientid . $lastnewmarkerid;
            
            $myfile = $myfiledir ."/". $markerimgname . "txt" . ".txt";
            
            $file_handle = fopen($myfile, "w");
            $file_contents = $metadata2;
            fwrite($file_handle, $file_contents);
            fclose($file_handle);
            
            
            $mimage = $_FILES["btnnewupload"]["name"];
            if($mimage){
                $filename2 = $_FILES['btnnewupload']['name'];
                $mimname2 = explode('.',$filename2);
                $filename3 = strtolower($mimname2[1]);
            
                if(!in_array($filename3,$this->allowedImgExtention)){//checking files type code start
                    $this->_helper->flashMessenger->addMessage(array(
                            'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/newmarker');
                    header("Refresh: 0;");    
                }//checking file types code end        
                else
                {
                    $mimgname    = $_FILES["btnnewupload"]["name"];
                    $mimname1    = explode('.',$mimgname);
                    $mextindex   = (count($mimname1)-1);
                    $mext        = strtolower($mimname1[$mextindex]);
              
                    $mdestination = $pathdirectory;
                    $markerimagename = "marker" . $pid . $hdnclientid . $lastnewmarkerid;
                    $mdestination1 =  $mdestination . '/'. $markerimagename . '.' . $mext ;
                        
                    if (file_exists($mdestination1))
                    {
                        echo $_FILES["btnnewupload"]["name"] . " already exists. ";
                    }
                    else
                    {
                        move_uploaded_file($_FILES["btnnewupload"]["tmp_name"],$mdestination1);
                        $result = $this->InsData($newmarkerwidth,$markerimgname,$metadata2,$myfile,$mdestination1);
                        //print_r($result);
                        
                        $resultSplit = explode("GMT",$result);
                        $jsonresult = $resultSplit[1];
                        $vuforiavalues = json_decode($jsonresult,true);
                        
                        foreach($vuforiavalues as $vuforiakey => $vuforiaval){
                            $vuforiadetails .=  $vuforiakey . ':' . $vuforiaval . "|";
                        }
                        
                        $vuforiasubstring = substr_replace($vuforiadetails, "", -1);
                        echo $vuforiasubstring;

                        $vuforiaupdatedata=array();
                        $vuforiaupdatedata['vuforia_details'] = $vuforiasubstring;
                        $vuforiawhere=' marker_id='.$lastnewmarkerid;
                        $modelmarker->updateanywhere('ar_marker',$vuforiaupdatedata,$vuforiawhere);
                    }
                    $this->_helper->flashMessenger->addMessage(array('success'=>"The values are successfully inserted"));
                    $this->_redirect('markermanage/newmarker');
                }
            }//if($mimage)
            //working with vuforia webservices code end
        }
        
    }//newmarkerAction
    
    public function dropdownbindingAction(){
           $modelclient = new Application_Model_DbTable_Clients();
        $modelmarker = new Application_Model_DbTable_Markers();
        $modeluserdetails = new Application_Model_DbTable_Userdetails();
        $ns = new Zend_Session_Namespace('someaction');
        $users=$ns->data;
        
        $publisherid = $this->_getParam('publisherid');
        $clientpubdetails = $modelclient->getclientdddetails($publisherid);
    
        $this->view->clientbinding = $clientpubdetails;
        
        $publisherfilter = $this->_getParam('mpubid');
        $clientidfilter = $this->_getParam('clnid');
        
        $selectclient = "";
        $clientpubdetailsval->client_id;
        
        
        $rtnhtml="";
        //if(count($clientpubdetails)>0){
            foreach($clientpubdetails as $clientpubdetailsval){
                  $publisherclientid = $clientpubdetailsval->ar_publishers_pid;
                  $clientval = $clientpubdetailsval->client_id;
                  
                  if($clientidfilter == $clientval){
                        $selectclient = 'selected = "selected"';
            
                  }
                  else{
                       $selectclient = '';
                  }
                $rtnhtml .="<option ". "echo $selectclient "." value='".$clientpubdetailsval->client_id."' >".$clientpubdetailsval->ccontactfname."</option>";
            }
        //}
        echo $rtnhtml;
        exit();
        
    }//dropdown binding action
    
    public function updatemarkerAction(){
        $modelclient = new Application_Model_DbTable_Clients();
        $modelmarker = new Application_Model_DbTable_Markers();
        $modelpublishers = new Application_Model_DbTable_Publishers();
        $modeluserdetails = new Application_Model_DbTable_Userdetails();
        $ns = new Zend_Session_Namespace('someaction');
        $users=$ns->data;
        $layout = Zend_Layout::getMvcInstance();
        $layout->setLayout('blank');
        $markerid = $this->_getParam('marker_id');
        $markerdetails = $modelmarker->getmarkerdetailbyid($markerid);
        $this->view->markerdetails = $markerdetails;
        $upcreditdetails = $modelmarker->getcreditdetails();
        $upavailabelcredits = $upcreditdetails[0]->cicredit;
        $this->view->credits = $upavailabelcredits;
        foreach($users  as $userstypeid){
             $this->view->userstype = $userstypeid;
        }
        $userid = $users['user_id']; //current login userid for created by
        $curlogin_pid = $modeluserdetails->getpid($userid);
        foreach($curlogin_pid as $curlog_pid){
            $curloginpid = $curlog_pid->ar_publishers_pid;
        }
        $pid = $curloginpid;
        if($userstypeid == 1){
            $fullclientmarkerdetails = $modelclient->getallclientdetails();
            $creditdfulletails = $modelmarker->getcreditdetails();
        }
        else {
            $fullclientmarkerdetails = $modelclient->getallclientdetails1($pid);
            $creditdfulletails = $modelmarker->getcreditdetails1($pid);
        }
        $this->view->fullclientdetails = $fullclientmarkerdetails;
        $this->view->publisherdetails = $creditdfulletails;
        
        $updateconfigvalue = $modelmarker->getconfigvalues();
        $this->view->configdetails = $updateconfigvalue;
        
        $getpublisherall = $modelpublishers->getpublisherall();
        $this->view->getpublisherall = $getpublisherall;
        
        $updatemarkerdetails = $modelmarker->getmarkerdisplay($markerid);
        $this->view->updatemarkerdisplay = $updatemarkerdetails;
        
        $allclient = $modelclient->getclientname();
        $this->view->allclient = $allclient;
        
         $resourceid = $modelmarker->getmarkerresourceid($markerid);
         $lastimg = $resourceid[0]->ar_markerresource_mr_id;  
           $this->view->img=$resourceid;
           $this->view->resource= $lastimg;
    
         $updateresourceid = $modelmarker->getmarkerupdateresourceid($markerid);
        
         if($lastimg != ""){
             $updateresourcedata = $modelmarker->getupdatemarkerresouce($lastimg);  
            /*$updatemresdata = $updateresourcedata[0]->mrname; */
            $updatemrid = $updateresourcedata[0]->mr_id;
         }
        
         $resourcename =  $updateresourcedata[0]->mrname;
            
        if($this->_request->isPost()){
            $markername = $this->_request->getpost('txtupdatemarkername');
            $markerdescription = $this->_request->getpost('descupdatemarker');
            $mpublisher = $this->_request->getpost('ddupdatenewmarkerpublisher');
            $mclient = $this->_request->getpost('ddupdatemarkerclient');
            $mdisplayunit = $this->_request->getpost('updatedisplay');
            $mpublish = $this->_request->getpost('hdnpublishupdatetime');
            $mdurationfrom = $this->_request->getpost('hdnupdatedurationstart');
            $mdurationto = $this->_request->getpost('hdnupdatedurationend');
            $musage = $this->_request->getpost('txtupdateusage');
            $mstatus = $this->_request->getpost('txtmstatus');
            
            
            
            //code start for vuforia webservices uploaded  part1
            
            $upmarkeruploadmarker = $this->_request->getpost('marker_updateimage');  //var_dump($upmarkeruploadmarker);
            $updatemarkerimageuploder = $this->_request->getpost('old_img1');
            $upmarkerwidth = $this->_request->getpost('txtmarkerwidth');
            $mimage = $_FILES['marker_updateimage']['name'];
            //$mimage1 = $_FILES['old_img1']['name'];
            
            
            
            //code end for vuforia webservices uploaded part1
            
            
            if($mstatus == "0"){
                $mupdatestatus = "1";
            }
            else if($mstatus == ""){
                $mupdatestatus = "0";
            }
            else if($mstatus == "1"){
                $mupdatestatus = "1";
            }
            
            $updateeditordesc = $this->_request->getpost('updesceditor');
            $updateeditorlink = $this->_request->getpost('txtuphypeditor');
            $updateuploadimage = $this->_request->getpost('imageupdate_upload');
            $updatecapturelink = $this->_request->getpost('txtupcapturelink');
            $updatevideolink = $this->_request->getpost('txtupvideolink1');
            $upadtescreenlink = $this->_request->getpost('txtupvideolink2');
            $updatevideodesc = $this->_request->getpost('updescvideo');
            $updatemarkerimage = $this->_request->getpost('old_img1');
            $updatemarkerimageuploader = $updatemarkerimage;
            
            if($lastimg != ""){
             $deleteresourcewhere = 'mr_id='.$lastimg;
             $modelmarker->delete('ar_markerresource',$deleteresourcewhere);
              }
            
            
            
            $mimage = $_FILES["marker_updateimage"]["name"];  
            if($mimage){
                $filename2  = $_FILES['marker_updateimage']['name'];
                $mimname2 = explode('.',$filename2);
                $filename3 = strtolower($mimname2[1]);
            
                if(!in_array($filename3,$this->allowedImgExtention)){//checking files type code start
                    $this->_helper->flashMessenger->addMessage(array(
                            'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/updatemarker');
                }//checking file types code end        
            }
            $mimage1 = $_FILES["old_img1"]["name"];
            if($mimage1){
              $filename5  = $_FILES['old_img1']['name'];
              $mimname6 = explode('.',$filename5);
              $filename7 = strtolower($mimname6[1]);
               if(!in_array($filename7,$this->allowedImgExtention)){//checking files type code start
                    $this->_helper->flashMessenger->addMessage(array(
                            'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/updatemarker');
                }//checking file types code end    
            }
            
            $image = $_FILES["imageupdate_upload"]["name"];  
               if($image){
                   $filename = $_FILES['imageupdate_upload']['name'];
                $imname = explode('.',$filename);
                $filename1 = strtolower($imname[1]);
                if(!in_array($filename1,$this->allowedImgExtention)){//checking upload file types code start
                    $this->_helper->flashMessenger->addMessage(array(
                        'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/updatemarker');
                } //checking upload file types code end
            }
        
        $imageuploadpath = Zend_Registry::get('config')->constants->image_uploadpath;  
        $pathdirectory = $imageuploadpath . $mpublisher . "/" . $mclient . "/" . $markerid;    
      
        $resourcesdir = Zend_Registry::get('config')->constants->resourcespath;
        $myfiledir = $pathdirectory . "/" . $resourcesdir;
            
            $upmarkerresourceid  = "0";
            $ids = $this->_request->getParam('ids');
                  $this->view->grid= $ids;
                  $upimage = $_FILES["imageupdate_upload"]["name"];
                   if($upimage){
                       $upfilename = $_FILES['imageupdate_upload']['name'];
                        $upimname = explode('.',$upfilename);
                        $upfilename1 = strtolower($upimname[1]);
                        if (($upfilename1 != "jpg") && ($upfilename1 != "jpeg") && ($upfilename1 != "png") && ($upfilename1 != "gif"))
                        {
                          echo "<script type='text/javascript'>alert('Unknown extension!Valid file types are .jpg, .png, .gif');</script>";
                        }
                         else{
                              $upimage_name = $upfilename;
                              $upimname1    = explode('.',$upimage_name);
                              $upextindex   = (count($upimname1)-1);
                              $upext        = strtolower($upimname1[$upextindex]);
                              $resoureimgname =  $mpublisher . $mclient . $markerid;
                                $destination = $myfiledir.'/'.$resoureimgname.'.'.$upext;  
                            
                              if(move_uploaded_file($_FILES['imageupdate_upload']['tmp_name'], $destination))
                              {
                                 $newmarkerresourcedata = array();
                                 $mr_type = "Image";
                                 $newmarkerresourcedata['mrname']        = $resoureimgname;
                                 $newmarkerresourcedata['mrextention']         = $upext;
                                 $newmarkerresourcedata['mrtype'] = $mdisplayunit;
                                 $newmarkerresourcedata['mrlastmodified']=date('Y-m-d H:i:s');
                                 $upmarkerresourceid = $modelmarker->insertanywhere('ar_markerresource', $newmarkerresourcedata);
                              }
                              
                         }
                    }

            $markerupdatedata=array();
            $markerupdatedata['marker_id'] = $markerid;
            $markerupdatedata['p_id'] = $mpublisher;
            $markerupdatedata['ar_clients_client_id'] = $mclient;
            $markerupdatedata['mname'] = $markername;
            
            if($mimage == ""){
                $markerupdatedata['mimgname'] = $updatemarkerimage; //marker image name newly added
            }
            else{
                $markerupdatedata['mimgname'] = $mimage;
            }
            $markerupdatedata['mimgwidth'] = $upmarkerwidth; //marker image width newly added
            $markerupdatedata['mdescription'] = $markerdescription;
            $markerupdatedata['ar_markerresource_mr_id'] = $upmarkerresourceid;
            $markerupdatedata['mdisplayunit'] = $mdisplayunit;
            $markerupdatedata['mpublishingdate'] = $mpublish;
            $markerupdatedata['mdurationfrom'] = $mdurationfrom;
            $markerupdatedata['mdurationto'] = $mdurationto;
            $markerupdatedata['musagecount'] = $musage;
            $markerupdatedata['mstatus'] = $mupdatestatus;
            $markerupdatedata['mmodifiedby'] = $userid;
            $markerwhere=' marker_id='.$markerid;
            $modelmarker->updateanywhere('ar_marker',$markerupdatedata,$markerwhere);
        
            $deldisplaymarkerwherenew = 'marker_id='.$markerid;
            $modelmarker->delete('ar_markerdisplay',$deldisplaymarkerwherenew);
            
            $upmarkerdisplaydata=array();
            $upmarkerdisplaydata['marker_id'] = $markerid;
            $upmarkerdisplaydata['mdisplayunit'] =  $mdisplayunit;
            
            if($mdisplayunit == 1){
                $indexdisplay = "message";
                $indexvalue = $updateeditordesc;
                $upmarkerdisplaydata['fieldindex'] = $indexdisplay;
                $upmarkerdisplaydata['fieldvalue'] =  $indexvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                $linktext = "linktext";
                $linkvalue = $updateeditorlink;
                $upmarkerdisplaydata['fieldindex'] = $linktext;
                $upmarkerdisplaydata['fieldvalue'] =  $linkvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                
                $metadata2 = $updateeditordesc ."|".$updateeditorlink;  
                $metadata2 = "Text = " . $metadata2;
            }
            else if($mdisplayunit == 2){
                  
                $imgindex = "uploadimage"; //var_dump($imgindex);
                $imgvalue = $updateuploadimage; //var_dump($imgvalue);
                $upmarkerdisplaydata['fieldindex'] = $imgindex;
                $upmarkerdisplaydata['fieldvalue'] = $upimage_name;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
            
                $cameralink = "capturelink";
                $cameraval = $updatecapturelink;
                $upmarkerdisplaydata['fieldindex'] = $cameralink;
                $upmarkerdisplaydata['fieldvalue'] = $cameraval;  
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                
                $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
                $updateuploadimage = "Image = "."http://". $_SERVER['HTTP_HOST'] . $baseUrl ."/". $destination;
                $metadata2 = $updateuploadimage . "|" . $updatecapturelink;
            }  
            else if($mdisplayunit == 3){
                $videodisplay = "videolink";
                $videovalue = $updatevideolink;
                $upmarkerdisplaydata['fieldindex'] = $videodisplay;
                $upmarkerdisplaydata['fieldvalue'] =  $videovalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                $screendisplay = "screenlink";
                $screenvalue = $upadtescreenlink;
                $upmarkerdisplaydata['fieldindex'] = $screendisplay;
                $upmarkerdisplaydata['fieldvalue'] =  $screenvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                $videodescdisplay = "videodescription";
                $videodescvalue = $updatevideodesc;
                $upmarkerdisplaydata['fieldindex'] = $videodescdisplay;
                $upmarkerdisplaydata['fieldvalue'] =  $videodescvalue;
                $modelmarker->insertanywhere('ar_markerdisplay',$upmarkerdisplaydata);
                
                $metadata2 = $updatevideolink . "|" . $upadtescreenlink . "|" . $updatevideodesc;
                $metadata2 = "Video = " . "http://". $_SERVER['HTTP_HOST'] . $baseUrl ."/". $metadata2;
            }
    
    
    //code start for vuforia webservices part 2
            
            $markerimgname = $mpublisher . $mclient . $markerid;
            
            $myfile = $myfiledir ."/". $markerimgname . "txt" . ".txt";
            
            $file_handle = fopen($myfile, "w");
            $file_contents = $metadata2;
            fwrite($file_handle, $file_contents);
            fclose($file_handle);
            
            
            // code end for vuforia webservices part 2
            
            
            //code starting for  marker image update
            
                $mimage = $_FILES["marker_updateimage"]["name"];
                /*$mimageupdate =  $_FILES["hdnmarkerimage"]["name"];
                */
            if($mimage){
                $filename2 = $_FILES['marker_updateimage']['name'];
                $mimname2 = explode('.',$filename2);
                $filename3 = strtolower($mimname2[1]);
            
                if(!in_array($filename3,$this->allowedImgExtention)){//checking files type code start
                    $this->_helper->flashMessenger->addMessage(array(
                            'failed' => $this->msgWrongImgFormat
                    ));
                    $this->_redirect('markermanage/updatemarker');
                    header("Refresh: 0;");    
                }//checking file types code end        
                else
                {
                    $mimgname    = $_FILES["marker_updateimage"]["name"];
                    $mimname1    = explode('.',$mimgname);
                    $mextindex   = (count($mimname1)-1);
                    $mext        = strtolower($mimname1[$mextindex]);
              
                    $mdestination = $pathdirectory;
                    $markerimagename = "marker" . $mpublisher . $mclient . $markerid;
                    $mdestination1 =  $mdestination . '/'. $markerimagename . '.' . $mext ;
                        
                    move_uploaded_file($_FILES["marker_updateimage"]["tmp_name"],$mdestination1);
                        
                    $getvuforiadetails = $modelmarker->getvuforiadetailsbyid($markerid);//get vuforia details from db
                   //code start for getting vuforia target id and other details
                   foreach($getvuforiadetails as $getvuforiadetailsval){
                       $vuforiaalldetails = $getvuforiadetailsval->vuforia_details;
                   }
                   
                   $vuforiadetails = explode("|",$vuforiaalldetails);
                   $vuforiaresult = $vuforiadetails[0];
                   $vuforiatransid = $vuforiadetails[1];
                   $vuforiatargetid = $vuforiadetails[2];
                   
                   $vwstargetid = explode(":",$vuforiatargetid);
                   $vwstarget_id = $vwstargetid[1];
                   //code end for getting vuforia target id and other details
                   
                    $target_id = $vwstarget_id;
                    $metadata_url = $myfile;  
                    $img_url12 = $mdestination1;
                    $vwsupdate = $this->UpdateData($img_url12, $metadata_url, $target_id,$upmarkerwidth,$markerimgname);
                    
                    $this->_helper->flashMessenger->addMessage(array('success'=>"The values are successfully updated"));
                    header("Refresh: 0;");
                }
            }//if($mimage)
            //working with vuforia webservices code end
            //code end for marker image update
        }
        
        
        $this->view->currentmarkerid = $markerid;
        $imgpathclientid = $modelmarker->getclientid($markerid);
        foreach($imgpathclientid as $imgpathclientidval){
            $imagepathcid = $imgpathclientidval->ar_clients_client_id;
            $markerimgext = $imgpathclientidval->mimgname;
        }
        $this->view->imagpathcid = $imagepathcid;
        $this->view->markerimagext = $markerimgext;
        $imgpathpid = $modelmarker->getpublisherid($imagepathcid);
        foreach($imgpathpid as $imgpathpidval){
            $imagepathpid = $imgpathpidval->ar_publishers_pid;
        }
        $this->view->imagepathpid = $imagepathpid;
        
        
    }//updatemarkerAction
    public function termsandconditionsAction(){
        $ns = new Zend_Session_Namespace('someaction');
        $users=$ns->data;
        $layout = Zend_Layout::getMvcInstance();
        $layout->setLayout('layout');
        foreach($users  as $userstypeid){
             $this->view->userstype = $userstypeid;
        }
    }
    public function deletemarkerAction(){
           $modelmarker = new Application_Model_DbTable_Markers();
        $this->_helper->layout->disableLayout();
        $markerid = $this->_getParam('delmarker_id');
        
        $targetId  = "698f5cfc6c9e492f8430541537f53f7d";
        $requestPath     = "/targets/";
        
        $this->DeleteTarget($requestPath,$targetId);
        
        $resourceid = $modelmarker->getmarkerresourceid($markerid);
        $lastimg = $resourceid[0]->ar_markerresource_mr_id;
          
        if($lastimg != ""){
            $deleteresourcewhere = 'mr_id='.$lastimg;
            //$modelmarker->delete('ar_markerresource',$deleteresourcewhere);
         }
          
        $delmarkerwhere =' marker_id='.$markerid;
        //$modelmarker->delete('ar_marker',$delmarkerwhere);
        
        $deldisplaymarkerwhere = 'marker_id='.$markerid;
        //$modelmarker->delete('ar_markerdisplay',$deldisplaymarkerwhere);
        
        $this->_redirect('/markermanage/index');
   }//deletemarkerAction()
   
    public function InsData($newmarkerwidth,$markerimgname,$metadata2,$myfile,$mdestination1){
        $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
        $vuforia_targetpath = Zend_Registry::get('config')->constants->vuforiatargetpath;
        $img_url = $mdestination1;
        $b64_img = file_get_contents($img_url);
        $image = base64_encode($b64_img);
        $txtfile = $myfile;
        $txtfile1 = file_get_contents($txtfile);
        $txtfile2 = base64_encode($txtfile1);
        $arr = array("name"=>$markerimgname,"width"=>$newmarkerwidth,"image"=>$image , "active_flag" => 1,"application_metadata"=>$txtfile2);
        $content = json_encode($arr);
        $credentials = $this->createSignature("/targets", "POST", "application/json", $content);
        return $this->postData($credentials, $vuforia_targetpath, $content);
        
    }
    
    public function postData($credentials, $target, $data){
        $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
        $vuforia_dateformat = Zend_Registry::get('config')->constants->vuforiadateformat;
        $date = new DateTime("now", new DateTimeZone("GMT"));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $target);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_POST, TRUE);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Date: ' .$date->format($vuforia_dateformat). " GMT", 'Content-Type: application/json', 'Authorization: VWS ' .$credentials));
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $json = curl_exec($ch);
        curl_close($ch);
        return $json;
    }//postData($credentials, $target, $data)
    
    public function createSignature($requestPath, $postType = "GET", $contentType = "", $content = ""){
        $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
        $serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
        $serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
        $vuforia_dateformat1 = Zend_Registry::get('config')->constants->vuforiadateformat;
        $serveraccesskey = $serveraccess_key;
        $serversecretkey = $serversecret_key;
        $contentMD5 = md5($content);
        $date = new DateTime("now", new DateTimeZone("GMT"));
        $stringToSign = $postType . "\n" . $contentMD5 . "\n" . $contentType . "\n" . $date->format($vuforia_dateformat1) . " GMT\n" . $requestPath;
        $signature = $this->hexToBase64(hash_hmac('sha1', $stringToSign, $serversecretkey));
        $credentials = $serveraccesskey.":".$signature;
        return $credentials;
    }//createSignature()
    
    public function hexToBase64($hex){
        $return = '';
        foreach(str_split($hex, 2) as $pair){
            $return .= chr(hexdec($pair));
        }
        return base64_encode($return);
    }//hexToBase64($hex)
    
    
    public function UpdateData($img_url12, $metadata_url, $target_id,$upmarkerwidth,$markerimgname){
        $b64_img = file_get_contents($img_url12);
        $image = base64_encode($b64_img);
        $getmetadata = file_get_contents($metadata_url);
        $metadata = base64_encode($getmetadata);
        $arr = array("name"=>$markerimgname,"width"=>$upmarkerwidth,"image"=>$image , "active_flag" => 1,"application_metadata"=>$metadata);
        $content = json_encode($arr);
        $credentials = $this->createSignature("/targets/$target_id", "PUT", "application/json", $content);
        $target = "https://vws.vuforia.com/targets/$target_id";
        return $this->updateTarget($credentials, $target, $content);
        
    } //UpData($img_url, $metadata_url, $target_id)
    
    public function updateTarget($credentials, $target, $data){
        $date = new DateTime("now", new DateTimeZone("GMT"));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $target);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Date: ' .$date->format("D, d M Y H:i:s"). " GMT", 'Content-Type: application/json', 'Authorization: VWS ' .$credentials));
        $json = curl_exec($ch);
        curl_close($ch);
        return $json;
  } //updateTarget($credentials, $target, $data)
 

   /* public function getDeleteID($TargetID){
        $credentials = createSignature("https://vws.vuforia.com/targets/".$TargetID,"DELETE"); var_dump($credentials);die;
        return $this->delData($credentials, "https://vws.vuforia.com/targets/".$TargetID,$TargetID);
        
        
    }

    public function delData($credentials, $target ,$TargetID){
        $date = new DateTime("now", new DateTimeZone("GMT"));
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $target);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_HEADER, true);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        $t = curl_setopt($ch, CURLOPT_HTTPHEADER, array("DELETE https://vws.vuforia.com/targets/targets/".$TargetID." HTTP/1.1","Host: vws.vuforia.com",'Authorization: VWS ' .$credentials,'DATE: '.$date->format("D, d M Y H:i:s") . ' GMT'));
        die($t);
        $page = curl_exec($ch);
        curl_close($ch);
        return $page;
        
    }*/
    
    function DeleteTarget($requestPath,$targetId){

        $requestPath = $requestPath . $targetId;
        
        $this->execDeleteTarget();

    }

    public function execDeleteTarget($requestPath){

        $url = "https://vws.vuforia.com";
        $request = new HTTP_Request2();
        $request->setMethod( HTTP_Request2::METHOD_DELETE );
        
        $request->setConfig(array(
                'ssl_verify_peer' => false
        ));

        $request->setURL( $url . $requestPath );

        // Define the Date and Authentication headers
        $this->setHeaders($request);

        try {

            $response = $this->request->send();

            if (200 == $response->getStatus()) {
                echo $response->getBody();
            } else {
                echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
                        $response->getReasonPhrase(). ' ' . $response->getBody();
            }
        } catch (HTTP_Request2_Exception $e) {
            echo 'Error: ' . $e->getMessage();
        }

    }

    private function setHeaders($request){
        $serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
        $serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
        $sb =     new SignatureBuilder();
        $date = new DateTime("now", new DateTimeZone("GMT"));

        // Define the Date field using the proper GMT format
        $this->request->setHeader('Date', $date->format("D, d M Y H:i:s") . " GMT" );
        // Generate the Auth field value by concatenating the public server access key w/ the private query signature for this request
        $this->request->setHeader("Authorization" , "VWS " . $serveraccess_key . ":" . $sb->tmsSignature( $request , $serversecret_key ));

    }
    
    public function tmsSignature( $request , $secret_key ){
        
        $serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
        $serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
        
        $request = new HTTP_Request2();
        $request->setMethod( HTTP_Request2::METHOD_DELETE );
        
        $method = $request->getMethod();
        // The HTTP Header fields are used to authenticate the request
        $requestHeaders = $request->getHeaders();
        // note that header names are converted to lower case
        $dateValue = $requestHeaders['date'];
        
        $requestPath = $request->getURL()->getPath();
        
        // Not all requests will define a content-type
        if( isset( $requestHeaders['content-type'] ))
            $this->contentType = $requestHeaders['content-type'];
    
        if ( $method == 'GET' || $method == 'DELETE' ) {
            // Do nothing because the strings are already set correctly
        } else if ( $method == 'POST' || $method == 'PUT' ) {
            // If this is a POST or PUT the request should have a request body
            $this->hexDigest = md5( $request->getBody() , false );
            
        } else {
            print("ERROR: Invalid content type passed to Sig Builder");
        }
        

        $toDigest = $method . "\n" . $this->hexDigest . "\n" . $this->contentType . "\n" . $dateValue . "\n" . $requestPath ;

        echo $toDigest;
        
        $shaHashed = "";
        
        try {
            // the SHA1 hash needs to be transformed from hexidecimal to Base64
            $shaHashed = $this->shexToBase64( hash_hmac("sha1", $toDigest , $serversecret_key) );
            
        } catch ( Exception $e) {
            $e->getMessage();
        }

        return $shaHashed;    
    }
    
    private function shexToBase64($hex){
        $return = "";
        foreach(str_split($hex, 2) as $pair){
            $return .= chr(hexdec($pair));
        }
        return base64_encode($return);
    }
    
}
 

how to delete cloud target image and metadata package using php

May 27, 2013 - 10:22am #22

Can you post the code that you're using?

how to delete cloud target image and metadata package using php

May 27, 2013 - 10:20am #21

Hi masters,

       undertood my problems? or ...?

how to delete cloud target image and metadata package using php

May 27, 2013 - 9:55am #20

HI,

i installed the http/request2.php (reference-->http://pear.php.net/package/HTTP_Request2/)  , then in my class page i added the require_once 'HTTP/Request2.php'; then added corresponding delete target code and signature builder method code also,but i cant see any output just page display only the white screen, then when i remove 'HTTP/Request2.php'; this line of code the page work normally but delete function only not working me, when i added the 'HTTP/Request2.php'; this line of code the page cant run , totally i get the white screen only,  so how to solve this problem, could you please guide me. and then i am using windows xp operating system

 

how to delete cloud target image and metadata package using php

May 25, 2013 - 5:24am #19

HI,

i installed the http/request2.php (reference-->http://pear.php.net/package/HTTP_Request2/)  , then in my class page i added the require_once 'HTTP/Request2.php'; then added corresponding delete target code and signature builder method code also,but i cant see any output just page display only the white screen, then when i remove 'HTTP/Request2.php'; this line of code the page work normally but delete function only not working me, when i added the 'HTTP/Request2.php'; this line of code the page cant run , totally i get the white screen only,  so how to solve this problem, could you please guide me. and then i am using windows xp operating system.

how to delete cloud target image and metadata package using php

May 24, 2013 - 2:07pm #18

Hi,

        Thank you for your quick reply

how to delete cloud target image and metadata package using php

May 24, 2013 - 10:29am #17

HTTP_Request2 is a PHP PEAR extension, you can install it from the command line.

See: http://pear.php.net/package/HTTP_Request2/

how to delete cloud target image and metadata package using php

May 24, 2013 - 10:21am #16

hi masters,

                   i check it your vws samples of php code, but i have some doubt in that samples , how can i implement the http/request2.php file, please advise me,

how to delete cloud target image and metadata package using php

May 21, 2013 - 2:28am #15

please correct this code, what mistakes in this code.

 

 

public function createSignature($requestPath, $postType = "GET", $contentType = "", $content = ""){
        $baseUrl     = Zend_Controller_Front::getInstance()->getBaseUrl();
        $serveraccess_key = Zend_Registry::get('config')->constants->serveraccesskey;
        $serversecret_key = Zend_Registry::get('config')->constants->serversecretkey;
        $vuforia_dateformat1 = Zend_Registry::get('config')->constants->vuforiadateformat;
        $serveraccesskey = $serveraccess_key;
        $serversecretkey = $serversecret_key;
        $contentMD5 = md5($content);
        $date = new DateTime("now", new DateTimeZone("GMT"));
        $stringToSign = $postType . "\n" . $contentMD5 . "\n" . $contentType . "\n" . $date->format($vuforia_dateformat1) . " GMT\n" . $requestPath;
        $signature = $this->hexToBase64(hash_hmac('sha1', $stringToSign, $serversecretkey));
        $credentials = $serveraccesskey.":".$signature;
        return $credentials;
    }//createSignature()

 

function getDeleteID($TargetID){
    $credentials = $this->createSignature("/targets/".$TargetID,"DELETE");
    return $this->delData($credentials, "https://vws.vuforia.com/targets/",$TargetID);
}

function delData($credentials, $target ,$TargetID){
    $date = new DateTime("now", new DateTimeZone("GMT"));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("DELETE /targets/".$TargetID." HTTP/1.1","Host: vws.vuforia.com",'Authorization: VWS ' .$credentials,'DATE: '.$date->format("D, d M Y H:i:s") . ' GMT'));
    $page = curl_exec($ch);
    curl_close($ch);
    return $page;
}

 

 

how to delete cloud target image and metadata package using php

May 21, 2013 - 2:25am #14

i put inactivate the target by manually, and then use delete code but cant delete the target, then i i saw the vws sample php code , in that code have http/request2.php includes files but i need curl operation in php, because i already did the insert and update, the target using curl operation so i wish to do the delete process also using curl operation in php so could give some code using curl method. its very helpfull to all php developers

how to delete cloud target image and metadata package using php

May 20, 2013 - 2:54pm #13

DELETE is the correct operation, but you need to first deactivate your target w/ a PUT update if it is currently active.

Check out our new PHP samples in the VWS samples archive for examples - VWS Sample Code

how to delete cloud target image and metadata package using php

May 20, 2013 - 2:12pm #12

vuforia server can support the  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); this code? or not?

how to delete cloud target image and metadata package using php

May 20, 2013 - 11:03am #11

Hi masters,

                    thanks in advance

how to delete cloud target image and metadata package using php

May 20, 2013 - 9:35am #10

i already work with this below code for delete target image and meta data packages with the help of vuforia forums, but in this code have some mistakes so kindly help me for deleting the targets using curl method in php

 

function getDeleteID($TargetID){
    $credentials = createSignature("/targets/".$TargetID,"DELETE"); // /targetsID c01b73868ac0447395a12c01300b9400
    return delData($credentials, "https://vws.vuforia.com/targets/",$TargetID);
}

function delData($credentials, $target ,$TargetID){
    $date = new DateTime("now", new DateTimeZone("GMT"));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("DELETE /targets/".$TargetID." HTTP/1.1","Host: vws.vuforia.com",'Authorization: VWS ' .$credentials,'DATE: '.$date->format("D, d M Y H:i:s") . ' GMT'));
    $page = curl_exec($ch);
    curl_close($ch);
    return $page;
}

how to delete cloud target image and metadata package using php

May 20, 2013 - 9:31am #9

Hi masters,

                       i refer your url and files for deleting the targets but i already did the insert and update the cloud target  using curl method, so delete process i will do using curl method, so how to delete the target image and meta data package using curl method in php, please advise me , its very useful to me, thanks in advance

how to delete cloud target image and metadata package using php

May 18, 2013 - 2:25am #8

Hi master,

                    how to deactivate the cloud target for delete purpose, using php?

 

how to delete cloud target image and metadata package using php

May 17, 2013 - 1:48pm #7

hi masters

              Thanks for your reply

how to delete cloud target image and metadata package using php

May 17, 2013 - 1:30pm #6

Did you find the PHP samples? - try clearing your browser cache if you're only seeing the Java samples.

Also be sure to deactivate your target, then check its status to confirm it's deactivate before attempting to Delete a target. You can't Delete an active target.

how to delete cloud target image and metadata package using php

May 17, 2013 - 12:49pm #5

Hi masters

                      i used the below mentioned code but i cant done delete process, so could you please advise how to done delete process

 

function getDeleteID($TargetID){
    $credentials = createSignature("/targets/".$TargetID,"DELETE"); // /targetsID c01b73868ac0447395a12c01300b9400
    return delData($credentials, "https://vws.vuforia.com/targets/",$TargetID);
}

function delData($credentials, $target ,$TargetID){
    $date = new DateTime("now", new DateTimeZone("GMT"));
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $target);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("DELETE /targets/".$TargetID." HTTP/1.1","Host: vws.vuforia.com",'Authorization: VWS ' .$credentials,'DATE: '.$date->format("D, d M Y H:i:s") . ' GMT'));
    $page = curl_exec($ch);
    curl_close($ch);
    return $page;
}

 

how to delete cloud target image and metadata package using php

May 17, 2013 - 12:45pm #4

hi master

                  i going to visit that link , there have one zip file , i extracted there have java files only so dont have any of php files.......

how to delete cloud target image and metadata package using php

May 17, 2013 - 12:43pm #3

HI masters,

                       Thanks for your reply.

how to delete cloud target image and metadata package using php

May 17, 2013 - 12:24pm #2

Here you go - VWS Sample Code

Log in or register to post comments