当前位置: 首页>>代码示例>>PHP>>正文


PHP sanitize_filename函数代码示例

本文整理汇总了PHP中sanitize_filename函数的典型用法代码示例。如果您正苦于以下问题:PHP sanitize_filename函数的具体用法?PHP sanitize_filename怎么用?PHP sanitize_filename使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了sanitize_filename函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: file

 /**
  * Try to Upload the given file returning the filename on success
  *
  * @param array $file $_FILES array element
  * @param string $dir destination directory
  * @param boolean $overwrite existing files of the same name?
  * @param integer $size maximum size allowed (can also be set in php.ini or server config)
  */
 public function file($file, $dir, $overwrite = FALSE, $size = FALSE)
 {
     // Invalid upload?
     if (!isset($file['tmp_name'], $file['name'], $file['error'], $file['size']) or $file['error'] != UPLOAD_ERR_OK) {
         return FALSE;
     }
     // File to large?
     if ($size and $size > $file['size']) {
         return FALSE;
     }
     // Create $basename, $filename, $dirname, & $extension variables
     extract(pathinfo($file['name']) + array('extension' => ''));
     // Make the name file system safe
     $filename = sanitize_filename($filename);
     // We must have a valid name and file type
     if (empty($filename) or empty($extension)) {
         return FALSE;
     }
     $extension = strtolower($extension);
     // Don't allow just any file!
     if (!$this->allowed_file($extension)) {
         return FALSE;
     }
     // Make sure we can use the destination directory
     Directory::usable($dir);
     // Create a unique name if we don't want files overwritten
     $name = $overwrite ? "{$filename}.{$ext}" : $this->unique_filename($dir, $filename, $extension);
     // Move the file to the correct location
     if (move_uploaded_file($file['tmp_name'], $dir . $name)) {
         return $name;
     }
 }
开发者ID:PermeAgility,项目名称:FrameworkBenchmarks,代码行数:40,代码来源:Upload.php

示例2: fire

 /**
  * {@inheritdoc}
  */
 protected function fire()
 {
     $process = new Process('mysqldump --version');
     $process->run();
     if (!$process->isSuccessful()) {
         throw new \RuntimeException('mysqldump could not be found in your $PATH.');
     }
     ee()->load->helper('security');
     // where to create the file, default to current dir
     $path = $this->argument('path') ?: '.';
     $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $gzip = $this->option('gzip');
     if ($gzip) {
         $process = new Process('gzip --version');
         $process->run();
         if (!$process->isSuccessful()) {
             throw new \RuntimeException('gzip could not be found in your $PATH.');
         }
     }
     $extension = $gzip ? '.sql.gz' : '.sql';
     $name = $this->option('name');
     // set a default name <db>[-<env>]-<yyyymmddhhmmss>
     if (!$name) {
         $name = sanitize_filename(ee()->db->database);
         $env = $this->getApplication()->getEnvironment();
         if ($env) {
             $name .= '-' . $env;
         }
         $name .= '-' . date('YmdHis');
     }
     $file = $path . $name . $extension;
     // compile the mysqldump command using EE's db credentials
     $command = sprintf('MYSQL_PWD=%s mysqldump -u %s -h %s %s %s > %s', escapeshellarg(ee()->db->password), escapeshellarg(ee()->db->username), escapeshellarg(ee()->db->hostname), escapeshellarg(ee()->db->database), $gzip ? ' | gzip' : '', escapeshellarg($file));
     $process = new Process($command);
     $process->setTimeout(3600);
     $process->run();
     if (!$process->isSuccessful()) {
         $this->error('Could not execute mysqldump.');
         return;
     }
     $backups = $this->option('backups');
     // check if we need to delete any old backups
     if (is_numeric($backups)) {
         $finder = new Finder();
         // look for other files in the path that use the
         // sql / sql.gz extension
         $finder->files()->in($path)->name('*' . $extension)->sortByModifiedTime();
         // omit the X most recent files
         $files = array_slice(array_reverse(iterator_to_array($finder)), $backups);
         // if there are backups beyond our limit, delete them
         foreach ($files as $file) {
             unlink($file->getRealPath());
         }
     }
     $this->info($file . ' created.');
 }
开发者ID:A2-Hosting,项目名称:eecli,代码行数:59,代码来源:DbDumpCommand.php

