public function sedFile($ftp, $ftp_folder, $file)
 {
     $directory = explode('/', $file);
     $real_file = $directory[count($directory) - 1];
     if (count($directory) > 1) {
         unset($directory[count($directory) - 1]);
         $path = implode('/', $directory);
         addDir($ftp_folder, $path, $ftp);
     }
     if ($real_file != '') {
         $send = ftp_put($ftp, $ftp_folder . $file, $file, FTP_ASCII);
     }
 }
function addDir($root, $level = 0)
{
    $root = realpath($root);
    $out = '';
    $prepend = !$level ? "\n\n### " : "\n" . str_repeat('  ', $level) . '* ';
    foreach (glob($root . '/*') as $filepath) {
        if (substr($filepath, -9) === 'README.md') {
            continue;
        }
        if (is_dir($filepath)) {
            $basename = preg_replace('/^\\d{2}_/', '', basename($filepath));
            $basename = str_replace('_', ' ', $basename);
            $out .= $prepend . '**' . $basename . '**' . addDir($filepath, $level + 1);
        } elseif (preg_match('/^#+\\s*(.*)/', file_get_contents($filepath), $m)) {
            $url = str_replace(realpath(__DIR__ . '/../'), 'https://github.com/s9e/TextFormatter/blob/master', $filepath);
            $out .= $prepend . '[' . str_replace('[', '\\[', $m[1]) . '](' . $url . ')';
        }
    }
    return $out;
}
Exemple #3
0
 * 
 * @author Martin Vagovszky
 */
define('VERBOSE_MODE', false);
$srcRoot = dirname(__DIR__);
$buildRoot = __DIR__;
$filename = 'nlp.phar';
if (file_exists($buildRoot . DIRECTORY_SEPARATOR . $filename)) {
    unlink($buildRoot . DIRECTORY_SEPARATOR . $filename);
}
$pharPath = $buildRoot . DIRECTORY_SEPARATOR . $filename;
$phar = new \Phar($pharPath, 0, $filename);
$phar->startBuffering();
$phar->addFromString('index.php', php_strip_whitespace($srcRoot . DIRECTORY_SEPARATOR . "index.php"));
addDir($phar, $srcRoot . DIRECTORY_SEPARATOR . "vendor", $srcRoot);
addDir($phar, $srcRoot . DIRECTORY_SEPARATOR . "module", $srcRoot);
$stub = <<<EOF
<?php
Phar::mapPhar("{$filename}");
require "phar://{$filename}/index.php";
__HALT_COMPILER();

