Run the query files in a given directory.

@param string $strAction create, insert, or drop
@throws Exception
16414
protected function queryFiles($strAction)
	{
		if (!in_array($strAction, ['create', 'insert', 'drop']))
			throw new Exception('Invalid parameter "' . $strAction . '" sent to SudoBible::queryFiles()');

		$strPath = 'queries/' . $this->dbType . '/' . $strAction;
		foreach (scandir($strPath) as $strFilename) {

			// Only run SQL files (eliminates ., .., and subdirs)
			// Using in_array() in case DBs other than SQL are supported in the future.
			if (in_array(substr($strFilename, -4), ['.sql'])) {
				$mResult = $this->db->query(file_get_contents($strPath . '/' . $strFilename));

				// Check success if creating or dropping
				if ('insert' !== $strAction && true !== $mResult) {
					throw new Exception('Unable to ' . $strAction . ' table in ' . $strFilename
						. ' - please ensure your DB user has the right permissions.');
				}
			}
		}
	}
667282
public function run()
  {
    $moduleFile = $this->getModulePath();
    $moduleName = $this->getModuleClass();

    /* load required /app/mod_{$this->moduleName}.php file */
    if(!file_exists($moduleFile) || !is_readable($moduleFile))
    {
      throw new Exception("Module resource not found (" . $this->getModuleName() . ")", 404);
    }
    else
    {
      require_once($moduleFile);
    }

    /* check if required module class exists */
    if(!class_exists($moduleName) || !in_array("TS3WA_Module", class_parents($moduleName)))
    {
      throw new Exception("Module resource not found (" . $this->getModuleName() . ")", 404);
    }

    /* spawn new module */
    $this->module = new $moduleName($this);

    /* check if required action method exists */
    if(!method_exists($this->module, $this->getActionMethod()))
    {
      throw new Exception("Action resource not found (" . $this->getActionName() . ")", 404);
    }

    /* call required action method */
    call_user_func(array($this->module, $this->getActionMethod()));

    /* render template */
    if($this->module->isRender())
    {
      $this->module->dispatch();
    }
  }
1018594
public function run()
    {
        require __DIR__.'/../../../../vendor/autoload.php';
        $handler_pool = new \Pool($this->API->settings['threading']['handler_workers']);
        $this->ready = true;
        while ($this->API->run_workers) {
            try {
                $this->API->datacenter->sockets[$this->current]->reading = true;
                //$this->logger->logger('RECEIVING');
                $error = $this->API->recv_message($this->current);
                $this->logger->logger('NOW HANDLE');
                $handler_pool->submit(new SocketHandler($this->API, $this->current, $error));
                $this->logger->logger('SUBMITTED');
                $this->API->datacenter->sockets[$this->current]->reading = false;
            } catch (\danog\MadelineProto\NothingInTheSocketException $e) {
                //$this->logger->logger('Nothing in the socket for dc '.$this->current, \danog\MadelineProto\Logger::VERBOSE);
            }
        }
        while ($number = $handler_pool->collect()) {
            $this->logger->logger(sprintf(\danog\MadelineProto\Lang::$current_lang['shutting_down_handler_pool'], $this->current, $number), \danog\MadelineProto\Logger::NOTICE);
        }
        $this->setGarbage();
    }
62983
public function run()
    {
        $this->run_called = true;
        $this->hook('beforeRender');
        $this->is_rendering = true;

        // if no App layout set
        if (!isset($this->html)) {
            throw new Exception(['App layout should be set.']);
        }

        $this->html->template->set('title', $this->title);
        $this->html->renderAll();
        $this->html->template->appendHTML('HEAD', $this->html->getJS());
        $this->is_rendering = false;
        $this->hook('beforeOutput');

        if (isset($_GET['__atk_callback']) && $this->catch_runaway_callbacks) {
            $this->terminate('!! Callback requested, but never reached. You may be missing some arguments in '.$_SERVER['REQUEST_URI']);
        }

        echo $this->html->template->render();
    }