示例3: gimmeZip

 public function gimmeZip($id)
 {
     set_time_limit(300);
     $contest = Contest::findOrFail($id);
     $entries = UserContestEntry::where('contest_id', $id)->with('user')->get();
     $tmpBase = sys_get_temp_dir() . "/c{$id}-" . time();
     $workingFolder = "{$tmpBase}/working";
     $outputFolder = "{$tmpBase}/out";
     try {
         if (!is_dir($workingFolder)) {
             mkdir($workingFolder, 0755, true);
         }
         if (!is_dir($outputFolder)) {
             mkdir($outputFolder, 0755, true);
         }
         // fetch entries
         foreach ($entries as $entry) {
             $targetDir = "{$workingFolder}/" . ($entry->user ?? new \App\Models\DeletedUser())->username . " ({$entry->user_id})/";
             if (!is_dir($targetDir)) {
                 mkdir($targetDir, 0755, true);
             }
             copy($entry->fileUrl(), "{$targetDir}/" . sanitize_filename($entry->original_filename));
         }
         // zip 'em
         $zipOutput = "{$outputFolder}/contest-{$id}.zip";
         $zip = new \ZipArchive();
         $zip->open($zipOutput, \ZipArchive::CREATE);
         foreach (glob("{$workingFolder}/**/*.*") as $file) {
             // we just want the path relative to the working folder root
             $new_filename = str_replace("{$workingFolder}/", '', $file);
             $zip->addFile($file, $new_filename);
         }
         $zip->close();
         // send 'em on their way
         header('Content-Disposition: attachment; filename=' . basename($zipOutput));
         header('Content-Type: application/zip');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($zipOutput));
         readfile($zipOutput);
     } finally {
         deltree($tmpBase);
     }
 }
开发者ID:ppy,项目名称:osu-web,代码行数:45,代码来源:ContestsController.php

示例4: fire

 /**
  * {@inheritdoc}
  */
 protected function fire()
 {
     ee()->load->helper('security');
     // where to create the file, default to current dir
     $path = $this->argument('path') ?: '.';
     $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $gzip = $this->option('gzip');
     $extension = $gzip ? '.sql.gz' : '.sql';
     $name = $this->option('name');
     // set a default name <db>[-<env>]-<yyyymmddhhmmss>
     if (!$name) {
         $name = sanitize_filename(ee()->db->database);
         $env = $this->getApplication()->getEnvironment();
         if ($env) {
             $name .= '-' . $env;
         }
         $name .= '-' . date('YmdHis');
     }
     $file = $path . $name . $extension;
     // compile the mysqldump command using EE's db credentials
     $command = sprintf('MYSQL_PWD="%s" /usr/bin/env mysqldump -u "%s" -h "%s" "%s"%s > %s', ee()->db->password, ee()->db->username, ee()->db->hostname, ee()->db->database, $gzip ? ' | gzip' : '', $file);
     $executed = system($command);
     $backups = $this->option('backups');
     // check if we need to delete any old backups
     if (is_numeric($backups)) {
         $finder = new Finder();
         // look for other files in the path that use the
         // sql / sql.gz extension
         $finder->files()->in($path)->name('*' . $extension)->sortByModifiedTime();
         // omit the X most recent files
         $files = array_slice(array_reverse(iterator_to_array($finder)), $backups);
         // if there are backups beyond our limit, delete them
         foreach ($files as $file) {
             unlink($file->getRealPath());
         }
     }
     if ($executed !== false) {
         $this->info($file . ' created.');
     } else {
         $this->error('Could not execute mysqldump.');
     }
 }
开发者ID:diemer,项目名称:eecli,代码行数:45,代码来源:DbDumpCommand.php

示例5: SUBSTRING

