Exemple #1
1
 function __construct(array $config = array())
 {
     $this->_config =& $config;
     // Try to locate app folder.
     if (!isset($config['app_dir'])) {
         $cwd = getcwd();
         while (!is_dir("{$cwd}/app")) {
             if ($cwd == dirname($cwd)) {
                 throw new \LogicException('/app folder not found.');
             }
             $cwd = dirname($cwd);
         }
         $config['app_dir'] = "{$cwd}/app";
     }
     $is_web_request = isset($_SERVER['SERVER_NAME']);
     $config += array('debug' => !$is_web_request || $_SERVER['SERVER_NAME'] == 'localhost', 'register_exception_handler' => $is_web_request, 'register_error_handler' => $is_web_request, 'core_dir' => __DIR__ . '/../..', 'data_dir' => "{$config['app_dir']}/../data");
     $this->exception_handler = new ExceptionHandler($this->debug);
     if ($this->register_exception_handler) {
         set_exception_handler(array($this->exception_handler, 'handle'));
     }
     if ($this->register_error_handler) {
         $this->errorHandler = \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
     }
     foreach (array($config['data_dir'], "{$config['data_dir']}/cache", "{$config['data_dir']}/logs") as $dir) {
         if (!is_dir($dir)) {
             mkdir($dir);
         }
     }
 }
Exemple #2
0
 public static function archive($name = false, $listFilesAndFolders, $export_files_dir, $export_files_dir_name, $backupName, $move = false, $identifier, $type)
 {
     if (empty($export_files_dir)) {
         return;
     }
     $dir_separator = DIRECTORY_SEPARATOR;
     $backupName = 'backup' . $dir_separator . $backupName;
     $installFilePath = 'system' . $dir_separator . 'admin-scripts' . $dir_separator . 'miscellaneous' . $dir_separator;
     $dbSQLFilePath = 'backup' . $dir_separator;
     $old_path = getcwd();
     chdir($export_files_dir);
     $tar = new Archive_Tar($backupName, 'gz');
     if (SJB_System::getIfTrialModeIsOn()) {
         $tar->setIgnoreList(array('system/plugins/mobile', 'system/plugins/facebook_app', 'templates/mobile', 'templates/Facebook'));
     }
     SessionStorage::write('backup_' . $identifier, serialize(array('last_time' => time())));
     switch ($type) {
         case 'full':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($dbSQLFilePath . $name, '', $dbSQLFilePath);
             $tar->addModify($listFilesAndFolders, '');
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $name);
             break;
         case 'files':
             $tar->addModify("{$installFilePath}install.php", '', $installFilePath);
             $tar->addModify($listFilesAndFolders, '');
             break;
         case 'database':
             $tar->addModify($dbSQLFilePath . $listFilesAndFolders, '', $dbSQLFilePath);
             SJB_Filesystem::delete($export_files_dir . $dbSQLFilePath . $listFilesAndFolders);
             break;
     }
     chdir($old_path);
     return true;
 }
Exemple #3
0
 public function execute()
 {
     global $wgUser;
     # Change to current working directory
     $oldCwd = getcwd();
     chdir($oldCwd);
     # Options processing
     $user = $this->getOption('u', 'Delete page script');
     $reason = $this->getOption('r', '');
     $interval = $this->getOption('i', 0);
     if ($this->hasArg()) {
         $file = fopen($this->getArg(), 'r');
     } else {
         $file = $this->getStdin();
     }
     # Setup
     if (!$file) {
         $this->error("Unable to read file, exiting", true);
     }
     $wgUser = User::newFromName($user);
     $dbw = wfGetDB(DB_MASTER);
     # Handle each entry
     for ($linenum = 1; !feof($file); $linenum++) {
         $line = trim(fgets($file));
         if ($line == '') {
             continue;
         }
         $page = Title::newFromText($line);
         if (is_null($page)) {
             $this->output("Invalid title '{$line}' on line {$linenum}\n");
             continue;
         }
         if (!$page->exists()) {
             $this->output("Skipping nonexistent page '{$line}'\n");
             continue;
         }
         $this->output($page->getPrefixedText());
         $dbw->begin();
         if ($page->getNamespace() == NS_FILE) {
             $art = new ImagePage($page);
             $img = wfFindFile($art->mTitle);
             if (!$img || !$img->isLocal() || !$img->delete($reason)) {
                 $this->output(" FAILED to delete image file... ");
             }
         } else {
             $art = new Article($page);
         }
         $success = $art->doDeleteArticle($reason);
         $dbw->commit();
         if ($success) {
             $this->output(" Deleted!\n");
         } else {
             $this->output(" FAILED to delete article\n");
         }
         if ($interval) {
             sleep($interval);
         }
         wfWaitForSlaves();
     }
 }
