示例#1
0
function generate_application($app_path)
{
    $app_name = strtolower(end(split(DIRECTORY_SEPARATOR, $app_path)));
    $app_real_path = realpath($app_path);
    p('info', sprintf('will generate application %s in %s ', ucfirst($app_name), $app_real_path));
    create_folder($app_real_path);
    foreach (array('app', 'public', 'config', 'vendor', 'lib', 'log') as $f) {
        create_folder(make_path($app_real_path, $f));
    }
    $medick_path = realpath(make_path(dirname(__FILE__), '..'));
    create_file($app_real_path, 'boot.php', 'boot.php', array('app_real_path' => $app_real_path, 'medick_path' => $medick_path));
    create_file($app_real_path, 'config.xml', make_path('config', $app_name . '.xml'), array('app_name' => $app_name, 'app_real_path' => $app_real_path));
    create_file($app_real_path, 'htaccess', make_path('public', '.htaccess'), array('app_name' => $app_name));
    create_file($app_real_path, 'index.php', make_path('public', 'index.php'), array('app_name' => $app_name, 'app_real_path' => $app_real_path));
    touch(make_path($app_real_path, 'log', 'localhost.log'));
    chmod(make_path($app_real_path, 'log', 'localhost.log'), 0777);
    exit;
}
示例#2
0
 function get($id)
 {
     if (!$this->auth->logged()) {
         redirect('inicio');
     }
     $dir = make_path($this->config->item('upload_path') . 'arquivo/');
     $file = $this->product->getUserDownloadById($id);
     if ($file) {
         $file = $dir . $file;
         header("Content-type: application/force-download");
         header("Content-Transfer-Encoding: Binary");
         header("Content-length: " . filesize($file));
         header("Content-disposition: attachment; filename=\"" . basename($file) . "\"");
         readfile("{$file}");
         $this->product->updateQuantity($id);
     } else {
         $this->messages->add("Desculpe, o limite de download para este produto foi esgotado!");
         redirect('downloads');
         die;
     }
 }
示例#3
0
function make_path($pathname, $is_filename = false)
{
    if ($is_filename) {
        $pathname = substr($pathname, 0, strrpos($pathname, '/'));
    }
    // Check if directory already exists
    if (is_dir($pathname) || empty($pathname)) {
        return true;
    }
    // Ensure a file does not already exist with the same name
    $pathname = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $pathname);
    if (is_file($pathname)) {
        trigger_error('mkdir() File exists', E_USER_WARNING);
        return false;
    }
    // Crawl up the directory tree
    $next_pathname = substr($pathname, 0, strrpos($pathname, DIRECTORY_SEPARATOR));
    if (make_path($next_pathname)) {
        if (!file_exists($pathname)) {
            return mkdir($pathname, 0777);
        }
    }
    return false;
}
示例#4
0
         }
     }
     Session::Messages($langElRen, 'alert-success');
     redirect_to_home_page($redirect_base_url, true);
 }
 // Step 1: Show rename dialog box
 if (isset($_GET['rename'])) {
     $fileName = Database::get()->querySingle("SELECT filename FROM document\n                                             WHERE {$group_sql} AND\n                                                   path = ?s", $_GET['rename'])->filename;
     $dialogBox .= "\n            \n            <div id='rename_doc_file' class='row'>\n                <div class='col-xs-12'>\n                    <div class='form-wrapper'>\n                        <form class='form-horizontal' role='form' method='post' action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}'>\n                            <fieldset>                                \n                                    <input type='hidden' name='sourceFile' value='" . q($_GET['rename']) . "' />\n                                    {$group_hidden_input}\n                                    <div class='form-group'>\n                                        <label for='renameTo' class='col-sm-2 control-label word-wrapping' >" . q($fileName) . "</label>\n                                        <div class='col-sm-10'>\n                                            <input class='form-control' type='text' name='renameTo' value='" . q($fileName) . "' />\n                                        </div>\n                                    </div>\n                                    <div class='form-group'>\n                                        <div class='col-sm-offset-2 col-sm-10'>\n                                            <input class='btn btn-primary' type='submit' value='{$langRename}' >\n                                        </div>\n                                    </div>\n                            </fieldset>\n                        </form>\n                    </div>\n                </div>\n            </div>";
 }
 // create directory
 // step 2: create the new directory
 if (isset($_POST['newDirPath'])) {
     $newDirName = canonicalize_whitespace($_POST['newDirName']);
     if (!empty($newDirName)) {
         $newDirPath = make_path($_POST['newDirPath'], array($newDirName));
         // $path_already_exists: global variable set by make_path()
         if ($path_already_exists) {
             $action_message = "<div class='alert alert-danger'>{$langFileExists}</div>";
         } else {
             $r = Database::get()->querySingle("SELECT id FROM document WHERE {$group_sql} AND path = ?s", $newDirPath);
             Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $r->id);
             $action_message = "<div class='alert alert-success'>{$langDirCr}</div>";
         }
     }
 }
 // step 1: display a field to enter the new dir name
 if (isset($_GET['createDir'])) {
     $createDir = q($_GET['createDir']);
     $dialogBox .= "\n        <div class='row'>        \n        <div class='col-md-12'>            \n                <div class='panel padding-thin focused'>\n                    <form action='{$_SERVER['SCRIPT_NAME']}?course={$course_code}' method='post' class='form-inline' role='form'>\n                        {$group_hidden_input}\n                        <input type='hidden' name='newDirPath' value='{$createDir}' />\n                        <div class='form-group'>\n                            <input type='text' class='form-control' id='newDirName' name='newDirName' placeholder='{$langNameDir}'>\n                        </div>\n                        <button type='submit' class='btn btn-primary'>\n                            <i class='fa fa-plus space-after-icon'></i>\n                            {$langCreateDir}\n                        </button>\n                    </form>\n                </div>\n            </div>\n        </div>";
 }