echo "<p>Reorganizing your images folder...";
# strip images prefix from pictures table
$sql = "UPDATE " . TABLE_PREFIX . "pictures SET path = SUBSTRING(path,8) WHERE SUBSTRING(path,1,7) = 'images/'";
$result = mysql_query($sql);
$sql = "SELECT id,name FROM " . TABLE_PREFIX . "collections";
$result = mysql_query($sql) or die(mysql_error() . "<br /><br />" . $sql);
while ($row = mysql_fetch_assoc($result)) {
    $sql = "UPDATE " . TABLE_PREFIX . "collections SET path = '" . strtolower(sanitize_filename($row['name'])) . "' WHERE id = " . $row['id'];
    #print $sql;
    #print "<br>";
    mysql_query($sql);
}
$sql = "SELECT id,name FROM " . TABLE_PREFIX . "albums";
$result = mysql_query($sql) or die(mysql_error() . "<br /><br />" . $sql);
while ($row = mysql_fetch_assoc($result)) {
    $sql = "UPDATE " . TABLE_PREFIX . "albums SET path = '" . strtolower(sanitize_filename($row['name'])) . "' WHERE id = " . $row['id'];
    #print $sql;
    #print "<br>";
    mysql_query($sql);
}
// loop through each image from the pictures table, get its parent album name and parent collection
// name, create subdirectories, move the file, and update the PATH field in pictures.
// We need to do a join on the tables to get album names and collection names
$sql = "SELECT p.path AS path, p.id AS pid,c.path AS collection_path, a.path AS album_path\r\n\t\tFROM " . TABLE_PREFIX . "albums a, " . TABLE_PREFIX . "pictures p, " . TABLE_PREFIX . "collections c \r\n\t\tWHERE p.parent_album = a.id AND p.parent_collection = c.id";
$result = mysql_query($sql) or die(mysql_error() . "<br /><br />" . $sql);
echo "<ul>";
while ($row = mysql_fetch_assoc($result)) {
    $errors = 0;
    $filename = basename($row['path']);
    $directory = $row['collection_path'] . "/" . $row['album_path'] . "/";
    $new_path = "images/" . $directory . $filename;
开发者ID:alanhaggai,项目名称:plogger,代码行数:31,代码来源:_upgrade.php

示例6: plogger_get_thumbnail_info

function plogger_get_thumbnail_info()
{
    global $thumbnail_config;
    global $config;
    $thumb_config = $thumbnail_config[THUMB_SMALL];
    $base_filename = sanitize_filename(basename($GLOBALS["current_picture"]["path"]));
    $prefix = $thumb_config['filename_prefix'] . $GLOBALS["current_picture"]["id"] . "-";
    $thumbpath = $config['basedir'] . 'thumbs/' . $prefix . $base_filename;
    $image_info = getimagesize($thumbpath);
    return $image_info;
}
开发者ID:alanhaggai,项目名称:plogger,代码行数:11,代码来源:plog-functions.php

示例7: dirname

<?php

require_once dirname(__FILE__) . '/classes/core/startup.php';
require_once dirname(__FILE__) . '/config-defaults.php';
require_once dirname(__FILE__) . '/common.php';
require_once $homedir . '/classes/core/class.progressbar.php';
require_once dirname(__FILE__) . '/classes/core/language.php';
if (!isset($surveyid)) {
    $surveyid = returnglobal('sid');
} else {
    //This next line ensures that the $surveyid value is never anything but a number.
    $surveyid = sanitize_int($surveyid);
}
if (isset($_GET['filegetcontents'])) {
    $sFileName = sanitize_filename($_GET['filegetcontents']);
    if (substr($sFileName, 0, 6) == 'futmp_') {
        $sFileDir = $tempdir . '/upload/';
    } elseif (substr($sFileName, 0, 3) == 'fu_') {
        $sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
    }
    readfile($sFileDir . $sFileName);
    exit;
}
// Compute the Session name
// Session name is based:
// * on this specific limesurvey installation (Value SessionName in DB)
// * on the surveyid (from Get or Post param). If no surveyid is given we are on the public surveys portal
$usquery = "SELECT stg_value FROM " . db_table_name("settings_global") . " where stg_name='SessionName'";
$usresult = db_execute_assoc($usquery, '', true);
//Checked
if ($usresult) {
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:uploader.php

示例8: PrinterStoring__generateFilename

function PrinterStoring__generateFilename($raw_name)
{
    $return_name = NULL;
    $CI =& get_instance();
    $CI->load->helper('security');
    // remove unsecurity chars and non ascii chars
    $return_name = filter_var(sanitize_filename($raw_name), FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
    // replace space and some chars
    $return_name = str_replace(array(' ', '`', '|', ':', '*', '%', ',', '^'), '_', $return_name);
    //TODO check if we need to filter '(' and ')' for interface or not
    return $return_name;
}
开发者ID:Jaesin,项目名称:zim-web,代码行数:12,代码来源:printerstoring_helper.php

示例9: flush

<p><img src="../../img/symbole/rotation.gif" alt="" width="15" height="15"><strong class="title">&nbsp;selected files uploaded via ftp will be taken over!</strong></p><?php 
    echo "<p class=\"v10\">";
    flush();
    foreach ($ftp["mark"] as $key => $value) {
        if (!ini_get('safe_mode') && function_exists('set_time_limit')) {
            set_time_limit(60);
        }
        $file = $ftp["file"][$key];
        $file_path = PHPWCMS_ROOT . $phpwcms["ftp_path"] . $file;
        if (is_file($file_path)) {
            $file_type = '';
            $file_error["upload"] = 0;
            $file_size = filesize($file_path);
            $file_ext = check_image_extension($file_path);
            $file_ext = false === $file_ext ? which_ext($file) : $file_ext;
            $file_name = sanitize_filename($ftp["filename"][$key]);
            $file_hash = md5($file_name . microtime());
            if (trim($file_type) === '') {
                //check file_type
                if (is_mimetype_by_extension($file_ext)) {
                    $file_type = get_mimetype_by_extension($file_ext);
                } else {
                    $file_check = getimagesize($file_path);
                    if (version_compare("4.3.0", phpversion(), ">=") && $file_check) {
                        $file_type = image_type_to_mime_type($file_check[2]);
                    }
                    if (!is_mimetype_format($file_type)) {
                        $file_type = get_mimetype_by_extension($file_ext);
                    }
                }
            }
开发者ID:EDVLanger,项目名称:phpwcms,代码行数:31,代码来源:act_ftptakeover.php

示例10: sanitize_dirname

/**
 * Function: sanitize_dirname
 * sanitizes a string that will be used as a directory name
 *
 * Parameters:
 *     $string - The string to sanitize.
 *     $force_lowercase - Force the string to lowercase?
 *     $alphanumeric - If set to *true*, will remove all non-alphanumeric characters.
 */
function sanitize_dirname($string, $force_lowercase = false, $alphanumeric = false)
{
    $string = str_replace(".", "", $string);
    return sanitize_filename($string, $force_lowercase, $alphanumeric);
}
开发者ID:mfavetti,项目名称:LimeSurvey,代码行数:14,代码来源:sanitize_helper.php

示例11: is

<?php

require 'test-more.php';
require '../../cacti/scripts/ss_get_by_ssh.php';
$debug = true;
is(sanitize_filename(array('foo' => 'bar'), array('foo', 'biz'), 'tail'), 'bar_tail', 'sanitize_filename');
is_deeply(proc_stat_parse(null, file_get_contents('samples/proc_stat-001.txt')), array('STAT_interrupts' => '339490', 'STAT_context_switches' => '697948', 'STAT_forks' => '11558', 'STAT_CPU_user' => '24198', 'STAT_CPU_nice' => '0', 'STAT_CPU_system' => '69614', 'STAT_CPU_idle' => '2630536', 'STAT_CPU_iowait' => '558', 'STAT_CPU_irq' => '5872', 'STAT_CPU_softirq' => '1572', 'STAT_CPU_steal' => '0', 'STAT_CPU_guest' => '0'), 'samples/proc_stat-001.txt');
is_deeply(proc_stat_parse(null, file_get_contents('samples/proc_stat-002.txt')), array('STAT_interrupts' => '87480486', 'STAT_context_switches' => '125521467', 'STAT_forks' => '239810', 'STAT_CPU_user' => '2261920', 'STAT_CPU_nice' => '38824', 'STAT_CPU_system' => '986335', 'STAT_CPU_idle' => '39683698', 'STAT_CPU_iowait' => '62368', 'STAT_CPU_irq' => '19193', 'STAT_CPU_softirq' => '8499', 'STAT_CPU_steal' => '0', 'STAT_CPU_guest' => '0'), 'samples/proc_stat-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/proc_stat-001.txt', 'type' => 'proc_stat', 'host' => 'localhost', 'items' => 'gw,gx,gy,gz,hg,hh,hi,hj,hk,hl,hm,hn')), 'gw:24198 gx:0 gy:69614 gz:2630536 hg:558 hh:5872 hi:1572 hj:0 hk:0' . ' hl:339490 hm:697948 hn:11558', 'main(samples/proc_stat-001.txt)');
is_deeply(memory_parse(null, file_get_contents('samples/free-001.txt')), array('STAT_memcached' => '22106112', 'STAT_membuffer' => '1531904', 'STAT_memshared' => '0', 'STAT_memfree' => '17928192', 'STAT_memused' => '21389312', 'STAT_memtotal' => '62955520'), 'samples/free-001.txt');
is_deeply(memory_parse(null, file_get_contents('samples/free-002.txt')), array('STAT_memcached' => '1088184320', 'STAT_membuffer' => '131469312', 'STAT_memshared' => '0', 'STAT_memfree' => '189325312', 'STAT_memused' => '7568291328', 'STAT_memtotal' => '8977270272'), 'samples/free-002.txt (issue 102)');
is(ss_get_by_ssh(array('file' => 'samples/free-001.txt', 'type' => 'memory', 'host' => 'localhost', 'items' => 'hq,hr,hs,ht,hu,hv')), 'hq:22106112 hr:1531904 hs:0 ht:17928192 hu:21389312 hv:62955520', 'main(samples/free-001.txt)');
is_deeply(w_parse(null, file_get_contents('samples/w-001.txt')), array('STAT_loadavg' => '0.00', 'STAT_numusers' => '2'), 'samples/w-001.txt');
is_deeply(w_parse(null, file_get_contents('samples/w-002.txt')), array('STAT_loadavg' => '0.29', 'STAT_numusers' => '6'), 'samples/w-002.txt');
is_deeply(w_parse(null, file_get_contents('samples/w-003.txt')), array('STAT_loadavg' => '0.02', 'STAT_numusers' => '1'), 'samples/w-003.txt');
is_deeply(w_parse(null, file_get_contents('samples/w-004.txt')), array('STAT_loadavg' => '11.02', 'STAT_numusers' => '1'), 'samples/w-004.txt');
is_deeply(w_parse(null, file_get_contents('samples/uptime-001.txt')), array('STAT_loadavg' => '0.00', 'STAT_numusers' => '0'), 'samples/uptime-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/w-001.txt', 'type' => 'w', 'host' => 'localhost', 'items' => 'ho,hp')), 'ho:0.00 hp:2', 'main(samples/w-001.txt)');
is_deeply(memcached_parse(null, file_get_contents('samples/memcached-001.txt')), array('MEMC_pid' => '2120', 'MEMC_uptime' => '32314', 'MEMC_time' => '1261775864', 'MEMC_version' => '1.2.2', 'MEMC_pointer_size' => '32', 'MEMC_rusage_user' => '396024', 'MEMC_rusage_system' => '1956122', 'MEMC_curr_items' => '0', 'MEMC_total_items' => '0', 'MEMC_bytes' => '0', 'MEMC_curr_connections' => '1', 'MEMC_total_connections' => '5', 'MEMC_connection_structures' => '2', 'MEMC_cmd_get' => '0', 'MEMC_cmd_set' => '0', 'MEMC_get_hits' => '0', 'MEMC_get_misses' => '0', 'MEMC_evictions' => '0', 'MEMC_bytes_read' => '45', 'MEMC_bytes_written' => '942', 'MEMC_limit_maxbytes' => '67108864', 'MEMC_threads' => '1'), 'samples/memcached-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/memcached-001.txt', 'type' => 'memcached', 'host' => 'localhost', 'items' => 'ij,ik,il,im,in,io,ip,iq,ir,is,it,iu,iv')), 'ij:396024 ik:1956122 il:0 im:0 in:0 io:1 ip:5 iq:0 ir:0 is:0 it:0 iu:45' . ' iv:942', 'main(samples/memcached-001.txt)');
is_deeply(nginx_parse(null, file_get_contents('samples/nginx-001.txt')), array('NGINX_active_connections' => '251', 'NGINX_server_accepts' => '255601634', 'NGINX_server_handled' => '255601634', 'NGINX_server_requests' => '671013148', 'NGINX_reading' => '5', 'NGINX_writing' => '27', 'NGINX_waiting' => '219'), 'samples/nginx-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/nginx-001.txt', 'type' => 'nginx', 'host' => 'localhost', 'items' => 'hw,hx,hy,hz,ig,ih,ii')), 'hw:251 hx:255601634 hy:255601634 hz:671013148 ig:5 ih:27 ii:219', 'main(samples/nginx-001.txt)');
is_deeply(apache_parse(null, file_get_contents('samples/apache-001.txt')), array('APACHE_Requests' => '3452389', 'APACHE_Bytes_sent' => '23852769280', 'APACHE_Idle_workers' => '8', 'APACHE_Busy_workers' => '1', 'APACHE_CPU_Load' => '.023871', 'APACHE_Waiting_for_connection' => '8', 'APACHE_Starting_up' => 0, 'APACHE_Reading_request' => 0, 'APACHE_Sending_reply' => '1', 'APACHE_Keepalive' => 0, 'APACHE_DNS_lookup' => 0, 'APACHE_Closing_connection' => 0, 'APACHE_Logging' => 0, 'APACHE_Gracefully_finishing' => 0, 'APACHE_Idle_cleanup' => 0, 'APACHE_Open_slot' => '247'), 'samples/apache-001.txt');
is_deeply(apache_parse(null, file_get_contents('samples/apache-002.txt')), array('APACHE_Requests' => '368', 'APACHE_Bytes_sent' => 1151 * 1024, 'APACHE_Idle_workers' => '19', 'APACHE_Busy_workers' => '1', 'APACHE_CPU_Load' => '.0284617', 'APACHE_Waiting_for_connection' => '19', 'APACHE_Starting_up' => 0, 'APACHE_Reading_request' => 0, 'APACHE_Sending_reply' => '1', 'APACHE_Keepalive' => 0, 'APACHE_DNS_lookup' => 0, 'APACHE_Closing_connection' => 0, 'APACHE_Logging' => 0, 'APACHE_Gracefully_finishing' => 0, 'APACHE_Idle_cleanup' => 0, 'APACHE_Open_slot' => '236'), 'samples/apache-002.txt');
is(ss_get_by_ssh(array('file' => 'samples/apache-001.txt', 'type' => 'apache', 'host' => 'localhost', 'items' => 'gg,gh,gi,gj,gk,gl,gm,gn,go,gp,gq,gr,gs,gt,gu,gv')), 'gg:3452389 gh:23852769280 gi:8 gj:1 gk:.023871 gl:8 gm:0 gn:0 go:1 gp:0' . ' gq:0 gr:0 gs:0 gt:0 gu:0 gv:247', 'main(samples/apache-001.txt)');
is_deeply(diskstats_parse(array('device' => 'hda1'), file_get_contents('samples/diskstats-001.txt')), array('DISK_reads' => '12043', 'DISK_reads_merged' => '387', 'DISK_sectors_read' => '300113', 'DISK_time_spent_reading' => '6472', 'DISK_writes' => '12737', 'DISK_writes_merged' => '21340', 'DISK_sectors_written' => '272616', 'DISK_time_spent_writing' => '22360', 'DISK_io_time' => '12368', 'DISK_io_time_weighted' => '28832', 'DISK_io_ops' => '24780'), 'samples/diskstats-001.txt');
is_deeply(diskstats_parse(array('device' => 'sda4'), file_get_contents('samples/diskstats-002.txt')), array('DISK_reads' => '30566', 'DISK_reads_merged' => '3341', 'DISK_sectors_read' => '586664', 'DISK_time_spent_reading' => '370308', 'DISK_writes' => '150943', 'DISK_writes_merged' => '163833', 'DISK_sectors_written' => '2518672', 'DISK_time_spent_writing' => '12081496', 'DISK_io_time' => '347416', 'DISK_io_time_weighted' => '12451664', 'DISK_io_ops' => '181509'), 'samples/diskstats-002.txt');
is_deeply(diskstats_parse(array('device' => 'sda2'), file_get_contents('samples/diskstats-003.txt')), array('DISK_reads' => '15425346', 'DISK_reads_merged' => '0', 'DISK_sectors_read' => '385290786', 'DISK_time_spent_reading' => '0', 'DISK_writes' => '472909074', 'DISK_writes_merged' => '0', 'DISK_sectors_written' => '3783272616', 'DISK_time_spent_writing' => '0', 'DISK_io_time' => '0', 'DISK_io_time_weighted' => '0', 'DISK_io_ops' => '488334420'), 'samples/diskstats-003.txt');
is(ss_get_by_ssh(array('file' => 'samples/diskstats-001.txt', 'type' => 'diskstats', 'host' => 'localhost', 'items' => 'iw,ix,iy,iz,jg,jh,ji,jj,jk,jl,jm', 'device' => 'hda1')), 'iw:12043 ix:387 iy:300113 iz:6472 jg:12737 jh:21340 ji:272616 jj:22360' . ' jk:24780 jl:12368 jm:28832', 'main(samples/diskstats-001.txt)');
is_deeply(openvz_parse(array(), file_get_contents('samples/openvz-001.txt')), array('OPVZ_kmemsize_held' => '8906701', 'OPVZ_kmemsize_failcnt' => '0', 'OPVZ_lockedpages_held' => '0', 'OPVZ_lockedpages_failcnt' => '0', 'OPVZ_privvmpages_held' => '39695', 'OPVZ_privvmpages_failcnt' => '0', 'OPVZ_shmpages_held' => '688', 'OPVZ_shmpages_failcnt' => '0', 'OPVZ_numproc_held' => '32', 'OPVZ_numproc_failcnt' => '0', 'OPVZ_physpages_held' => '11101', 'OPVZ_physpages_failcnt' => '0', 'OPVZ_vmguarpages_held' => '0', 'OPVZ_vmguarpages_failcnt' => '0', 'OPVZ_oomguarpages_held' => '11101', 'OPVZ_oomguarpages_failcnt' => '0', 'OPVZ_numtcpsock_held' => '6', 'OPVZ_numtcpsock_failcnt' => '0', 'OPVZ_numflock_held' => '6', 'OPVZ_numflock_failcnt' => '0', 'OPVZ_numpty_held' => '1', 'OPVZ_numpty_failcnt' => '0', 'OPVZ_numsiginfo_held' => '0', 'OPVZ_numsiginfo_failcnt' => '0', 'OPVZ_tcpsndbuf_held' => '338656', 'OPVZ_tcpsndbuf_failcnt' => '0', 'OPVZ_tcprcvbuf_held' => '98304', 'OPVZ_tcprcvbuf_failcnt' => '0', 'OPVZ_othersockbuf_held' => '9280', 'OPVZ_othersockbuf_failcnt' => '0', 'OPVZ_dgramrcvbuf_held' => '0', 'OPVZ_dgramrcvbuf_failcnt' => '0', 'OPVZ_numothersock_held' => '9', 'OPVZ_numothersock_failcnt' => '0', 'OPVZ_dcachesize_held' => '0', 'OPVZ_dcachesize_failcnt' => '0', 'OPVZ_numfile_held' => '788', 'OPVZ_numfile_failcnt' => '0', 'OPVZ_numiptent_held' => '10', 'OPVZ_numiptent_failcnt' => '0'), 'samples/openvz-001.txt');
is(ss_get_by_ssh(array('file' => 'samples/openvz-001.txt', 'type' => 'openvz', 'host' => 'localhost', 'items' => 'jn,jo,jp,jq,jr,js,jt,ju,jv,jw,jx,jy,jz,kg,kh,ki,kj,kk,kl,km,kn,ko,kp,kq,kr,ks,kt,ku,kv,kw,kx,ky,kz,lg,lh,li,lj,lk,ll,lm')), 'jn:8906701 jo:0 jp:0 jq:0 jr:39695 js:0 jt:688 ju:0 jv:32 jw:0 jx:11101' . ' jy:0 jz:0 kg:0 kh:11101 ki:0 kj:6 kk:0 kl:6 km:0 kn:1 ko:0 kp:0 kq:0' . ' kr:338656 ks:0 kt:98304 ku:0 kv:9280 kw:0 kx:0 ky:0 kz:9 lg:0 lh:0 li:0' . ' lj:788 lk:0 ll:10 lm:0', 'main(samples/openvz-001.txt)');
开发者ID:stardata,项目名称:percona-monitoring-plugins,代码行数:31,代码来源:get_by_ssh.php