Exemple #4
0
 function suggest_university()
 {
     if (!$this->tank_auth->is_admin_logged_in()) {
         redirect('admin/adminlogin/');
     } else {
         $data = $this->path->all_path();
         $data['user_id'] = $this->tank_auth->get_admin_user_id();
         $data['admin_user_level'] = $this->tank_auth->get_admin_user_level();
         $data['admin_priv'] = $this->adminmodel->get_user_privilege($data['user_id']);
         if (!$data['admin_priv']) {
             redirect('admin/adminlogout');
         }
         $hint = strtolower($_GET["q"]);
         if (!$hint) {
             return;
         }
         $data['univ_info'] = $this->autosuggest_model->get_univ_detail($hint);
         if ($data['univ_info'] != 0) {
             foreach ($data['univ_info'] as $univ_info) {
                 $univ_name = $univ_info->univ_name;
                 $univ_id = $univ_info->univ_id;
                 if (file_exists(getcwd() . '/uploads/univ_gallery/' . $univ_info->univ_logo_path) && $univ_info->univ_logo_path != '') {
                     $img_name = $univ_info->univ_logo_path;
                 } else {
                     $img_name = 'logo.png';
                 }
                 $img = '<img src="' . base_url() . '/uploads/univ_gallery/' . $img_name . '" style="width:50px;height:25px;">';
                 echo $img . '<b>' . "{$univ_name}|{$univ_id}\n";
             }
         } else {
             echo 'No Result Found';
         }
     }
 }
Exemple #5
0
 private function react($type, $fqcn, $variables)
 {
     $className = $this->getClassName($fqcn);
     $nameSpace = $this->getNameSpace($fqcn);
     $variablesArray = array();
     foreach ($variables as $variableString) {
         $parts = explode(':', $variableString);
         $variablesArray[$parts[1]] = $parts[0];
     }
     switch ($type) {
         case 'dto':
             $generator = new DTO($className, $nameSpace, $variablesArray);
             break;
         case 'dto-unit':
             $generator = new DTOUnit($className, $nameSpace, $variablesArray);
             $className .= 'Test';
             break;
         default:
             throw new \RuntimeException('A formula for that reaction is not found!');
     }
     $directory = getcwd() . '/' . $this->getPath($fqcn);
     if (is_dir($directory) && !is_writable($directory)) {
         $output->writeln(sprintf('The "%s" directory is not writable', $directory));
         return;
     }
     if (!is_dir($directory)) {
         mkdir($directory, 0777, true);
     }
     file_put_contents($directory . '/' . $className . '.php', $generator->generate());
     return "Done!";
 }