示例#5
0
文件: Watcher.php 项目: shinichi81/ci
 /**
  * Add path to exclusions list.
  *
  * @param $path
  * @param $exclude_folders
  */
 private function addToExclusions($path, $exclude_folders)
 {
     foreach ($exclude_folders as $folder) {
         $this->exclusions[] = make_path([$path, $folder]);
     }
 }
function process_extracted_file($p_event, &$p_header)
{
    global $uploadPath, $realFileSize, $basedir, $course_id, $subsystem, $subsystem_id, $uploadPath, $group_sql;
    $replace = isset($_POST['replace']);
    if (!isset($uploadPath)) {
        $uploadPath = '';
    }
    $file_category = isset($_POST['file_category']) ? $_POST['file_category'] : 0;
    $file_creator = isset($_POST['file_creator']) ? $_POST['file_creator'] : '';
    $file_author = isset($_POST['file_author']) ? $_POST['file_author'] : '';
    $file_subject = isset($_POST['file_subject']) ? $_POST['file_subject'] : '';
    $file_language = isset($_POST['file_language']) ? $_POST['file_language'] : '';
    $file_copyrighted = isset($_POST['file_copyrighted']) ? $_POST['file_copyrighted'] : '';
    $file_comment = isset($_POST['file_comment']) ? $_POST['file_comment'] : '';
    $file_description = isset($_POST['file_description']) ? $_POST['file_description'] : '';
    $realFileSize += $p_header['size'];
    $stored_filename = $p_header['stored_filename'];
    if (invalid_utf8($stored_filename)) {
        $stored_filename = cp737_to_utf8($stored_filename);
    }
    $path_components = explode('/', $stored_filename);
    $filename = php2phps(array_pop($path_components));
    if (unwanted_file($filename)) {
        $filename .= '.bin';
    }
    $file_date = date("Y\\-m\\-d G\\:i\\:s", $p_header['mtime']);
    $path = make_path($uploadPath, $path_components);
    if ($p_header['folder']) {
        // Directory has been created by make_path(),
        // only need to update the index
        $r = Database::get()->querySingle("SELECT id FROM document WHERE {$group_sql} AND path = ?s", $path);
        Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $r->id);
        return 0;
    } else {
        // Check if file already exists
        $result = Database::get()->querySingle("SELECT id, path, visible FROM document\n                                           WHERE {$group_sql} AND\n                                                 path REGEXP ?s AND\n                                                 filename = ?s LIMIT 1", "^{$path}/[^/]+\$", $filename);
        $format = get_file_extension($filename);
        if ($result) {
            $old_id = $result->id;
            $file_path = $result->path;
            $vis = $result->visible;
            if ($replace) {
                // Overwrite existing file
                $p_header['filename'] = $basedir . $file_path;
                Database::get()->query("UPDATE document\n                                                 SET date_modified = ?t\n                                                 WHERE {$group_sql} AND\n                                                       id = ?d", $file_date, $old_id);
                return 1;
            } else {
                // Rename existing file
                $backup_n = 1;
                do {
                    $backup = preg_replace('/\\.[a-zA-Z0-9_-]+$/', '', $filename) . '_backup_' . $backup_n . '.' . $format;
                    $n = Database::get()->querySingle("SELECT COUNT(*) as count FROM document\n                                                              WHERE {$group_sql} AND\n                                                                    path REGEXP ?s AND\n                                                                    filename = ?s LIMIT 1", "^{$path}/[^/]+\$", $backup)->count;
                    $backup_n++;
                } while ($n > 0);
                Database::get()->query("UPDATE document SET filename = ?s\n                                                 WHERE {$group_sql} AND\n                                                       path = ?s", $backup, $file_path);
                Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $old_id);
            }
        }
        $path .= '/' . safe_filename($format);
        $id = Database::get()->query("INSERT INTO document SET\n                                 course_id = ?d,\n                                 subsystem = ?d,\n                                 subsystem_id = ?d,\n                                 path = ?s,\n                                 filename = ?s,\n                                 visible = 1,\n                                 comment = ?s,\n                                 category = ?d,\n                                 title = '',\n                                 creator = ?s,\n                                 date = ?t,\n                                 date_modified = ?t,\n                                 subject = ?s,\n                                 description = ?s,\n                                 author = ?s,\n                                 format = ?s,\n                                 language = ?s,\n                                 copyrighted = ?d", $course_id, $subsystem, $subsystem_id, $path, $filename, $file_comment, $file_category, $file_creator, $file_date, $file_date, $file_subject, $file_description, $file_author, $format, $file_language, $file_copyrighted)->lastInsertID;
        // Logging
        Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $id);
        Log::record($course_id, MODULE_ID_DOCS, LOG_INSERT, array('id' => $id, 'filepath' => $path, 'filename' => $filename, 'comment' => $file_comment));
        // File will be extracted with new encoded filename
        $p_header['filename'] = $basedir . $path;
        return 1;
    }
}
示例#7
0
/**
 * @brief insert common docs
 * @global type $course_id
 * @global type $course_code
 * @global string $group_sql
 * @param type $file
 * @param type $target_dir
 */