1252544
public function run($path)
    {

        $this->createMigrationRepository();
        $repository = $this->migrator->getRepository();
        $migrations = $this->migrator->getMigrationFiles($path);
        $ran        = $repository->getRan();
        if (!empty($migrations)) {
            $files = array_keys($migrations);
            foreach ($files as $name) {
                if (!in_array($name, $ran)) {
                    continue;
                }
                $migration            = new stdClass();
                $migration->migration = $name;
                $repository->delete($migration);
            }
        }


        $this->migrator->run($path);
    }
1359861
public function execute($arguments)
  {
    // Validate on given command.
    if (!isset($this->options['cmd'])) {
      throw new \Exception(sprintf('No command given for "%s"', $this->name));
      exit(1);
    }

    // If a explicit working directory is specifified, we change to that to call
    // the command.
    $workingDir = $this->getWorkingDir();
    if (isset($workingDir)) {
      chdir($workingDir);
    }

    // Execute the command.
    $status = NULL;
    $cmd = $this->options['cmd'];

    // If a explicit command dir is given, we use an absolute path to the command.
    $cmdDir = $this->getCmdDir();
    if (isset($cmdDir)) {
      $cmd = $cmdDir . '/' . $cmd;
    }
    $cmd = escapeshellcmd($cmd);

    // Add passed arguments to the command.
    foreach ($arguments as $arg) {
      $cmd .= ' ' . escapeshellarg($arg);
    }
    passthru($cmd, $status);
    exit($status);
  }
287653
public function Run($data = null) {
        $FrameworkList = DirectoryManager::GetFilesNamesRecursively(
                        "APP_ROOT_DIR" . \Puzzlout\Framework\Enums\FrameworkFolderName::ViewsFolderName);
        $ApplicationList = DirectoryManager::GetFilesNamesRecursively(
                        "APP_ROOT_DIR" .
                        \Puzzlout\Framework\Enums\ApplicationFolderName::AppsFolderName .
                        "APP_NAME" .
                        \Puzzlout\Framework\Enums\ApplicationFolderName::ViewsFolderName);
        $this->InitGenerateFrameworkFile($FrameworkList);
        $this->InitGenerateApplicationFile($ApplicationList);
    }
514381
public static function start(String $file)
    {
        if( ! Info::available($file) )
        {
            throw new Exception\FileNotFoundException($file);
        }

        self::readFileContent($file);
    }
695448
public function run($params = null)
    {
        $this->parser = new Parser($this->paths);

        try {
            $argc = ($params === null) ? null : count($params);
            $this->result = $this->parser->parse($argc, $params);
        } catch (\Exception $e) {
            $this->parser->displayError($e->getMessage());
        }

        $this->parse();
    }
219280
public function run()
    {
        if (is_object($this->connection())) {
            try {
                $stmt = $this->connection()->prepare($this->schema);

                if ($this->checkSchemaExistence) {
                    return $stmt->rowCount();
                } elseif ($return = $stmt->execute()) {
                    return $return;
                } else {
                    return false;
                }
            } catch (\PDOException $e) {
                throw new \Exception($e->getMessage());
            }
        }
    }