Exemple #6
0
 /** @return Deployer */
 private function createDeployer($config)
 {
     $config = array_change_key_case($config, CASE_LOWER) + ['local' => '', 'passivemode' => TRUE, 'ignore' => '', 'allowdelete' => TRUE, 'purge' => '', 'before' => '', 'after' => '', 'preprocess' => TRUE];
     if (empty($config['remote']) || !parse_url($config['remote'])) {
         throw new \Exception("Missing or invalid 'remote' URL in config.");
     }
     $server = parse_url($config['remote'], PHP_URL_SCHEME) === 'sftp' ? new SshServer($config['remote']) : new FtpServer($config['remote'], (bool) $config['passivemode']);
     if (!preg_match('#/|\\\\|[a-z]:#iA', $config['local'])) {
         if ($config['local'] && getcwd() !== dirname($this->configFile)) {
             $this->logger->log('WARNING: the "local" path is now relative to the directory where ' . basename($this->configFile) . ' is placed', 'red');
         }
         $config['local'] = dirname($this->configFile) . '/' . $config['local'];
     }
     $deployment = new Deployer($server, $config['local'], $this->logger);
     if ($config['preprocess']) {
         $deployment->preprocessMasks = $config['preprocess'] == 1 ? ['*.js', '*.css'] : self::toArray($config['preprocess']);
         // intentionally ==
         $preprocessor = new Preprocessor($this->logger);
         $deployment->addFilter('js', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('js', [$preprocessor, 'compressJs'], TRUE);
         $deployment->addFilter('css', [$preprocessor, 'expandApacheImports']);
         $deployment->addFilter('css', [$preprocessor, 'expandCssImports']);
         $deployment->addFilter('css', [$preprocessor, 'compressCss'], TRUE);
     }
     $deployment->ignoreMasks = array_merge(['*.bak', '.svn', '.git*', 'Thumbs.db', '.DS_Store'], self::toArray($config['ignore']));
     $deployment->deploymentFile = empty($config['deploymentfile']) ? $deployment->deploymentFile : $config['deploymentfile'];
     $deployment->allowDelete = $config['allowdelete'];
     $deployment->toPurge = self::toArray($config['purge'], TRUE);
     $deployment->runBefore = self::toArray($config['before'], TRUE);
     $deployment->runAfter = self::toArray($config['after'], TRUE);
     $deployment->testMode = !empty($config['test']) || $this->mode === 'test';
     return $deployment;
 }
Exemple #7
0
 /**
  * Executes Composer and runs a specified command (e.g. install / update)
  */
 public function execute()
 {
     $path = $this->phpci->buildPath;
     $build = $this->build;
     if ($this->directory == $path) {
         return false;
     }
     $filename = str_replace('%build.commit%', $build->getCommitId(), $this->filename);
     $filename = str_replace('%build.id%', $build->getId(), $filename);
     $filename = str_replace('%build.branch%', $build->getBranch(), $filename);
     $filename = str_replace('%project.title%', $build->getProject()->getTitle(), $filename);
     $filename = str_replace('%date%', date('Y-m-d'), $filename);
     $filename = str_replace('%time%', date('Hi'), $filename);
     $filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     if (!is_array($this->format)) {
         $this->format = array($this->format);
     }
     foreach ($this->format as $format) {
         switch ($format) {
             case 'tar':
                 $cmd = 'tar cfz "%s/%s.tar.gz" ./*';
                 break;
             default:
             case 'zip':
                 $cmd = 'zip -rq "%s/%s.zip" ./*';
                 break;
         }
         $success = $this->phpci->executeCommand($cmd, $this->directory, $filename);
     }
     chdir($curdir);
     return $success;
 }
 public function testGetoleData()
 {
     $index = 0;
     $renderFormat = "png";
     $result = $this->object->getoleData($index, $renderFormat);
     $this->assertFileExists(getcwd() . '/Data/Output/DrawingObject_' . $index . '.' . $renderFormat);
 }
Exemple #9
0
 /**
  * Configure the command options.
  *
  * @return void
  */
 protected function configure()
 {
     $this->basePath = getcwd();
     $this->projectName = basename(getcwd());
     $this->defaultName = strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/', '-', $this->projectName)));
     $this->setName('make')->setDescription('Install Fourstead into the current project')->addOption('name', null, InputOption::VALUE_OPTIONAL, 'The name of the virtual machine.', $this->defaultName)->addOption('hostname', null, InputOption::VALUE_OPTIONAL, 'The hostname of the virtual machine.', $this->defaultName)->addOption('ip', null, InputOption::VALUE_OPTIONAL, 'The IP address of the virtual machine.')->addOption('after', null, InputOption::VALUE_NONE, 'Determines if the after.sh file is created.')->addOption('aliases', null, InputOption::VALUE_NONE, 'Determines if the aliases file is created.')->addOption('example', null, InputOption::VALUE_NONE, 'Determines if a Fourstead.yaml.example file is created.');
 }
 public function __construct()
 {
     parent::__construct();
     $this->addArgument('gateway', 'Create IPN messages for which gateway', true);
     $this->addOption('max-messages', 'At most create <n> messages', 10, 'm');
     $this->addOption('output-dir', 'Write messages to this directory', getcwd(), 'o');
 }
 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
 function setting_manager($post = false)
 {
     $this->sanitizer =& TextSanitizer::getInstance();
     if ($post) {
         $this->readPost();
     } else {
         $this->database = 'mysql';
         $this->dbhost = 'localhost';
         $this->prefix = 'xoops';
         $this->db_pconnect = 0;
         $this->root_path = str_replace("\\", "/", getcwd());
         // "
         $this->root_path = str_replace("/install", "", $this->root_path);
         $filepath = !empty($_SERVER['REQUEST_URI']) ? dirname($_SERVER['REQUEST_URI']) : dirname($_SERVER['SCRIPT_NAME']);
         $filepath = str_replace("\\", "/", $filepath);
         // "
         $filepath = str_replace("/install", "", $filepath);
         if (substr($filepath, 0, 1) == "/") {
             $filepath = substr($filepath, 1);
         }
         if (substr($filepath, -1) == "/") {
             $filepath = substr($filepath, 0, -1);
         }
         $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
         $this->xoops_url = !empty($filepath) ? $protocol . $_SERVER['HTTP_HOST'] . "/" . $filepath : $protocol . $_SERVER['HTTP_HOST'];
     }
 }
Exemple #13
0
 function testDot()
 {
     $dir = new WatchmanDirectoryFixture();
     $root = $dir->getPath();
     try {
         $this->assertEqual(true, chdir($root), "failed to chdir {$root}");
         $this->assertEqual($root, getcwd(), "chdir/getcwd are consistent");
         $is_cli = $this->isUsingCLI();
         if (phutil_is_windows()) {
             $dot = '';
             $err = 'unable to resolve root : path "" must be absolute';
         } else {
             $dot = '.';
             $err = 'unable to resolve root .: path "." must be absolute';
         }
         $res = $this->watch($dot, false);
         if (!$this->isUsingCLI()) {
             $this->assertEqual($err, idx($res, 'error'));
         } else {
             $this->assertEqual(null, idx($res, 'error'));
             $this->assertEqual($root, idx($res, 'watch'));
         }
     } catch (Exception $e) {
         chdir($this->getRoot());
         throw $e;
     }
 }
Exemple #14
0
 /** Resolve full filesystem path of given URL. Returns FALSE if the URL
  * cannot be resolved
  * @param string $url
  * @return string */
 static function url2fullPath($url)
 {
     $url = self::normalize($url);
     $uri = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : false);
     $uri = self::normalize($uri);
     if (substr($url, 0, 1) !== "/") {
         if ($uri === false) {
             return false;
         }
         $url = dirname($uri) . "/{$url}";
     }
     if (isset($_SERVER['DOCUMENT_ROOT'])) {
         return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/{$url}");
     } else {
         if ($uri === false) {
             return false;
         }
         if (isset($_SERVER['SCRIPT_FILENAME'])) {
             $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']);
             return self::normalize(substr($scr_filename, 0, -strlen($uri)) . "/{$url}");
         }
         $count = count(explode('/', $uri)) - 1;
         for ($i = 0, $chdir = ""; $i < $count; $i++) {
             $chdir .= "../";
         }
         $chdir = self::normalize($chdir);
         $dir = getcwd();
         if ($dir === false || !@chdir($chdir)) {
             return false;
         }
         $rdir = getcwd();
         chdir($dir);
         return $rdir !== false ? self::normalize($rdir . "/{$url}") : false;
     }
 }
