本文整理汇总了PHP中Common::isFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Common::isFile方法的具体用法?PHP Common::isFile怎么用?PHP Common::isFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common
的用法示例。
在下文中一共展示了Common::isFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
if (false === Common::isFile(GWF_GESHI_PATH)) {
return '';
// FIXME: {gizmore} log it? GESHI_PATH is may not readable
}
require_once GWF_GESHI_PATH;
$geshi = new GeSHi();
$langs = $geshi->get_supported_languages(false);
$key = htmlspecialchars(Common::getGetString('key', ''), ENT_QUOTES);
sort($langs);
// $this->niceArray($langs, false, '-------')
$this->niceArray($langs, 'python', 'Python');
$this->niceArray($langs, 'perl', 'Perl');
$this->niceArray($langs, 'cpp', 'CPP');
$this->niceArray($langs, 'php', 'PHP');
$back = $this->module->lang('th_lang') . ':' . PHP_EOL;
$back .= '<select id="bb_code_lang_sel_' . $key . '">' . PHP_EOL;
$back .= '<option value="0">' . $this->module->lang('th_lang') . '</option>' . PHP_EOL;
foreach ($langs as $lang) {
$back .= sprintf('<option value="%s">%s</option>', $lang, $lang) . PHP_EOL;
}
$back .= '</select>' . PHP_EOL;
$back .= $this->module->lang('th_title') . ': <input type="text" id="bb_code_title_' . $key . '" size="20" value="" />' . PHP_EOL;
$back .= '<input type="submit" value="' . $this->module->lang('btn_code') . '" onclick="return bbInsertCodeNow(\'' . $key . '\');" />' . PHP_EOL;
return $back;
}
示例2: write
public static function write($image, $fontfile, $x, $y, $text, $color, $maxwidth, $size = 11, $spacingx = 2, $spacingy = 2, $mx = 1, $my = 1, $angle = 0)
{
if (!Common::isFile($fontfile)) {
echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(htmlspecialchars($fontfile)));
return false;
}
$dim = GWF_GDText::getFontSize($fontfile, $size, $angle);
$fontwidth = $dim->w;
$fontheight = $dim->h;
if ($maxwidth != NULL) {
// die(''.$maxwidth);
$maxcharsperline = floor($maxwidth / $fontwidth);
$text = wordwrap($text, $maxcharsperline, "\n", 1);
// die($text);
}
// die(var_dump($color));
$lines = explode("\n", $text);
$x += $mx;
$y += $my;
foreach ($lines as $line) {
$y += $fontheight + $spacingy;
imagettftext($image, $size, $angle, $x, $y, $color, $fontfile, $line);
}
return true;
}
示例3: execute
public function execute()
{
if (false === ($user = GWF_User::getByName(Common::getGetString('username')))) {
return GWF_HTML::err('ERR_UNKNOWN_USER');
}
if (false !== ($error = $this->module->isExcludedFromAPI($user, false))) {
return $error;
}
$this->module->includeClass('WC_RegAt');
$format = Common::getGetString('format', self::FORMAT);
$bg = Common::getGetString('bg', self::BGCOLOR);
$fg = Common::getGetString('fg', self::FGCOLOR);
$size = Common::clamp(Common::getGetInt('s', self::SIZE), 6, 30);
$spacingx = Common::clamp(Common::getGetInt('sx', 1), 0, 30);
$spacingy = Common::clamp(Common::getGetInt('sy', 1), 0, 30);
$marginx = Common::clamp(Common::getGetInt('mx', 1), 0, 30);
$marginy = Common::clamp(Common::getGetInt('my', 1), 0, 30);
$divider = Common::getGetString('div', ' ');
$font = Common::getGetString('font', self::FONT);
$_GET['font'] = $font;
if (!preg_match('/^[a-z_0-9]+$/iD', $font) || !Common::isFile(GWF_EXTRA_PATH . 'font/' . $font . '.ttf')) {
return "Font not found. Available fonts: " . $this->listFonts();
}
die($this->displayBanner($user, $format, $bg, $fg, $size, $spacingx, $spacingy, $marginx, $marginy, $divider));
}
示例4: loadModuleClass
public static function loadModuleClass($module, $file)
{
$path = GWF_CORE_PATH . 'module/' . $module . '/' . $file;
if (false === Common::isFile($path)) {
return false;
}
require_once $path;
}
示例5: imageExists
public static function imageExists($path)
{
if (0 === preg_match('/^<img src="([^"\'=\\(+:]+)" \\/>$/', $path, $matches)) {
return false;
}
$path = $matches[1];
return Common::isFile(trim($path, '/'));
}
示例6: getHTAccess
public static function getHTAccess()
{
$custom_hta = GWF_PROTECTED_PATH . 'pre_htaccess.txt';
$custom = Common::isFile($custom_hta) ? file_get_contents($custom_hta) . PHP_EOL : '';
if ($custom !== '') {
$custom = '##################################' . PHP_EOL . '### protected/pre_htaccess.txt ###' . PHP_EOL . '##################################' . PHP_EOL . $custom . PHP_EOL . PHP_EOL;
}
return $custom . '#############################' . PHP_EOL . '### Generated by GWFv3.00 ###' . PHP_EOL . '#############################' . PHP_EOL . PHP_EOL . PHP_EOL . '# No dot files' . PHP_EOL . 'RedirectMatch 404 /\\..*$' . PHP_EOL . PHP_EOL . '# Custom error pages' . PHP_EOL . 'ErrorDocument 400 ' . GWF_WEB_ROOT_NO_LANG . 'index.php?mo=GWF&me=ShowError&code=400' . PHP_EOL . 'ErrorDocument 401 ' . GWF_WEB_ROOT_NO_LANG . 'index.php?mo=GWF&me=ShowError&code=401' . PHP_EOL . 'ErrorDocument 403 ' . GWF_WEB_ROOT_NO_LANG . 'index.php?mo=GWF&me=ShowError&code=403' . PHP_EOL . 'ErrorDocument 404 ' . GWF_WEB_ROOT_NO_LANG . 'index.php?mo=GWF&me=ShowError&code=404' . PHP_EOL . PHP_EOL . 'RewriteEngine On' . PHP_EOL . PHP_EOL . self::getLangRewrites() . PHP_EOL . PHP_EOL;
}
示例7: getHTAccess
public static function getHTAccess()
{
if (false === Common::isFile(GWF_WWW_PATH . '.htaccess')) {
GWF_HTML::error('ERR_FILE_NOT_FOUND', array(GWF_WWW_PATH . '.htaccess'));
# TODO
return false;
}
return file_get_contents(GWF_WWW_PATH . '.htaccess');
}
示例8: execute
public function execute()
{
if ('' === ($filename = Common::getGetString('filename'))) {
return GWF_Error::err('ERR_NO_PERMISSION');
}
$path = $this->module->getContentPath();
$filename = $path . '/' . $filename;
if (!Common::isFile($filename)) {
return GWF_Error::err404($filename);
}
GWF_Upload::outputFile($filename);
}
示例9: __call
public function __call($name, $args)
{
$path = GWF_CORE_PATH . str_replace('_', '/', $name) . '.php';
if (false === Common::isFile($path)) {
return GWF_HTML::err('ERR_FILE_NOT_FOUND', array(htmlspecialchars($path)));
}
require_once $path;
if (false === function_exists($name)) {
return GWF_HTML::err('ERR_METHOD_MISSING', array(htmlspecialchars($name)));
}
return call_user_func($name, $args);
}
示例10: onUpload
public static function onUpload(Module_PageBuilder $module)
{
if (false !== ($error = GWF_Form::validateCSRF_WeakS())) {
return $error;
}
if (false === ($file = GWF_Upload::getFile('file'))) {
return GWF_HTML::err('ERR_MISSING_UPLOAD');
}
$back = '';
# TODO: There are more unsafe languages!
# But we want to keep the file extension.
# Not really a big deal, unless you have malicious admin users.
$name = $file['name'];
// $name = str_replace(array('/', '\\'), '', $name);
// $forbidden = array('.php',/* '.pl', '.py', '.asp'*/);
// foreach ($forbidden as $ext)
// {
// if (Common::endsWith($name, $ext))
// if (Common::endsWith($name, '.php'))
// {
// $name .= '.html';
// $back .= $module->error('err_file_ext');
// return $back;
// }
// }
# This is evil, sometimes even with foo.php.html
if (stripos($name, '.php') !== false) {
return $module->error('err_file_ext');
}
# We do a sanity check here
if (!preg_match('#^[a-z0-9_][a-z0-9_\\.]{0,62}$#iD', $name)) {
$back .= $module->error('err_file_name');
return $back;
}
# Copy the file
$path = 'dbimg/content/' . $name;
$epath = htmlspecialchars($path);
if (Common::isFile($path)) {
return $back . $module->error('err_upload_exists');
}
if (false === GWF_Upload::moveTo($file, $path)) {
return $back . GWF_HTML::err('ERR_WRITE_FILE', array($epath));
}
# Is bbcode mode?
$bbcode = (Common::getPostInt('type', 0) & (GWF_Page::HTML | GWF_Page::SMARTY)) === 0;
# Append to page content as image or anchor.
$_POST['content'] .= self::fileToContent($name, $path, $bbcode);
return $module->message('msg_file_upped', array($epath));
}
示例11: hook
public static function hook(GWF_User $user, GWF_Download $dl)
{
$dlid = $dl->getID();
if ($dlid > 2) {
return true;
}
$demo = $dlid == 2;
if (false === ($row = BAIM_MC::generate($user, $demo))) {
return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
}
$mime = $dl->getVar('dl_mime');
$path = $dl->getDownloadPath();
$temp_path = GWF_PATH . 'extra/temp/baim/' . $user->getVar('user_id') . '_' . $row->getToken();
if (!Common::isFile($path)) {
return GWF_HTML::err('ERR_FILE_NOT_FOUND', htmlspecialchars($path));
}
if (Common::isFile($temp_path)) {
if (false === unlink($temp_path)) {
return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
}
}
if ($mime === 'application/zip') {
if (false === copy($path, $temp_path)) {
return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
}
$have_zip = true;
} else {
$have_zip = false;
}
$zip = new GWF_ZipArchive();
if (false === $zip->open($temp_path, GWF_ZipArchive::CREATE)) {
return GWF_HTML::err('ERR_WRITE_FILE', array($temp_path));
}
if ($have_zip === false) {
$filename = $dl->getVar('dl_filename');
$zip->addFile($path, $filename);
$dl->setCustomDownloadName($filename . '.zip');
}
if (false === $zip->addFromString('B.AiM/key.dat', self::getIniContent($row))) {
return GWF_HTML::error('BAIM', 'The download slot is not a zip archive!');
}
$zip->addFromString('B.AiM/readme.txt', self::getReadmeContent($row));
$zip->addFromString('B.AiM/release_notes.txt', self::getReleaseNotes($row));
$zip->close();
$dl->setCustomDownloadPath($temp_path);
return '';
}
示例12: cron_level_6
function cron_level_6($entry, $fullpath, $args = NULL)
{
$home = $fullpath;
$username = $entry;
$filename = $home . '/level/6/solution.txt';
if (Common::isFile($filename)) {
$solution = $home . '/level/6/real_solution.txt';
if (!Common::isFile($solution)) {
// Create solution file
$tmp = '/root/_tmp_6';
file_put_contents($tmp, 'The solution to level 6 is "SymbolicFlag".');
chmod($tmp, '0700');
chown($tmp, $username);
chgrp($tmp, $username);
// Copy it to user home
rename($tmp, $solution);
}
}
}
示例13: cron_level_5
function cron_level_5($entry, $fullpath, $args = NULL)
{
$home = $fullpath;
$username = $entry;
$dir = $fullpath . '/level';
if (false === ($stat = @stat($dir))) {
return;
}
$chmod = $stat['mode'];
if ($chmod & 04) {
return;
}
$filename = $home . '/level/5/solution.txt';
if (!Common::isFile($filename)) {
// Create solution file
$tmp = '/root/_tmp_5';
@file_put_contents($tmp, "The solution to level 5 is 'OhRightThePerms', without the quotes.\n");
@chmod($tmp, '0700');
@chown($tmp, $username);
@chgrp($tmp, $username);
// Copy it to user home
@rename($tmp, $filename);
}
}
示例14: addFiles
private function addFiles(GWF_ZipArchive $archive, array $files)
{
foreach ($files as $file) {
if (!$this->isFileWanted($file)) {
continue;
}
if (!Common::isFile($file)) {
echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(GWF_HTML::display($file)));
return false;
}
if (false === $archive->addFile($file)) {
echo GWF_HTML::err('ERR_FILE_NOT_FOUND', array(GWF_HTML::display($file)));
return false;
}
}
return true;
}
示例15: mergeConfig
private static function mergeConfig()
{
if (!Common::isFile('protected/config.php')) {
return;
}
foreach (self::$vars as $var) {
# debug
// if (count($var) != 5) { var_dump($var); }
list($type, $section, $varname, $value, $comment) = $var;
if (defined($varname)) {
$defined_value = self::getDefinedValue($varname);
if (false !== ($error = self::testVar($varname, $defined_value))) {
echo self::error('err_config_value', array($varname));
echo $error;
continue;
}
self::setVar($varname, $defined_value);
}
}
}