示例12: test_sanitize_filename

 function test_sanitize_filename()
 {
     $this->assertEquals('hello.doc', sanitize_filename('hello.doc'));
     $filename = './<!--foo-->';
     $this->assertEquals('foo', sanitize_filename($filename));
 }
开发者ID:DavBfr,项目名称:BlogMVC,代码行数:6,代码来源:security_helper_test.php

示例13: simplexml_load_string

 $podcast_simplexml = simplexml_load_string(file_get_contents(trim($podcast_url)));
 if (!$podcast_simplexml) {
     echo "{$podcast_title} ({$podcast_url}) is not providing valid XML. Skipping.\n";
     break;
 }
 if (!file_exists(PODDIE_PODCAST_STORAGE . "/{$podcast_title}")) {
     echo "New podcast subscription detected: {$podcast_title}.\n";
     exec("mkdir -p '" . PODDIE_PODCAST_STORAGE . "/{$podcast_title}'");
 }
 foreach ($podcast_simplexml->channel->item as $item) {
     if (++$episodes_kept >= $episodes_to_keep) {
         break;
     }
     $url = (string) $item->enclosure['url'];
     $episode_title_filename_extension = strtolower(pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION));
     $episode_title_filename = date('Y-m-d', strtotime((string) $item->pubDate)) . " - " . sanitize_filename(remove_timestamp((string) $item->title)) . ".{$episode_title_filename_extension}";
     if ($url != '' && !file_exists(PODDIE_PODCAST_STORAGE . "/{$podcast_title}/{$episode_title_filename}") && strpos($poddie_already_fetched, $url) === false) {
         echo "Fetching '{$url}' into '" . PODDIE_PODCAST_STORAGE . "/{$podcast_title}/{$episode_title_filename}'\n";
         download($url, PODDIE_PODCAST_STORAGE . "/{$podcast_title}/{$episode_title_filename}");
         $id3tag = substr($episode_title_filename, 0, strrpos($episode_title_filename, '.'));
         exec(PODDIE_ID3TAG_BIN . " --song='{$id3tag}' '" . PODDIE_PODCAST_STORAGE . "/{$podcast_title}/{$episode_title_filename}'");
         log_fetched($url);
         $downloaded_files_count++;
     }
 }
 $downloaded_files = scan_dir(PODDIE_PODCAST_STORAGE . "/{$podcast_title}");
 for ($index = intval($episodes_to_keep); $index <= count($downloaded_files) - 1; $index++) {
     $file_to_remove = PODDIE_PODCAST_STORAGE . "/{$podcast_title}/{$downloaded_files[$index]}";
     echo "Removing {$index} from {$podcast_title} ({$file_to_remove})\n";
     unlink($file_to_remove);
 }
