저자: David Grudl
상속: extends Object, implements ICacheStorage
예제 #1
0
 function getWeather($zip)
 {
     if (!$zip) {
         $zip = '02111';
     }
     $file = file_get_contents('http://rss.weather.com/weather/rss/local/' . $zip . '?cm_ven=LWO&cm_cat=rss&par=LWO_rss');
     $fs = new FileStorage($this->cache, FS_WRITE);
     $fs->write($file);
     $error = XMLParseFile($parser, $this->cache, 0);
     if ($error) {
         return $error;
     } else {
         $ret = array();
         foreach ($parser->structure as $k => $v) {
             if (is_string($v) && strstr($v, 'For more') !== FALSE) {
                 $v = str_replace('°', '°', $v);
                 if (strstr($v, '---') !== FALSE) {
                     $days = explode('---', $v);
                     $junk = array_pop($days);
                     $ret['forecast'] = $days;
                 } else {
                     $v = strip_tags($v);
                     $ret['current'] = substr($v, 0, strpos($v, 'For more') - 1);
                 }
             }
             if (count($ret) == 2) {
                 break;
             }
         }
     }
     return $ret;
 }
 public function addDataSource($FileName)
 {
     $Storage = new FileStorage($this->Patch, $this->Build);
     $TMPDataName = strtolower(str_replace('.dbc', '', str_replace('.db2', '', $FileName)));
     $Data = $Storage->getFileData('DBC', $FileName);
     $this->Prefix = $Data->Prefix;
     $ReaderName = strtoupper($Storage->FileData['fileExtension']) . 'Reader';
     $StorageReader = new $ReaderName($Storage->DBClientFiles, $Storage->FileData);
     $this->Tables['Data'][] = ['File' => $FileName, 'Table' => $Data->Prefix . $Data->FileData['tableName'], 'Format' => $Data->FileData['formatString'], 'Structure' => $Data->WorkingWith->Fields, 'Data' => $StorageReader->readFile()];
     unset($Storage);
 }
예제 #3
0
function createCSVFile($results)
{
    $csvPath = SettingsStorage::settings()["csv_file_locations"];
    $rand = Utils::generateRandomString(10) . '.csv';
    $results->asCSV(FileStorage::getPath($rand, $csvPath));
    return $rand;
}
예제 #4
0
 /**
  * Read file contents or return null if file has timed out
  *
  * @return mixed
  */
 public function read()
 {
     if ($this->isTimedOut()) {
         return null;
     }
     return parent::read();
 }
예제 #5
0
 public function __construct($dir)
 {
     if (self::$useDirectories === NULL) {
         // checks whether directory is writable
         $uniq = uniqid('_', TRUE);
         umask(00);
         if (!@mkdir("{$dir}/{$uniq}", 0777)) {
             // @ - is escalated to exception
             throw new InvalidStateException("Unable to write to directory '{$dir}'. Make this directory writable.");
         }
         // tests subdirectory mode
         self::$useDirectories = !ini_get('safe_mode');
         if (!self::$useDirectories && @file_put_contents("{$dir}/{$uniq}/_", '') !== FALSE) {
             // @ - error is expected
             self::$useDirectories = TRUE;
             unlink("{$dir}/{$uniq}/_");
         }
         rmdir("{$dir}/{$uniq}");
     }
     $this->dir = $dir;
     $this->useDirs = (bool) self::$useDirectories;
     if (mt_rand() / mt_getrandmax() < self::$gcProbability) {
         $this->clean(array());
     }
 }
