Example #1
0
 /**
  * Delete a key from the cache
  *
  * @param string $key Identifier for the data
  * @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
  */
 public function delete($key)
 {
     if ($this->_setKey($key) === false || !$this->_init) {
         return false;
     }
     $path = $this->_File->getRealPath();
     $this->_File = null;
     return unlink($path);
 }
Example #2
0
 /**
  * Delete a key from the cache
  *
  * @param string $key Identifier for the data
  * @return boolean True if the value was successfully deleted, false if it didn't exist or couldn't be removed
  */
 public function delete($key)
 {
     if ($this->_setKey($key) === false || !$this->_init) {
         return false;
     }
     $path = $this->_File->getRealPath();
     $this->_File = null;
     //@codingStandardsIgnoreStart
     return @unlink($path);
     //@codingStandardsIgnoreEnd
 }
Example #3
0
/**
 * Delete all values from the cache
 *
 * @param boolean $check Optional - only delete expired cache items
 * @return boolean True if the cache was successfully cleared, false otherwise
 */
	public function clear($check) {
		if (!$this->_init) {
			return false;
		}
		$dir = dir($this->settings['path']);
		if ($check) {
			$now = time();
			$threshold = $now - $this->settings['duration'];
		}
		$prefixLength = strlen($this->settings['prefix']);
		while (($entry = $dir->read()) !== false) {
			if (substr($entry, 0, $prefixLength) !== $this->settings['prefix']) {
				continue;
			}
			if ($this->_setKey($entry) === false) {
				continue;
			}
			if ($check) {
				$mtime = $this->_File->getMTime();

				if ($mtime > $threshold) {
					continue;
				}

				$expires = (int)$this->_File->current();

				if ($expires > $now) {
					continue;
				}
			}
			$path = $this->_File->getRealPath();
			$this->_File = null;
			if (file_exists($path)) {
				unlink($path);
			}
		}
		$dir->close();
		return true;
	}
    function download($id)
    {
        $conditions = array('conditions' => array('Halaman.lesson_id' => $id), 'order' => array('Halaman.order' => 'ASC'));
        $isi = $this->Halaman->find('all', $conditions);
        $lesson = $this->Halaman->Lesson->read(null, $id);
        $this->kosongin(WWW_ROOT . DS . 'wow_book/files/*');
        $servername = $_SERVER['SERVER_NAME'];
        foreach ($isi as $item) {
            $source = $this->getContents($item['Halaman']['content'], 'http://' . $servername . '/skope/app/webroot/', '"');
            $count = $item['Halaman']['order'];
            $count = 0;
            foreach ($source as $row) {
                //echo $count.' '.$row."</br>";
                $row = str_replace("%20", " ", $row);
                mkdir(dirname(WWW_ROOT . "wow_book/files/" . $row), 0777, true);
                copy(WWW_ROOT . $row, WWW_ROOT . "wow_book/files/" . $row);
                $count++;
            }
            $source2 = $this->getContents($item['Halaman']['content'], 'src="/skope/files/image_mikroskop/', '"');
            foreach ($source2 as $row2) {
                //echo $count.' '.$row."</br>";
                $row2 = trim(str_replace("%20", " ", $row2));
                mkdir(dirname(WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2), 0777, true);
                copy(WWW_ROOT . "files/image_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2);
            }
            $source3 = $this->getContents($item['Halaman']['content'], 'src="/skope/files/video_mikroskop/', '"');
            foreach ($source3 as $row2) {
                //echo $count.' '.$row."</br>";
                $row2 = trim(str_replace("%20", " ", $row2));
                mkdir(dirname(WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2), 0777, true);
                copy(WWW_ROOT . "files/video_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2);
            }
            //var_dump($source);
        }
        $isifeature = '<!doctype html>
		<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
		<head>
			<meta charset="utf-8">
			<style>
			.js #features {
			margin-left: -12000px; width: 100%;
		}
		</style>
			<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
			   Remove this if you use the .htaccess -->
			<meta charset="utf-8">
			<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		    <!--  Mobile viewport optimized: j.mp/bplateviewport -->
			<meta name="viewport" content="width=device-width, initial-scale=1.0">
		    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
		    <meta name="description" content="">
			<title>SKOPE</title>
			
			<!-- Bootstrap core CSS -->
			<!-- CSS : implied media="all" -->
		    <link href="css/style.css" rel="stylesheet">
		    <link href="wow_book.css" rel="stylesheet">
		    <link href="css/preview.css" rel="stylesheet">
		    <link href="css/nanoscroller.css" rel="stylesheet">
		    <link href="css/component_lesson.css" rel="stylesheet">
			<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
		
		</head>
		<body>
			<div id="container">
			<div id="main">
				<img id="click_to_open" src="images/click_to_open.png" alt="click to open" />
		  		<div id="features">';
        $isifeature .= '<div class="feaature bk-book book-1 bk-bookdefault viewlesson">
				<div class="bk-front">
			        <div class="bk-cover">
			            <h2>
			                <span>' . $lesson['Lesson']['author'] . '</span>
			                <span style="text-transform:uppercase;">' . $lesson['Lesson']['title'] . '</span><br/>
			                <span style="font-size:0.5em;font-family:arial,helvetica;text-transform:lowercase;">' . $lesson['Lesson']['description'] . '</span>
			            </h2>
			        </div>
			        <div class="bk-cover-back"></div>
			    </div>
			</div>
				<div class="feature">
					<div class="contenttextbook nano">
						<div class="nano-content">
							<div class="contentareablock titlearea">
							
			                <span>' . $lesson['Lesson']['author'] . '</span>
			                <h1 style="text-transform:uppercase;font-size:43px;">' . $lesson['Lesson']['title'] . '</h1>
			                <span style="font-size:1em;font-family:arial,helvetica;text-transform:lowercase;">' . $lesson['Lesson']['description'] . '</span>
			            	<p>Kelas :  ' . $lesson['Lesson']['grade_id'] . '
			            	<br/>Pelajaran :  ' . $lesson['Pelajaran']['nama'] . '</p>
			            	<br/>
			            	<p style="font-weight:bold;">---- KELOMPOK ----</p>
			            	<p>' . nl2br($lesson['Lesson']['kelompok']) . '</p>
			            	
						</div>
						</div>
					</div>
					
				</div>


				<div class="feature">
					<div class="contenttextbook nano">
						<div class="nano-content">
							<div class="contentareablock titlearea">
							
			                
						</div>
						</div>
					</div>
					
				</div>';
        foreach ($isi as $item) {
            //$this->getContents($item['Halaman']['content'],'http://localhost/skope/app/webroot/','"')
            $item['Halaman']['content'] = str_replace("http://" . $servername . "/skope/app/webroot/", "files/", $item['Halaman']['content']);
            $item['Halaman']['content'] = str_replace("/skope/files/image_mikroskop/", "files/image_mikroskop/", $item['Halaman']['content']);
            $item['Halaman']['content'] = str_replace("/skope/files/video_mikroskop/", "files/video_mikroskop/", $item['Halaman']['content']);
            $isifeature .= '<div class="echo">
									<div class="contenttextbook nano">
										<div class="nano-content">
											<div class="contentareablock">
											<h2 style="font-size:37px;">' . $item['Halaman']['deskripsi_halaman'] . '</h2>
											 ' . $item['Halaman']['content'] . '
										</div>
										</div>
									</div>
									
								</div>';
        }
        $isifeature .= '</div><nav class="navigasiwow">
					<ul>
						<li><a id="first"     href="#" title="goto first page"   >First page</a></li>
						<li><a id="back"      href="#" title="go back one page"  >Back</a></li>
						<li><a id="next"      href="#" title="go foward one page">Next</a></li>
						<li><a id="last"      href="#" title="goto last page"    >last page</a></li>
						<li><a id="zoomin"    href="#" title="zoom in"           >Zoom In</a></li>
						<li><a id="zoomout"   href="#" title="zoom out"          >Zoom Out</a></li>
						<li><a id="slideshow" href="#" title="start slideshow"   >Slide Show</a></li>
						<li><a id="flipsound" href="#" title="flip sound on/off" >Flip sound</a></li>
					</ul>
				</nav>
				
				</div> <!--! end of #container -->
				<footer>
					
				</footer>
			</div>
				<script type="text/javascript" src="wow_book.min.js"></script>
				<script type="text/javascript" src="js/jquery.nanoscroller.min.js"></script>
			<style>
			.makecenter{
				position: absolute;
				display: inline-block;
				right: 0;
				width: 61px;
				padding: 5px 10px;
			}
			.makecenter > a {
				color: #000;
				background-color: transparent;
				border: 1px solid;
				margin: 2px;
			
			}
			</style>
			
				<script type="text/javascript" src="wow_conf.js"></script>
				<script type="text/javascript" src="js/plugins.js"></script>
				<script type="text/javascript" src="js/script.js"></script>
			
			</body>
			</html>';
        //var_dump($isifeature);exit();
        $path = WWW_ROOT . DS . 'wow_book/index.html';
        $file = new File($path, true, 0777);
        $file->open('w', true);
        $file->write($isifeature);
        $file->close();
        // Get real path for our folder
        $rootPath = realpath(WWW_ROOT . DS . 'wow_book');
        // Initialize archive object
        $zip = new ZipArchive();
        $zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
        // Create recursive directory iterator
        /** @var SplFileInfo[] $files */
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY);
        foreach ($files as $name => $file) {
            // Skip directories (they would be added automatically)
            if (!$file->isDir()) {
                // Get real and relative path for current file
                $filePath = $file->getRealPath();
                $relativePath = substr($filePath, strlen($rootPath) + 1);
                // Add current file to archive
                $zip->addFile($filePath, $relativePath);
            }
        }
        // Zip archive will be created only after closing object
        $zip->close();
        $this->layout = 'default_blank';
    }
    function download($id)
    {
        $conditions = array('conditions' => array('Halaman.lesson_id' => $id), 'order' => array('Halaman.order' => 'ASC'));
        $isi = $this->Halaman->find('all', $conditions);
        $lesson = $this->Halaman->Lesson->read(null, $id);
        $this->kosongin(WWW_ROOT . DS . 'wow_book/files/*');
        $servername = $_SERVER['SERVER_NAME'];
        //echo $_SERVER['DOCUMENT_ROOT'];
        $url = $_SERVER['REQUEST_URI'];
        //returns the current URL
        $parts = explode('/', $url);
        foreach ($isi as $item) {
            $source = $this->getContents($item['Halaman']['content'], 'http://' . $servername . '/' . $parts[1] . '/app/webroot/', '"');
            $count = $item['Halaman']['order'];
            $count = 0;
            foreach ($source as $row) {
                //echo $count.' '.$row."</br>";
                $row = str_replace("%20", " ", $row);
                mkdir(dirname(WWW_ROOT . "wow_book/files/" . $row), 0777, true);
                copy(WWW_ROOT . $row, WWW_ROOT . "wow_book/files/" . $row);
                $count++;
            }
            $source2 = $this->getContents($item['Halaman']['content'], 'src="/' . $parts[1] . '/source/SKOPE/image_mikroskop/', '"');
            foreach ($source2 as $row2) {
                //echo $count.' '.$row."</br>";
                $row2 = trim(str_replace("%20", " ", $row2));
                mkdir(dirname(WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2), 0777, true);
                copy(WWW_ROOT . "source/SKOPE/image_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/image_mikroskop/" . $row2);
            }
            $source3 = $this->getContents($item['Halaman']['content'], 'src="/' . $parts[1] . '/source/SKOPE/video_mikroskop/', '"');
            foreach ($source3 as $row2) {
                //echo $count.' '.$row."</br>";
                $row2 = trim(str_replace("%20", " ", $row2));
                mkdir(dirname(WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2), 0777, true);
                copy(WWW_ROOT . "source/SKOPE/video_mikroskop/" . $row2, WWW_ROOT . "wow_book/files/video_mikroskop/" . $row2);
            }
            //var_dump($source);
        }
        $isifeature = '
		<!doctype html>

		<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
		<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
		<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
		<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
		<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
		<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
		<head>
			<script>(function(H){H.className=H.className.replace(/\\bno-js\\b/,"js")})(document.documentElement)</script>
			<meta charset="utf-8">
			<style>
			.js #features {
			margin-left: -12000px; width: 100%;
		}
		#videocontent{
			width: 100%;
		}
		</style>
			<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
			   Remove this if you use the .htaccess -->
			<meta charset="utf-8">
			<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		    <!--  Mobile viewport optimized: j.mp/bplateviewport -->
			<meta name="viewport" content="width=device-width, initial-scale=1.0">
		    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
		    <meta name="description" content="">
			<link rel="icon" type="image/png" href="favicon.ico"/>
			<title>SKOPE</title>
			
			<!-- Bootstrap core CSS -->
		    <link href="/skope_kaltim/css/bootstrap.min.css" rel="stylesheet">
			<!-- CSS : implied media="all" -->
			<link rel="stylesheet" type="text/css" href="css/style.css" />	<link rel="stylesheet" type="text/css" href="wow_book.css" />	<link rel="stylesheet" type="text/css" href="css/preview.css" />	<link rel="stylesheet" type="text/css" href="css/nanoscroller.css" />	<link rel="stylesheet" type="text/css" href="css/component_lesson.css" />
			<script type="text/javascript" src="js/modernizr.custom.39460.js"></script>	<script type="text/javascript" src="js/jquery-2.1.4.min.js"></script>
			<script type="text/javascript" src="js/jwplayer.js"></script><script type="text/javascript">jwplayer.key="J0+IRhB3+LyO0fw2I+2qT2Df8HVdPabwmJVeDWFFoplmVxFF5uw6ZlnPNXo=";


		</script>

		</head>

		<body>
			<div id="videocontent">
				<div id="example_video_1">
				</div>
			</div>
			<div id="penelitiancontent">
			<div class="container-fluid">
			</div>
			<div id="container">
			<div id="main">
				<img id="click_to_open" src="images/click_to_open.png" alt="click to open" />
		  		<div id="features">';
        $isifeature .= '<div class="feaature bk-book book-1 bk-bookdefault viewlesson">
						<div class="bk-front">
					        <div class="bk-cover ' . $lesson['Lesson']['color'] . '">
					            <h2>
					                <span>' . $lesson['Lesson']['author'] . '</span>
					                <span style="text-transform:uppercase;">' . $lesson['Lesson']['title'] . '</span><br/>
					                <span style="font-size:0.5em;font-family:arial,helvetica;">' . $lesson['Lesson']['description'] . '</span>
					            </h2>
					        </div>
					        <div class="bk-cover-back"></div>
					    </div>
					</div>
						<div class="feature">
							<div class="contenttextbook nano">
								<div class="nano-content">
									<div class="contentareablock titlearea">
									
					                <!--<span>' . $lesson['Lesson']['author'] . '</span>-->	
					                <h1 style="text-transform:uppercase;font-size:43px;">' . $lesson['Lesson']['title'] . '</h1>
					                <span style="font-size:1em;font-family:arial,helvetica;margin-top:10px;display:block;">' . $lesson['Lesson']['description'] . '</span>
					            	<p style="margin-top:150px;display:block;font-weight:bold;font-size:1.1em;">' . $lesson['Pelajaran']['nama'] . ' - ' . $lesson['Grade']['details'] . '</p>
					            	<br/>
					            	<p style="font-weight:normal;margin-top:20px;display:block;">dibuat oleh:
					            	</p>
									<p style="margin-top:7px;display:block;">
					            	' . $lesson['Lesson']['author'] . '
					            	
					            	<br/>' . nl2br($lesson['Lesson']['kelompok']) . '</p>
					            	
								</div>
								</div>
							</div>
							
						</div>


						<div class="feature">
							<div class="contenttextbook nano">
								<div class="nano-content">
									<div class="contentareablock titlearea">
									<img src="images/smicro/poweredby.png">
					                
								</div>
								</div>
							</div>
							
						</div>';
        foreach ($isi as $item) {
            //$this->getContents($item['Halaman']['content'],'http://localhost/skope/app/webroot/','"')
            $item['Halaman']['content'] = str_replace("http://" . $servername . "/" . $parts[1] . "/app/webroot/", "files/", $item['Halaman']['content']);
            $item['Halaman']['content'] = str_replace("/" . $parts[1] . "/source/SKOPE/image_mikroskop/", "files/image_mikroskop/", $item['Halaman']['content']);
            $item['Halaman']['content'] = str_replace("/" . $parts[1] . "/source/SKOPE/video_mikroskop/", "files/video_mikroskop/", $item['Halaman']['content']);
            $isifeature .= '<div class="feature">
								<div class="contenttextbook nano">
									<div class="nano-content">
										<div class="contentareablock">
										<h2 style="font-size:33px;background-color:#66CAE8;color:#fff;padding:10px;margin-left:-10px;">' . $item['Halaman']['deskripsi_halaman'] . '</h2>
										' . $item['Halaman']['content'] . '
									</div>
									</div>
								</div>
								
							</div>';
        }
        $countpages = count($isi);
        if ($countpages % 2 == 0) {
            $isifeature .= '<div class="feature">
								<div class="bk-front">
							        <div class="bk-cover ' . $lesson['Lesson']['color'] . '">
							            <img style="margin-top:120px;" src="images/smicro/backcover.png">
							        </div>
							        <div class="bk-cover-back"></div>
							    </div>
							</div>';
        } elseif ($countpages == 0) {
            $isifeature .= '<div class="feature">
								<div class="contenttextbook nano">
									<div class="nano-content">
										<div class="contentareablock titlearea">
										
							            
									</div>
									</div>
								</div>
								
							</div>

							<div class="feature">

								<div class="bk-front">
							        <div class="bk-cover ' . $lesson['Lesson']['color'] . '">
							            <img style="margin-top:120px;" src="images/smicro/backcover.png">
							        </div>
							        <div class="bk-cover-back"></div>
							    </div>
								
								
							</div>';
        } else {
            $isifeature .= '<div class="feature">
					<div class="contenttextbook nano">
						<div class="nano-content">
							<div class="contentareablock titlearea">
							
				            
						</div>
						</div>
					</div>
					
				</div>

				<div class="feature">

					<div class="bk-front">
				        <div class="bk-cover ' . $lesson['Lesson']['color'] . '">
				            <img style="margin-top:120px;" src="<?php echo $this->webroot;?>art/smicro/backcover.png">
				        </div>
				        <div class="bk-cover-back"></div>
				    </div>
					
					
				</div>';
        }
        $isifeature .= '</div><!--! end of #feature --></div><nav class="navigasiwow">
					<ul>
						<li><a id="first"     href="#" title="goto first page"   >First page</a></li>
						<li><a id="back"      href="#" title="go back one page"  >Back</a></li>
						<li><a id="next"      href="#" title="go foward one page">Next</a></li>
						<li><a id="last"      href="#" title="goto last page"    >last page</a></li>
						<li><a id="zoomin"    href="#" title="zoom in"           >Zoom In</a></li>
						<li><a id="zoomout"   href="#" title="zoom out"          >Zoom Out</a></li>
						<li><a id="slideshow" href="#" title="start slideshow"   >Slide Show</a></li>
						<li><a id="flipsound" href="#" title="flip sound on/off" >Flip sound</a></li>
					</ul>
				</nav>
				
				</div> <!--! end of #container -->
				<footer>
					
				</footer>
			</div>
				<script type="text/javascript" src="wow_book.min.js"></script>
				<script type="text/javascript" src="js/jquery.nanoscroller.min.js"></script>
			<style>
			.makecenter{
				position: absolute;
				display: inline-block;
				right: 0;
				width: 61px;
				padding: 5px 10px;
			}
			.makecenter > a {
				color: #000;
				background-color: transparent;
				border: 1px solid;
				margin: 2px;
			
			}
			</style>
			<script type="text/javascript">
				$(document).ready(function() {
					$(".nano").nanoScroller();

					$("#features").wowBook({
						 height : 550
						,width  : 950
						,centeredWhenClosed : true
						,hardcovers : true
						,turnPageDuration : 1000
						,numberedPages : [1,-2]
						,controls : {
								zoomIn    : "#zoomin",
								zoomOut   : "#zoomout",
								next      : "#next",
								back      : "#back",
								first     : "#first",
								last      : "#last",
								slideShow : "#slideshow",
								flipSound : "#flipsound"
							}
					}).css({"display":"none", "margin":"auto"}).fadeIn(1000);

					$("#cover").click(function(){
						$.wowBook("#features").advance();
					});

				});
			</script>
				<script type="text/javascript" src="js/plugins.js"></script>
				<script type="text/javascript" src="js/script.js"></script>
				<script src="js/bootstrap.min.js"></script>
			    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
			    <script type="text/javascript">
			    var heightWindow = $( window ).height();
			    jwplayer("example_video_1").setup({
			          file: "opening/opening_skope.flv",
			          image: "opening/cover_opening_skope.png",
			          width: "100%",
			          height:heightWindow,
			          aspectratio: "12:5",
			          autostart:true,
			          onComplete: function() {
			          	alert("done");
			    		$("#videocontent").fadeOut();
				  	$("#penelitiancontent").fadeIn();
						}
				});
				jwplayer("example_video_1").onComplete(function() {
					$("#videocontent").fadeOut();
				}); 
			    </script>
			</body>
			</html>';
        //var_dump($isifeature);exit();
        $path = WWW_ROOT . DS . 'wow_book/index.html';
        $file = new File($path, true, 0777);
        $file->open('w', true);
        $file->write($isifeature);
        $file->close();
        // Get real path for our folder
        $rootPath = realpath(WWW_ROOT . DS . 'wow_book');
        // Initialize archive object
        $zip = new ZipArchive();
        $zip->open('file.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
        // Create recursive directory iterator
        /** @var SplFileInfo[] $files */
        $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY);
        foreach ($files as $name => $file) {
            // Skip directories (they would be added automatically)
            if (!$file->isDir()) {
                // Get real and relative path for current file
                $filePath = $file->getRealPath();
                $relativePath = substr($filePath, strlen($rootPath) + 1);
                // Add current file to archive
                $zip->addFile($filePath, $relativePath);
            }
        }
        // Zip archive will be created only after closing object
        $zip->close();
        //$pathbatch=WWW_ROOT.DS.'compiler.bat';
        //system("cmd /c ".$pathbatch);
        $this->layout = 'default_blank';
    }
