コード例 #1
0
ファイル: Generator.php プロジェクト: vyppn/stirlingframe
 public static function delete($command)
 {
     array_shift($command);
     array_shift($command);
     $cmd_string = implode(':', $command);
     if (preg_match_all("/^(project|app)[:]([a-zA-z][a-zA-z0-9]+)\$/", $cmd_string, $regex_output)) {
         $type = $regex_output[1][0];
         $name = $regex_output[2][0];
         switch ($type) {
             case 'project':
                 $dir = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'dist' . DIRECTORY_SEPARATOR . $name;
                 if (file_exists($dir)) {
                     $chk = true;
                     $confirm = "Are you sure you want to " . Color::RED . "delete" . Color::RESET . " `{$name}` [no/yes]?" . Color::RESET . ': ';
                     fwrite(STDOUT, "");
                     fwrite(STDOUT, $confirm);
                     while ($chk) {
                         $handle = fopen("php://stdin", "r");
                         $line = fgets($handle);
                         if (trim($line) != 'yes' and trim($line) != 'no') {
                             fwrite(STDOUT, "");
                             fwrite(STDOUT, "Just type '" . Color::BOLD_GREEN . "yes'" . Color::RESET . " or '" . Color::BOLD_GREEN . "no'" . Color::RESET . PHP_EOL);
                             fwrite(STDOUT, $confirm);
                         } else {
                             $chk = false;
                         }
                     }
                     if (trim($line) == 'no') {
                         fwrite(STDOUT, "");
                         fwrite(STDOUT, '[ABORTED]: ' . Color::BOLD_UNDERLINE . "Nothing is deleted." . Color::RESET . PHP_EOL . PHP_EOL);
                     } else {
                         self::$i = 0;
                         self::$allfiles = self::count_files($dir . '/');
                         StopWatch::start();
                         self::rrmdir($dir);
                         $seconds = round(StopWatch::elapsed(), 4);
                         fwrite(STDERR, "");
                         fwrite(STDERR, PHP_EOL);
                         fwrite(STDOUT, "");
                         fwrite(STDOUT, Color::BOLD_GREEN . '[SUCCESS]: Project deleted.' . Color::RESET . PHP_EOL);
                         fwrite(STDOUT, Drawing::SUCCESS_BOX('Stirlingframe->Delelte:', "# Project `{$name}` has been delete.", "# " . self::$allfiles . " files have been removed in " . $seconds . "s."));
                         fwrite(STDOUT, PHP_EOL);
                     }
                 } else {
                     fwrite(STDOUT, "");
                     $header = 'Stirlingframe delete error:';
                     $desc = '# Project `' . $name . '` not exist';
                     fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Can\'t delete project.' . Color::RESET . PHP_EOL);
                     fwrite(STDOUT, Drawing::ERROR_BOX($header, $desc));
                     fwrite(STDOUT, PHP_EOL);
                 }
                 break;
             case 'app':
                 fwrite(STDOUT, '$create ' . $type . ' ' . $name . PHP_EOL);
                 break;
         }
     } else {
         $msg = Color::CYAN . '$' . Color::RESET . ' delete [project|app] [name]               ';
         fwrite(STDOUT, "");
         fwrite(STDOUT, Color::BOLD_RED . '[ERROR]: Invalid command.' . Color::RESET . PHP_EOL);
         fwrite(STDOUT, Drawing::ERROR_BOX('Stirlingframe create error:', '# Invalid parameters: command should be', $msg));
         fwrite(STDOUT, PHP_EOL);
     }
 }
コード例 #2
0
ファイル: admin_check_imgs.php プロジェクト: xctcc/congtu
	if(!empty($not_in_all_folders)){
		echo_msg( '--- Removing images not found in all folders<br/>');
		echo_msg( '---<br/>',1);

		foreach($not_in_all_folders as $k=>$v){
			@unlink(CFIMAGEPATH.$v);
			@unlink(CFTHUMBPATH.$v);
			@unlink(CFSMALLTHUMBPATH.$v);
			@unlink(CFBANDWIDTHPATH.$k.'_imgbw.db');
		}
		echo_msg('---<br/>',1);
	}
	unset($not_in_all_folders);

	echo_msg('--- Done<br/>--- Total Time Elapsed: '.round($stopwatch->elapsed(),4).' seconds<br />');
	echo_msg('</body></html>');


//////////////////////////////////////////////////////////////////////////////////////////
// functions

	function echo_msg($msg,$flush = 0){
		global $autouse;
		if($autouse) return;
		echo $msg;
		if($flush) flushNow($flush);
	}

	function get_extension($imagetype, $includeDot = false){
		global $acceptedFormats;