Exemple #15
0
 function LandFAAS($http_post_vars, $afsID = "", $propertyID = "", $formAction = "", $sess)
 {
     $this->sess = $sess;
     $this->tpl = new rpts_Template(getcwd(), "keep");
     $this->tpl->set_file("rptsTemplate", "LandFAAS.htm");
     $this->tpl->set_var("TITLE", "Encode Land");
     $this->formArray = array("afsID" => $afsID, "propertyID" => $propertyID, "arpNumber" => "", "propertyIndexNumber" => "", "propertyAdministrator" => "", "personID" => "", "lastName" => "", "firstName" => "", "middleName" => "", "gender" => "", "birth_month" => date("n"), "birth_day" => date("j"), "birth_year" => date("Y"), "maritalStatus" => "", "tin" => "", "addressID" => "", "number" => "", "street" => "", "barangay" => "", "district" => "", "municipalityCity" => "", "province" => "", "telephone" => "", "mobileNumber" => "", "email" => "", "verifiedByID" => "", "verifiedBy" => "", "verifiedByName" => "", "plottingsByID" => "", "plottingsBy" => "", "plottingsByName" => "", "notedByID" => "", "notedBy" => "", "notedByName" => "", "marketValue" => "", "kind" => "", "actualUse" => "", "adjustedMarketValue" => "", "assessmentLevel" => "", "assessedValue" => "", "previousOwner" => "", "previousAssessedValue" => "", "taxability" => "", "effectivity" => "", "appraisedByID" => "", "appraisedBy" => "", "appraisedByName" => "", "appraisedByDate" => "", "recommendingApprovalID" => "", "recommendingApproval" => "", "recommendingApprovalName" => "", "recommendingApprovalDate" => "", "approvedByID" => "", "approvedBy" => "", "approvedByName" => "", "approvedByDate" => "", "memoranda" => "", "postingDate" => "", "octTctNumber" => "", "surveyNumber" => "", "north" => "", "east" => "", "south" => "", "west" => "", "classification" => "", "subClass" => "", "area" => "", "unitValue" => "", "adjustmentFactor" => "", "percentAdjustment" => "", "valueAdjustment" => "", "as_month" => date("n"), "as_day" => date("j"), "as_year" => date("Y"), "re_month" => date("n"), "re_day" => date("j"), "re_year" => date("Y"), "av_month" => date("n"), "av_day" => date("j"), "av_year" => date("Y"), "formAction" => $formAction);
     foreach ($http_post_vars as $key => $value) {
         $this->formArray[$key] = $value;
         //echo $key." = ".$this->formArray[$key]."<br>";
     }
     $as_dateStr = $this->formArray["as_year"] . "-" . putPreZero($this->formArray["as_month"]) . "-" . putPreZero($this->formArray["as_day"]);
     $this->formArray["appraisedByDate"] = $as_dateStr;
     $re_dateStr = $this->formArray["re_year"] . "-" . putPreZero($this->formArray["re_month"]) . "-" . putPreZero($this->formArray["re_day"]);
     $this->formArray["recommendingApprovalDate"] = $re_dateStr;
     $av_dateStr = $this->formArray["av_year"] . "-" . putPreZero($this->formArray["av_month"]) . "-" . putPreZero($this->formArray["av_day"]);
     $this->formArray["approvedByDate"] = $av_dateStr;
     $AssessorList = new SoapObject(NCCBIZ . "AssessorList.php", "urn:Object");
     if (!($xmlStr = $AssessorList->getAssessorList())) {
         $this->tpl->set_block("rptsTemplate", "Dropdown", "DropdownBlock");
         $this->tpl->set_var("DropdownBlock", "page not found");
     } else {
         if (!($domDoc = domxml_open_mem($xmlStr))) {
             $this->tpl->set_block("rptsTemplate", "Dropdown", "DropdownBlock");
             $this->tpl->set_var("DropdownBlock", "error xmlDoc");
         } else {
             $assessorRecords = new AssessorRecords();
             $assessorRecords->parseDomDocument($domDoc);
             $this->assessorList = $assessorRecords->getArrayList();
         }
     }
 }
