コード例 #1
0
ファイル: actions.class.php プロジェクト: theolymp/diem
 public function executeCommand(sfWebRequest $request)
 {
     $command = trim($request->getParameter("dm_command"));
     if (substr($command, 0, 2) == "sf") {
         $command = substr($command, 3);
         $exec = sprintf('%s "%s" %s --color', sfToolkit::getPhpCli(), dmProject::getRootDir() . '/symfony', $command);
     } else {
         $options = substr(trim($command), 0, 2) == 'll' || substr(trim($command), 0, 2) == 'ls' ? '--color' : '';
         $parts = explode(" ", $command);
         $parts[0] = dmArray::get($this->getAliases(), $parts[0], $parts[0]);
         $command = implode(" ", $parts);
         $parts = explode(" ", $command);
         $command = dmArray::get($this->getAliases(), $command, $command);
         if (!in_array($parts[0], $this->getCommands())) {
             return $this->renderText(sprintf("%s<li>This command is not available. You can do: <strong>%s</strong></li>", $this->renderCommand($command), implode(' ', $this->getCommands())));
         }
         $exec = sprintf("%s {$options}", $command);
     }
     ob_start();
     passthru($exec . ' 2>&1', $return);
     $raw = dmAnsiColorFormatHtmlRenderer::render(ob_get_clean());
     $arr = explode("\n", $raw);
     $res = $this->renderCommand($command);
     foreach ($arr as $a) {
         $res .= "<li class='dm_result_command'><pre>" . $a . "</pre></li>";
     }
     return $this->renderText($res);
 }
コード例 #2
0
ファイル: dmFileBackup.php プロジェクト: theolymp/diem
 /**
  * Backup a file
  * return boolean success
  */
 public function save($file)
 {
     if (!$this->isEnabled()) {
         return true;
     }
     if (!dmProject::isInProject($file)) {
         $file = dmOs::join(dmProject::getRootDir(), $file);
     }
     if (!is_readable($file)) {
         throw new dmException('Can no read ' . $file);
     }
     $relFile = dmProject::unRootify($file);
     $backupPath = dmOs::join($this->getDir(), dirname($relFile));
     if (!$this->filesystem->mkdir($backupPath)) {
         throw new dmException('Can not create backup dir ' . $backupPath);
     }
     $backupFile = dmOs::join($backupPath, basename($relFile) . '.' . date('Y-m-d_H-i-s'));
     if (!$this->filesystem->touch($backupFile, 0777)) {
         throw new dmException('Can not copy ' . $file . ' to ' . $backupFile);
     }
     file_put_contents($backupFile, file_get_contents($file));
     $this->filesystem->chmod($file, 0777);
     return true;
 }
コード例 #3
0
ファイル: indexSuccess.php プロジェクト: theolymp/diem
<?php

echo _tag('div#content_message_editor.clearfix.mt10', ''), _tag('div#dm_code_editor.clearfix', array('json' => array('get_dir_content_url' => _link('+/dmCodeEditor/getDirContent')->getHref(), 'save_file_url' => _link('+/dmCodeEditor/saveFile')->getHref(), 'open_file_url' => _link('+/dmCodeEditor/openFile')->getHref(), 'path_replacements' => array_flip($editor->getOption('path_replacements')))), _tag('div#dm_code_editor_tree.ui-corner-all', _tag('p.dm_root_dir.ui-corner-top', _tag('span.s16.s16_drive_arrow.block', '&nbsp;' . dmProject::getRootDir())) . _tag('div#dm_code_editor_tree_inner')) . _tag('div#dm_code_editor_content', _tag('div.dm_code_editor_content_tabs', _tag('ul'))));