function insert_common_docs($file, $target_dir) {
    global $course_id, $course_code, $group_sql;

    $common_docs_dir_map = array();

    if ($file->format == '.dir') {
        $target_dir = make_path($target_dir, array($file->filename));
        $r = Database::get()->querySingle("SELECT id FROM document WHERE $group_sql AND path = ?s", $target_dir);
        Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $r->id);
        $common_docs_dir_map[$file->path] = $target_dir;
        $q = Database::get()->queryArray("SELECT * FROM document
                                      WHERE course_id = -1 AND
                                            subsystem = " . COMMON . " AND
                                            path LIKE ?s
                                      ORDER BY path", $file->path . '/%');
        foreach ($q as $file) {
            $new_target_dir = $common_docs_dir_map[dirname($file->path)];
            if ($file->format == '.dir') {
                $new_dir = make_path($new_target_dir, array($file->filename));
                $r2 = Database::get()->querySingle("SELECT id FROM document WHERE $group_sql AND path = ?s", $new_dir);
                Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $r2->id);
                $common_docs_dir_map[$file->path] = $new_dir;
            } else {
                insert_common_docs($file, $new_target_dir);
            }
        }
    } else {
        $path = preg_replace('|^.*/|', $target_dir . '/', $file->path);
        if ($file->extra_path) {
            $extra_path = $file->extra_path;
        } else {
            $extra_path = "common:$file->path";
        }
        $q = Database::get()->query("INSERT INTO document SET
                                course_id = ?d,
                                subsystem = " . MAIN . ",
                                path = ?s,
                                extra_path = ?s,
                                filename = ?s,
                                visible = 1,
                                comment = ?s,
                                title =	?s,
                                date = " . DBHelper::timeAfter() . ",
                                date_modified =	" . DBHelper::timeAfter() . ",
                                format = ?s", $course_id, $path, $extra_path, $file->filename, $file->comment, $file->title, $file->format);
        $id = $q->lastInsertID;
        Indexer::queueAsync(Indexer::REQUEST_STORE, Indexer::RESOURCE_DOCUMENT, $id);
    }
}
示例#8
0
文件: Test.php 项目: shinichi81/ci
 public function getFullPathAttribute($value)
 {
     return make_path([$this->suite->testsFullPath, $this->name]);
 }