예제 #6
0
 /**
  * 解析cvs文件
  *
  * @param
  *
  */
 public function csv($start, $end = null, $bundle = null, $type = 'access')
 {
     if (!$end) {
         $end = time();
     }
     if ($bundle) {
         $bundles = (array) $bundle;
     }
     $bundles[] = '#';
     $file = Storage::getStorageFile($type, date('Ymd', $start));
     $storage = new FileStorage($file, 'rb');
     while ($v = $storage->read()) {
         $this->parse($v, $start, $end, $bundles);
     }
     return $this->results;
 }
 /**
  * Get a copy of the actual record before we delete it to have it present in afterDelete
  *
  * @param boolean $cascade
  * @return boolean
  */
 public function beforeDelete($cascade = true)
 {
     if (!parent::beforeDelete($cascade)) {
         return false;
     }
     $Event = new CakeEvent('VideoStorage.beforeDelete', $this, array('record' => $this->record, 'storage' => $this->getStorageAdapter($this->record[$this->alias]['adapter'])));
     $this->getEventManager()->dispatch($Event);
     if ($Event->isStopped()) {
         return false;
     }
     return true;
 }
예제 #8
0
 /**
 	remove a name from the known users list.
 	@access public
 	**/
 function unreg()
 {
     $user = $this->getArg(1);
     if ($user) {
         $fs = new FileStorage(REG_USERS_FILE);
         $fs->read();
         $new = array();
         foreach ($fs->contents as $nick) {
             if ($nick != $user) {
                 $new[] = $nick;
             } else {
                 $found = true;
                 $this->pm($nick . " removed.");
             }
         }
         if (!$found) {
             $this->pm($nick . " wasnt in the list.");
         } else {
             $fs = new FileStorage(REG_USERS_FILE, FS_WRITE);
             $fs->write($new);
         }
     }
 }
예제 #9
0
 function setDataFile($to)
 {
     $this->dataFile = $to;
     if (file_exists($to)) {
         $fs = new FileStorage($to, FS_READ);
         $fs->read();
         foreach ($fs->contents as $line) {
             $data = explode('::', $line, 2);
             if ($data[1]) {
                 foreach (array_keys($this->qset->questions) as $k) {
                     $field = $this->qset->getQuestionAttribute($k, 'FIELD');
                     if ($data[0] == $field) {
                         if (!is_array($this->responses[$k])) {
                             $this->responses[$k] = array();
                         }
                         array_push($this->responses[$k], $data[1]);
                         $this->satisfied[$k] = true;
                     }
                 }
             }
         }
     }
 }
예제 #10
0
 /**
  * @return iCorporateDesign
  */
 public static function getCorporateDesign()
 {
     try {
         $FB = new FileBrowser();
         $FB->addDir(FileStorage::getFilesDir());
         $FB->addDir(Util::getRootPath() . "specifics");
         $T = $FB->getAsLabeledArray("iCorporateDesign", ".class.php");
         foreach ($T as $c) {
             $CD = new $c();
             break;
         }
         #throw new ClassNotFoundException();
     } catch (ClassNotFoundException $e) {
         $CD = new CorporateDesign();
     }
     return $CD;
 }
예제 #11
0
 public function setPath()
 {
     $bps = $this->getMyBPSData();
     #Aspect::registerOnetimePointCut("aboveList", "GUIFactory::getContainer", "FileManagerGUI::adviceAboveList");
     $rootDir = null;
     if ($bps != -1 and isset($bps["root"])) {
         $rootDir = preg_replace("/^([A-Z])%/", "\\1:", $bps["root"]);
     }
     #echo $rootDir;
     if ($rootDir != null) {
         $T = new HTMLTable(1);
         #$rel = "specifics/$rootDir";
         #$root = Util::getRootPath().$rel;
         $root = FileStorage::getFilesDir() . $rootDir;
         $_SESSION["BPS"]->setProperty("FileManagerGUI", "path", preg_replace("/^([A-Z]):/", "\\1%", $root));
         $_SESSION["BPS"]->setProperty("FileManagerGUI", "root", preg_replace("/^([A-Z]):/", "\\1%", $root));
         $F = new File($root);
         $F->loadMe();
         if ($F->getA() == null) {
             if (is_writable(FileStorage::getFilesDir())) {
                 mkdir($root);
             } else {
                 $B = new Button("", "stop");
                 $B->type("icon");
                 $B->style("float:left;margin-right:10px;");
                 $T->addRow($B . "Das Verzeichnis <code>{$rel}</code> existiert nicht und kann nicht automatisch angelegt werden, da keine Schreibberechtigung für <code>specifics</code> vorliegt.");
                 return $T;
             }
         }
     }
     $bps = $this->getMyBPSData();
     //go again
     #print_r($bps);
     if (isset($bps["path"]) and strpos($bps["path"], $bps["root"]) === false) {
         $bps["path"] = preg_replace("/^([A-Z])%/", "\\1:", $bps["root"]);
     }
     #$bps["root"];
     if ($bps != -1 and isset($bps["path"])) {
         $this->setDir(preg_replace("/^([A-Z])%/", "\\1:", $bps["path"]));
     }
     return true;
 }