816343
public function run()
	{
		// First lets login to the phpMyAdmin Server, if not already.
		if ($this->loggedIn == null)
		{
			$result = $this->taskPhpMyAdminLogin()
				->phpMyAdminUrl($this->phpMyAdminUrl)
				->phpMyAdminUser($this->phpMyAdminUser)
				->phpMyAdminPass($this->phpMyAdminPass)
				->remoteDbHost($this->remoteDbHost)
			->run();

			if (!$result->wasSuccessful())
			{
				throw new RuntimeException('Failed to Login!');
			}

			$this->loggedIn = $result->getTask();
		}

		// Create our dump filename
		$dump_name = tempnam(sys_get_temp_dir(), 'dump');

		// Create our dump locally
		$cmd = 'mysqldump '.
			'-h'.$this->localDbHost.
			' -u'.$this->localDbUser.
			' '.(empty($this->localDbPass) ? '' : '-p'.$this->localDbPass).
			' '.$this->localDbName.' > '.$dump_name
		;

		$this->printTaskInfo('Dumping db on local server - <info>'.$cmd.'</info>');
		if (!$this->taskExec($cmd)->run()->wasSuccessful())
		{
			throw new RuntimeException
			(
				'Failed to create dump locally.'.
				'HINT: Is the `mysqldump` binary in your "PATH"?'
			);
		}

		// Compress the dump
		$this->printTaskInfo('Compressing dump on local server');
		if ($fp_out = gzopen($dump_name.'.gz', 'wb9'))
		{
			if ($fp_in = fopen($dump_name, 'rb'))
			{
				while (!feof($fp_in))
				{
					gzwrite($fp_out, fread($fp_in, 1024 * 512));
				}

				fclose($fp_in);
			}
			else
			{
				throw new RuntimeException
				(
					'Failed to open source dump file for reading.'
				);
			}

			gzclose($fp_out);
		}
		else
		{
			throw new RuntimeException
			(
				'Failed to open destination compressed dump file for writing.'
			);
		}

		// Get a list of tables from phpMyAdmin
		$result = $this->taskPhpMyAdminListTables($this->loggedIn)
			->remoteDbName($this->remoteDbName)
		->run();

		if (!$result->wasSuccessful())
		{
			throw new RuntimeException('Failed to get list of tabels!');
		}

		$tables = $result->getTask()->getTables();

		// Check to see if we have any tables
		if (count($tables) > 0)
		{
			// Create the sql query to drop all those tables
			$sql = 'SET foreign_key_checks = 0; DROP TABLE ';
			foreach ($tables as $table) $sql .= $table.', ';
			$sql = substr($sql, 0, -2).'; SET foreign_key_checks = 1;';

			// Droping the tables
			$this->printTaskInfo('Droping tables from phpmyadmin.');
			$result = $this->taskExecuteSqlViaPhpMyAdmin($sql, $this->loggedIn)
				->remoteDbName($this->remoteDbName)
			->run();

			// Check to make sure it worked
			if (!$result->wasSuccessful())
			{
				throw new RuntimeException('Failed to drop tables via phpmyadmin.');
			}
		}

		// Upload the dump
		$this->printTaskInfo('Uploading sql dump.');
		$response = $this->loggedIn->getClient()->post('import.php',
		[
			'multipart' =>
			[
				[
					'name' => 'db',
					'contents' => $this->remoteDbName
				],
				[
					'name' => 'server',
					'contents' => $this->loggedIn->getServerId()
				],
				[
					'name' => 'token',
					'contents' => $this->loggedIn->getToken()
				],
				[
					'name' => 'import_type',
					'contents' => 'database'
				],
				[
					'name' => 'file_location',
					'contents' => 'on'
				],
				[
					'name' => 'import_file',
					'contents' => fopen($dump_name.'.gz', 'r')
				],
				[
					'name' => 'charset_of_file',
					'contents' => 'utf-8'
				],
				[
					'name' => 'allow_interrupt',
					'contents' => 'yes'
				],
				[
					'name' => 'skip_queries',
					'contents' => '0'
				],
				[
					'name' => 'format',
					'contents' => 'sql'
				],
				[
					'name' => 'sql_compatibility',
					'contents' => 'NONE'
				],
				[
					'name' => 'sql_no_auto_value_on_zero',
					'contents' => 'something'
				]
			]
		])->getBody();

		// Check that it worked
		if (!s::create($response)->contains('Import has been successfully finished'))
		{
			throw new RuntimeException('Failed to import dump via phpmyadmin. OH NO - we just dropped all the tables!!!');
		}

		// Remove the dump from the local server
		$this->printTaskInfo('Removing dump from local server. - <info>'.$dump_name.'</info>');
		unlink($dump_name); unlink($dump_name.'.gz');

		// If we get to here assume everything worked
		return Result::success($this);
	}
1221998
public static function autocreate_directory($directory)
    {
        if (!file_exists($directory)) {
            mkdir($directory, 0777, true);
        }

        if (!is_writable($directory)) {
            throw new \Exception("Directory \"{$directory}\" is not writable");
        }
    }