开发者ID:jakobbg,项目名称:poddie,代码行数:31,代码来源:poddie.php

示例14: header

        if (isset($_POST['printableexport'])) {
            $pdf->intopdf(FlattenText($fname[0] . $fname[1], true) . ": " . $fname[2]);
            $pdf->ln(2);
        } else {
            $printoutput .= "\t<tr class='printanswersquestionhead'><td  colspan='2'>{$fname[0]}</td></tr>\n";
        }
    } else {
        if (isset($_POST['printableexport'])) {
            $pdf->intopdf(FlattenText($fname[0] . $fname[1], true) . ": " . $fname[2]);
            $pdf->ln(2);
        } else {
            $printoutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
        }
    }
}
$printoutput .= "</table>\n";
if (isset($_POST['printableexport'])) {
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    $sExportFileName = sanitize_filename($surveyname);
    $pdf->Output($sExportFileName . "-" . $surveyid . ".pdf", "D");
}
//Display the page with user answers
if (!isset($_POST['printableexport'])) {
    sendcacheheaders();
    doHeader();
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/startpage.pstpl'));
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/printanswers.pstpl'), array('ANSWERTABLE' => $printoutput));
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/endpage.pstpl'));
    echo "</body></html>";
}
开发者ID:karime7gezly,项目名称:OpenConextApps-LimeSurvey,代码行数:31,代码来源:printanswers.php