예제 #12
0
 public function download()
 {
     $this->loadMe();
     if (strpos($this->getID(), realpath(FileStorage::getFilesDir())) === false) {
         return;
     }
     #if(strpos($this->ID, "specifics") === false) return;
     #if(strpos(strtolower($this->ID), ".pdf") !== false)
     #	header("Content-Type: application/pdf");
     #if(strpos(strtolower($this->ID), ".jpg") !== false)
     #	header("Content-Type: image/jpg");
     #if(strpos(strtolower($this->ID), ".png") !== false)
     #	header("Content-Type: image/png");
     #if(strpos(strtolower($this->ID), ".gif") !== false)
     #	header("Content-Type: image/gif");
     $ex = explode(DIRECTORY_SEPARATOR, $this->ID);
     header("Content-Type: " . $this->A("FileMimetype"));
     header("Content-Disposition: attachment; filename=\"" . $ex[count($ex) - 1] . "\"");
     header('Content-Length: ' . filesize($this->ID));
     readfile($this->ID);
 }
예제 #13
0
        continue;
    }
    $ek = Util::eK();
    if ($lastUser == $ek) {
        syslog(LOG_ERR, "Changing cloud failed! Test 1");
        throw new Exception("Changing cloud failed 1 ({$lastZugang} > {$zugang})!");
    }
    if ($lastDir == FileStorage::getFilesDir()) {
        syslog(LOG_ERR, "Changing cloud failed! Test 2");
        throw new Exception("Changing cloud failed 2 ({$lastZugang} > {$zugang})!");
    }
    $e->addClassPath(FileStorage::getFilesDir());
    try {
        syslog(LOG_INFO, "{$zugang} updating...");
        mRSSParser::update();
    } catch (FieldDoesNotExistException $ex) {
        echo $zugang . " " . get_class($ex) . ": " . $ex->getField() . "\n";
    } catch (Exception $ex) {
        echo $zugang . " " . get_class($ex) . ": " . $ex->getMessage() . "\n";
    }
    syslog(LOG_INFO, "{$zugang} finished");
    $lastZugang = $zugang;
    $lastUser = $ek;
    $lastDir = FileStorage::getFilesDir();
    DBStorage::disconnect();
}
$e->cleanUp();
flock($fp, LOCK_UN);
fclose($fp);
syslog(LOG_INFO, "Done.");
closelog();
예제 #14
0
 /**
  * Returns file name.
  * @param  string
  * @return string
  */
 protected function getCacheFile($key)
 {
     return parent::getCacheFile($key) . '.php';
 }
예제 #15
0
 protected function _getfontpath($file = null)
 {
     if (file_exists(Util::getRootPath() . "specifics/{$file}")) {
         return Util::getRootPath() . "specifics/{$file}";
     }
     if (file_exists(FileStorage::getFilesDir() . $file)) {
         return FileStorage::getFilesDir() . $file;
     }
     if (file_exists(Util::getRootPath() . "ubiquitous/Fonts/{$file}")) {
         return Util::getRootPath() . "ubiquitous/Fonts/{$file}";
     }
     if (file_exists(dirname(__FILE__) . '/font/' . $file)) {
         return dirname(__FILE__) . '/font/' . $file;
     }
     #if (!defined('FPDF_FONTPATH') && is_dir(dirname(__FILE__) . '/font'))
     #	define('FPDF_FONTPATH', dirname(__FILE__) . '/font/');
     #return defined('FPDF_FONTPATH') ? FPDF_FONTPATH : '';
 }
