public function make($items = array(), $html = '', $partial_path = null) { foreach ($items as $child) { $url = empty($child['url']) ? '#' : $child['url']; $has_partial = false; // if partial path is not null // lets try to load from there first if (!is_null($partial_path)) { $has_partial = $this->view_exists($partial_path); if ($has_partial) { $html .= View::make($has_partial)->with('child', $child)->with('theme', $this)->with('url', $url); continue; } } // look on themes partial $has_partial = $this->view_exists($this->theme->_theme_absolute_path . DS . 'views' . DS . 'partials' . DS . 'menu_li'); if ($has_partial) { $html .= View::make($has_partial)->with('child', $child)->with('theme', $this)->with('url', $url); continue; } // look on shared folder partials $has_partial = $this->view_exists(path('public') . 'shared' . DS . 'views' . DS . 'partials' . DS . 'menu_li'); if ($has_partial) { $html .= View::make($has_partial)->with('child', $child)->with('theme', $this)->with('url', $url); continue; } // we did not find the partial // load the default provided by // navigation module $html .= View::make('navigation::partials.menu_li')->with('child', $child)->with('theme', $this)->with('url', $url); } return $html; }
public function index() { $this->subtitle($this('list_teams'))->load->library('table'); $teams = $this->table->add_columns(array(array('content' => function ($data) { return button_sort($data['team_id'], 'admin/ajax/teams/sort.html'); }, 'size' => TRUE), array('title' => $this('teams'), 'content' => function ($data) { return '<a href="' . url('teams/' . $data['team_id'] . '/' . $data['name'] . '.html') . '"><img src="' . path($data['icon_id']) . '" alt="" /> ' . $data['title'] . '</a>'; }), array('title' => $this('game'), 'content' => function ($data) { return '<a href="' . url('admin/games/' . $data['team_id'] . '/' . $data['game'] . '.html') . '"><img src="' . path($data['game_icon']) . '" alt="" /> ' . $data['game_title'] . '</a>'; }), array('title' => '<i class="fa fa-users" data-toggle="tooltip" title="' . $this('players') . '"></i>', 'content' => function ($data) { return $data['users']; }, 'size' => TRUE), array('content' => array(function ($data) { return button_edit('admin/teams/' . $data['team_id'] . '/' . $data['name'] . '.html'); }, function ($data) { return button_delete('admin/teams/delete/' . $data['team_id'] . '/' . $data['name'] . '.html'); }), 'size' => TRUE)))->data($this->model()->get_teams())->no_data($this('no_team'))->display(); $roles = $this->table->add_columns(array(array('content' => function ($data) { return button_sort($data['role_id'], 'admin/ajax/teams/roles/sort.html'); }, 'size' => TRUE), array('content' => function ($data) { return '<a href="' . url('admin/teams/roles/' . $data['role_id'] . '/' . url_title($data['title']) . '.html') . '">' . $data['title'] . '</a>'; }), array('content' => array(function ($data) { return button_edit('admin/teams/roles/' . $data['role_id'] . '/' . url_title($data['title']) . '.html'); }, function ($data) { return button_delete('admin/teams/roles/delete/' . $data['role_id'] . '/' . url_title($data['title']) . '.html'); }), 'size' => TRUE)))->pagination(FALSE)->data($this->model('roles')->get_roles())->no_data($this('no_role'))->display(); return new Row(new Col(new Panel(array('title' => $this('roles'), 'icon' => 'fa-sitemap', 'content' => $roles, 'footer' => button_add('admin/teams/roles/add.html', $this('add_role')), 'size' => 'col-md-12 col-lg-4'))), new Col(new Panel(array('title' => $this('list_teams'), 'icon' => 'fa-gamepad', 'content' => $teams, 'footer' => button_add('admin/teams/add.html', $this('add_team')), 'size' => 'col-md-12 col-lg-8')))); }
/** * Get all of the files at a given path. * * @param string $path * @return array */ protected function globSeedFiles() { if (isset($this->seedFiles)) { return $this->seedFiles; } // If the seeds haven't been read before, we will glob the directories and sort // them alphabetically just in case the developer is using numbers to make // the seed run in a certain order based on their database design needs. $folders = array(path('app') . 'seeds' . DS); foreach (Bundle::$bundles as $bundle) { $folders[] = Bundle::path($bundle['location']) . 'seeds' . DS; } $files = array(); foreach ($folders as $folder) { $files = array_merge($files, glob($folder . '*.php')); } if (false !== $this->getParameter('except')) { $exclude = explode(',', $this->getParameter('except')); foreach ($files as $key => $file) { if (in_array(pathinfo($file, PATHINFO_FILENAME), $exclude)) { unset($files[$key]); } } } sort($files); return $this->seedFiles = $files; }
/** * Install a bundle from by downloading a Zip. * * @param string $url * @param array $bundle * @param string $path * @return void */ protected function zipball($url, $bundle, $path) { $work = path('storage') . 'work/'; // When installing a bundle from a Zip archive, we'll first clone // down the bundle zip into the bundles "working" directory so // we have a spot to do all of our bundle extration work. $target = $work . 'laravel-bundle.zip'; File::put($target, $this->download($url)); $zip = new \ZipArchive(); $zip->open($target); // Once we have the Zip archive, we can open it and extract it // into the working directory. By convention, we expect the // archive to contain one root directory with the bundle. mkdir($work . 'zip'); $zip->extractTo($work . 'zip'); $latest = File::latest($work . 'zip')->getRealPath(); @chmod($latest, 0777); // Once we have the latest modified directory, we should be // able to move its contents over into the bundles folder // so the bundle will be usable by the develoepr. File::mvdir($latest, $path); File::rmdir($work . 'zip'); $zip->close(); @unlink($target); }
function isConnected($URL = false) { if (!SESSION("ZanUser")) { redirect($URL !== false ? $URL : path("users/login/?return_to=" . urlencode(getURL()))); } return true; }
/** * * @param string $view * @param mixed $viewData * @param array $composer * @return mixed */ public function __construct($view, $viewData, $composers) { if (count($composers) != 0) { foreach ($composers as $composer) { $composer = new $composer(); if ($composer->composerData != null) { extract($composer->composerData); } } } if ($viewData != null) { extract($viewData); } $h = IoC::resolve('ViewHelper'); $helper = IoC::resolve('Helper'); ob_start(); require_once path("application/views/{$view}.php"); $layout = isset($layout) ? $layout : 'master'; $view = ob_get_contents(); ob_end_clean(); ob_start(); require_once path("application/views/layout/" . $layout . ".php"); $output = ob_get_contents(); ob_end_clean(); Event::trigger('before_echo', array()); return $this->output = $output; }
/** * Méthode qui charge le fichier plugins.xml (ancien format) * * @return null * @author Stephane F **/ public function loadConfig() { $aPlugins = array(); if (!is_file(path('XMLFILE_PLUGINS'))) { return false; } # Mise en place du parseur XML $data = implode('', file(path('XMLFILE_PLUGINS'))); $parser = xml_parser_create(PLX_CHARSET); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 0); xml_parse_into_struct($parser, $data, $values, $iTags); xml_parser_free($parser); # On verifie qu'il existe des tags "plugin" if (isset($iTags['plugin'])) { # On compte le nombre de tags "plugin" $nb = sizeof($iTags['plugin']); # On boucle sur $nb for ($i = 0; $i < $nb; $i++) { $name = $values[$iTags['plugin'][$i]]['attributes']['name']; $activate = $values[$iTags['plugin'][$i]]['attributes']['activate']; $value = isset($values[$iTags['plugin'][$i]]['value']) ? $values[$iTags['plugin'][$i]]['value'] : ''; $aPlugins[$name] = array('activate' => $activate, 'title' => $value, 'instance' => null); } } return $aPlugins; }
public function run(&$params) { //1.判断用户是否登录,如果登录了才能得到用户id,进而才有可能获取到所拥有的权限 // $userinfo = session('USERINFO'); $userinfo = login(); //自动登录 $admin_id = cookie('admin_id'); $token = cookie('token'); if (!$userinfo) { //自动登录 D('AdminToken')->checkToken($admin_id, $token); // $userinfo = session('USERINFO'); $userinfo = login(); } $url = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME; //忽略验证的请求 $ignore = C('IGNORE_PATH'); if (in_array($url, $ignore)) { return true; } return true; //判断是否有权限,如果没有权限就判断是否登录,登录了就提示切换用户,否则跳到登录页面 if (!in_array($url, path())) { if ($userinfo) { echo '无权访问,<a href="' . U('Admin/Admin/login') . '">切换用户</a>'; exit; } else { redirect(U('Admin/Admin/login'), '请先登录'); exit; } } }
/** * Handle an exception by logging it and either * displaying detailed report or directing to base * exceptions pages * @param Exception $exception The exception being handled * @return void */ public static function exception($exception) { // Send exception to be logged static::log($exception); // If debug enabled, format the exception // to clean message and display on screen if (Configuration::get('error.debug')) { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $trace = $exception->getTraceAsString(); $date = date('d-M-Y H:i:s'); $logMessage = "<h3>System Exception:</h3>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<strong>Date:</strong> {$date}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<strong>Message:</strong> {$message}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<strong>Code:</strong> {$code}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<strong>File:</strong> {$file}\n\t\t\t\t\t</p>\n\t\t\t\t\t<p>\n\t\t\t\t\t\t<strong>Line:</strong> {$line}\n\t\t\t\t\t</p>\n\n\t\t\t\t\t<h3>Stack Trace:</h3>\n\t\t\t\t\t<pre>{$trace}</pre>\n\t\t\t\t\t<br/>\n\t\t\t\t\t<hr/>\n\t\t\t\t\t<br/><br/>"; echo $logMessage; return; } else { // If detailed reports NOT enabled direct to // base exception pages $code = $exception->getCode(); if (!in_array($code, static::$_exceptions)) { $code = '500'; } header("Content-type: text/html"); $view = file_get_contents(path('app') . "views/errors/{$code}" . EXT); echo $view; exit; } // Should it all fail render a fallback template header("Content-type: text/html"); echo "An error occurred."; exit(1); }
public function post_new_city() { $rules = array('city' => 'required|unique:photos', 'picture' => 'required'); $v = Validator::make(Input::all(), $rules); if ($v->fails()) { return Redirect::to('admin/cityphotos')->with_errors($v)->with_input(); } else { $new_photo = array('city' => ucwords(Input::get('city'))); $photo = new Photo($new_photo); if ($photo->save()) { $upload_path = path('public') . Photo::$upload_path_city . $photo->city; if (!File::exists($upload_path)) { File::mkdir($upload_path); } $filename = $photo->city . '.jpg'; $path_to_file = $upload_path . '/' . $filename; $dynamic_path = '/' . Photo::$upload_path_city . $photo->city . '/' . $filename; $success = Resizer::open(Input::file('picture'))->resize(1024, 724, 'auto')->save($path_to_file, 75); if ($success) { $new_photo = Photo::find($photo->id); $new_photo->location = $dynamic_path; $new_photo->save(); } return Redirect::to('admin/cityphotos')->with('msg', '<div class="alert alert-success"><strong>City foto is geupload!</strong></div>'); } else { return Redirect::to('admin/cityphotos')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong></div>'); } } }
public function handle() { $path = BASE_PATH . 'cache' . path('ds') . 'framework' . path('ds'); if ($this->option('skip-database')) { $this->output('Skipping database cache'); } else { $this->output('Clearing database cache'); $this->unlink($path, 'database'); $this->output('Database cache cleared'); } if ($this->option('skip-defaults')) { $this->output('Skipping defaults cache'); } else { $this->output('Clearing defaults cache'); $this->unlink($path, 'defaults'); $this->output('Defaults cache cleared'); } if ($this->option('skip-router')) { $this->output('Skipping router cache'); } else { $this->output('Clearing router cache'); $this->unlink($path, 'router'); $this->output('Router cache cleared'); } }
public function action_create() { $input = Input::all(); if (isset($input['description'])) { $input['description'] = filter_var($input['description'], FILTER_SANITIZE_STRING, FILTER_FLAG_NO_ENCODE_QUOTES); } $rules = array('image' => 'required|image|max:200', 'description' => 'required', 'name' => 'required'); $messages = array('image_required' => 'Please select an image for upload!', 'image_max' => 'Make sure image is no larger than 500kb', 'image_image' => 'Please select an image file'); $validation = Validator::make($input, $rules, $messages); if ($validation->fails()) { return Redirect::to('admin/gallery/new')->with_errors($validation); } $extension = File::extension($input['image']['name']); $directory = path('public') . 'uploads/' . sha1(Auth::user()->id); $filename = sha1(Auth::user()->id . time()) . ".{$extension}"; $upload_success = Input::upload('image', $directory, $filename); if ($upload_success) { $photo = new Image(array('name' => Input::get('name'), 'location' => '/uploads/' . sha1(Auth::user()->id) . '/' . $filename, 'description' => $input['description'], 'type' => $extension)); Auth::user()->images()->insert($photo); Session::flash('status_create', 'Successfully uploaded your new Instapic'); Session::flash('id', $photo->id); } else { Log::write('admin.gallery.create', 'Image was not uploaded, $photo->create() returned false.'); Session::flash('error_create', 'An error occurred while uploading your new Instapic - please try again.'); } return Redirect::to('admin/gallery/new'); }
/** * @test */ public function it_provides_helper_functions() { expect(ds())->to_be(DIRECTORY_SEPARATOR); expect(ds('foo', 'bar', 'baz'))->to_be('foo' . ds() . 'bar' . ds() . 'baz'); expect(path('foo'))->to_be_a('PhpPackages\\Fs\\Path'); expect((string) path(path('foo')))->to_be('foo'); }
public function test_load() { $path = path(__DIR__, '../configs/config.yml'); $driver = new YamlConfigDriver(); $config = $driver->loadFile($path); $this->assertEquals(['foo' => 'bar', 'bar' => 'foo', 'section' => ['yolo' => 'swag']], $config); }
public function execute(callable $next) { $this->application->getProvider()->register(); config()->parseDir(path('app')); chain([Localize::class]); return $next(); }
static function findOneModule($classname) { global $domain, $site_domains; $inc = getIncludePaths(); $dir = getcwd(); // узнаем имя модуля if (substr(strtolower($classname), 0, 1) == "t") { $filename = substr(strtolower($classname), 1); } $modulename = $filename; $filename = $filename . ".class.php"; foreach ($inc as $v) { $path = path($v) . "/"; if (isset($site_domains) && in_array($domain, array_keys($site_domains))) { // Сначала ищем в директории с названием $site_domains[$domain]['modules'] $search_pattern = $path == './' ? $dir . '/modules/' . $site_domains[$domain]['modules'] : $path . PATH . '/modules/' . $site_domains[$domain]['modules']; $search_pattern = realpath($search_pattern) . '/' . $modulename . '/'; if (is_file($search_pattern . $filename)) { break; } } // Теперь ищем в общей папке с модулями $search_pattern = $path == './' ? $dir . '/modules/' : $path . ENGINE_VERSION . '/' . ENGINE_TYPE . '/modules/'; $search_pattern = $search_pattern . $modulename . '/'; if (is_file($search_pattern . $filename)) { break; } } if (is_file($search_pattern . $filename)) { return $search_pattern . $filename; } else { return false; } }
public function test_load_invalid_file() { $path = path(__DIR__, '../configs/foo.ini'); $driver = new IniConfigDriver(); $this->setExpectedException(InvalidConfigFormatException::class); $driver->loadFile($path); }
public function getUploadedFile($tag, $where = '/app/cache/uploads/') { $return = array('error' => false, 'path' => false, 'name' => false); if (isset($_FILES[$tag]['name']) && $_FILES[$tag]['name'] != '') { $image = $_FILES[$tag]; $orig_name = isset($image['name']) ? $image['name'] : false; $type = isset($image['type']) ? $image['type'] : false; $tmp_name = isset($image['tmp_name']) ? $image['tmp_name'] : false; $error_value = isset($image['error']) ? $image['error'] : false; if ($error_value === false) { $return['error'] = 'The file could not be uploaded because ' . $error_value; } else { $dots = explode('.', $orig_name); if (count($dots) == 1) { $return['error'] = 'Your filename does not have an extension'; } else { $extension = $dots[count($dots) - 1]; unset($dots[count($dots) - 1]); $orig_file_name = implode('.', $dots); $new_name = sanitize(trim($orig_file_name)) . '_' . md5(time() . $orig_name) . '.' . $extension; while (file_exists(path($where . $new_name))) { $new_name = time() % 100 . $new_name; } if (!move_uploaded_file($tmp_name, path($where . $new_name))) { $return['error'] = 'The file could not be uploaded. Please try again.'; } else { $return['path'] = $where . $new_name; $return['name'] = $orig_name; } } } } return $return; }
/** * Create a new cache driver instance. * * @param string $driver * @return Cache\Drivers\Driver */ protected static function factory($driver) { if (isset(static::$registrar[$driver])) { $resolver = static::$registrar[$driver]; return $resolver(); } switch ($driver) { case 'apc': return new Cache\Drivers\APC(Config::get('cache.key')); case 'file': return new Cache\Drivers\File(path('storage') . 'cache' . DS); case 'memcached': return new Cache\Drivers\Memcached(Memcached::connection(), Config::get('cache.key')); case 'memory': return new Cache\Drivers\Memory(); case 'redis': return new Cache\Drivers\Redis(Redis::db()); case 'database': return new Cache\Drivers\Database(Config::get('cache.key')); case 'wincache': return new Cache\Drivers\WinCache(Config::get('cache.key')); default: throw new \Exception("Cache driver {$driver} is not supported."); } }
/** * Set include paths from $_paths array, * build file name using include path, search * and if found include * @param string $class The class name being searched for */ public static function load($class) { // fix extra backslashes in $_POST/$_GET if (get_magic_quotes_gpc()) { $globals = array("_POST", "_GET", "_COOKIE", "_REQUEST", "_SESSION"); foreach ($globals as $global) { if (isset($GLOBALS[$global])) { $GLOBALS[$global] = self::_clean($GLOBALS[$global]); } } } $paths = array_map(function ($item) { return path('app') . $item; }, self::$_paths); $paths[] = get_include_path(); set_include_path(join(PATH_SEPARATOR, $paths)); $paths = explode(PATH_SEPARATOR, get_include_path()); $flags = PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE; $file = strtolower(str_replace("\\", DIRECTORY_SEPARATOR, trim($class, "\\"))) . ".php"; foreach ($paths as $path) { $combined = $path . DIRECTORY_SEPARATOR . $file; if (file_exists($combined)) { include $combined; return; } } $paths = array(); throw new \Exception("{$class} not found"); }
public function resource($arguments) { $pluralize = new Laravel\Pluralizer(Laravel\Config::get('strings')); foreach ($arguments as $key => $model) { $content = array(); $nameClass = ucwords($model); $content[] = "<?php namespace Admin;"; $content[] = "class {$nameClass} extends Appmodel{"; $content[] = "\tpublic static \$table ='" . Str::plural($model) . "'; "; $content[] = "\tpublic \$index= array(); "; $content[] = "\tpublic \$new=array(); "; $content[] = "\tpublic \$edit= array(); "; $content[] = "\tpublic \$show= array(); "; $content[] = "\tpublic \$rules= array(); "; $content[] = "}"; $DS = DIRECTORY_SEPARATOR; $path = path('bundle') . $DS . "lara_admin" . $DS . "models" . $DS . strtolower($model) . ".php"; if (!file_exists($path)) { file_put_contents($path, implode(" \n ", $content)); echo "done"; } else { echo " already exists. send force like third parameter"; } } }
function bootstrap($cwd, $home) { $result = array('base' => null, 'overlay' => array(), 'core' => array(), 'local' => array(), 'files' => array()); $parts = explode(PATH_SEPARATOR . PATH_SEPARATOR, get_include_path()); // Check local module first scanpath($result, pathfiles($cwd), $cwd, $home); // We rely classpath always includes "." at the beginning if (isset($parts[1])) { foreach (explode(PATH_SEPARATOR, substr($parts[1], 2)) as $path) { scanpath($result, array($path), $cwd, $home); } } // We rely modules always includes "." at the beginning foreach (array_unique(explode(PATH_SEPARATOR, substr($parts[0], 2))) as $path) { if ('' === $path) { continue; } else { if ('~' === $path[0]) { $path = $home . substr($path, 1); } } scanpath($result, pathfiles($path), $path, $home); } // Always add current directory $result['local'][] = path($cwd); return $result; }
/** * Render The View * * @param string $template * @param array $data * @return void */ public function render($template, $data = array()) { extract(self::$shared); extract($data); $errors = isset($errors) ? $errors : array(); require path("/views/{$template}.tpl"); }
public function setupdb($arguments) { $dbpath = path('app') . 'config/database' . EXT; $currentconfig = File::get($dbpath); $driver = isset($arguments['driver']) ? $arguments['driver'] : ''; $host = isset($arguments['host']) ? $arguments['host'] : ''; $database = isset($arguments['database']) ? $arguments['database'] : ''; $username = isset($arguments['username']) ? $arguments['username'] : ''; $password = isset($arguments['password']) ? $arguments['password'] : ''; $charset = isset($arguments['charset']) ? $arguments['charset'] : 'utf8'; switch ($driver) { case 'mysql': $setting_db = "array('mysql' => array(\n\t\t\t\t\t\t\t'driver' => '{$driver}',\n\t\t\t\t\t\t\t'host' => '{$host}',\n\t\t\t\t\t\t\t'database' => '{$database}',\n\t\t\t\t\t\t\t'username' => '{$username}',\n\t\t\t\t\t\t\t'password' => '{$password}',\n\t\t\t\t\t\t\t'charset' => '{$charset}',\n\t\t\t\t\t\t\t'prefix' => '',\n\t\t\t\t\t\t))"; break; case 'sqlite': $setting_db = "array('sqlite' => array(\n\t\t\t\t\t'driver' => '{$driver}',\n\t\t\t\t\t'database' => '{$database}',\n\t\t\t\t\t'prefix' => '',\n\t\t\t\t))"; break; case 'pgsql': $setting_db = "array('pgsql' => array(\n\t\t\t\t\t'driver' => '{$driver}',\n\t\t\t\t\t'host' => '{$host}',\n\t\t\t\t\t'database' => '{$database}',\n\t\t\t\t\t'username' => '{$username}',\n\t\t\t\t\t'password' => '{$password}',\n\t\t\t\t\t'charset' => '{$charset}',\n\t\t\t\t\t'prefix' => '',\n\t\t\t\t\t'schema' => 'public',\n\t\t\t\t))"; break; case 'sqlsrv': $setting_db = "array('sqlsrv' => array(\n\t\t\t\t\t'driver' => '{$driver}',\n\t\t\t\t\t'host' => '{$host}',\n\t\t\t\t\t'database' => '{$database}',\n\t\t\t\t\t'username' => '{$username}',\n\t\t\t\t\t'password' => '{$password}',\n\t\t\t\t\t'prefix' => '',\n\t\t\t\t))"; break; default: $setting_db = ''; break; } $config = str_replace("'default' => '',", "'default' => '{$driver}',", $currentconfig, $count); $config = str_replace("'connections' => array(),", "'connections' => {$setting_db},", $config, $count); File::put($dbpath, $config); }
public function parseDir($dir) { if (!$dir) { return; } $cache = new Cache($dir); $settings = []; if (false && $cache->isBuilt()) { $settings = $cache->get(); } else { /** * @T00D00 * We need to parse config directory recursively. * defaults.php and env.php needs to be taken differently (as root namespace). */ $files = ["defaults" => $dir . 'config' . path('ds') . "defaults.php", "database" => $dir . 'config' . path('ds') . "database.php", "router" => $dir . 'config' . path('ds') . "router.php", "env" => $dir . 'config' . path('ds') . "env.php"]; foreach ($files as $key => $file) { $content = is_file($file) ? require $file : []; if (in_array($key, ['defaults', 'env'])) { $settings = $this->merge($settings, $content); } else { $settings[$key] = $content; } } } $this->data = $this->merge($this->data, $settings); }
public function handle() { $packets = ['auth', 'collection', 'concept', 'database', 'framework', 'generic', 'htmlbuilder', 'import', 'mail', 'manager', 'migrator', 'payment', 'queue', 'tempus', 'translator', 'charts']; $clean = ['nothing to commit, working directory clean', 'nothing to commit, working tree clean']; $composer = json_decode(file_get_contents(path('root') . 'composer.lock'), true); $outdated = false; foreach ($packets as $packet) { $this->output('Checking ' . $packet); $path = path('root') . 'vendor' . path('ds') . 'pckg' . path('ds') . $packet; $statusCommand = 'cd ' . $path . ' && git status'; $diffCommand = 'cd ' . $path . ' && git diff'; $pullCommand = 'cd ' . $path . ' && git pull --ff'; $pushCommand = 'cd ' . $path . ' && git push'; $logCommand = 'cd ' . $path . ' && git log'; $commitCommand = 'cd ' . $path . ' && git add . --all && git commit -m'; $outputs = $this->exec($statusCommand, false); if (isset($outputs[0])) { $output = $outputs[0]; $end = end($output); if (in_array($end, $clean)) { $this->output('Packet is clean.'); $this->exec($pullCommand); } else { $this->output('Packet is changed.'); $this->exec($statusCommand); $this->exec($diffCommand); if ($message = $this->askQuestion('Enter commit message (or leave empty if you want to skip commit)')) { $this->exec($pullCommand); $this->output('Committing changes.'); $this->exec($commitCommand . ' ' . $message); $this->output('Changes commited.'); if ($this->askConfirmation('Push changes?')) { $this->exec($pushCommand); } $this->exec($pullCommand); } else { $this->output('Skipping commit.'); $this->exec($pullCommand); } } foreach ($composer['packages'] as $composerPacket) { if ($composerPacket['name'] == 'pckg/' . $packet) { $installed = $composerPacket['source']['reference']; $logOutput = $this->exec($logCommand, false); $git = str_replace('commit ', '', $logOutput[0][0]); $this->output('Installed: ' . $installed); $this->output('Git: ' . $git); if ($git != $installed) { $this->output('Run composer update or project update command'); $outdated = true; } } } } $this->output(); } if ($outdated) { $this->output('Some packages are outdated!'); } }
/** * Create a new session driver instance. * * @param string $driver * @return Session\Drivers\Driver */ public static function factory($driver) { if (isset(static::$registrar[$driver])) { $resolver = static::$registrar[$driver]; return $resolver(); } switch ($driver) { case 'apc': return new Session\Drivers\APC(Cache::driver('apc')); case 'cookie': return new Session\Drivers\Cookie(); case 'database': return new Session\Drivers\Database(Database::connection()); case 'file': return new Session\Drivers\File(path('storage') . 'sessions' . DS); case 'memcached': return new Session\Drivers\Memcached(Cache::driver('memcached')); case 'memory': return new Session\Drivers\Memory(); case 'redis': return new Session\Drivers\Redis(Cache::driver('redis')); default: throw new \Exception("Session driver [{$driver}] is not supported."); } }
/** * @param string $file * @return mixed|null */ function config($file = 'app') { $path = path('app') . '/config'; $levels = explode('.', $file); if (count($levels) == 1) { if (file_exists($path . DS . $file . '.php')) { return require $path . DS . $file . '.php'; } else { die("<h1>{$path}/{$file}.php not found</h1>"); } } else { if (count($levels) > 1) { $file = array_shift($levels); if (file_exists($path . DS . $file . '.php')) { $array = (require $path . DS . $file . '.php'); } else { die("<h1>{$path}/{$file}.php not found</h1>"); } if (count($levels) == 1 && isset($array[$levels[0]])) { return $array[$levels[0]]; } else { $pointer = $array; foreach ($levels as $k => $v) { if (isset($pointer[$v])) { $pointer = $pointer[$v]; } else { return null; } } return $pointer; } } } return null; }
public function build($data) { list($team, $year) = $data; $redirect = path('player_attach_ncaa_ids', array('slug' => $team->getSlug())); $this->setPlayerNcaaIdsForTeam($team, $year); $form = $this->form = $this->CI->form->open(path('player_attach_ncaa_ids_for_year', array('slug' => $team->getSlug(), 'year' => $year)), null, 'class="form-horizontal"'); $globalError = false; foreach ($team->getPlayers($year) as $player) { $class = ''; if (count($player->getAllNcaaIds())) { foreach ($player->getAllNcaaIds() as $ncaaId) { if (in_array($ncaaId, array_splice(array_keys($this->players), 1))) { $class = 'success'; } } if (!$class) { $class = 'error'; $globalError = true; } } else { $class = ''; if (!$this->matchNameInArray($player)) { $globalError = true; } } $form->html(sprintf('<div class="control-group %s form-inline"><label class="control-label">%s, %s</label>', $class, $player->getLastName(), $player->getFirstName()))->select(sprintf('player[%s]', $player->getId()), $this->players, null, $this->matchNameInArray($player), null, 'class="span8"')->html('</div>'); } $form->html('<div class="form-actions">')->submit('Save Changes', 'submit', 'class="btn btn-primary"')->html('</div>')->model('document', 'validate', 'team/edit')->onsuccess('redirect', $redirect); if (!$globalError) { $this->save($form, $data, $redirect); } return $form; }
private function editOrSave($action) { $validations = array("exists" => array("Slug" => slug(POST("title", "clean")), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Language" => POST("language")), "title" => "required", "content" => "required"); $this->categories = POST("categories"); $this->tags = POST("tags"); $this->URL = path("blog/" . date("Y")) . "/" . date("m") . "/" . date("d") . "/" . slug(POST("title", "clean")); $this->muralExist = POST("mural_exist"); $this->Files = $this->core("Files"); $this->mural = FILES("mural"); if ($this->mural["name"] !== "") { $dir = "www/lib/files/images/mural/"; $this->mural = $this->Files->uploadImage($dir, "mural", "mural"); if (is_array($this->mural)) { return $this->mural["alert"]; } } $dir = "www/lib/files/images/blog/"; $this->image = $this->Files->uploadImage($dir, "image", "resize", TRUE, TRUE, FALSE); $data = array("ID_User" => SESSION("ZanUserID"), "ID_URL" => 1, "Slug" => slug(POST("title", "clean")), "Content" => POST("content", "clean"), "Author" => SESSION("ZanUser"), "Year" => date("Y"), "Month" => date("m"), "Day" => date("d"), "Image_Small" => isset($this->image["small"]) ? $this->image["small"] : NULL, "Image_Medium" => isset($this->image["medium"]) ? $this->image["medium"] : NULL, "Pwd" => POST("pwd") ? POST("pwd", "encrypt") : NULL, "Start_Date" => now(4), "Text_Date" => now(2)); $this->Data->ignore(array("categories", "tags", "mural_exists", "mural", "pwd", "category", "language_category", "application", "mural_exist")); $this->data = $this->Data->proccess($data, $validations); if (isset($this->data["error"])) { return $this->data["error"]; } }