EOF;
$phar->setStub($stub);
$phar->stopBuffering();
if (file_exists($pharPath)) {
    echo "Phar created successfully in {$pharPath}\n";
    chmod($pharPath, 0755);
} else {
    echo "Error during the compile of the Phar file {$pharPath}\n";
    exit(2);
Exemple #4
0
     /*	Display of tool options */
     $content = settingsForm(array('show_score' => $course_info['show_score'], 'student_delete_own_publication' => $studentDeleteOwnPublication));
     break;
 case 'add':
 case 'create_dir':
     if (!$is_allowed_to_edit) {
         api_not_allowed();
     }
     $form = new FormValidator('form1', 'post', api_get_path(WEB_CODE_PATH) . 'work/work.php?action=create_dir&' . api_get_cidreq());
     $form->addElement('header', get_lang('CreateAssignment'));
     $form->addElement('hidden', 'action', 'add');
     $defaults = isset($_POST) ? $_POST : array();
     $form = getFormWork($form, $defaults);
     $form->addButtonCreate(get_lang('CreateDirectory'));
     if ($form->validate()) {
         $result = addDir($_POST, $user_id, $_course, $group_id, $id_session);
         if ($result) {
             $message = Display::return_message(get_lang('DirectoryCreated'), 'success');
         } else {
             $message = Display::return_message(get_lang('CannotCreateDir'), 'error');
         }
         Session::write('message', $message);
         header('Location: ' . $currentUrl);
         exit;
     } else {
         $content = $form->return_form();
     }
     break;
 case 'delete_dir':
     if ($is_allowed_to_edit) {
         $work_to_delete = get_work_data_by_id($_REQUEST['id']);
             $dirbox[] = $darray[1];
             $i++;
         }
     }
     //系统附件存放目录
     $dirarray[$i++] = addDir($cfg_medias_dir, '图片/上传文件默认路径', 0, 0, 1);
     //专题目录
     $dirarray[$i++] = addDir('/special', '专题目录', 0, 0, 1);
     //data/js目录
     $dirarray[$i++] = addDir('/data/js', '生成js目录', 0, 0, 1);
     //$remotefile = array();
     //把非系统目录的内容提取出来
     foreach ($remotefile as $key => $value) {
         //处理用户自定义配置
         if ($value['issystem'] == 0) {
             $dirarray[$i++] = addDir($value['filedir'], $value['description'], $value['dfserv'], $value['state'], $value['issystem']);
         }
     }
     updateConfig($dirarray);
     ShowMsg("成功更新同步目录,请重新对目录进行同步操作!", "makeremote_all.php");
     exit;
 } else {
     if ($dopost == 'make') {
         if ($step == 1) {
             if ($maketype == 'makeall') {
                 //如果更新所有,则需要重新组合$Iterm
                 foreach ($remotefile as $key => $val) {
                     $Iterm[] = $val['filedir'];
                 }
             } else {
                 //初始化配置
Exemple #6
0
$BUILD_NUMBER = $info->nextBuild++;
$opts = getopt("", ["rc", "beta"]);
if (isset($opts["beta"])) {
    $CLASS = "Beta";
} elseif (isset($opts["rc"])) {
    $CLASS = "RC";
}
$VERSION = $info->version->major . "." . $info->version->minor . "-" . $CLASS . "#" . $BUILD_NUMBER;
file_put_contents("compile/info.json", json_encode($info, JSON_BIGINT_AS_STRING | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
$permissions = [];
if (is_file("permissions.xml")) {
    $permissions = parsePerms(new SimpleXMLElement(file_get_contents("permissions.xml")), [])["children"];
}
$file = "compile/" . $NAME . "_" . $CLASS . ".phar";
if (is_file($file)) {
    unlink($file);
}
$phar = new Phar($file);
$phar->setStub('<?php require_once "phar://" . __FILE__ . "/entry/entry.php"; __HALT_COMPILER();');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->startBuffering();
$phar->addFromString("plugin.yml", yaml_emit(["name" => $NAME, "author" => $info->author, "authors" => $info->authors ?? [], "main" => $info->main, "api" => $info->api, "depend" => $info->depend ?? [], "softdepend" => $info->softdepend ?? [], "loadbefore" => $info->loadbefore ?? [], "description" => $info->description ?? "", "website" => $info->website ?? "", "prefix" => $info->prefix ?? $NAME, "load" => $info->load ?? "POSTWORLD", "version" => $VERSION, "commands" => $info->commands ?? [], "permissions" => $permissions, "generated" => date(DATE_ISO8601)]));
addDir($phar, "src", "src");
addDir($phar, "entry", "entry");
addDir($phar, "resources", "resources");
$phar->stopBuffering();
echo "Created {$NAME} {$CLASS} #{$BUILD_NUMBER}", PHP_EOL;
exec("git add " . escapeshellarg($file));
if (is_file("priv/postCompile.php")) {
    include_once "priv/postCompile.php";
}
// define file and path
$filename = 'zf2rapid.phar';
$pharPath = ZF2RAPID_ROOT . '/' . $filename;
// unlink phar if exists
if (file_exists($pharPath)) {
    unlink($pharPath);
}
// create phar and add files
$phar = new \Phar($pharPath, 0, $filename);
$phar->startBuffering();
$phar->addFromString(ZF2RAPID_ROOT . '/bin/zf2rapid.php', substr(php_strip_whitespace(ZF2RAPID_ROOT . '/bin/zf2rapid.php'), 19));
addDir($phar, ZF2RAPID_ROOT . '/bin', ZF2RAPID_ROOT);
addDir($phar, ZF2RAPID_ROOT . '/config', ZF2RAPID_ROOT);
addDir($phar, ZF2RAPID_ROOT . '/language', ZF2RAPID_ROOT);
addDir($phar, ZF2RAPID_ROOT . '/src', ZF2RAPID_ROOT);
addDir($phar, ZF2RAPID_ROOT . '/vendor', ZF2RAPID_ROOT);
$phar->setStub($phar->createDefaultStub('bin/zf2rapid.php'));
$phar->stopBuffering();
// stop processing
if (file_exists($pharPath)) {
    echo 'Phar created successfully in ' . $pharPath . "\n";
    chmod($pharPath, 0755);
} else {
    echo 'Error during the compile of the Phar file ' . $pharPath . "\n";
    exit(2);
}
/**
 * Add a directory in phar removing whitespaces from PHP source code
 *
 * @param Phar   $phar
 * @param string $sDir
Exemple #8
0
    fwrite($destHandle, "\n    /" . "/ Totally, {$totalBytes} Bytes in {$srcCnt} Files added.\n}\n");
    fclose($destHandle);
}
function addDir($dirname, $mask)
{
    $dirhandle = @opendir($dirname);
    if (!$dirhandle) {
        echo "Cannot open directory \"{$dirname}\".";
        exit;
    }
    while ($folderentry = readdir($dirhandle)) {
        if ($folderentry[0] != '.' && !is_dir("{$dirname}/{$folderentry}")) {
            if (preg_match($mask, $folderentry)) {
                addFile("{$dirname}/{$folderentry}", $folderentry);
            }
        }
    }
    closedir($dirhandle);
}
/*****************************************************************************
 * Needed Files
 *****************************************************************************/
openDest('data.cpp');
addFile('skins/silveriness.sjs/main.xml', 'defaultskin.xml');
addDir('skins/silveriness.sjs', '/^z_.*\\.xml$/');
addDir('skins/silveriness.sjs', '/^z_.*\\.png$/');
addDir('karaoke_bg/', '/^.*\\.jpg$/');
addFile('icons/icons16.png', 'icons16.png');
addFile('icons/icons32.png', 'icons32.png');
addFile('icons/aboutlogo.gif', 'aboutlogo.gif');
closeDest();
 * @license http://framework.zend.com/license/new-bsd New BSD License
 */
$srcRoot = dirname(__DIR__);
$buildRoot = __DIR__;
$filename = 'namespacer.phar';
if (file_exists($buildRoot . "/{$filename}")) {
    unlink($buildRoot . "/{$filename}");
}
$pharPath = $buildRoot . "/{$filename}";
$phar = new \Phar($pharPath, 0, $filename);
$phar->startBuffering();
// remove the first line in zf.php
$phar->addFromString('namespacer.php', substr(php_strip_whitespace("{$srcRoot}/namespacer.php"), 19));
addDir($phar, "{$srcRoot}/vendor", $srcRoot);
addDir($phar, "{$srcRoot}/config", $srcRoot);
addDir($phar, "{$srcRoot}/src", $srcRoot);
$stub = <<<EOF
#!/usr/bin/env php
<?php
/*
* This file is part of Namespacer command line tool
*/
Phar::mapPhar('{$filename}');
require 'phar://{$filename}/namespacer.php';
__HALT_COMPILER();

EOF;
$phar->setStub($stub);
$phar->stopBuffering();
if (file_exists($pharPath)) {
    echo "Phar created successfully in {$pharPath}\n";
 /**
  * Restore Works
  * @param int $sessionId
  */
 public function restore_works($sessionId = 0)
 {
     require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
     if ($this->course->has_resources(RESOURCE_WORK)) {
         $table_work_assignment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
         $resources = $this->course->resources;
         foreach ($resources[RESOURCE_WORK] as $obj) {
             // check resources inside html from ckeditor tool and copy correct urls into recipient course
             $obj->params['description'] = DocumentManager::replace_urls_inside_content_html_from_copy_course($obj->params['description'], $this->course->code, $this->course->destination_path, $this->course->backup_path, $this->course->info['path']);
             $id_work = $obj->params['id'];
             $obj->params['id'] = null;
             $obj->params['c_id'] = $this->destination_course_info['real_id'];
             // re-create dir
             // @todo check security against injection of dir in crafted course backup here!
             $path = $obj->params['url'];
             $path = '/' . str_replace('/', '', substr($path, 1));
             $workData = array();
             switch ($this->file_option) {
                 case FILE_SKIP:
                     $workData = get_work_data_by_path($path, $this->destination_course_info['real_id']);
                     if (!empty($workData)) {
                         continue;
                     }
                 case FILE_OVERWRITE:
                     // Creating folder.
                     $workData = get_work_data_by_path($path, $this->destination_course_info['real_id']);
                 case FILE_RENAME:
                     $obj->params['new_dir'] = $obj->params['title'];
                     if (!empty($this->course_origin_id)) {
                         $sql = 'SELECT * FROM ' . $table_work_assignment . '
                                 WHERE
                                     c_id = ' . $this->course_origin_id . ' AND
                                     publication_id = ' . $id_work;
                         $result = Database::query($sql);
                         $cant = Database::num_rows($result);
                         if ($cant > 0) {
                             $row = Database::fetch_assoc($result);
                         }
                         //$obj->params['qualification'] = empty($row['enable_qualification']) ? true : false;
                         $obj->params['enableExpiryDate'] = $row['expires_on'] == '0000-00-00 00:00:00' ? false : true;
                         $obj->params['enableEndDate'] = $row['ends_on'] == '0000-00-00 00:00:00' ? false : true;
                         $obj->params['expires_on'] = $row['expires_on'];
                         $obj->params['ends_on'] = $row['ends_on'];
                         $obj->params['enable_qualification'] = $row['enable_qualification'];
                         $obj->params['add_to_calendar'] = !empty($row['add_to_calendar']) ? 1 : 0;
                         if (empty($workData)) {
                             addDir($obj->params, api_get_user_id(), $this->destination_course_info, 0, $sessionId);
                         } else {
                             $workId = $workData['id'];
                             updateWork($workId, $obj->params, $this->destination_course_info, $sessionId);
                             updatePublicationAssignment($workId, $obj->params, $this->destination_course_info, 0);
                         }
                     }
                     break;
             }
         }
     }
 }
Exemple #11
0
    $localPath = rtrim($localPath, "/\\") . "/";
    echo "Directory transfer: {$realPath} > {$localPath}", PHP_EOL;
    foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($realPath)) as $path) {
        if (!$path->isFile()) {
            continue;
        }
        $path = str_replace("\\", "/", (string) $path);
        if (strpos($path, ".git") !== false) {
            continue;
        }
        $relative = ltrim(substr($path, strlen($realPath)), "/");
        $local = $localPath . $relative;
        $num = str_pad((string) ++$i, 3, "0", STR_PAD_LEFT);
        echo "\r[{$num}] Adding: " . realpath($path) . " to {$local}";
        $phar->addFile($path, $local);
    }
    echo "\n";
}
$phar = new Phar($filename);
$phar->setStub('<?php require_once "entry/entry.php"; __HALT_COMPILER();');
$phar->setSignatureAlgorithm(Phar::SHA1);
$phar->setMetadata($manifest);
$phar->startBuffering();
$phar->addFromString("plugin.yml", $pluginYml);
$phar->addFromString("resources/meta.build.json", json_encode($buildData, JSON_UNESCAPED_SLASHES | JSON_BIGINT_AS_STRING));
addDir($phar, realpath("src"), "src");
addDir($phar, realpath("resources"), "resources");
$phar->stopBuffering();
if (is_file("priv\\postCompile.php")) {
    require_once "priv\\postCompile.php";
}
 */
$srcRoot = dirname(__DIR__);
$filename = 'zs-client.phar';
$pharPath = __DIR__ . "/{$filename}";
if (file_exists($pharPath)) {
    unlink($pharPath);
}
$phar = new \Phar($pharPath, 0, $filename);
$phar->startBuffering();
// remove the first line in the index file
$phar->addFromString("index.php", substr(php_strip_whitespace("{$srcRoot}/bin/zs-client.php"), 19));
addDir($phar, "{$srcRoot}/vendor", $srcRoot);
if (is_dir("{$srcRoot}/config")) {
    addDir($phar, "{$srcRoot}/config", $srcRoot);
}
addDir($phar, "{$srcRoot}/module", $srcRoot);
$stub = <<<EOF
#!/usr/bin/env php
<?php
/*
 * This file is part of Zend Server WebAPI command line tool
 *
 * @link      http://github.com/zendframework/ZFTool for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */
define('PHAR', true);
define('CWD', getcwd());
chdir(dirname(__DIR__));
Phar::mapPhar('{$filename}');
require 'phar://{$filename}/index.php';