private function importDataToImportFile(Gpf_Io_File $importFile)
 {
     $fileName = $importFile->getFileName() . "\n";
     $this->file->rewind();
     while ($line = $this->file->readLine()) {
         if ($line == $fileName) {
             $importFile->setFileMode("w");
             $this->importRowsToImportFile($importFile);
             break;
         }
     }
 }
Example #2
0
 public function read() {
     $file = new Gpf_Io_File($this->path);
     if (!$file->isExists()) {
         throw new Gpf_Exception("File '".$this->path."' does not exist");
     }
     $file->open();
     if (!$countries = $file->readLine()) {
         $countries = '';
     }
     $file->close();
     
     return $countries;
 }
Example #3
0
 public function readRawString()
 {
     $this->actualLineNumber++;
     return $this->file->readLine();
 }
    /**
     * check if the given URL matches some of the approved DirectLink URLs. 
     * If yes, return userID to whom this URL belongs 
     */
    public function checkDirectLinkMatch($url) {
    	$realFileName = $this->settingsDirectory . self::FILE_NAME;
    	if(!file_exists($realFileName)) {
    		throw new Gpf_Exception("DirectLink config file '$realFileName' does not exist!");
    	}

    	$url = str_replace('https://', '', $url);
    	$url = str_replace('http://', '', $url);
    	
    	$file = new Gpf_Io_File($realFileName);
    	$file->open();
        while (!$file->isEof()) {
        	$buffer = $file->readLine(4065);
        	if($buffer[0] == '<' || $buffer[0] == '?') {
        		continue;
        	}

        	$buffer = trim($buffer);
        	$arr = explode('|', $buffer, 7);
        	if(!is_array($arr) || count($arr) != 7) {
        		continue; 
        	}
        	
        	$userid = $arr[0];
        	$substring = $arr[1];
        	$clearUrl = $arr[2];
        	$preg = $arr[3];
        	$channelid = $arr[4];
        	$campaignid = $arr[5];
        	$bannerid = $arr[6];
        	if($this->isMatch($url, $substring, $preg)) {
        		$file->close();
        		return array('userid' => $userid, 
        					 'url' => $clearUrl,
        					 'channelid' => $channelid,
        					 'campaignid' => $campaignid,
        		     		 'bannerid' => $bannerid,
        		);
        	}
        }
        
        $file->close();
        return false;
    }