예제 #16
0
파일: cronjob.php 프로젝트: nemiah/fheME
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 3 of the License, or
 *  (at your option) any later version.
 *  lightAd is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  2007 - 2016, Rainer Furtmeier - Rainer@Furtmeier.IT
 */
if (isset($argv[1])) {
    $_GET["cloud"] = $argv[1];
}
if (isset($argv[2])) {
    $_SERVER["HTTP_HOST"] = $argv[2];
}
session_name("ExtConnOWM");
require_once realpath(dirname(__FILE__) . "/../../system/connect.php");
$absolutePathToPhynx = Util::getRootPath();
$e = new ExtConn($absolutePathToPhynx);
$e->addClassPath($absolutePathToPhynx . "ubiquitous/OWM");
$e->addClassPath($absolutePathToPhynx . "specifics");
$e->addClassPath(FileStorage::getFilesDir());
$e->useDefaultMySQLData();
$e->useUser();
#echo "<pre>";
mOpenWeatherMap::update();
$e->cleanUp();
#echo "</pre>";
예제 #17
0
<pre>
<?php 
require_once '../../Nette/loader.php';
/*use Nette\Debug;*/
set_time_limit(0);
function randomStr()
{
    $s = str_repeat('LaTrine', rand(100, 20000));
    return sha1($s, TRUE) . $s;
}
function checkStr($s)
{
    return substr($s, 0, 20) === sha1(substr($s, 20), TRUE);
}
define('COUNT_FILES', 3);
$storage = new FileStorage(dirname(__FILE__) . '/tmp');
// clear playground
for ($i = 0; $i <= COUNT_FILES; $i++) {
    $storage->write($i, randomStr(), array());
}
// test loop
echo "Testing...\n";
Debug::timer();
$hits = array('ok' => 0, 'notfound' => 0, 'error' => 0, 'cantwrite' => 0, 'cantdelete' => 0);
for ($counter = 0; $counter < 1000; $counter++) {
    // write
    $ok = $storage->write(rand(0, COUNT_FILES), randomStr(), array());
    if ($ok === FALSE) {
        $hits['cantwrite']++;
    }
    // remove
 /**
  * Constructs this MTimeProtectedFastFileStorage object.
  *
  * @param array $configuration
  *   An associated array, containing at least these keys (the rest are
  *   ignored):
  *   - directory: The directory where the files should be stored.
  *   - secret: A cryptographically hard to guess secret string.
  *   -bin. The storage bin. Multiple storage objects can be instantiated with
  *   the same configuration, but for different bins.
  */
 public function __construct(array $configuration)
 {
     parent::__construct($configuration);
     $this->secret = $configuration['secret'];
 }
예제 #19
0
 public function deletePoolFile($dir, $fileName)
 {
     unlink(FileStorage::getFilesDir() . "{$dir}/" . $fileName);
 }
예제 #20
0
 /**
  * @test
  *
  * @return null
  */
 public function shouldValueNotExists()
 {
     $storage = new FileStorage('/');
     $this->assertFalse($storage->exists("key"));
 }
예제 #21
0
 /**
 @access private
 @param string nick
 */
 function registered($u)
 {
     $fs = new FileStorage(REG_USERS_FILE);
     $fs->read();
     return in_array($u, $fs->contents);
 }
예제 #22
0
 /**
  * Returns file name.
  * @param  string
  * @return string
  */
 protected function getCacheFile($key)
 {
     return parent::getCacheFile(substr_replace($key, trim(strtr($this->hint, '\\/@', '.._'), '.') . '-', strpos($key, Cache::NAMESPACE_SEPARATOR) + 1, 0)) . '.php';
 }
예제 #23
0
 public static function stamp($args, $die = true)
 {
     #if(strtolower($args["P0"]) == "303005f7b4")
     #	die('{"status":"command", "action":"reload"}');
     if (!isset($_SESSION["BPS"])) {
         $_SESSION["BPS"] = new BackgroundPluginState();
     }
     addClassPath(Util::getRootPath() . "personalKartei/Zeiterfassung/");
     addClassPath(Util::getRootPath() . "personalKartei/Personal/");
     addClassPath(Util::getRootPath() . "personalKartei/ObjekteL/");
     #if(file_exists(Util::getRootPath()."personalKartei/Schichten/"))
     #	addClassPath(Util::getRootPath()."personalKartei/Schichten/");
     addClassPath(Util::getRootPath() . "open3A/Kategorien/");
     $CCP = new CCPage();
     $CCP->loadPlugin("personalKartei", "Schichten", true);
     $T = anyC::getFirst("ZETerminal", "ZETerminalID", $args["P1"]);
     if (!$T) {
         if ($die) {
             die('{"status":"error", "message":"Unbekanntes Terminal"}');
         } else {
             return;
         }
     }
     $CT = FileStorage::getFilesDir() . "ChipTrans.csv";
     if ($args["P3"] and $args["P4"] > 0) {
         $P = new Personal($args["P4"]);
         if (trim($P->A("PersonalChipNummer")) == "") {
             $P->changeA("PersonalChipNummer", trim(strtolower($args["P0"])));
             $P->saveMe();
         } else {
             file_put_contents($CT, "{$args['P4']}:" . trim(strtolower($args["P0"])) . "\n", FILE_APPEND);
         }
     }
     $A = new stdClass();
     $Date = new Datum();
     $Date->subDay();
     $Date->addDay();
     $A->ChipID = trim(strtolower($args["P0"]));
     $A->Date = $Date->time();
     $A->Time = Util::parseTime("de_DE", date("H:i", !isset($args["P5"]) ? time() : $args["P5"]));
     $A->Type = $args["P2"];
     $A->Mode = "";
     $A->TerminalID = $args["P1"];
     try {
         $ok = ZEData::addTime($A);
     } catch (Exception $e) {
         try {
             $hex = str_pad(trim(strtolower(dechex($args["P0"]))), 10, "0", STR_PAD_LEFT);
             $A->ChipID = $hex;
             $ok = ZEData::addTime($A);
         } catch (Exception $e) {
             try {
                 if (!$args["P3"]) {
                     throw new Exception("Chip unknown", 100);
                 }
                 if (!file_exists($CT)) {
                     file_put_contents($CT, "");
                 }
                 $trans = file_get_contents($CT);
                 $found = false;
                 foreach (explode("\n", $trans) as $line) {
                     $line = trim($line);
                     $ex = explode(":", $line);
                     if (trim(strtolower($ex[1])) != trim(strtolower($args["P0"]))) {
                         continue;
                     }
                     $P = new Personal($ex[0]);
                     $A->ChipID = $P->A("PersonalChipNummer");
                     $found = true;
                 }
                 if (!$found) {
                     throw new Exception("Learn", 200);
                 }
                 #if(!$found)
                 #	throw new Exception ("Chip unknown", 100);
                 $ok = ZEData::addTime($A);
             } catch (Exception $e) {
                 switch ($e->getCode()) {
                     case 100:
                         try {
                             $F = new Factory("ZETerminalFail");
                             $F->sA("ZETerminalFailTime", time());
                             $F->sA("ZETerminalFailData", json_encode($args));
                             $F->sA("ZETerminalFailZETerminalID", $args["P1"]);
                             $F->store();
                         } catch (Exception $e) {
                         }
                         if ($die) {
                             die('{"status":"error", "message":"Unbekannter Chip"}');
                         } else {
                             return;
                         }
                         break;
                     case 200:
                         $AC = anyC::get("Personal", "isDeleted", "0");
                         $AC->setFieldsV3(array("CONCAT(nachname, ' ', vorname) AS name"));
                         $AC->addAssocV3("TRIM(CONCAT(nachname, vorname))", "!=", "");
                         $AC->addOrderV3("nachname");
                         $AC->addOrderV3("vorname");
                         $knownPID = array();
                         $file = file($CT);
                         foreach ($file as $line) {
                             $line = trim($line);
                             $ex = explode(":", $line);
                             $knownPID[$ex[0]] = true;
                         }
                         $array = array();
                         while ($A = $AC->n()) {
                             if (isset($knownPID[$A->getID()])) {
                                 continue;
                             }
                             $subArray = array();
                             foreach ($A->getA() as $key => $value) {
                                 $subArray[$key] = $value;
                             }
                             $array[] = $subArray;
                         }
                         if ($die) {
                             die('{"status":"learn", "message":' . json_encode($array, defined("JSON_UNESCAPED_UNICODE") ? JSON_UNESCAPED_UNICODE : 0) . '}');
                         } else {
                             return;
                         }
                         break;
                     default:
                         try {
                             $F = new Factory("ZETerminalFail");
                             $F->sA("ZETerminalFailTime", time());
                             $F->sA("ZETerminalFailData", $e->getMessage());
                             $F->sA("ZETerminalFailZETerminalID", $args["P1"]);
                             $F->store();
                         } catch (Exception $e) {
                         }
                         if ($die) {
                             die('{"status":"error", "message":"' . $e->getMessage() . '"}');
                         } else {
                             return;
                         }
                 }
             }
         }
     }
     if ($args["P2"] == "G") {
         $AC = anyC::get("ZEData", "ZEDataPersonalID", $ok["Personal"]->getID());
         $AC->addAssocV3("ZEDataType", "=", "K");
         $AC->addAssocV3("ZEDataDate + ZEDataTime", ">", time() - 3600 * 13);
         $AC->addAssocV3("ZEDataDate + ZEDataTime", "<", time());
         $AC->addAssocV3("ZEDataIsDeleted", "=", "0");
         $AC->addOrderV3("ZEDataDate + ZEDataTime", "DESC");
         $AC->setLimitV3("1");
         $Kommen = $AC->getNextEntry();
         if ($Kommen != null) {
             $Gehen = $ok["ZEData"];
             $T = new ZETerminal($args["P1"]);
             $AC2 = anyC::get("PZuO", "ObjektLID", $T->A("ZETerminalObjektLID"));
             $AC2->addAssocV3("PersonalID", "=", $Kommen->A("ZEDataPersonalID"));
             $PZuO = $AC2->n();
             if ($PZuO !== null) {
                 $worked = $Gehen->A("ZEDataDate") + $Gehen->A("ZEDataTime") - ($Kommen->A("ZEDataDate") + $Kommen->A("ZEDataTime"));
                 $AZ = mZEArbeitsZeit::getArbeitszeiten($PZuO->getID(), time());
                 if (isset($AZ[0])) {
                     $hasTo = $AZ[0]->A("ZEArbeitsZeitEnde") - $AZ[0]->A("ZEArbeitsZeitStart");
                     if ($worked > 0 and $worked / $hasTo > 0.9) {
                         # AND $hasTo / $worked < 1.15){
                         $DE = $ok["ZEData"];
                         $DE->changeA("ZEDataPause", $AZ[0]->A("ZEArbeitsZeitMittag"));
                         $DE->saveMe(false, false);
                     }
                 }
             }
         }
     }
     #303046a1b7
     BPS::setProperty("ZEAuswertung", "objektLID", $T->A("ZETerminalObjektLID"));
     BPS::setProperty("ZEAuswertung", "personalID", $ok["Personal"]->getID());
     BPS::setProperty("ZEAuswertung", "month", date("Ym"));
     #$ZEA = new ZEAuswertung($A->ChipID);
     #$ZEA->debug = false;
     #$current = $ZEA->getContent();
     if ($die) {
         die('{"status":"OK", "message": "' . addslashes($ok["Personal"]->A("vorname") . " " . $ok["Personal"]->A("nachname")) . '", "details": ""}');
     } else {
         return;
     }
 }
예제 #24
0
 function __construct($id)
 {
     parent::__construct(BASEPATH . "/storage/comments_{$id}.txt", array('commenter', 'comment', 'date'));
 }
예제 #25
0
 function deleteSingle($table, $keyName, $id)
 {
     if (strpos($id, FileStorage::getFilesDir()) === false) {
         Red::errorD("Die Datei kann wegen fehlender Berechtigung nicht gelöscht werden!");
     }
     if (is_dir($id)) {
         $fp = opendir($id);
         $i = 0;
         while (($file = readdir($fp)) !== false) {
             if ($file == ".") {
                 continue;
             }
             if ($file == "..") {
                 continue;
             }
             $i++;
         }
         closedir($fp);
         if ($i > 0) {
             Red::errorD("Das Verzeichnis kann nicht gelöscht werden, es ist nicht leer!");
         }
         rmdir($id);
     } else {
         if (!is_writable($id)) {
             Red::errorD("Die Datei kann wegen fehlender Berechtigung nicht gelöscht werden!");
         }
         unlink($id);
     }
 }
예제 #26
0
 /**
 Writes bug items to file
 @access private
 @return void
 */
 function write()
 {
     $fs = new FileStorage($this->bugfile, FS_WRITE);
     $fs->write($this->encode($this->bugs));
 }
예제 #27
0
 function backgroudUpload($DeviceID, $filename)
 {
     $O = anyC::getFirst("fheOverview", "fheOverviewDeviceID", $DeviceID);
     $d = json_decode($O->A("fheOverviewDesktop"));
     $d->background = "OverviewBG." . Util::ext($filename);
     $C = $_SESSION["TempFiles"]->getCollector();
     $v = $C[0];
     file_put_contents(realpath(FileStorage::getFilesDir()) . "/OverviewBG." . Util::ext($filename), file_get_contents($v->A("filename")));
     unlink($v->A("filename"));
     unset($_SESSION["TempFiles"]);
     $O->changeA("fheOverviewDesktop", json_encode($d));
     $O->saveMe();
     echo OnEvent::script("\$j('#wrapper').css('background-image', 'url(./specifics/{$d->background})');");
 }
예제 #28
0
 public static function findImages($html)
 {
     $images = array();
     preg_match_all("/src\\=\"\\.\\.\\/interface\\/loadFrame\\.php\\?p=DBImage&amp;id=tinyMCEGUI:::([a-zA-Z0-9:\\.@_-]*)\"/ismU", $html, $matches);
     if (isset($matches[1])) {
         foreach ($matches[1] as $k => $imageUrl) {
             $images[] = FileStorage::getFilesDir() . str_replace(":::", "/", $imageUrl);
         }
     }
     $images = array_unique($images);
     return $images;
 }
예제 #29
0
 public function testMoveUploadedFile()
 {
     $storage = new FileStorage('somewhere');
     self::$functions->expects($this->at(0))->method('is_dir')->with($this->equalTo('somewhere'))->will($this->returnValue(true));
     self::$functions->expects($this->at(1))->method('move_uploaded_file')->with($this->equalTo('src_file'), $this->equalTo('somewhere' . DIRECTORY_SEPARATOR . 'mykey'))->will($this->returnValue(true));
     $this->assertTrue($storage->moveUploadedFile('src_file', 'mykey'));
 }
예제 #30
0
 public function previewPDF()
 {
     if (strpos($this->getID(), realpath(FileStorage::getFilesDir())) === false) {
         return;
     }
     header('Content-Type: application/pdf');
     header('Content-Length: ' . filesize($this->getID()));
     header('Content-disposition: inline; filename="' . basename($this->getID()) . '"');
     readfile($this->getID());
 }