Exemple #16
0
 /**
  * Implements CoreInterface::clearCache().
  */
 public function clearCache()
 {
     // Need to change into the Drupal root directory or the registry explodes.
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     drupal_flush_all_caches();
 }
Exemple #17
0
 /**
  * This function is to replace PHP's extremely buggy realpath().
  * @param string The original path, can be relative etc.
  * @return string The resolved path, it might not exist.
  */
 public function truepath($path)
 {
     // whether $path is unix or not
     $unipath = strlen($path) == 0 || $path[0] != '/';
     // attempts to detect if path is relative in which case, add cwd
     if (strpos($path, ':') === false && $unipath) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     // resolve path parts (single dot, double dot and double delimiters)
     $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path);
     $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen');
     $absolutes = array();
     foreach ($parts as $part) {
         if ('.' == $part) {
             continue;
         }
         if ('..' == $part) {
             array_pop($absolutes);
         } else {
             $absolutes[] = $part;
         }
     }
     $path = implode(DIRECTORY_SEPARATOR, $absolutes);
     // resolve any symlinks
     if (file_exists($path) && linkinfo($path) > 0) {
         $path = readlink($path);
     }
     // put initial separator that could have been lost
     $path = !$unipath ? '/' . $path : $path;
     return $path;
 }
 /**
  * Packs the current repository + the vendor directory. Returns the filename
  * or null if the file was not generated.
  *
  * @param array $excludePaths Paths to exclude before pack zip file
  * @param array $copyPaths Paths to copy from project before create zip file
  *
  * @return string Filename
  */
 public function pack(array $excludePaths = [], array $copyPaths = [])
 {
     $this->removeTempFolder();
     // Clone the repo into a tmp folder
     $this->output->writeln("Clonning clean repository...");
     exec('git clone . ../.deployment > /dev/null');
     if (false === empty($copyPaths)) {
         $this->copyPaths($copyPaths);
     }
     // Create the zip the file
     $currentDir = getcwd();
     $zipFilename = exec('echo ver_$(git log --format="%H" -n 1).zip');
     chdir("../.deployment");
     if (false === empty($excludePaths)) {
         $this->removePaths($excludePaths);
     }
     $this->output->writeln("Creating zip file...");
     exec('zip -r ' . $zipFilename . ' * > /dev/null');
     exec('mv ' . $zipFilename . ' "' . $currentDir . '/' . $zipFilename . '"');
     chdir($currentDir);
     // Remove tmp folder
     $this->output->writeln("Removing temporary files...");
     $this->removeTempFolder();
     return $zipFilename;
 }
 private function parseIniFile()
 {
     $settings = array();
     $settingStack = array();
     $open_basedir_restriction = ini_get('open_basedir');
     if (empty($open_basedir_restriction)) {
         $settingStack[] = '/etc/dbc.ini';
         $settingStack[] = '/usr/local/etc/dbc.ini';
         if (function_exists("posix_getpwuid") && function_exists("posix_getuid")) {
             $userData = posix_getpwuid(posix_getuid());
             $settingStack[] = $userData['dir'] . '/.dbc.ini';
         }
     }
     $settingStack[] = dirname(__FILE__) . '/../dbc.ini';
     $settingStack[] = getcwd() . '/dbc.ini';
     foreach ($settingStack as $settingsFile) {
         if (is_readable($settingsFile)) {
             $settings = array_merge(parse_ini_file($settingsFile, true), $settings);
         }
     }
     //merge with default settings
     $settings = array_merge($this->settingsData, $settings);
     if (empty($settings)) {
         throw new Exception('No settings file found. Aborting.');
     }
     if (!isset($settings['dbConn:standard'])) {
         throw new Exception('Mandatory "dbConn:standard" is missing in settings file. Aborting.');
     }
     $this->settingsData = $this->parseValues($settings);
 }