355208
public function run()
    {
        if (PHP_SAPI === 'cli' && is_subclass_of($this, ConsoleAppInterface::class))
        {
            $this->execConsoleApp();
        }
        else if (is_subclass_of($this, WebAppInterface::class))
        {
            $this->execWebApp();
        }
        else
        {
            throw new \Exception("No interface was implemented");
        }
    }
167300
private function runView(): void
    {
        $action = ($this->routeAction) ? $this->routeAction : 'index';

        \call_user_func([$this->view, $action]);
    }
1311479
public void execRun(String command) throws IOException, PHPException {
	    writeCommand("R" + command);
	    phpConsoleLogger.write(command);
		String readLine = readLine();
        phpConsoleLogger.read(readLine);
		
	}
581854
final function execute() {
		//parse content first, to allow for any ADDTEMPLATE items
		$content = $this->parseContent($this->data['bodycontent']);

		if( !$this->getLayoutClass()	){
			throw new \Exception('No layout class defined.');
		}
		$layoutClass = $this->getLayoutClass();
		$layout = new $layoutClass($this->getSkin(), $this);
		//set up standard content zones
		//head element (including opening body tag)
		$layout->addHTMLTo('head', $this->html('headelement') );
		//the logo image defined in LocalSettings
		$layout->addHTMLTo('logo', $this->data['logopath']);
		$layout->addHTMLTo('prepend:body', $this->html( 'prebodyhtml' ));
		//the article title
		if($this->showTitle){
			$layout->addHTMLTo('content-container.class', 'has-title');
			$layout->addHTMLTo('title-html', $this->data['title']);
		}
		//article content
		$layout->addHTMLTo('content-html', $content);
		//the site notice
		if( !empty($this->data['sitenotice'])){
			$layout->addHTMLTo('site-notice', $this->data['sitenotice']);
		}
		//the site tagline, if there is one
		if($this->showTagline){
			$layout->addHTMLTo('content-container.class', 'has-tagline');
			$layout->addHTMLTo('tagline', $this->getMsg('tagline') );
		}
		$breadcrumbTrees = $this->breadcrumbs();
		$layout->addTemplateTo('breadcrumbs', 'breadcrumbs', array('trees' => $breadcrumbTrees) );

		// if(\Skinny::hasContent('toc')){
		// 	$layout->addHTMLTo('toc', (\Skinny::getContent('toc')[0]['html']));
		// }

		// if ( $this->data['dataAfterContent'] ) {
		// 	$layout->addHTMLTo('append:content', $this->data['dataAfterContent']);
		// }
		//the contents of Mediawiki:Sidebar
		// $layout->addTemplate('classic-sidebar', 'classic-sidebar', array(
		// 	'sections'=>$this->data['sidebar']
		// ));
		// //list of language variants
		// $layout->addTemplate('language-variants', 'language-variants', array(
		// 	'variants'=>$this->data['language_urls']
		// ));

		//page footer
		$layout->addHookTo('footer-links', array($this,'getFooterLinks'));
		$layout->addHookTo('footer-icons', array($this,'getFooterIcons'));
		//mediawiki needs this to inject script tags after the footer
		$layout->addHookTo('append:body', array($this,'afterFooter'));


		$this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getCode();

		//allow skins to set up before render
		$this->initialize();

		echo $layout->render();
		// $this->printTrail();
	}
825554
public function run($request)
    {
        $currentSite = Multisites::inst()->getCurrentSite();
        $folderName  = $currentSite->Host ? $currentSite->Host : "site-$currentSite->ID";
        $folder      = Folder::find_or_make($folderName);

        $files = File::get()->filter('ParentID', array(0))->exclude('ID', $folder->ID);

        if (!$files->count()) {
            return;
        }

        foreach ($files as $file) {
            if (file_exists($file->getFullPath())) {
                $file->ParentID = $folder->ID;
                $file->write();
                echo $file->Filename.' moved <br />';
            }
        }
    }