本文整理汇总了PHP中extension函数的典型用法代码示例。如果您正苦于以下问题:PHP extension函数的具体用法?PHP extension怎么用?PHP extension使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了extension函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fileSize
public function fileSize(string $path, string $type = 'b', int $decimal = 2) : float
{
$size = 0;
$extension = extension($path);
if (!empty($extension)) {
$size = ftp_size($this->connect, $path);
} else {
if ($this->files($path)) {
foreach ($this->files($path) as $val) {
$size += ftp_size($this->connect, $path . "/" . $val);
}
$size += ftp_size($this->connect, $path);
} else {
$size += ftp_size($this->connect, $path);
}
}
if ($type === "b") {
return $size;
}
if ($type === "kb") {
return round($size / 1024, $decimal);
}
if ($type === "mb") {
return round($size / (1024 * 1024), $decimal);
}
if ($type === "gb") {
return round($size / (1024 * 1024 * 1024), $decimal);
}
}
示例2: copyr
function copyr($source, $dest, $fileFilter = array())
{
global $objZip;
//*** Simple copy for a file.
if (is_file($source)) {
if (count($fileFilter) == 0 || in_array(extension($source), $fileFilter)) {
$objZip->addFile($source, $dest);
logExport($source);
return true;
} else {
return false;
}
}
if (!is_dir($source)) {
return false;
}
//*** Loop through the folder
$dir = dir($source);
while (false !== ($entry = $dir->read())) {
//*** Skip pointers
if ($entry == "." || $entry == "..") {
continue;
}
//*** Deep copy directories
if ($dest !== "{$source}/{$entry}") {
copyr("{$source}/{$entry}", "{$dest}/{$entry}", $fileFilter);
}
}
logExport($source);
//*** Clean up
$dir->close();
return true;
}
示例3: createThumb
function createThumb($from, $to, $maxWidth, $maxHeight)
{
$extension = extension($from);
switch ($extension) {
case "jpg":
case "jpeg":
$source = imagecreatefromjpeg($from);
break;
case "png":
$source = imagecreatefrompng($from);
break;
case "gif":
$source = imagecreatefromgif($from);
break;
}
list($width, $height) = getimagesize($from);
$percent = $maxWidth / $width;
$new_width = $maxWidth;
$new_height = $height * $percent;
if ($new_height > $maxHeight) {
$percent = $maxHeight / $height;
$new_height = $maxHeight;
$new_width = $width * $percent;
}
if ($new_width > $width || $new_height > $height) {
$new_width = $width;
$new_height = $height;
}
$image_p = imagecreatetruecolor($new_width, $new_height);
imagecopyresampled($image_p, $source, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
// Output
imagejpeg($image_p, $to, 80);
chmod($to, 0777);
}
示例4: zone_fork
public function zone_fork($disposition_id, $disposition, $url, $theme, $page, $zone)
{
$url = str_replace(url(), '', $url);
if (!$url || preg_match('#^index(?:\\.|/)#', $url)) {
$url = '/';
}
if (extension($url) == 'html') {
$url = substr($url, 0, -5) . '/*';
}
$url = explode('/', $url);
if (!empty($url[0]) && ($module = $this->load->module($url[0])) && !empty($module->routes) && ($method = $module->get_method(array_slice($url, 1, -1), TRUE))) {
$url = array($url[0], $method, '*');
}
$url = implode('/', $url);
if ($page == '*' || !$this->db->select('1')->from('nf_dispositions')->where('page', $url)->row()) {
foreach ($disposition as &$rows) {
foreach ($rows->cols as &$col) {
foreach ($col->widgets as &$w) {
$widget = $this->db->select('widget', 'type', 'title', 'settings')->from('nf_widgets')->where('widget_id', $w->widget_id)->row();
$w->widget_id = $this->db->insert('nf_widgets', array('widget' => $widget['widget'], 'type' => $widget['type'], 'title' => $widget['title'], 'settings' => $widget['settings']));
}
}
}
return Zone::display($this->db->insert('nf_dispositions', array('theme' => $theme, 'page' => $url, 'zone' => $zone, 'disposition' => serialize($disposition))), $disposition, $url, $zone, TRUE);
} else {
$this->model()->delete_disposition($disposition);
$this->db->where('disposition_id', $disposition_id)->delete('nf_dispositions');
$disposition = $this->db->select('disposition_id', 'disposition')->from('nf_dispositions')->where('theme', $theme)->where('page', '*')->where('zone', $zone)->row();
return Zone::display($disposition['disposition_id'], unserialize($disposition['disposition']), '*', $zone, TRUE);
}
}
示例5: getParams
public function getParams()
{
foreach ($this->params as $key => $value) {
$out[] = $key . '=' . $value;
}
// EXTENCION
$out[] = 'f=' . extension($this->fileName);
return join("&", $out);
}
示例6: index
function index()
{
global $db;
global $body;
global $languages;
global $navigation;
global $lang;
$alanguages = array();
if ($handle = opendir(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lang')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && is_file(dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'lang' . DIRECTORY_SEPARATOR . $file) && strtolower(extension($file)) == 'php') {
$alanguages[] = substr($file, 0, -4);
}
}
closedir($handle);
}
$languages = '';
$no = 0;
$activelanguages = '';
foreach ($alanguages as $ti) {
$default = '';
$opacity = '';
$titlemakedefault = 'title="Make language default"';
$setdefault = 'onclick="javascript:language_makedefault(\'' . $ti . '\')"';
if (strtolower($lang) == strtolower($ti)) {
$default = ' (Default)';
$opacity = '0.5;cursor:default;';
$titlemakedefault = '';
$setdefault = '';
}
++$no;
$activelanguages .= '<li class="ui-state-default" id="' . $no . '" d1="' . $ti . '"><span style="font-size:11px;float:left;margin-top:3px;margin-left:5px;" id="' . $ti . '_title">' . $ti . $default . '</span><span style="font-size:11px;float:right;margin-top:0px;margin-right:5px;"><a href="javascript:void(0)" ' . $setdefault . ' style="margin-right:5px;"><img src="images/default.png" ' . $titlemakedefault . ' style="opacity:' . $opacity . ';"></a><a href="?module=language&action=editlanguage&data=' . $ti . '" style="margin-right:5px"><img src="images/config.png" title="Edit Language"></a><a href="?module=language&action=exportlanguage&data=' . $ti . '&token=' . $_SESSION['token'] . '" target="_blank" style="margin-right:5px;"><img src="images/export.png" title="Download Language"></a><a href="javascript:void(0)" onclick="javascript:language_removelanguage(\'' . $ti . '\')"><img src="images/remove.png" title="Remove Language"></a></span><div style="clear:both"></div></li>';
}
$body = <<<EOD
\t{$navigation}
\t<div id="rightcontent" style="float:left;width:720px;border-left:1px dotted #ccc;padding-left:20px;">
\t\t<h2>Languages</h2>
\t\t<h3>To set the language, click on the star button next to the language.</h3>
\t\t<div>
\t\t\t<div id="centernav">
\t\t\t\t\t<div>
\t\t\t\t\t\t<ul id="modules_livelanguage">
\t\t\t\t\t\t\t{$activelanguages}
\t\t\t\t\t\t</ul>
\t\t\t\t\t</div>\t\t\t\t
\t\t\t\t</div>\t
\t\t\t</div>
\t\t</div>
\t<div style="clear:both"></div>
EOD;
template();
}
示例7: _theme_installation
public function _theme_installation()
{
$this->extension('json');
if (!empty($_FILES['theme']) && extension($_FILES['theme']['name']) == 'zip') {
if ($zip = zip_open($_FILES['theme']['tmp_name'])) {
$theme_name = NULL;
while ($zip_entry = zip_read($zip)) {
$entry_name = zip_entry_name($zip_entry);
$is_dir = substr($entry_name, -1) == '/';
if (is_null($theme_name) && $is_dir) {
$theme_name = substr($entry_name, 0, -1);
}
if ($theme_name && strpos($entry_name, $theme_name . '/') === 0) {
if ($is_dir) {
mkdir('./themes/' . $entry_name, 0777, TRUE);
} else {
if (zip_entry_open($zip, $zip_entry, 'r')) {
$content = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
if ($entry_name == $theme_name . '/' . $theme_name . '.php' && file_exists('./themes/' . $entry_name)) {
if (preg_match('/\\$version[ \\t]*?=[ \\t]*?([\'"])(.+?)\\1;/', $content, $match)) {
$old_version = preg_replace('/[^\\d.]/', '', $this->load->theme($theme_name, FALSE)->version);
$new_version = preg_replace('/[^\\d.]/', '', $match[2]);
if ($cmp = version_compare($new_version, $old_version)) {
$update = TRUE;
} else {
zip_entry_close($zip_entry);
return json_encode(array('error' => $this($cmp == 0 ? 'already_installed_version' : 'not_newer_installed_version')));
}
}
}
file_put_contents('./themes/' . $entry_name, $content);
zip_entry_close($zip_entry);
}
}
}
}
zip_close($zip);
if ($theme_name && ($theme = $this->load->theme($theme_name, FALSE))) {
if (empty($update)) {
$theme->uninstall()->install();
} else {
$this->db->insert('nf_settings_addons', array('name' => $theme_name, 'type' => 'theme', 'enable' => TRUE));
}
return json_encode(array('success' => TRUE));
} else {
if ($theme_name) {
rmdir_all('./themes/' . $theme_name);
}
return json_encode(array('error' => $this('error_theme_install')));
}
}
}
return json_encode(array('error' => $this('zip_file_required')));
}
示例8: _row
public function _row($filepath, $filename) {
$row = (object) array(
'extension' => extension($filename),
'name' => strtolower($filename),
'random' => time() . '_' . substr(md5(unique_id()), 0, 10)
);
$row->filename = $row->random . '.' . $row->extension;
$row->filepath = $filepath . $row->filename;
return $row;
}
示例9: getFn
private function getFn($method)
{
static $prefix;
if (!$prefix) {
if (extension('apcu')) {
$prefix = 'apcu_';
} elseif (extension('apc')) {
$prefix = 'apc_';
} else {
throw new \Exception('Require APC or APCu extension!');
}
}
return $prefix . $method;
}
示例10: __construct
public function __construct()
{
parent::__construct();
$this->_configs['base_url'] = str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
$this->_configs['request_url'] = $_SERVER['REQUEST_URI'] != $this->_configs['base_url'] ? substr($_SERVER['REQUEST_URI'], strlen($this->_configs['base_url'])) : 'index.html';
$this->_configs['extension_url'] = extension($this->_configs['request_url'], $this->_configs['request_url']);
$this->_configs['ajax_header'] = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
$ext = extension($url = !empty($_GET['request_url']) ? $_GET['request_url'] : $this->_configs['request_url'], $url);
$this->_configs['segments_url'] = explode('/', rtrim(substr($url, 0, -strlen($ext)), '.'));
if ($this->_configs['segments_url'][0] == 'admin') {
$this->_configs['admin_url'] = TRUE;
}
if (empty($this->_configs['admin_url']) && $this->_configs['segments_url'][0] == 'ajax' || !empty($this->_configs['admin_url']) && isset($this->_configs['segments_url'][1]) && $this->_configs['segments_url'][1] == 'ajax') {
$this->_configs['ajax_url'] = TRUE;
}
if (is_null($configs = NeoFrag::loader()->db->select('site, lang, name, value, type')->from('nf_settings')->get())) {
exit('Database is empty');
}
foreach ($configs as $setting) {
if ($setting['type'] == 'array') {
$value = unserialize(utf8_html_entity_decode($setting['value']));
} else {
if ($setting['type'] == 'list') {
$value = explode('|', $setting['value']);
} else {
if ($setting['type'] == 'bool') {
$value = (bool) $setting['value'];
} else {
if ($setting['type'] == 'int') {
$value = (int) $setting['value'];
} else {
$value = $setting['value'];
}
}
}
}
$this->_settings[$setting['site']][$setting['lang']][$setting['name']] = $value;
if (empty($site) && $setting['name'] == 'nf_domains' && in_string($_SERVER['HTTP_HOST'], $setting['value'])) {
$site = $value;
}
}
$this->update('');
$this->update('default');
if (!empty($site)) {
$this->update('default');
}
}
示例11: use
public function use(string $randomPageVariable, array $randomDataVariable = NULL, bool $randomObGetContentsVariable = false)
{
if (!empty(Properties::$parameters['usable'])) {
$randomObGetContentsVariable = Properties::$parameters['usable'];
}
if (!empty(Properties::$parameters['data'])) {
$randomDataVariable = Properties::$parameters['data'];
}
Properties::$parameters = [];
$eol = EOL;
$randomPageVariableExtension = extension($randomPageVariable);
$randomPageVariableBaseUrl = baseUrl($randomPageVariable);
$return = '';
if (!is_file($randomPageVariable)) {
throw new InvalidArgumentException('Error', 'fileParameter', '1.($randomPageVariable)');
}
if ($randomPageVariableExtension === 'js') {
$return = '<script type="text/javascript" src="' . $randomPageVariableBaseUrl . '"></script>' . $eol;
} elseif ($randomPageVariableExtension === 'css') {
$return = '<link href="' . $randomPageVariableBaseUrl . '" rel="stylesheet" type="text/css" />' . $eol;
} elseif (stristr('svg|woff|otf|ttf|' . implode('|', Config::get('ViewObjects', 'font')['differentFontExtensions']), $randomPageVariableExtension)) {
$return = '<style type="text/css">@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}</style>' . $eol;
} elseif ($randomPageVariableExtension === 'eot') {
$return = '<style type="text/css"><!--[if IE]>@font-face{font-family:"' . divide(removeExtension($randomPageVariable), "/", -1) . '"; src:url("' . $randomPageVariableBaseUrl . '") format("truetype")}<![endif]--></style>' . $eol;
} else {
$randomPageVariable = suffix($randomPageVariable, '.php');
if (is_file($randomPageVariable)) {
if (is_array($randomDataVariable)) {
extract($randomDataVariable, EXTR_OVERWRITE, 'zn');
}
if ($randomObGetContentsVariable === false) {
require $randomPageVariable;
} else {
ob_start();
require $randomPageVariable;
$randomSomethingFileContent = ob_get_contents();
ob_end_clean();
return $randomSomethingFileContent;
}
}
}
if ($randomObGetContentsVariable === false) {
echo $return;
} else {
return $return;
}
}
示例12: upload
public function upload($files, $dir = NULL, &$filename = NULL, $file_id = NULL, $var = NULL)
{
if (!file_exists($dir = './upload/' . ($dir ?: 'unknow'))) {
if (!mkdir($dir, 0777, TRUE)) {
return FALSE;
}
}
do {
$file = unique_id() . '.' . extension(basename($var ? $files['name'][$var] : $files['name']));
} while (file_exists($filename = $dir . '/' . $file));
if (move_uploaded_file($var ? $files['tmp_name'][$var] : $files['tmp_name'], $filename)) {
if ($file_id) {
$this->_unlink($file_id);
$this->db->where('file_id', $file_id)->update('nf_files', array('user_id' => $this->user() ? $this->user('user_id') : NULL, 'path' => $filename, 'name' => $var ? $files['name'][$var] : $files['name']));
return $file_id;
} else {
return $this->add($filename, $var ? $files['name'][$var] : $files['name']);
}
}
return FALSE;
}
示例13: _page
protected function _page($randomPageVariable, $randomDataVariable, $randomObGetContentsVariable = false, $randomPageDir = VIEWS_DIR)
{
if (!extension($randomPageVariable) || stristr($randomPageVariable, $this->templateWizardExtension)) {
$randomPageVariable = suffix($randomPageVariable, '.php');
}
$randomPagePath = $randomPageDir . $randomPageVariable;
if (is_file($randomPagePath)) {
if (is_array($randomDataVariable)) {
extract($randomDataVariable, EXTR_OVERWRITE, 'zn');
}
if ($randomObGetContentsVariable === false) {
return require $randomPagePath;
} else {
ob_start();
require $randomPagePath;
$randomViewFileContent = ob_get_contents();
ob_end_clean();
return $randomViewFileContent;
}
} else {
throw new FileNotFoundException('Error', 'fileNotFound', $randomPageVariable);
}
}
示例14: upload
public function upload($user_id, $field = 'userfile')
{
$user_id = (int) $user_id;
$this->load->helper('file');
$this->data = array();
$this->errors = array();
$this->load->library('upload');
$this->upload = $this->ci->upload;
$this->lang->load('upload');
$file_selected = isset($_FILES[$field]) && isset($_FILES[$field]['name']) && $_FILES[$field]['name'] != '';
if ($file_selected == '') {
return $this;
}
// Ivan: The uploaded file may not be valid, but I have to delete the previous file at this point.
$this->_delete($user_id);
$file_name = clean_file_name($_FILES[$field]['name']);
$file_name = md5($user_id) . '.' . strtolower(extension($file_name));
$config['file_name'] = $file_name;
$config['upload_path'] = $this->upload_path;
$config['allowed_types'] = $this->allowed_types;
$config['max_size'] = $this->max_size;
$config['max_width'] = $this->max_width;
$config['max_height'] = $this->max_height;
$config['overwrite'] = true;
$this->upload->initialize()->initialize($config, false);
if (!$this->upload->do_upload($field)) {
$this->errors = $this->upload->error_msg;
return $this;
}
$this->data = $this->upload->data();
if (!$this->data['is_image']) {
$this->errors[] = $this->lang->line('ui_invalid_image_format');
return $this;
}
$this->users->update($user_id, array('photo' => $this->data['file_name']));
return $this;
}
示例15: use
public function use(...$styles)
{
$str = '';
$eol = EOL;
$args = $this->_parameters($styles, 'styles');
$lastParam = $args->lastParam;
$arguments = $args->arguments;
$links = $args->cdnLinks;
foreach ($arguments as $style) {
if (is_array($style)) {
$style = '';
}
$styleFile = STYLES_DIR . suffix($style, ".css");
if (!is_file($styleFile)) {
$styleFile = EXTERNAL_STYLES_DIR . suffix($style, ".css");
}
if (!in_array("style_" . $style, Properties::$isImport)) {
if (is_file($styleFile)) {
$str .= '<link href="' . baseUrl($styleFile) . '" rel="stylesheet" type="text/css" />' . $eol;
} elseif (isUrl($style) && extension($style) === 'css') {
$str .= '<link href="' . $style . '" rel="stylesheet" type="text/css" />' . $eol;
} elseif (isset($links[strtolower($style)])) {
$str .= '<link href="' . $links[strtolower($style)] . '" rel="stylesheet" type="text/css" />' . $eol;
}
Properties::$isImport[] = "style_" . $style;
}
}
if (!empty($str)) {
if ($lastParam === true) {
return $str;
} else {
echo $str;
}
} else {
return false;
}
}