Exemple #20
0
 protected function printDefectTrace(PHPUnit_Framework_TestFailure $defect)
 {
     global $CFG;
     parent::printDefectTrace($defect);
     $failedTest = $defect->failedTest();
     $testName = get_class($failedTest);
     $exception = $defect->thrownException();
     $trace = $exception->getTrace();
     if (class_exists('ReflectionClass')) {
         $reflection = new ReflectionClass($testName);
         $file = $reflection->getFileName();
     } else {
         $file = false;
         $dirroot = realpath($CFG->dirroot) . DIRECTORY_SEPARATOR;
         $classpath = realpath("{$CFG->dirroot}/lib/phpunit/classes") . DIRECTORY_SEPARATOR;
         foreach ($trace as $item) {
             if (strpos($item['file'], $dirroot) === 0 and strpos($item['file'], $classpath) !== 0) {
                 if ($content = file_get_contents($item['file'])) {
                     if (preg_match('/class\\s+' . $testName . '\\s+extends/', $content)) {
                         $file = $item['file'];
                         break;
                     }
                 }
             }
         }
     }
     if ($file === false) {
         return;
     }
     $cwd = getcwd();
     if (strpos($file, $cwd) === 0) {
         $file = substr($file, strlen($cwd) + 1);
     }
     $this->write("\nTo re-run:\n phpunit {$testName} {$file}\n");
 }
