function getDetails($array, $useHash, $realPath, $dirRoot, $urlPrefix) { foreach ($array as $file) { $finfo = finfo_open(FILEINFO_MIME_TYPE); $pathFile = str_replace($realPath, $dirRoot, realPath($file)); // remove last directory path from arguments. ex : /home/user/doc/file.txt to file.txt $realPathFile = str_replace($dirRoot . "/", "", $pathFile); // Exclude dir from list if (is_dir($file) == false) { $files[$realPathFile]['location'] = $realPathFile; $files[$realPathFile]['url'] = $urlPrefix . $realPathFile; $files[$realPathFile]['type'] = finfo_file($finfo, $file); $files[$realPathFile]['size'] = filesize($file); $files[$realPathFile]['last_modified'] = date("F d Y H:i:s", filemtime($file)); if ($useHash == true) { $files[$realPathFile]['md5'] = md5_file($file); $files[$realPathFile]['crc32'] = hash_file('crc32', $file); $files[$realPathFile]['sha1'] = hash_file('sha1', $file); $files[$realPathFile]['sha256'] = hash_file('sha256', $file); $files[$realPathFile]['sha512'] = hash_file('sha512', $file); } echo "Processing File " . $realPathFile . " ...\n"; } finfo_close($finfo); } return array('files' => $files); }
/** * @param \Slim\App $slimInstance * @param string|string[] $controllerDirs * @param string $cacheDir * @throws \Exception */ public function __construct(\Slim\App $slimInstance, $controllerDirs, $cacheDir, RouteParser $parser = null, DataGenerator $generator = null) { parent::__construct($parser, $generator); // We save current Slim instance self::$_slimInstance = $slimInstance; // We save controller dirs if (is_string($controllerDirs)) { $controllerDirs = [$controllerDirs]; } if (!is_array($controllerDirs)) { throw new \InvalidArgumentException('Controllers directory must be either string or array'); } $this->_controllerDirs = []; foreach ($controllerDirs as $d) { $realPath = realPath($d); if ($realPath !== false) { $this->_controllerDirs[] = $realPath; } } // We save the cache dir if (!is_dir($cacheDir)) { $result = @mkdir($cacheDir, 0777, true); if ($result === false) { throw new \RuntimeException('Can\'t create cache directory'); } } if (!is_writable($cacheDir)) { throw new \RuntimeException('Cache directory must be writable by web server'); } $this->_cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; $this->_generateRoutes(); }
/** * Build views in order to parse php files * * @param array $viewPaths * @param string $domain * @return bool * @throws FileCreationException */ public function compileViews(array $viewPaths, $domain) { // Check the output directory $targetDir = $this->storagePath . DIRECTORY_SEPARATOR . $this->storageContainer; if (!file_exists($targetDir)) { $this->createDirectory($targetDir); } // Domain separation $domainDir = $targetDir . DIRECTORY_SEPARATOR . $domain; $this->clearDirectory($domainDir); $this->createDirectory($domainDir); foreach ($viewPaths as $path) { $path = $this->basePath . DIRECTORY_SEPARATOR . $path; if (!($realPath = realPath($path))) { throw new Exceptions\DirectoryNotFoundException("Failed to resolve {$path}, please check that it exists"); } $fs = new \Illuminate\Filesystem\Filesystem($path); $files = $fs->allFiles($realPath); $compiler = new \Illuminate\View\Compilers\BladeCompiler($fs, $domainDir); foreach ($files as $file) { $filePath = $file->getRealPath(); $compiler->setPath($filePath); $contents = $compiler->compileString($fs->get($filePath)); $compiledPath = $compiler->getCompiledPath($compiler->getPath()); $fs->put($compiledPath . '.php', $contents); } } return true; }
/** * {@inheritdoc} */ public function load($filePath) { $yaml = new Parser(); $filePath = realPath($filePath); if (!$filePath) { throw new \InvalidArgumentException(sprintf('Constant File Does not Exist! %s', $filePath)); } return $yaml->parse(file_get_contents($filePath)); }
public function run($addonId, $path) { $addonModel = XenForo_Model::create('XenForo_Model_AddOn'); $this->printMessage('Importing ' . $addonId . ' from ' . realPath($path) . '...'); $print = 'importing addon.xml...'; $print .= str_repeat(' ', $this->_column - strlen($print)); $t = microtime(true); $m = memory_get_usage(true); $this->printMessage($print, false); $xml = new SimpleXMLElement($path . '/addon.xml', 0, true); $addOnData = array('addon_id' => (string) $xml['addon_id'], 'title' => (string) $xml['title'], 'version_string' => (string) $xml['version_string'], 'version_id' => (string) $xml['version_id'], 'install_callback_class' => (string) $xml['install_callback_class'], 'install_callback_method' => (string) $xml['install_callback_method'], 'uninstall_callback_class' => (string) $xml['uninstall_callback_class'], 'uninstall_callback_method' => (string) $xml['uninstall_callback_method'], 'url' => (string) $xml['url']); $version = file_get_contents($path . '/version.txt'); if ($version) { foreach ($addOnData as &$data) { $data = str_replace('{@revision}', $version, $data); } } $addOnData['version_id'] = (int) $addOnData['version_id']; $existingAddOn = $addonModel->verifyAddOnIsInstallable($addOnData, $addonModel->getAddonById($addonId) ? $addonId : false); $db = XenForo_Application::getDb(); XenForo_Db::beginTransaction($db); if ($addOnData['install_callback_class'] && $addOnData['install_callback_method']) { call_user_func(array($addOnData['install_callback_class'], $addOnData['install_callback_method']), $existingAddOn, $addOnData); } $addOnDw = XenForo_DataWriter::create('XenForo_DataWriter_AddOn'); if ($existingAddOn) { $addOnDw->setExistingData($existingAddOn, true); } $addOnDw->bulkSet($addOnData); $addOnDw->save(); $t = abs(microtime(true) - $t); $m = abs(memory_get_usage(true) - $m); $m = $m / 1024 / 1024; $this->printMessage('done (' . number_format($t, 2) . 'sec, ' . number_format($m, 2) . 'mb)'); $this->_importXml($addonId, $path . '/admin_navigation.xml', 'AdminNavigation'); $this->_importXml($addonId, $path . '/admin_permissions.xml', 'Admin', 'importAdminPermissionsAddOnXml'); $this->_importXml($addonId, $path . '/code_events.xml', 'CodeEvent', 'importEventsAddOnXml'); $this->_importXml($addonId, $path . '/code_event_listeners.xml', 'CodeEvent', 'importEventListenersAddOnXml'); $this->_importXml($addonId, $path . '/cron.xml', 'Cron', 'importCronEntriesAddOnXml'); $this->_importXml($addonId, $path . '/email_templates.xml', 'EmailTemplate'); $this->_importXml($addonId, $path . '/options.xml', 'Option'); $this->_importXml($addonId, $path . '/permissions.xml', 'Permission'); $this->_importXml($addonId, $path . '/route_prefixes.xml', 'RoutePrefix', 'importPrefixesAddOnXml'); $this->_importXml($addonId, $path . '/style_properties.xml', 'StyleProperty', 'importStylePropertyXml', array(0, $addonId)); $this->_importXml($addonId, $path . '/admin_style_properties.xml', 'StyleProperty', 'importStylePropertyXml', array(-1, $addonId)); foreach (array('templates/admin', 'templates/master', 'phrases') as $dir) { $this->_removeDirectory(XenForo_Application::getInstance()->getRootDir() . '/' . $dir . '/' . $addonId); } $this->_importXml($addonId, $path . '/templates.xml', 'Template'); $this->_importXml($addonId, $path . '/admin_templates.xml', 'AdminTemplate'); $this->_importXml($addonId, $path . '/phrases.xml', 'Phrase'); // TODO: bbcode XenForo_Db::commit($db); $this->printEmptyLine(); $this->manualRun('rebuild', false, false, array('caches' => 'addon')); }
public function getDestination($realPath = true) { $destination = $this->destination; if ($realPath) { $destination = realPath($destination); if (false === $destination) { throw new \RuntimeException("Invalid destination path ({$this->destination})"); } } return $destination; }
/** * Extracts the zip file $zipFile into the folder $folder. Some validation on content types may be given in $types. * @param str $zipFile The path to the zip file * @param str $folder The path of the folder to extract the zip to * @param str|array $types A string or an array containing either : * <ul><li>"*" (default behaviour) to extract any kind of contents</li> * <li>An array of the extensions that are allowed to be axtracted</li> * </ul> * @return ZipArchive The archive object */ public function extract($zipFile, $folder, $types = '*') { if ($types == '*' || $types == array('*') || empty($types)) { $allTypes = true; } else { $allTypes = false; } $symlinksFiles = array(); $zip = new ZipArchive(); if ($zip->open($zipFile)) { for ($i = 0; $i < $zip->numFiles; $i++) { $entry = $zip->getNameIndex($i); if (substr($entry, -1) == '/') { $isFolder = true; } else { $ext = array_pop(explode('.', $entry)); $isFolder = false; } if ($allTypes || $isFolder || in_array($ext, $types)) { // We verify if the file is a symlink $fileName = basename($entry); if ($fileName == self::SYMLINK_FILENAME) { // after the dezipping process, we will add the symlinks $symlinksFiles[] = $entry; } $zip->extractTo($folder, $entry); } } foreach ($symlinksFiles as $symlinksFile) { $symlinks = file($folder . '/' . $symlinksFile); foreach ($symlinks as $symlink) { list($source, $destination) = explode(' ', $symlink, 2); $this->helper->create_symLink($source, realPath(dirname($source) . '/' . $destination)); } //echo 'On a un symlink de '.$source.' vers '.$destination.'<br />'; } $zip->close(); } else { return false; } return $zip; }
public function fire(Factory $viewFactory) { //add config templates directory to view locations $viewFactory->addLocation(realpath(__DIR__ . '/ConfigMigrations/templates')); if (($destPath = $this->option('dest-path')) === null) { $destPath = 'config'; } if (($author = $this->argument('author')) === null) { throw new InvalidArgumentException('Missing author option'); } if (($sourceFilePath = $this->option('source-file')) === null) { $sourceFilePath = 'config/doctrine.php'; } $destPath = realpath($destPath); if (!is_dir($destPath)) { mkdir($destPath, 0777, true); } if (!is_writable($destPath)) { throw new InvalidArgumentException(sprintf("Configuration destination directory '<info>%s</info>' does not have write permissions.", $destPath)); } $destFilePath = $destPath . '/doctrine.generated.php'; $originalSourceFilePath = $sourceFilePath; $sourceFilePath = realPath($sourceFilePath); if (!file_exists($sourceFilePath)) { throw new InvalidArgumentException(sprintf("Source file at path '<info>%s</info>' does not exist.", $originalSourceFilePath)); } $sourceArrayConfig = (include $sourceFilePath); //TODO make this relative switch ($author) { case 'atrauzzi': //$convertedConfigString = $this->convertAtrauzzi($sourceArrayConfig, $viewFactory); break; case 'mitchellvanw': $convertedConfigString = $this->convertMitchell($sourceArrayConfig, $viewFactory); break; default: throw new InvalidArgumentException('Author provided was not a valid choice.'); } file_put_contents($destFilePath, '<?php ' . $convertedConfigString); $this->info('Conversion successful. File generated at ' . $destFilePath); }
public function uploadBuild($target) { if (!isset($_FILES[$target]["name"]) || !$_FILES[$target]["size"]) { $this->error_id = 1; $this->error_message = "No file provided."; return $this->error_id; } if ($_FILES[$target]["size"] > 10000000) { $this->error_id = 2; $this->error_message = "The Maximum upload file size is 10 MB"; return $this->error_id; } //a filter for file names //allows letters, numbers, '.', '-', '_', '\'', and ' ' $this->name = basename($_FILES[$target]["name"]); if (preg_replace("/[^a-zA-Z0-9\\.\\-\\_\\ \\']/", "", $this->name) !== $this->name) { $this->error_id = 2; $this->error_message = "Invalid characters in file name"; return $this->error_id; } $fileExt = pathinfo($this->name, PATHINFO_EXTENSION); $targetPath = realPath(dirname(__FILE__) . "uploads/" . $this->name); if ($fileExt != "bls") { $this->error_id = 2; $this->error_message = "Only .bls files are allowed"; return $this->error_id; } if (file_exists($targetPath)) { $this->error_id = 2; $this->error_message = "A file with that name already exists."; return $this->error_id; } //basic parse of .bls file //$contents = explode("\n", file_get_contents($_FILES["uploadfile"]["tmp_name"])); $contents = file($_FILES[$target]["tmp_name"]); return $this->validateFileContents($contents); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ public function execute(InputInterface $input, OutputInterface $output) { if (($destPath = $input->getOption('dest-path')) === null) { $destPath = 'config'; } if (($author = $input->getArgument('author')) === null) { throw new InvalidArgumentException('Missing author option'); } if (($sourceFilePath = $input->getOption('source-file')) === null) { $sourceFilePath = 'config/doctrine.php'; } $destPath = realpath($destPath); if (!is_dir($destPath)) { mkdir($destPath, 0777, true); } if (!is_writable($destPath)) { throw new InvalidArgumentException(sprintf("Configuration destination directory '<info>%s</info>' does not have write permissions.", $destPath)); } $destFilePath = $destPath . '/doctrine.generated.php'; $originalSourceFilePath = $sourceFilePath; $sourceFilePath = realPath($sourceFilePath); if (!file_exists($sourceFilePath)) { throw new InvalidArgumentException(sprintf("Source file at path '<info>%s</info>' does not exist.", $originalSourceFilePath)); } $sourceArrayConfig = (include $sourceFilePath); $viewFactory = $this->createViewFactory(); $className = __NAMESPACE__ . '\\ConfigMigrations\\' . ucfirst($author) . 'Migrator'; if (!class_exists($className)) { throw new InvalidArgumentException('Author provided was not a valid choice.'); } else { $configMigrator = new $className($viewFactory); $convertedConfigString = $configMigrator->convertConfiguration($sourceArrayConfig); } file_put_contents($destFilePath, '<?php ' . $convertedConfigString); $output->writeln('Conversion successful. File generated at ' . $destFilePath); }
function iwp_mmb_get_file_size($file) { clearstatcache(); $normal_file_size = filesize($file); if ($normal_file_size !== false && $normal_file_size >= 0) { return $normal_file_size; } else { $file = realPath($file); if (!$file) { echo 'iwp_mmb_get_file_size_error : realPath error'; } $ch = curl_init("file://" . $file); curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_FILE); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); $data = curl_exec($ch); $curl_error = curl_error($ch); curl_close($ch); if ($data !== false && preg_match('/Content-Length: (\\d+)/', $data, $matches)) { return (string) $matches[1]; } else { echo 'iwp_mmb_get_file_size_error : ' . $curl_error; return $normal_file_size; } } }
/** * Save the form controls data to the database * * @param object $form Jelix jForm object * @return Boolean True if the has been saved */ public function saveFormDataToDb($form) { // Set the form from request //$form->initFromRequest(); // Optionnaly query for the feature $cnx = jDb::getConnection($this->layerId); $layerName = $this->layerName; $capabilities = $this->project->getEditionLayers()->{$layerName}->capabilities; // Update or Insert $updateAction = false; $insertAction = false; if ($this->featureId) { $updateAction = true; } else { $insertAction = true; } // Get list of fields which are not primary keys $fields = array(); foreach ($this->dataFields as $fieldName => $prop) { // For update : And get only fields corresponding to edition capabilities if (!$prop->primary and (strtolower($capabilities->modifyAttribute) == 'true' and $fieldName != $this->geometryColumn or strtolower($capabilities->modifyGeometry) == 'true' and $fieldName == $this->geometryColumn or $insertAction)) { $fields[] = $fieldName; } } if (count($fields) == 0) { jLog::log('Not enough capabilities for this layer ! SQL cannot be constructed: no fields available !', 'error'); $form->setErrorOn($this->geometryColumn, 'An error has been raised when saving the form: Not enough capabilities for this layer !'); jMessage::clearAll(); jMessage::add(jLocale::get('view~edition.link.error.sql'), 'error'); return false; } // Loop though the fields and filter the form posted values $update = array(); $insert = array(); $refs = array(); foreach ($fields as $ref) { // Get and filter the posted data foreach form control $value = $form->getData($ref); if (is_array($value)) { $value = '{' . implode(',', $value) . '}'; } switch ($this->formControls[$ref]->fieldDataType) { case 'geometry': $value = "ST_GeomFromText('" . filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES) . "', " . $this->srid . ")"; $rs = $cnx->query('SELECT GeometryType(' . $value . ') as geomtype'); $rs = $rs->fetch(); if (!preg_match('/' . $this->geometryType . '/', strtolower($rs->geomtype))) { if (preg_match('/' . str_replace('multi', '', $this->geometryType) . '/', strtolower($rs->geomtype))) { $value = 'ST_Multi(' . $value . ')'; } else { $form->setErrorOn($this->geometryColumn, "The geometry type doen't match!"); return false; } } break; case 'date': case 'datetime': $value = filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); if (!$value) { $value = 'NULL'; } else { $value = $cnx->quote($value); } break; case 'integer': $value = filter_var($value, FILTER_SANITIZE_NUMBER_INT); if (!$value) { $value = 'NULL'; } break; case 'float': $value = (double) $value; if (!$value) { $value = 'NULL'; } break; default: $value = $cnx->quote(filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); break; } if ($form->hasUpload() && array_key_exists($ref, $form->getUploads())) { $value = $form->getData($ref); $choiceValue = $form->getData($ref . '_choice'); $hiddenValue = $form->getData($ref . '_hidden'); $repPath = $this->repository->getPath(); if ($choiceValue == 'update') { $refPath = realpath($repPath . '/media') . '/upload/' . $this->project->getKey() . '/' . $this->tableName . '/' . $ref; $form->saveFile($ref, $refPath); $value = 'media' . '/upload/' . $this->project->getKey() . '/' . $this->tableName . '/' . $ref . '/' . $value; if ($hiddenValue && file_exists(realPath($repPath) . '/' . $hiddenValue)) { unlink(realPath($repPath) . '/' . $hiddenValue); } } else { if ($choiceValue == 'delete') { if ($hiddenValue && file_exists(realPath($repPath) . '/' . $hiddenValue)) { unlink(realPath($repPath) . '/' . $hiddenValue); } $value = 'NULL'; } else { $value = $hiddenValue; } } if (!$value) { $value = 'NULL'; } else { if ($value != 'NULL') { $value = $cnx->quote(filter_var($value, FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES)); } } } // Build the SQL insert and update query $insert[] = $value; $refs[] = '"' . $ref . '"'; $update[] = '"' . $ref . '"=' . $value; } $sql = ''; // update if ($updateAction) { if (ctype_digit($this->featureId)) { $featureId = array($this->featureId); } // featureId is set // SQL for updating on line in the edition table $sql = " UPDATE " . $this->table . " SET "; $sql .= implode(', ', $update); $v = ''; $i = 0; $sql .= ' WHERE'; foreach ($this->primaryKeys as $key) { $sql .= "{$v} {$key} = " . $featureId[$i]; $i++; $v = " AND "; } // Add login filter if needed if (!$this->loginFilteredOveride) { $this->filterDataByLogin($this->layerName); if (is_array($this->loginFilteredLayers)) { $sql .= ' AND ' . $this->loginFilteredLayers['where']; } } } // insert if ($insertAction) { // SQL for insertion into the edition this->table function dquote($n) { return '"' . $n . '"'; } $dfields = array_map("dquote", $fields); $sql = " INSERT INTO " . $this->table . " ("; $sql .= implode(', ', $refs); $sql .= " ) VALUES ("; $sql .= implode(', ', $insert); $sql .= " );"; } try { $rs = $cnx->query($sql); //~ jLog::log($sql); } catch (Exception $e) { $form->setErrorOn($this->geometryColumn, 'An error has been raised when saving the form'); jLog::log("SQL = " . $sql); jLog::log("An error has been raised when saving form data edition to db : " . $e->getMessage(), 'error'); return false; } return true; }
<?php defined('APP_CONFIG_NAME') or define('APP_CONFIG_NAME', 'backend'); // web application configuration return array('basePath' => realPath(__DIR__ . '/..'), 'aliases' => array('bootstrap' => 'application.modules.bootstrap', 'menu' => 'application.modules.pb_menu', 'chartjs' => 'bootstrap.extensions.yii-chartjs-master'), 'behaviors' => array(), 'preload' => array('bootstrap', 'chartjs'), 'controllerMap' => array(), 'import' => array('bootstrap.*', 'bootstrap.components.*', 'bootstrap.models.*', 'bootstrap.controllers.*', 'bootstrap.helpers.*', 'bootstrap.widgets.*', 'bootstrap.extensions.*', 'chartjs.*', 'chartjs.widgets.*', 'chartjs.components.*', 'menu.*', 'menu.models.*', 'menu.widgets.*', 'menu.components.*', 'menu.controllers.*', 'menu.extensions.*'), 'modules' => array('bootstrap' => array('class' => 'bootstrap.BootStrapModule'), 'menu' => array('class' => 'menu.PbMenuModule')), 'components' => array('bsHtml' => array('class' => 'bootstrap.components.BSHtml'), 'chartjs' => array('class' => 'bootstrap.extensions.yii-chartjs-master.components.ChartJs'), 'menu' => array('class' => 'menu.components.MenuPlugin'), 'clientScript' => array(), 'urlManager' => array('urlFormat' => 'path', 'showScriptName' => false, 'rules' => array('<controller:\\w+>/<id:\\d+>' => '<controller>/view', '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>')), 'user' => array('allowAutoLogin' => true), 'errorHandler' => array('errorAction' => 'site/error')));
function fromTo($from, $to) { echo "\t", sprintf('%-20s', $from), ' => ', $to, PHP_EOL; } echo 'Setting up', PHP_EOL; $root = realPath(__DIR__ . '/../application/settings') . DIRECTORY_SEPARATOR; $env = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'dev'; fromTo('env.php', $root . 'env.php'); file_put_contents($root . 'env.php', '<?php $config = \'' . $env . '\';'); require dirName(__DIR__) . '/library/Nano.php'; $files = array('db.php' => 'db.php', 'log.php' => 'log.php', 'selenium.php' => 'selenium.php', 'web.php' => 'web.php', 'assets.php' => 'assets.php', 'plugins.php' => 'plugins.php'); $source = __DIR__ . '/setup/' . $env; if (file_exists($source)) { foreach ($files as $from => $to) { $sourceFile = $source . DS . $from; $destinationDir = realPath(dirName($root . $to)); $destinationFile = $destinationDir . DS . baseName($to); if (file_exists($sourceFile)) { fromTo($from, $destinationFile); copy($sourceFile, $destinationFile); } } } echo 'Done', PHP_EOL; if (file_exists($source . '.php')) { include $source . '.php'; if (function_exists('setupEnv')) { setupEnv(); } } Nano::reloadConfig();
$url = $rowInstall['link']; $certPath = MODX_CORE_PATH . 'components/upgrademodx/cacert.pem'; if (!file_exists($certPath)) { MODXInstaller::quit('Could not find cacert.pem'); } set_time_limit(0); $success = MODXInstaller::downloadFile($url, $source, $method, $certPath); /* Make sure we have the downloaded file */ if ($success !== true) { MODXInstaller::quit($success); } elseif (!file_exists($source)) { MODXInstaller::quit('Missing file: ' . $source); } elseif (filesize($source) < 64) { MODXInstaller::quit('File: ' . $source . ' is empty -- download failed'); } $tempDir = realPath(dirname(__FILE__)) . '/temp'; MODXInstaller::mmkdir($tempDir); clearstatcache(); $destination = $tempDir; if (!file_exists($tempDir)) { MODXInstaller::quit('Unable to create directory: ' . $tempDir); } if (!is_readable($tempDir)) { MODXInstaller::quit('Unable to read from /temp directory'); } set_time_limit(0); $success = MODXInstaller::unZip(MODX_CORE_PATH, $source, $destination, $forcePclZip); if ($success !== true) { MODXInstaller::quit($success); } $directories = MODXInstaller::getDirectories();
<?php //defines the path's for the application //cut off the filename and go up one directory to the base directory $rootPath = dirname(dirname(__FILE__)); defined('DS') or define('DS', DIRECTORY_SEPARATOR); //smarty defines DS the same way //realPath() makes sure we use the right seperator for the platform defined('PATH_CODE') or define('PATH_CODE', $rootPath); define('PATH_ADMIN', realPath($rootPath . "/administrator")); define('PATH_PUBLICDATA', realPath($rootPath . "/publicData")); define('PATH_WEB', realPath($rootPath . "/web")); define('PATH_INCLUDE', realPath($rootPath . "/include")); define('PATH_ACCESS', realPath($rootPath . "/include/sql_access")); define('PATH_3RD_PARTY', PATH_INCLUDE . '/3rdParty'); //Smarty define('PATH_SMARTY', PATH_3RD_PARTY . '/smarty'); define('PATH_SMARTY_TPL', realPath($rootPath . '/smarty_templates')); //Document root define('PATH_WEBROOT', $_SERVER['DOCUMENT_ROOT']);
/** * Check if there is are already core files available * at the download destination. * * @param string $version A version number * @return bool true when core files are available */ protected function checkCoreFilesAvailable($version) { $newCoreLocation = @realPath($this->symlinkToCoreFiles . '/../') . '/typo3_src-' . $version; return @is_dir($newCoreLocation); }
/** * Méthode retournant le chemin vers la racine de WebKiosk * @return string Le chemin vers la racine de WebKiosk */ private function _getPathToRoot() { return realPath(__DIR__ . '/../../../../..'); }
if (!is_numeric($count)) { $count = $total; } $files = array_slice($files, 0, $count); } $result; $result->total = $total; $result->items = $files; header("Content-Type", "text/json"); print "/* " . json_encode($result) . " */"; } else { //Query of a specific file (useful for fetchByIdentity and loadItem) //Make sure the path isn't trying to walk out of the rooted directory //As defined by $rootDir in the top of the php script. $rootPath = realPath($rootDir); $fullPath = realPath($rootPath . "/" . $path); if ($fullPath !== false) { if (strpos($fullPath, $rootPath) === 0) { //Root the path into the tree cleaner. if (strlen($fullPath) == strlen($rootPath)) { $path = "."; } else { //Fix the path to relative of root and put back into UNIX style (even if windows). $path = substr($fullPath, strlen($rootPath) + 1, strlen($fullPath)); $path = str_replace("\\", "/", $path); } if (file_exists($fullPath)) { $arr = split("/", $path); $size = count($arr); if ($size > 0) { $fName = $arr[$size - 1];
function gs_ringtone_set($user, $src, $bellcore, $change_file = false, $file = null) { if (!preg_match('/^[a-zA-Z\\d]+$/', $user)) { return new GsError('User must be alphanumeric.'); } if (!in_array($src, array('internal', 'external'), true)) { return new GsError('Source must be internal|external.'); } $bellcore = (int) $bellcore; if ($bellcore < 0 || $bellcore > 10) { return new GsError('Bellcore must be between 1 and 10 or 0 for silent.'); } if (!$change_file) { $file = null; } else { if (!$file) { # to remove a custom ringer $file = null; } else { $file = @realPath($file); if (!@file_exists($file)) { $file = @realPath(@$_ENV['PWD'] . '/' . $file); if (!@file_exists($file)) { return new GsError('File not found.'); } } //if (strToLower(subStr($file,-4)) != '.mp3') // return new GsError( 'File is not an mp3.' ); } } # connect to db # $db = gs_db_master_connect(); if (!$db) { return new GsError('Could not connect to database.'); } # get user_id # $user_id = (int) $db->executeGetOne('SELECT `id` FROM `users` WHERE `user`=\'' . $db->escape($user) . '\''); if (!$user_id) { return new GsError('Unknown user.'); } # make sure there is an entry in the db and set the bellcore ringer # $num = (int) $db->executeGetOne('SELECT COUNT(*) `num` FROM `ringtones` WHERE `user_id`=' . $user_id . ' AND `src`=\'' . $src . '\''); if ($num < 1) { $ok = $db->execute('INSERT INTO `ringtones` (`user_id`, `src`, `bellcore`, `file`) VALUES (' . $user_id . ', \'' . $src . '\', ' . $bellcore . ', NULL)'); } else { $ok = $db->execute('UPDATE `ringtones` SET `bellcore`=' . $bellcore . ' WHERE `user_id`=' . $user_id . ' AND `src`=\'' . $src . '\''); } if (!$ok) { return new GsError('DB error.'); } if (!$change_file) { return true; } # are we the web server? # if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) { $our_host_ips = @gs_get_listen_to_ips(); if (!is_array($our_host_ips)) { return new GsError('Failed to get our host IPs.'); } $we_are_the_webserver = in_array(GS_PROV_HOST, $our_host_ips); } else { $we_are_the_webserver = true; } # remove old ringer from htdocs/prov/ringtones/ dir # if ($we_are_the_webserver) { # local @exec('sudo rm -rf ' . GS_DIR . 'htdocs/prov/ringtones/' . $user . '-' . subStr($src, 0, 3) . '-* 1>>/dev/null 2>>/dev/null'); } else { # remotely $cmd = 'rm -rf /opt/gemeinschaft/htdocs/prov/ringtones/' . $user . '-' . subStr($src, 0, 3) . '-* 1>>/dev/null 2>>/dev/null &'; @exec('sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa('root@' . GS_PROV_HOST) . ' ' . qsa($cmd) . ' 1>>/dev/null 2>>/dev/null'); } # just remove custom ringer? # if (!$file) { $ok = $db->execute('UPDATE `ringtones` SET `file`=NULL WHERE `user_id`=' . $user_id . ' AND `src`=\'' . $src . '\''); if (!$ok) { return new GsError('DB error.'); } return true; } # convert sound file to the formats needed for each phone type # $to_sox_format = array('alaw' => 'al', 'ulaw' => 'ul'); $pinfo = pathInfo($file); //$base = $pinfo['basename']; $ext = strToLower(@$pinfo['extension']); if (array_key_exists($ext, $to_sox_format)) { $ext = $to_sox_format[$ext]; } $rand = base_convert(rand(1296, 46655), 10, 36); # 100(36) - zzz(36) $tmpbase = '/tmp/gs-ring-' . $user . '-' . $rand; $infile = $tmpbase . '-in.' . $ext; $outbase = $tmpbase . '-out'; $ok = @copy($file, $infile); @chmod($infile, 0666); if (!$ok) { return new GsError('Failed to copy file to "' . $infile . '".'); } include_once GS_DIR . 'inc/phone-capability.php'; $phone_types = glob(GS_DIR . 'htdocs/prov/*/capability.php'); if (!is_array($phone_types)) { $phone_types = array(); } for ($i = 0; $i < count($phone_types); ++$i) { $phone_types[$i] = baseName(dirName($phone_types[$i])); } gs_log(GS_LOG_DEBUG, 'Ringtone conversion: Found phone types: ' . implode(', ', $phone_types)); $errors = array(); $new_ringer_basename = $user . '-' . subStr($src, 0, 3) . '-' . $rand; foreach ($phone_types as $phone_type) { include_once GS_DIR . 'htdocs/prov/' . $phone_type . '/capability.php'; $class = 'PhoneCapability_' . $phone_type; if (!class_exists($class)) { gs_log(GS_LOG_WARNING, $phone_type . ': Class broken.'); $errors[] = $phone_type . ': Class broken.'; continue; } $PhoneCapa = new $class(); $outfile = $PhoneCapa->conv_ringtone($infile, $outbase); if (isGsError($outfile)) { gs_log(GS_LOG_WARNING, 'Ringtone conversion: ' . $phone_type . ': ' . $outfile->getMsg()); $errors[] = $phone_type . ': ' . $outfile->getMsg(); } elseif ($outfile === null) { gs_log(GS_LOG_DEBUG, 'Ringtone conversion: ' . $phone_type . ': Not implemented.'); continue; } elseif (!$outfile) { gs_log(GS_LOG_WARNING, 'Ringtone conversion: ' . $phone_type . ': Failed to convert file.'); $errors[] = $phone_type . ': ' . 'Failed to convert file.'; continue; } if (!file_exists($outfile)) { gs_log(GS_LOG_WARNING, 'Ringtone conversion: ' . $phone_type . ': Failed to convert file.'); $errors[] = $phone_type . ': ' . 'Failed to convert file.'; continue; } gs_log(GS_LOG_DEBUG, 'Ringtone conversion: ' . $phone_type . ': Converted.'); @chmod($outfile, 0666); $pinfo = pathInfo($outfile); $ext = strToLower(@$pinfo['extension']); $newbase = $new_ringer_basename . '-' . $phone_type . '.' . $ext; if ($phone_type === 'siemens' && !gs_get_conf('GS_SIEMENS_PROV_PREFER_HTTP')) { # if this is a Siemens phone, push the file on the FTP server @copy($infile, '/tmp/' . $newbase); //FIXME - why? $ok = $PhoneCapa->_upload_ringtone('/tmp/' . $newbase); if (!$ok) { gs_log(GS_LOG_WARNING, 'Failed to upload ringtone to FTP server.'); } if (is_file('/tmp/' . $newbase)) { @unlink('/tmp/' . $newbase); } } else { if ($we_are_the_webserver) { # local //rename( $outfile, GS_DIR .'htdocs/prov/ringtones/'. $newbase ); @exec('sudo mv ' . qsa($outfile) . ' ' . qsa(GS_DIR . 'htdocs/prov/ringtones/' . $newbase), $out, $err); } else { # remotely @exec('sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($outfile) . ' ' . qsa('root@' . GS_PROV_HOST . ':/opt/gemeinschaft/htdocs/prov/ringtones/' . $newbase) . ' >>/dev/null 2>>/dev/null', $out, $err); //@exec( 'sudo rm -f '. qsa($outfile) .' >>/dev/null 2>&1' ); @unlink($outfile); } if ($err != 0) { gs_log(GS_LOG_WARNING, 'Failed to mv ringtone.'); } } } if (is_file($infile)) { @unlink($infile); } @exec('rm -rf ' . $tmpbase . '-* 1>>/dev/null 2>>/dev/null &'); if (count($errors) > 0) { return new GsError("Failed to convert ringtone for some or all phone types: " . implode(", ", $errors)); } $ok = $db->execute('UPDATE `ringtones` SET `file`=\'' . $db->escape($new_ringer_basename) . '\' WHERE `user_id`=' . $user_id . ' AND `src`=\'' . $src . '\''); if (!$ok) { return new GsError('DB error.'); } return true; // OLD STUFF: /* # remove old ringer # $files = @glob( GS_DIR .'htdocs/prov/ringtones/'. $user .'/'. $src .'-*' ); if (is_array($files)) { foreach ($files as $f) { unlink(); } } die(); shell_exec( 'rm -f /opt/ast/htdocs/prov/ringtones/'. $ext .'-*' ); # get SIP name # $ext = $db->executeGetOne( 'SELECT `name` FROM `ast_sipfriends` WHERE `_user_id`='. $user_id ); if (! $ext) return new GsError( 'DB error.' ); if ($file) { $rand = rand(10000,99999).time(); shell_exec( 'mpg123 -m -r 8000 -w - -n 500 -q \''. $file .'\' > \'/opt/gemeinschaft/htdocs/prov/ringtones/'. $rand .'.wav\'' ); shell_exec( 'sox \'/opt/gemeinschaft/htdocs/prov/ringtones/'. $rand .'.wav\' -r 8000 -c 1 -w \'/opt/gemeinschaft/htdocs/prov/ringtones/'. $ext .'-'. time() .'.wav\'' ); shell_exec( 'rm \'/opt/gemeinschaft/htdocs/prov/ringtones/'. $rand .'.wav\'' ); } else { //shell_exec( 'rm -f /opt/gemeinschaft/htdocs/prov/ringtones/'. $ext .'-*' ); } return true; */ }
<?php /** * * console.php configuration file * * @author Antonio Ramirez <*****@*****.**> * @link http://www.ramirezcobos.com/ * @link http://www.2amigos.us/ * @copyright 2013 2amigOS! Consultation Group LLC * @license http://www.opensource.org/licenses/bsd-license.php New BSD License */ defined('APP_CONFIG_NAME') or define('APP_CONFIG_NAME', 'console'); return array('basePath' => realPath(__DIR__ . '/..'), 'aliases' => array('frontend' => realPath(__DIR__ . '/../frontend')), 'import' => array('frontend.modules.album.AlbumModule'), 'commandMap' => array('migrate' => array('class' => 'console.extensions.yiiext.commands.migrate.EMigrateCommand', 'migrationPath' => 'console.migrations', 'migrationTable' => 'tbl_migration', 'applicationModuleName' => 'core', 'modulePaths' => array('userAccount' => 'frontend.modules.userAccount.migrations', 'personIdentifier' => 'frontend.modules.personIdentifier.migrations', 'album' => 'frontend.modules.album.migrations'), 'migrationSubPath' => 'migrations', 'disabledModules' => array())));
<?php /** * console.php config file * * @author Antonio Ramirez <*****@*****.**> * @link http://www.ramirezcobos.com/ * @link http://www.2amigos.us/ * @copyright 2013 2amigOS! Consultation Group LLC * @license http://www.opensource.org/licenses/bsd-license.php New BSD License */ defined('APP_CONFIG_NAME') or define('APP_CONFIG_NAME', 'console'); return array('basePath' => realPath(__DIR__ . '/..'), 'commandMap' => array('migrate' => array('class' => 'system.cli.commands.MigrateCommand', 'migrationPath' => 'application.migrations')), 'modules' => array('user' => array('hash' => 'md5', 'sendActivationMail' => true, 'loginNotActiv' => false, 'activeAfterRegister' => false, 'autoLogin' => true, 'registrationUrl' => array('/user/registration'), 'recoveryUrl' => array('/user/recovery'), 'loginUrl' => array('/user/login'), 'returnUrl' => array('/user/profile'), 'returnLogoutUrl' => array('/user/login'))));
<?php return array('public_path' => realPath(public_path()), 'storage' => 'filesystem', 'image_processing_library' => 'GD', 'default_url' => '/:attachment/:style/missing.png', 'default_style' => 'original', 'styles' => array(), 'keep_old_files' => false, 'preserve_files' => false);
<?php /** * * backend.php configuration file * * @author Antonio Ramirez <*****@*****.**> * @link http://www.ramirezcobos.com/ * @link http://www.2amigos.us/ * @copyright 2013 2amigOS! Consultation Group LLC * @license http://www.opensource.org/licenses/bsd-license.php New BSD License */ defined('APP_CONFIG_NAME') or define('APP_CONFIG_NAME', 'backend'); // web application configuration return array('name' => '{APPLICATION NAME}', 'basePath' => realPath(__DIR__ . '/..'), 'aliases' => array('bootstrap' => dirname(__FILE__) . '/../..' . '/common/lib/vendor/2amigos/yiistrap', 'yiiwheels' => dirname(__FILE__) . '/../..' . '/common/lib/vendor/2amigos/yiiwheels'), 'behaviors' => array(), 'import' => array('yiiwheels.widgets.fineuploader.*', 'application.widgets.PhotoPortfolio.*', 'common.extensions.behaviors.*', 'application.components.*', 'application.modules.portfolio.models.*', 'application.models.*', 'backend.modules.user.models.*'), 'controllerMap' => array(), 'modules' => array('user' => array('class' => 'backend.modules.user.UserModule', 'hash' => 'md5', 'sendActivationMail' => true, 'loginNotActiv' => false, 'activeAfterRegister' => false, 'autoLogin' => true, 'registrationUrl' => array('/user/registration'), 'recoveryUrl' => array('/user/recovery'), 'loginUrl' => '/user/login', 'returnUrl' => array('/user/profile'), 'returnLogoutUrl' => '/user/login', 'adminUrl' => 'user/admin', 'tableUsers' => 'user', 'tableProfiles' => 'profiles', 'tableProfileFields' => 'profiles_fields'), 'portfolio' => array('class' => 'backend.modules.portfolio.PortfolioModule'), 'magazine' => array('class' => 'backend.modules.magazine.MagazineModule'), 'news' => array('class' => 'backend.modules.news.NewsModule'), 'tag' => array('class' => 'backend.modules.tag.TagModule'), 'portfolioposts' => array('class' => 'backend.modules.portfolioposts.PortfolioPostsModule'), 'partners' => array('class' => 'backend.modules.partners.PartnersModule'), 'banners' => array('class' => 'backend.modules.banners.BannersModule'), 'horoscope' => array('class' => 'backend.modules.horoscope.HoroscopeModule'), 'contacts' => array('class' => 'backend.modules.contacts.ContactsModule'), 'about' => array('class' => 'backend.modules.about.AboutModule')), 'components' => array('bootstrap' => array('class' => 'bootstrap.components.TbApi'), 'yiiwheels' => array('class' => 'yiiwheels.YiiWheels'), 'messages' => array('basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../common' . DIRECTORY_SEPARATOR . 'messages'), 'clientScript' => array('scriptMap' => array('bootstrap.min.css' => false, 'bootstrap.min.js' => false, 'bootstrap-yii.css' => false)), 'urlManager' => array('urlFormat' => 'path', 'showScriptName' => false, 'rules' => array('<controller:\\w+>/<id:\\d+>' => '<controller>/view', '<controller:\\w+>/<action:\\w+>/<id:\\d+>' => '<controller>/<action>', '<controller:\\w+>/<action:\\w+>' => '<controller>/<action>')), 'user' => array('authTimeout' => 86400), 'errorHandler' => array('errorAction' => 'site/error')));
cgiResponse(HTTP_V_METHOD_NOT_ALLOWED, "Method Not Allowed", NULL); header("Allow: " . getenv("CBTREE_METHODS")); error_log("Invalid or unsupported method: [" . $method . "]"); return; } // Validate the HTTP QUERY-STRING parameters $args = getArguments($method, $status); if ($args == null) { cgiResponse(HTTP_V_BAD_REQUEST, "Bad Request", "Malformed query arguments."); return; } if ($args->authToken) { // Your authentication may go here.... } $rootDir = str_replace("\\", "/", realPath($docRoot . "/" . $args->basePath)); $fullPath = str_replace("\\", "/", realPath($rootDir . "/" . $args->path)); if ($rootDir && $fullPath) { // Make sure the caller isn't backtracking by specifying paths like '../../../' if (strncmp($rootDir, $docRoot, strlen($docRoot)) || strncmp($fullPath, $rootDir, strlen($rootDir))) { cgiResponse(HTTP_V_FORBIDDEN, "Forbidden", "We're not going there..."); return; } switch ($method) { case "DELETE": $files = deleteFile($fullPath, $rootDir, $args, $status); if ($files) { // Compile the final result $result = new stdClass(); $result->total = count($files); $result->status = $status; $result->items = $files;
public static function run() { global $argv, $argc; $usage = PHP_EOL . " Usage: php [options] TestSuite.php <All|Misc|moduleName|TestClassName> [options]" . PHP_EOL . PHP_EOL . " All Run all tests." . PHP_EOL . " Framework Run all tests in framework/tests/functional." . PHP_EOL . " Misc Run the test suites in app/protected/tests/functional." . PHP_EOL . " moduleName Run the test suites in app/protected/modules/moduleName/tests/functional." . PHP_EOL . " TestClassName Run the tests in TestClassName.html, wherever that happens to be." . PHP_EOL . " options" . PHP_EOL . " -p port Example: -p4044" . PHP_EOL . " -h host Example: -hhttp://www.sitetotest/app/" . PHP_EOL . " -b browser <*firefox|*iexplore> if not specified, will run all in browsers " . PHP_EOL . " -c test server control url Example: -chttp://www.sitetotest/controlUrl.php" . PHP_EOL . " Example: -b*firefox " . PHP_EOL . " -userExtensions Example: -userExtensions pathToTheUserExtensionJS " . PHP_EOL . PHP_EOL . " Examples:" . PHP_EOL . PHP_EOL . " php TestSuiteSelenium.php accounts (Run the tests in the Accounts module.)" . PHP_EOL . " php TestSuiteSelenium.php RedBeanModelTest (Run the test suite RedBeanModelTest.html.)" . PHP_EOL . PHP_EOL . PhpUnitServiceUtil::checkVersion(); if ($argv[0] != 'TestSuite.php') { echo $usage; exit; } else { $whatToTest = $argv[1]; } $whatToTestIsModuleDir = self::isWhatToTestAModule($whatToTest); $suiteNames = array(); $htmlTestSuiteFiles = array(); if ($whatToTest == 'All' || $whatToTest == 'Misc' || !$whatToTestIsModuleDir) { $compareToTest = $whatToTest; if ($whatToTest == 'Misc') { $compareToTest = null; } $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory($htmlTestSuiteFiles, '.', $compareToTest); } if ($whatToTest != 'Misc' && !$whatToTestIsModuleDir) { $compareToTest = $whatToTest; if ($whatToTest == 'Framework') { $compareToTest = null; } $frameworkTestSuiteDirectory = '../../core/tests/functional'; $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory($htmlTestSuiteFiles, $frameworkTestSuiteDirectory, $compareToTest); } $moduleDirectoryName = '../../modules'; if (is_dir($moduleDirectoryName)) { $moduleNames = scandir($moduleDirectoryName); foreach ($moduleNames as $moduleName) { if ($moduleName != '.' && $moduleName != '..') { $moduleFunctionalTestDirectoryName = "{$moduleDirectoryName}/{$moduleName}/tests/functional"; if (is_dir($moduleFunctionalTestDirectoryName)) { if ($whatToTest == 'All' || $whatToTest == $moduleName || strtolower($whatToTest) == $moduleName || !$whatToTestIsModuleDir) { if ($whatToTest == $moduleName || strtolower($whatToTest) == $moduleName) { $compareToTest = null; } else { $compareToTest = $whatToTest; } $htmlTestSuiteFiles = self::buildSuiteFromSeleneseDirectory($htmlTestSuiteFiles, $moduleFunctionalTestDirectoryName, $compareToTest); } } } } } if (count($htmlTestSuiteFiles) == 0) { echo $usage; echo " No tests found for '{$whatToTest}'.\n" . PHP_EOL; exit; } echo 'Suites to run:' . PHP_EOL; foreach ($htmlTestSuiteFiles as $pathToSuite) { if (in_array(basename($pathToSuite), $suiteNames)) { echo 'Cannot run tests because there are 2 test suites with the same name.' . PHP_EOL; echo 'The duplicate found is here: ' . $pathToSuite . PHP_EOL; exit; } $suiteNames[] = basename($pathToSuite); echo $pathToSuite . PHP_EOL; } echo 'Running Test Suites using Selenium RC v2:' . PHP_EOL; $browsersToRun = self::resolveBrowserFromParameter(); foreach ($browsersToRun as $browserId => $browserDisplayName) { self::clearPreviousTestResultsByServerAndBrowser(self::getServerByServerControlUrl(self::resolveHostFromParameterAndConstant()), $browserDisplayName); foreach ($htmlTestSuiteFiles as $pathToSuite) { if (!self::isInstallationTest($pathToSuite)) { echo "Restoring test db" . PHP_EOL; self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'restore')); echo "Restored test db" . PHP_EOL; if (!self::isInstallationTest($pathToSuite)) { echo "Set user default time zone." . PHP_EOL; self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'setUserDefaultTimezone')); echo "User default time zone set." . PHP_EOL; } echo "Clear cache on remote server" . PHP_EOL; self::remoteAction(self::resolveHostFromParameterAndConstant(), array('clearCache' => '1', 'ignoreBrowserCheck' => '1')); //Eventually remove this since in code for 2.5.9 this is removed } else { echo "Uninstall zurmo" . PHP_EOL; self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'backupRemovePerInstance')); } echo "Cache cleared" . PHP_EOL; echo 'Running test suite: '; echo $pathToSuite . PHP_EOL; $host = self::resolveHostFromParameterAndConstant(); $hostFilePart = str_replace('http://', '', $host); $hostFilePart = str_replace('https://', '', $hostFilePart); $hostFilePart = str_replace('/', '', $hostFilePart); $hostFilePart = $hostFilePart . '.'; $testResultFileNamePrefix = str_replace('../', '', $pathToSuite); $testResultFileNamePrefix = str_replace('/', '.', $testResultFileNamePrefix); $testResultFileNamePrefix = str_replace('\\', '.', $testResultFileNamePrefix); $testResultFileNamePrefix = str_replace('..', '', $testResultFileNamePrefix); $testResultFileNamePrefix = str_replace('.html', '', $testResultFileNamePrefix); $testResultsFileName = $testResultFileNamePrefix . '.' . str_replace(' ', '', $browserDisplayName) . '.TestResults.html'; $finalTestResultsPath = TEST_RESULTS_PATH . $hostFilePart . $testResultsFileName; $finalCommand = 'java -jar "' . SELENIUM_SERVER_PATH . '" '; $finalCommand .= '-port ' . self::resolvePortFromParameterAndConstant(); $finalCommand .= ' -htmlSuite ' . $browserId . ' '; $finalCommand .= $host . ' ' . realPath($pathToSuite) . ' ' . $finalTestResultsPath; $finalCommand .= ' -userExtensions ' . self::resolveUserExtensionsJsFromParameterAndConstant(); echo $finalCommand . PHP_EOL; exec($finalCommand); echo 'Restoring test db'; self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'restore')); if (self::isInstallationTest($pathToSuite)) { self::remoteAction(self::resolveServerControlUrlFromParameterAndConstant(), array('action' => 'restorePerInstance')); } } } echo 'Functional Run Complete.' . PHP_EOL; self::updateTestResultsSummaryAndDetailsFiles(); }
# STDIN, STDOUT, STDERR # # http://bugs.php.net/bug.php?id=43283 # http://bugs.centos.org/view.php?id=1633 if (!defined('STDIN')) { define('STDIN', @fOpen('php://stdin', 'rb')); } if (!defined('STDOUT')) { define('STDOUT', @fOpen('php://stdout', 'wb')); } if (!defined('STDERR')) { define('STDERR', @fOpen('php://stderr', 'wb')); } # our root directory # define('GS_DIR', realPath(dirName(__FILE__) . '/../') . '/'); # DO NOT CHANGE! # log levels # define('GS_LOG_FATAL', 1 << 1); # SYSTEM CONSTANTS. DO NOT CHANGE! define('GS_LOG_WARNING', 1 << 2); # " define('GS_LOG_NOTICE', 1 << 3); # " define('GS_LOG_DEBUG', 1 << 4); # " function gs_get_conf($key, $default = null) { return @defined($key) ? constant($key) : $default; }
public function testCopyFiles() { $dest = dirname(__FILE__) . '/' . 'temproot'; $dest = MODXInstaller::normalize($dest); MODXInstaller::removeFolder($dest, true); MODXInstaller::mmkdir($dest); $directories = $this->getDirectories($dest); $directories = MODXInstaller::normalize($directories); $tempDir = realPath(dirname(__FILE__)) . '/temp'; $sourceDir = $tempDir . '/' . MODXInstaller::getModxDir($tempDir); $sourceDir = MODXInstaller::normalize($sourceDir); MODXInstaller::copyFiles($sourceDir, $directories); $this->assertTrue(is_dir($dest . '/setup')); $this->assertTrue(is_dir($dest . '/setup/controllers')); $this->assertTrue(is_dir($dest . '/core')); $this->assertTrue(is_dir($dest . '/core/docs')); $this->assertTrue(is_dir($dest . '/manager')); $this->assertTrue(is_dir($dest . '/manager/controllers')); $this->assertTrue(is_dir($dest . '/connectors')); $this->assertTrue(is_dir($dest . '/connectors/security')); $this->assertTrue(is_dir($dest . '/myprocessors')); }
/** * Function to generate an associative map of data about a specific file. * @param $file The name of the file this object represents. * @param $dir The sub-path that contains the file defined by $file * @param $rootDir The directory from which to append dir and name to get the full path to the file. * @param $expand boolean to denote that if the file is a directory, expand all children in the children attribute * to a a full object * @param $showHiddenFiles boolean to denote if hidden files should be shown in-view or not. * * @return Associative Map. The details about the file: * $file["name"] - Returns the shortname of the file. * $file["parentDir"] - Returns the relative path from the service root for the parent directory containing file $file["name"] * $file["path"] - The relative path to the file. * $file["directory"] - Boolean indicator if the file represents a directory. * $file["size"] - The size of the file, in bytes. * $file["modified] - The modified date of the file in milliseconds since Jan 1st, 1970. * $file["children"] - Children files of a directory. Empty if a standard file. */ function generateFileObj($file, $dir, $rootDir, $expand, $showHiddenFiles) { // summary: // Function to generate an object representation of a disk file. $path = $file; if ($dir != "." && $dir != "./") { $path = $dir . "/" . $file; } $fullPath = $rootDir . "/" . $path; $atts = stat($fullPath); $rootPath = realPath($rootDir); $resolvedDir = realPath($rootDir . "/" . $dir); $resolvedFullPath = realPath($fullPath); //Try to normalize down the paths so it does a consistent return. if (strcmp($rootPath, $resolvedDir) === 0) { $dir = "."; } else { $dir = substr($resolvedDir, strlen($rootPath) + 1, strlen($resolvedDir)); $dir = "./" . str_replace("\\", "/", $dir); } if (strcmp($rootPath, $resolvedFullPath) === 0) { $path = "."; } else { $path = substr($resolvedFullPath, strlen($rootPath) + 1, strlen($resolvedFullPath)); $path = "./" . str_replace("\\", "/", $path); } $fObj = array(); $fObj["name"] = $file; $fObj["parentDir"] = $dir; $fObj["path"] = $path; $fObj["directory"] = is_dir($fullPath); $fObj["size"] = filesize($fullPath); $fObj["modified"] = $atts[9]; if (is_dir($fullPath)) { $children = array(); $dirHandle = opendir($fullPath); while ($cFile = readdir($dirHandle)) { if ($cFile) { if ($cFile != ".." && $cFile != ".") { if ($showHiddenFiles || $cFile[0] != '.') { if (!$expand) { $children[] = $cFile; } else { $children[] = generateFileObj($cFile, $path, $rootDir, $expand, $showHiddenFiles); } } } } } closedir($dirHandle); $fObj["children"] = $children; } return $fObj; }
<?php /** * * console.php configuration file * * @author Antonio Ramirez <*****@*****.**> * @link http://www.ramirezcobos.com/ * @link http://www.2amigos.us/ * @copyright 2013 2amigOS! Consultation Group LLC * @license http://www.opensource.org/licenses/bsd-license.php New BSD License */ defined('APP_CONFIG_NAME') or define('APP_CONFIG_NAME', 'console'); return array('basePath' => realPath(__DIR__ . '/..'), 'commandMap' => array('migrate' => array('class' => 'system.cli.commands.MigrateCommand', 'migrationPath' => 'application.migrations')));