public function actionCreate($dir, $fileName)
	{
		if (FileSystem::write('./'.$dir.'/'.$fileName, '', 'x'))
			$msg = 'Файл Создан';
		else
			$msg = 'Файл Не Создан';
			
		echo CJSON::encode(array('msg' => $msg));
	}
 public function update()
 {
     $dir = 'mainContent.components.widgets.views.MainContent.'.$this->widgetModel->pk.'.';
             
     if (isset($_POST['list-template'])) {
         FileSystem::write(Yii::getPathOfAlias($dir.'listTemplate').'.twig', $_POST['list-template']);
     }
     if (isset($_POST['item'])) {
         FileSystem::write(Yii::getPathOfAlias($dir.'item').'.twig', $_POST['item']);
     }
     if (isset($_POST['full'])) {
         FileSystem::write(Yii::getPathOfAlias($dir.'full').'.twig', $_POST['full']);
     }
 }
 /**
  * Write to stream
  */
 public function stream_write($data)
 {
     if (!in_array($this->mode, ['w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+'])) {
         return 0;
     }
     //TODO: lock directory to ensure it exists when file is created
     $filename = $this->getFileName();
     $dirname = dirname($filename);
     if (!$this->fileSystem->isDirectory($dirname)) {
         trigger_error("Directory {$dirname} not exists", E_USER_WARNING);
         return 0;
     }
     $fpos = $this->fpos;
     if (in_array($this->mode, ['a', 'a+'])) {
         $fpos = -1;
     }
     $bytesWritten = $this->fileSystem->write($filename, $fpos, $data);
     if (!in_array($this->mode, ['a', 'a+'])) {
         $this->fpos += $bytesWritten;
     }
     return $bytesWritten;
 }
Beispiel #4
0
// TODO: considerar el language de la app
$ctx = YuppContext::getInstance();
$locale = $ctx->setLocale('en');
// Hace el request y catchea por posibles errores.
try {
    RequestManager::doRequest();
} catch (Exception $e) {
    // FIXME: mostrar la vista de error 500
    // FIXME: en modo PROD NUNCA deberia mostrar paths ni el stacktrace.
    // http://code.google.com/p/yupp/issues/detail?id=147
    if (YuppConfig::getInstance()->getCurrentMode() === YuppConfig::MODE_PROD) {
        echo 'Disculpe las molestias, verificaremos el error en breve.';
        // FIXME: i18n
        // Redirect a pagina de error por defecto?
        if (file_exists('ylogs/500')) {
            FileSystem::write('ylogs/500/err_' . date("Ymd.his") . '.log', print_r($ctx, true));
        }
    } else {
        echo '<html><body>';
        echo '<h1>Ha ocurrido un error!</h1>';
        // TODO: i18n
        echo '<div style="border:1px solid #333; padding:10px; width:800px;">';
        echo '<div style="border:1px solid #333; background-color:#ffffaa; overflow:auto; padding:5px; margin-bottom:2px;">';
        echo 'Mensaje:';
        // TODO: i18n
        echo '</div>';
        echo '<div style="border:1px solid #333; background-color:#ffff80; overflow:auto; padding:10px;">';
        echo $e->getMessage() . " [" . $e->getFile() . " : " . $e->getLine() . "]";
        echo '</div>';
        //print_r( $e->getTrace() );
        echo '<div style="border:1px solid #333; background-color:#ffaaaa; overflow:auto; padding:5px; margin-bottom:2px; margin-top:10px;">';
Beispiel #5
0
<?php

// Load in the file system class
include 'filesystem.class2.php';
$file = new FileSystem();
// Write to file (silent)
$filename = "../includes/nyheder/nyhedstitel.html";
$content = $_POST["titelnyhed"];
$file->write($filename, $content);
// Write to file (silent)
$filename = "../includes/nyheder/nyhedstekst.html";
$content = $_POST["tekstnyhed"];
$file->write($filename, $content);
// Redirect to form
header('Location: ../nyheder.php?success');
Beispiel #6
0
 /**
  * Crea una nueva aplicacion con nombre $name.
  * En $params se pasarian parametros extra como clases del
  * modelo y sus campos para crear una estructura mas rica.
  * Este parametro todavia no se usa.
  * Tira una excepcion si no puede crear la estructura de directorios.
  */
 public static function create($name, $params = array())
 {
     $normalizedName = String::toUnderscore(String::filterCharacters($name));
     $appStruct = array('./apps/' . $normalizedName, './apps/' . $normalizedName . '/controllers', './apps/' . $normalizedName . '/model', './apps/' . $normalizedName . '/views', './apps/' . $normalizedName . '/services', './apps/' . $normalizedName . '/i18n', './apps/' . $normalizedName . '/bootstrap', './apps/' . $normalizedName . '/config', './apps/' . $normalizedName . '/utils');
     foreach ($appStruct as $package) {
         //echo "intenta crear $package<br/>";
         if (!file_exists($package) && !mkdir($package)) {
             throw new Exception('No se puede crear el directorio ' . $package . ', verifique que tiene los permisos suficientes');
         }
     }
     // FIXME: pueden venir tildes y cualquier tipo de caracter, deberia filtrar todo lo que venga mal, o pedirle que lo corrija.
     // TODO: crear descriptor con el nombre de la app
     $appDescriptor = FileSystem::read('./core/app/templates/app.xml');
     $appDescriptor = str_replace('{appName}', $name, $appDescriptor);
     if (isset($params['description'])) {
         $appDescriptor = str_replace('{appDescription}', $params['description'], $appDescriptor);
     }
     if (isset($params['langs'])) {
         $appDescriptor = str_replace('{appLangs}', $params['langs'], $appDescriptor);
     }
     if (isset($params['controller'])) {
         $appDescriptor = str_replace('{epController}', $params['controller'], $appDescriptor);
         $appDescriptor = str_replace('{epAction}', 'index', $appDescriptor);
         $templateController = FileSystem::read('./core/app/templates/TemplateController.class.php');
         $templateController = str_replace('Template', String::firstToUpper($params['controller']), $templateController);
         echo './apps/' . $normalizedName . '/controllers/apps.' . $normalizedName . '.controllers.' . String::firstToUpper($params['controller']) . 'Controller.class.php';
         FileSystem::write('./apps/' . $normalizedName . '/controllers/apps.' . $normalizedName . '.controllers.' . String::firstToUpper($params['controller']) . 'Controller.class.php', $templateController);
     }
     FileSystem::write('./apps/' . $normalizedName . '/app.xml', $appDescriptor);
 }
Beispiel #7
0
	public function update()
	{
		return FileSystem::write($this->filePath.'/'.$this->alias.$this->ext, $this->template, 'w');
	}
Beispiel #8
0
      <?php 
// http://code.google.com/p/yupp/issues/detail?id=147
if (YuppConfig::getInstance()->getCurrentMode() === YuppConfig::MODE_PROD) {
    ?>
        Disculpe las molestias, verificaremos el error en breve.
        <?php 
    // TODO: esto deberia estar en Logger
    // log a disco
    /*
    if (!file_exists('_manage_errors'))
    {
       mkdir('_manage_errors', 755);
    }
    */
    if (file_exists('ylogs/500')) {
        FileSystem::write('ylogs/500/err_' . date("Ymd.his") . '.log', getOutput($m, true));
    }
    ?>
      <?php 
} else {
    ?>
        <div class="text">
          <?php 
    echo getOutput($m);
    ?>
        </div>
      <?php 
}
?>
    </div>
  </body>