Exemple #21
0
 function RPTOPDetails($http_post_vars, $sess, $rptopID)
 {
     global $auth;
     $this->sess = $sess;
     $this->user = $auth->auth;
     $this->formArray["uid"] = $auth->auth["uid"];
     $this->user = $auth->auth;
     // must have atleast AM-VIEW access
     $pageType = "%%1%%%%%%%";
     if (!checkPerms($this->user["userType"], $pageType)) {
         header("Location: Unauthorized.php" . $this->sess->url(""));
         exit;
     }
     $this->tpl = new rpts_Template(getcwd(), "keep");
     $this->tpl->set_file("rptsTemplate", "RPTOPDetails.htm");
     $this->tpl->set_var("TITLE", "RPTOP Information");
     $this->formArray = array("cityAssessorName" => "", "cityTreasurerName" => "");
     $this->formArray["rptopID"] = $rptopID;
     $this->formArray["landTotalMarketValue"] = 0;
     $this->formArray["landTotalAssessedValue"] = 0;
     $this->formArray["plantTotalMarketValue"] = 0;
     $this->formArray["plantTotalAssessedValue"] = 0;
     $this->formArray["bldgTotalMarketValue"] = 0;
     $this->formArray["bldgTotalAssessedValue"] = 0;
     $this->formArray["machTotalMarketValue"] = 0;
     $this->formArray["machTotalAssessedValue"] = 0;
     foreach ($http_post_vars as $key => $value) {
         $this->formArray[$key] = $value;
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $noDevMode = (bool) $input->getOption('no-dev');
     $optimize = (bool) $input->getOption('optimize-autoloader');
     $build = new Build(new ConsoleIO($input, $output, $this->getHelperSet()));
     $build->build(getcwd(), $optimize, $noDevMode);
 }
 /**
  * Delete selected gallery
  * Gallery must be empty, with no child galleries and no related articles
  */
 public static function deleteGalleryAction($mysqli)
 {
     // get posted gallery ID
     if (!empty($_POST["gallery"])) {
         // check for given gallery in DB
         include_once getcwd() . '/scripts/data-helpers/elrh_db_extractor.php';
         $result = ELRHDataExtractor::retrieveRow($mysqli, "SELECT g.id, (SELECT count(*) FROM elrh_gallery_images i WHERE i.gallery = g.id) AS images, (SELECT count(*) FROM elrh_gallery_galleries c WHERE c.parent = g.id) AS children, (SELECT count(*) FROM elrh_articles a WHERE a.gallery = g.id) AS articles FROM elrh_gallery_galleries g WHERE g.id='" . mysqli_real_escape_string($mysqli, $_POST["gallery"]) . "'");
         if (!empty($result) && $result[0] != "db_error") {
             // gallery details loaded
             if ($result["images"] == 0 && $result["children"] == 0 && $result["articles"] == 0) {
                 // perform delete
                 include_once getcwd() . '/scripts/data-helpers/elrh_db_manipulator.php';
                 $query = ELRHDataManipulator::deleteRecord($mysqli, "DELETE FROM elrh_gallery_galleries WHERE id='" . mysqli_real_escape_string($mysqli, $_POST["gallery"]) . "'");
                 if ($query) {
                     // gallery edited
                     return "admin_delete_gallery_success";
                 } else {
                     // delete query wasn't successful
                     return "admin_delete_gallery_fail";
                 }
             } else {
                 // cannot delete
                 return "admin_delete_gallery_restricted";
             }
         } else {
             // wrong gallery id
             return "admin_gallery_wrongid";
         }
     } else {
         // input not set correctly
         return "admin_gallery_noid";
     }
 }
 public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
 {
     $_source_file_path = str_replace(':', '.', $_template->source->filepath);
     $_cache_id = isset($_template->cache_id) ? preg_replace('![^\\w\\|]+!', '_', $_template->cache_id) : null;
     $_compile_id = isset($_template->compile_id) ? preg_replace('![^\\w\\|]+!', '_', $_template->compile_id) : null;
     $_filepath = $_template->source->uid;
     if ($_template->smarty->use_sub_dirs) {
         $_filepath = substr($_filepath, 0, 2) . DS . substr($_filepath, 2, 2) . DS . substr($_filepath, 4, 2) . DS . $_filepath;
     }
     $_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
     if (isset($_cache_id)) {
         $_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
     } else {
         $_cache_id = '';
     }
     if (isset($_compile_id)) {
         $_compile_id = $_compile_id . $_compile_dir_sep;
     } else {
         $_compile_id = '';
     }
     $_cache_dir = $_template->smarty->getCacheDir();
     if ($_template->smarty->cache_locking) {
         if (!preg_match('/^([\\/\\\\]|[a-zA-Z]:[\\/\\\\])/', $_cache_dir)) {
             $_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
         } else {
             $_lock_dir = $_cache_dir;
         }
         $cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock';
     }
     $cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
     $cached->timestamp = @filemtime($cached->filepath);
     $cached->exists = !!$cached->timestamp;
 }
 function _upLoadFiles($files)
 {
     $this->directorio = getcwd() . $this->carpeta;
     if (!is_array($files) || $files == "" || $files == null) {
         echo "No existe archivo que subir";
     } else {
         $nombre = basename($files['userfile']['name']);
         $tipoArchivo = basename($files['userfile']['type']);
         $tamano = basename($files['userfile']['size']);
         $messajes = false;
         if (!array_key_exists(array_search($tipoArchivo, $this->allowed), $this->allowed)) {
             echo "<p>La extensi&oacute;n " . $tipoArchivo . " o el tama&ntilde;o " . $tamano . " de los archivos no es correcta.";
         } else {
             if (!is_dir($this->directorio)) {
                 mkdir($this->directorio, 777, true);
             }
             chmod($this->carpeta, 777);
             $up = move_uploaded_file($files['userfile']['tmp_name'], $this->carpeta . $nombre);
             if ($up) {
                 $messajes = $nombre;
             }
             $files = null;
             return $messajes;
         }
     }
 }
 /**
  * Execute command
  *
  * @param InputInterface  $input  Input
  * @param OutputInterface $output Output
  *
  * @return int|null|void
  *
  * @throws Exception
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $path = $input->getArgument('path');
     /**
      * We load the options to work with
      */
     $options = $this->getUsableConfig($input);
     /**
      * Building the real directory or file to work in
      */
     $filesystem = new Filesystem();
     if (!$filesystem->isAbsolutePath($path)) {
         $path = getcwd() . DIRECTORY_SEPARATOR . $path;
     }
     if (!is_file($path) && !is_dir($path)) {
         throw new Exception('Directory or file "' . $path . '" does not exist');
     }
     /**
      * Print dry-run message if needed
      */
     $this->printDryRunMessage($input, $output, $path);
     /**
      * Print all configuration block if verbose level allows it
      */
     $this->printConfigUsed($output, $options);
     $fileFinder = new FileFinder();
     $files = $fileFinder->findPHPFilesByPath($path);
     /**
      * Parse and fix all found files
      */
     $this->parseAndFixFiles($input, $output, $files, $options);
 }