Example #6
0
 public function scan($id)
 {
     $scanner = new ScanAssets();
     $file_id = (int) $id;
     $file = new File();
     $file->findFileById($file_id);
     $success = false;
     $icon = File::getIconFromMime($file->getMime());
     if ($scanner->scanFile($file->getId())) {
         $success = true;
     }
     if ($icon === false) {
         $icon = $file->getUrl();
     }
     if ($success) {
         // we need to reload the file because scanner might have updated fields
         // and our object is out of date
         $file->findFileById($file_id);
         // move file to S3
         try {
             File::s3Upload($file->getRealPath(), APP_ATTACHMENT_PATH . $file->getFileName(), true, $file->getTitle());
             $file->setUrl(APP_ATTACHMENT_URL . $file->getFileName());
             $file->save();
             // delete the physical file now it is in S3
             unlink($file->getRealPath());
         } catch (Exception $e) {
             $success = false;
             $error = 'There was a problem uploading your file';
             error_log(__FILE__ . ": Error uploading images to S3:\n{$e}");
         }
     }
     return $this->setOutput(array('success' => $success, 'error' => isset($error) ? $error : '', 'fileid' => $file->getId(), 'url' => $file->getUrl(), 'icon' => $icon));
 }
Example #7
0
 /**
  * Adds a file to the collection.
  *
  * @param string $path File location, may be absolute, relative or even phar.
  *
  * @return void
  */
 public function addFile($path)
 {
     foreach (glob($path) as $path) {
         $file = new File($path);
         $path = $file->getRealPath() ? $file->getRealPath() : $file->getPathname();
         $this[$path] = $file;
     }
 }
Example #8
0
 /**
  * Adds a file to the collection.
  *
  * @param string $path File location, may be absolute, relative or even phar.
  *
  * @return void
  */
 public function addFile($path)
 {
     $paths = $this->getGlobbedPaths($path);
     foreach ($paths as $path) {
         $file = new File($path);
         $path = $file->getRealPath() ? $file->getRealPath() : $file->getPathname();
         $this[$path] = $file;
     }
 }