示例15: sprintf

    $newdirname = $usertemplaterootdir . "/" . $newname;
    $olddirname = $usertemplaterootdir . "/" . $copydir;
    if (isStandardTemplate($newname)) {
        echo "<script type=\"text/javascript\">\n<!--\nalert(\"" . sprintf($clang->gT("Template could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("This name is reserved for a standard template.", "js") . "\");\n//-->\n</script>";
    } elseif (rename($olddirname, $newdirname) == false) {
        echo "<script type=\"text/javascript\">\n<!--\nalert(\"" . sprintf($clang->gT("Directory could not be renamed to `%s`.", "js"), $newname) . " " . $clang->gT("Maybe you don't have permission.", "js") . "\");\n//-->\n</script>";
    } else {
        $templates[$newname] = $newdirname;
        $templatename = $newname;
    }
}
if ($action == "templateuploadfile") {
    if ($demoModeOnly == true) {
        $action = '';
    } else {
        $the_full_file_path = $usertemplaterootdir . "/" . $templatename . "/" . sanitize_filename($_FILES['the_file']['name']);
        if ($extfile = strrchr($_FILES['the_file']['name'], '.')) {
            if (!(stripos(',' . $allowedtemplateuploads . ',', ',' . substr($extfile, 1) . ',') === false)) {
                //Uploads the file into the appropriate directory
                if (!@move_uploaded_file($_FILES['the_file']['tmp_name'], $the_full_file_path)) {
                    echo "<strong><font color='red'>" . $clang->gT("Error") . "</font></strong><br />\n";
                    echo sprintf($clang->gT("An error occurred uploading your file. This may be caused by incorrect permissions in your %s folder."), $tempdir) . "<br /><br />\n";
                    echo "<input type='submit' value='" . $clang->gT("Main Admin Screen") . "' onclick=\"window.open('{$scriptname}', '_top')\" />\n";
                    echo "</td></tr></table>\n";
                    echo "</body>\n</html>\n";
                    exit;
                }
            } else {
                // if we came here is because the file extention is not allowed
                @unlink($_FILES['the_file']['tmp_name']);
                echo "<strong><font color='red'>" . $clang->gT("Error") . "</font></strong><br />\n";
开发者ID:himanshu12k,项目名称:ce-www,代码行数:31,代码来源:templates.php


注:本文中的sanitize_filename函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。