Exemple #27
0
function bacaFile($namafile)
{
    global $dir, $mysqli;
    $file = fopen(getcwd() . "/" . $namafile, "r");
    $baris = fgets($file);
    while (($baris = fgets($file)) == !FALSE) {
        $data = explode(",", $baris);
        if (count($data) > 3) {
            $strAngkot = $data[0];
            $strSQL = "SELECT * FROM angkot WHERE angkot_name = '{$strAngkot}'";
            $rst = $mysqli->query($strSQL);
            $rows = $rst->fetch_array();
            if (count($rows) == 0) {
                $strSQL = "INSERT INTO angkot SET angkot_name = '{$strAngkot}', angkot_desc = '{$strAngkot}', angkot_price = '4000'";
                $rst = $mysqli->query($strSQL);
                $angkot_id = $mysqli->insert_id;
            } else {
                $angkot_id = $rows[0];
            }
            $strJalan = $data[1];
            $latitude = $data[2];
            $longitude = $data[3];
            $strSQL = "INSERT INTO rute SET angkot_id = '{$angkot_id}', rute_name = '{$strJalan}', latitude = '{$latitude}', longitude = '{$longitude}'";
            $rst = $mysqli->query($strSQL);
        }
    }
}
 public function testDefaultDirsAreWorkingDir()
 {
     $env = new Environment();
     $this->assertEquals(getcwd(), $env->directories[0]);
     $env = new Environment('blah');
     $this->assertEquals(getcwd(), $env->compileDirectory);
 }
 public function Run($app_code, $action)
 {
     if (is_dir("../vendor_core/phing/phing")) {
         // installation from "claromentis/installer" folder
         $phing_path = "../vendor_core/phing/phing";
     } elseif (is_dir("vendor/phing/phing")) {
         // installation from "claromentis" folder (usually, by a developer or Cla 7)
         $phing_path = "vendor/phing/phing";
     } elseif (is_dir("../vendor/phing/phing")) {
         // should not be needed, but still included
         $phing_path = "../vendor/phing/phing";
     } else {
         throw new \Exception("Cannot find phing");
     }
     $phing_path = realpath($phing_path);
     $old_pwd = getcwd();
     chdir($this->base_dir);
     $cmd = PHP_BINARY . ' ' . $phing_path . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "phing -Dapp={$app_code} {$action}";
     $this->io->write("Running command: {$cmd}");
     $ret = -1;
     passthru($cmd, $ret);
     chdir($old_pwd);
     if ($ret !== 0) {
         $msg = "Phing returned non-zero code - {$ret}";
         $this->io->writeError($msg);
         throw new \Exception($msg);
     }
 }
 /**
  * populate Source Object with meta data from Resource
  *
  * @param Smarty_Template_Source   $source    source object
  * @param Smarty_Internal_Template $_template template object
  *
  * @throws SmartyException
  */
 public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
 {
     $uid = sha1(getcwd());
     $sources = array();
     $components = explode('|', $source->name);
     $exists = true;
     foreach ($components as $component) {
         $s = Smarty_Resource::source(null, $source->smarty, $component);
         if ($s->type == 'php') {
             throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
         }
         $sources[$s->uid] = $s;
         $uid .= realpath($s->filepath);
         if ($_template && $_template->smarty->compile_check) {
             $exists = $exists && $s->exists;
         }
     }
     $source->components = $sources;
     $source->filepath = $s->filepath;
     $source->uid = sha1($uid);
     if ($_template && $_template->smarty->compile_check) {
         $source->timestamp = $s->timestamp;
         $source->exists = $exists;
     }
     // need the template at getContent()
     $source->template = $_template;
 }