示例#9
0
// complete path to medick boot.php file.
include_once('<?php 
echo make_path($app_real_path, 'boot.php');
?>
');
// complete path to <?php 
echo $app_name;
?>
.xml and environment to load
$d= new Dispatcher( ContextManager::load(
      '<?php 
echo make_path($app_real_path, 'config', $app_name . '.xml');
?>
',
      'localhost'));
$d->dispatch();

示例#10
0
文件: Suite.php 项目: shinichi81/ci
 public function getTestsFullPathAttribute($value)
 {
     return make_path([$this->project->tests_full_path, $this->tests_path]);
 }
示例#11
0
echo "\r\n";
// Parse arguments
if (3 == $argc) {
    $path_search = rtrim($argv[1], '/');
    $filename_report = $argv[2];
} else {
    echo "password_search <directory> <report>\r\n";
    echo "\r\n";
    echo "<directory>  directory to search for password\r\n";
    echo "<report>     path to the report file (csv format)\r\n";
    echo "\r\n";
    exit(-1);
}
// Create report path and file
$path_parts = pathinfo($filename_report);
make_path($path_parts['dirname']);
$handle_report = fopen($filename_report, 'w');
if ($handle_report === FALSE) {
    echo "Cannot open {$filename_report}\r\n";
    echo "\r\n";
    exit(-2);
} else {
    fputcsv($handle_report, array("File", "Line", "Password"), ',');
}
// Expand the regular expression array and remove duplicates
$array_regex_expanded = array();
foreach ($array_regex as $regex) {
    foreach ($array_keywords as $keyword) {
        array_push($array_regex_expanded, str_replace('KEYWORD', $keyword, $regex));
    }
}
示例#12
0
function download_or_load($debug, $file_name, $url, $method, $referer = null, $post_hash = null)
{
    if (file_exists('proxy.txt')) {
        $proxy = file_get_contents('proxy.txt');
    }
    make_path($file_name, true);
    if ($debug) {
        if (!file_exists($file_name)) {
            if ($proxy) {
                $html = download_curl($url, $method, $proxy, $referer, $post_hash);
            } else {
                $html = download($url, $method, $referer, $post_hash);
            }
            file_put_contents($file_name, $html);
        } else {
            $html = file_get_contents($file_name);
        }
    } else {
        if ($proxy) {
            $html = download_curl($url, $method, $proxy, $referer, $post_hash);
        } else {
            $html = download($url, $method, $referer, $post_hash);
        }
    }
    return $html;
}
示例#13
0
文件: Data.php 项目: shinichi81/ci
 /**
  * Get the test output.
  *
  * @param $test
  * @param $outputFolder
  * @param $extension
  * @return bool|mixed|null|string
  */
 private function getOutput($test, $outputFolder, $extension)
 {
     if (!$outputFolder) {
         return null;
     }
     $name = str_replace(['.php', '::', '\\', '/'], ['', '.', '', ''], $test->name);
     $path = make_path([$test->suite->project->path, $outputFolder]);
     if (file_exists($file = make_path([$path, $name . $extension]))) {
         return $this->encodeFile($file);
     }
     return null;
 }