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


PHP parse_bytes函数代码示例

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


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

示例1: test_parse_bytes

 /**
  * rcube_shared.inc: parse_bytes()
  */
 function test_parse_bytes()
 {
     $data = array('1' => 1, '1024' => 1024, '2k' => 2 * 1024, '2 k' => 2 * 1024, '2kb' => 2 * 1024, '2kB' => 2 * 1024, '2m' => 2 * 1048576, '2 m' => 2 * 1048576, '2mb' => 2 * 1048576, '2mB' => 2 * 1048576, '2g' => 2 * 1024 * 1048576, '2 g' => 2 * 1024 * 1048576, '2gb' => 2 * 1024 * 1048576, '2gB' => 2 * 1024 * 1048576);
     foreach ($data as $value => $expected) {
         $result = parse_bytes($value);
         $this->assertEquals($expected, $result, "Invalid parse_bytes() result for {$value}");
     }
 }
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:11,代码来源:Shared.php

示例2: check_size

 function check_size($args)
 {
     $limit = parse_bytes(rcmail::get_instance()->config->get('max_message_size', '10MB'));
     $total = $args['size'];
     if ($_SESSION['compose'] && $_SESSION['compose']['attachments']) {
         foreach ($_SESSION['compose']['attachments'] as $attachment) {
             $total += $attachment['size'];
         }
     }
     if ($total > $limit) {
         $this->add_texts('localization/');
         $args['error'] = sprintf($this->gettext('overallsizeerror'), show_bytes(parse_bytes($limit)));
         $args['abort'] = true;
     }
     return $args;
 }
开发者ID:venenux,项目名称:simplemail-plugins,代码行数:16,代码来源:messagesize.php

示例3: import_events

 /**
  *
  */
 function import_events()
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         $this->rc->upload_progress();
     }
     @set_time_limit(0);
     // process uploaded file if there is no error
     $err = $_FILES['_data']['error'];
     if (!$err && $_FILES['_data']['tmp_name']) {
         $calendar = rcube_utils::get_input_value('calendar', rcube_utils::INPUT_GPC);
         $rangestart = $_REQUEST['_range'] ? date_create("now -" . intval($_REQUEST['_range']) . " months") : 0;
         // extract zip file
         if ($_FILES['_data']['type'] == 'application/zip') {
             $count = 0;
             if (class_exists('ZipArchive', false)) {
                 $zip = new ZipArchive();
                 if ($zip->open($_FILES['_data']['tmp_name'])) {
                     $randname = uniqid('zip-' . session_id(), true);
                     $tmpdir = slashify($this->rc->config->get('temp_dir', sys_get_temp_dir())) . $randname;
                     mkdir($tmpdir, 0700);
                     // extract each ical file from the archive and import it
                     for ($i = 0; $i < $zip->numFiles; $i++) {
                         $filename = $zip->getNameIndex($i);
                         if (preg_match('/\\.ics$/i', $filename)) {
                             $tmpfile = $tmpdir . '/' . basename($filename);
                             if (copy('zip://' . $_FILES['_data']['tmp_name'] . '#' . $filename, $tmpfile)) {
                                 $count += $this->import_from_file($tmpfile, $calendar, $rangestart, $errors);
                                 unlink($tmpfile);
                             }
                         }
                     }
                     rmdir($tmpdir);
                     $zip->close();
                 } else {
                     $errors = 1;
                     $msg = 'Failed to open zip file.';
                 }
             } else {
                 $errors = 1;
                 $msg = 'Zip files are not supported for import.';
             }
         } else {
             // attempt to import teh uploaded file directly
             $count = $this->import_from_file($_FILES['_data']['tmp_name'], $calendar, $rangestart, $errors);
         }
         if ($count) {
             $this->rc->output->command('display_message', $this->gettext(array('name' => 'importsuccess', 'vars' => array('nr' => $count))), 'confirmation');
             $this->rc->output->command('plugin.import_success', array('source' => $calendar, 'refetch' => true));
         } else {
             if (!$errors) {
                 $this->rc->output->command('display_message', $this->gettext('importnone'), 'notice');
                 $this->rc->output->command('plugin.import_success', array('source' => $calendar));
             } else {
                 $this->rc->output->command('plugin.import_error', array('message' => $this->gettext('importerror') . ($msg ? ': ' . $msg : '')));
             }
         }
     } else {
         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
             $msg = $this->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
         } else {
             $msg = $this->gettext('fileuploaderror');
         }
         $this->rc->output->command('plugin.import_error', array('message' => $msg));
     }
     $this->rc->output->send('iframe');
 }
开发者ID:nciftci,项目名称:plugins,代码行数:70,代码来源:calendar.php

示例4: key_import

 /**
  * Key import (page) handler
  */
 private function key_import()
 {
     // Import process
     if ($data = rcube_utils::get_input_value('_keys', rcube_utils::INPUT_POST)) {
         // Import from generation form (ajax request)
         $this->enigma->load_engine();
         $result = $this->enigma->engine->import_key($data);
         if (is_array($result)) {
             $this->rc->output->command('enigma_key_create_success');
             $this->rc->output->show_message('enigma.keygeneratesuccess', 'confirmation');
         } else {
             $this->rc->output->show_message('enigma.keysimportfailed', 'error');
         }
         $this->rc->output->send();
     } else {
         if ($_FILES['_file']['tmp_name'] && is_uploaded_file($_FILES['_file']['tmp_name'])) {
             $this->enigma->load_engine();
             $result = $this->enigma->engine->import_key($_FILES['_file']['tmp_name'], true);
             if (is_array($result)) {
                 // reload list if any keys has been added
                 if ($result['imported']) {
                     $this->rc->output->command('parent.enigma_list', 1);
                 } else {
                     $this->rc->output->command('parent.enigma_loadframe');
                 }
                 $this->rc->output->show_message('enigma.keysimportsuccess', 'confirmation', array('new' => $result['imported'], 'old' => $result['unchanged']));
                 $this->rc->output->send('iframe');
             } else {
                 $this->rc->output->show_message('enigma.keysimportfailed', 'error');
             }
         } else {
             if ($err = $_FILES['_file']['error']) {
                 if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                     $this->rc->output->show_message('filesizeerror', 'error', array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize')))));
                 } else {
                     $this->rc->output->show_message('fileuploaderror', 'error');
                 }
             }
         }
     }
     $this->rc->output->add_handlers(array('importform' => array($this, 'tpl_key_import_form')));
     $this->rc->output->set_pagetitle($this->enigma->gettext('keyimport'));
     $this->rc->output->send('enigma.keyimport');
 }
开发者ID:jgtoriginal,项目名称:roundcubemail,代码行数:47,代码来源:enigma_ui.php

示例5: upload_init

 /**
  * Initializes file uploading interface.
  */
 public function upload_init()
 {
     // Enable upload progress bar
     if (($seconds = $this->config->get('upload_progress')) && ini_get('apc.rfc1867')) {
         if ($field_name = ini_get('apc.rfc1867_name')) {
             $this->output->set_env('upload_progress_name', $field_name);
             $this->output->set_env('upload_progress_time', (int) $seconds);
         }
     }
     // find max filesize value
     $max_filesize = parse_bytes(ini_get('upload_max_filesize'));
     $max_postsize = parse_bytes(ini_get('post_max_size'));
     if ($max_postsize && $max_postsize < $max_filesize) {
         $max_filesize = $max_postsize;
     }
     $this->output->set_env('max_filesize', $max_filesize);
     $max_filesize = self::show_bytes($max_filesize);
     $this->output->set_env('filesizeerror', $this->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $max_filesize))));
     return $max_filesize;
 }
开发者ID:npk,项目名称:roundcubemail,代码行数:23,代码来源:rcmail.php

示例6: foreach

    <th width="120" align="center">操作</th>
  </tr>

<?php 
foreach ($fileRows as $row) {
    ?>
  <tr height="30">
    <td><a href="show.php?id=<?php 
    echo $row["id"];
    ?>
" target="_blank" title="点击查看缩略图"><?php 
    echo $row["file_name"];
    ?>
</a></td>
    <td width="100" align="center"><?php 
    echo parse_bytes($row["file_size"], 1024);
    ?>
</td>
    <td width="180" align="center"><?php 
    echo date("Y-m-d H:i:s", $row["created_at"]);
    ?>
</td>
    <td width="160" align="center">
      <a href="show.php?id=<?php 
    echo $row["id"];
    ?>
" target="_blank" title="点击查看缩略图">查看</a>
      <a href="wm_show.php?id=<?php 
    echo $row["id"];
    ?>
" title="点击进行水印设置">水印</a>
开发者ID:rwifeng,项目名称:php5.3-sdk-example,代码行数:31,代码来源:index.php

示例7: managesieve_save

 function managesieve_save()
 {
     // Init plugin and handle managesieve connection
     $error = $this->managesieve_start();
     // filters set add action
     if (!empty($_POST['_newset'])) {
         $name = get_input_value('_name', RCUBE_INPUT_POST);
         $copy = get_input_value('_copy', RCUBE_INPUT_POST);
         $from = get_input_value('_from', RCUBE_INPUT_POST);
         if (!$name) {
             $error = 'managesieve.emptyname';
         } else {
             if (mb_strlen($name) > 128) {
                 $error = 'managesieve.nametoolong';
             } else {
                 if ($from == 'file') {
                     // from file
                     if (is_uploaded_file($_FILES['_file']['tmp_name'])) {
                         $file = file_get_contents($_FILES['_file']['tmp_name']);
                         $file = preg_replace('/\\r/', '', $file);
                         // for security don't save script directly
                         // check syntax before, like this...
                         $this->sieve->load_script($file);
                         if (!$this->sieve->save($name)) {
                             $error = 'managesieve.setcreateerror';
                         }
                     } else {
                         // upload failed
                         $err = $_FILES['_file']['error'];
                         $error = true;
                         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                             $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
                         } else {
                             $error = 'fileuploaderror';
                         }
                     }
                 } else {
                     if (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) {
                         $error = 'managesieve.setcreateerror';
                     }
                 }
             }
         }
         if (!$error) {
             $this->rc->output->show_message('managesieve.setcreated', 'confirmation');
             $this->rc->output->command('parent.managesieve_reload', $name);
         } else {
             if ($msg) {
                 $this->rc->output->command('display_message', $msg, 'error');
             } else {
                 $this->rc->output->show_message($error, 'error');
             }
         }
     } else {
         if (isset($_POST['_name'])) {
             $name = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
             $fid = trim(get_input_value('_fid', RCUBE_INPUT_POST));
             $join = trim(get_input_value('_join', RCUBE_INPUT_POST));
             // and arrays
             $headers = $_POST['_header'];
             $cust_headers = $_POST['_custom_header'];
             $ops = $_POST['_rule_op'];
             $sizeops = $_POST['_rule_size_op'];
             $sizeitems = $_POST['_rule_size_item'];
             $sizetargets = $_POST['_rule_size_target'];
             $targets = $_POST['_rule_target'];
             $act_types = $_POST['_action_type'];
             $mailboxes = $_POST['_action_mailbox'];
             $act_targets = $_POST['_action_target'];
             $area_targets = $_POST['_action_target_area'];
             $reasons = $_POST['_action_reason'];
             $addresses = $_POST['_action_addresses'];
             $days = $_POST['_action_days'];
             // we need a "hack" for radiobuttons
             foreach ($sizeitems as $item) {
                 $items[] = $item;
             }
             $this->form['disabled'] = $_POST['_disabled'] ? true : false;
             $this->form['join'] = $join == 'allof' ? true : false;
             $this->form['name'] = $name;
             $this->form['tests'] = array();
             $this->form['actions'] = array();
             if ($name == '') {
                 $this->errors['name'] = $this->gettext('cannotbeempty');
             } else {
                 foreach ($this->script as $idx => $rule) {
                     if ($rule['name'] == $name && $idx != $fid) {
                         $this->errors['name'] = $this->gettext('ruleexist');
                         break;
                     }
                 }
             }
             $i = 0;
             // rules
             if ($join == 'any') {
                 $this->form['tests'][0]['test'] = 'true';
             } else {
                 foreach ($headers as $idx => $header) {
                     $header = $this->strip_value($header);
                     $target = $this->strip_value($targets[$idx], true);
//.........这里部分代码省略.........
开发者ID:shishenkov,项目名称:zpanel,代码行数:101,代码来源:managesieve.php

示例8: mem_check

 /**
  * Check if we can process not exceeding memory_limit
  *
  * @param integer Required amount of memory
  *
  * @return boolean True if memory won't be exceeded, False otherwise
  */
 public static function mem_check($need)
 {
     $mem_limit = parse_bytes(ini_get('memory_limit'));
     $memory = function_exists('memory_get_usage') ? memory_get_usage() : 16 * 1024 * 1024;
     // safe value: 16MB
     return $mem_limit > 0 && $memory + $need > $mem_limit ? false : true;
 }
开发者ID:rockchow2002,项目名称:roundcubemail,代码行数:14,代码来源:rcube_utils.php

示例9: parse_bytes

<h4>
  <a href="index.php">返回列表</a>
  <a href="upload.php">上传照片</a>
  <a href="logout.php">注销退出</a>
</h4>

<?php 
if ($base_url) {
    ?>

<p>文件名:<?php 
    echo $fileRow["file_name"];
    ?>
</p>
<p>文件大小:<?php 
    echo parse_bytes($fileRow["file_size"]);
    ?>
</p>
<p>上传时间:<?php 
    echo date("Y-m-d H:i:s", $fileRow["created_at"]);
    ?>
</p>
<p>
  <a href="download.php?id=<?php 
    echo $fileRow["id"];
    ?>
" title="点击下载原始尺图片">下载</a>
  <a href="delete.php?id=<?php 
    echo $fileRow["id"];
    ?>
" title="点击将该图片删除">删除</a>
开发者ID:ershiersan,项目名称:php5.3-sdk-example,代码行数:31,代码来源:show.php

示例10: managesieve_save

 function managesieve_save()
 {
     // load localization
     $this->add_texts('localization/', array('filters', 'managefilters'));
     // include main js script
     if ($this->api->output->type == 'html') {
         $this->include_script('managesieve.js');
     }
     // Init plugin and handle managesieve connection
     $error = $this->managesieve_start();
     // filters set add action
     if (!empty($_POST['_newset'])) {
         $name = get_input_value('_name', RCUBE_INPUT_POST, true);
         $copy = get_input_value('_copy', RCUBE_INPUT_POST, true);
         $from = get_input_value('_from', RCUBE_INPUT_POST);
         $exceptions = $this->rc->config->get('managesieve_filename_exceptions');
         $kolab = $this->rc->config->get('managesieve_kolab_master');
         $name_uc = mb_strtolower($name);
         $list = $this->list_scripts();
         if (!$name) {
             $this->errors['name'] = $this->gettext('cannotbeempty');
         } else {
             if (mb_strlen($name) > 128) {
                 $this->errors['name'] = $this->gettext('nametoolong');
             } else {
                 if (!empty($exceptions) && in_array($name, (array) $exceptions)) {
                     $this->errors['name'] = $this->gettext('namereserved');
                 } else {
                     if (!empty($kolab) && in_array($name_uc, array('MASTER', 'USER', 'MANAGEMENT'))) {
                         $this->errors['name'] = $this->gettext('namereserved');
                     } else {
                         if (in_array($name, $list)) {
                             $this->errors['name'] = $this->gettext('setexist');
                         } else {
                             if ($from == 'file') {
                                 // from file
                                 if (is_uploaded_file($_FILES['_file']['tmp_name'])) {
                                     $file = file_get_contents($_FILES['_file']['tmp_name']);
                                     $file = preg_replace('/\\r/', '', $file);
                                     // for security don't save script directly
                                     // check syntax before, like this...
                                     $this->sieve->load_script($file);
                                     if (!$this->save_script($name)) {
                                         $this->errors['file'] = $this->gettext('setcreateerror');
                                     }
                                 } else {
                                     // upload failed
                                     $err = $_FILES['_file']['error'];
                                     if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                                         $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
                                     } else {
                                         $this->errors['file'] = $this->gettext('fileuploaderror');
                                     }
                                 }
                             } else {
                                 if (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) {
                                     $error = 'managesieve.setcreateerror';
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (!$error && empty($this->errors)) {
             // Find position of the new script on the list
             $list[] = $name;
             asort($list, SORT_LOCALE_STRING);
             $list = array_values($list);
             $index = array_search($name, $list);
             $this->rc->output->show_message('managesieve.setcreated', 'confirmation');
             $this->rc->output->command('parent.managesieve_updatelist', 'setadd', array('name' => $name, 'index' => $index));
         } else {
             if ($msg) {
                 $this->rc->output->command('display_message', $msg, 'error');
             } else {
                 if ($error) {
                     $this->rc->output->show_message($error, 'error');
                 }
             }
         }
     } else {
         if (isset($_POST['_name'])) {
             $name = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
             $fid = trim(get_input_value('_fid', RCUBE_INPUT_POST));
             $join = trim(get_input_value('_join', RCUBE_INPUT_POST));
             // and arrays
             $headers = get_input_value('_header', RCUBE_INPUT_POST);
             $cust_headers = get_input_value('_custom_header', RCUBE_INPUT_POST);
             $ops = get_input_value('_rule_op', RCUBE_INPUT_POST);
             $sizeops = get_input_value('_rule_size_op', RCUBE_INPUT_POST);
             $sizeitems = get_input_value('_rule_size_item', RCUBE_INPUT_POST);
             $sizetargets = get_input_value('_rule_size_target', RCUBE_INPUT_POST);
             $targets = get_input_value('_rule_target', RCUBE_INPUT_POST, true);
             $mods = get_input_value('_rule_mod', RCUBE_INPUT_POST);
             $mod_types = get_input_value('_rule_mod_type', RCUBE_INPUT_POST);
             $body_trans = get_input_value('_rule_trans', RCUBE_INPUT_POST);
             $body_types = get_input_value('_rule_trans_type', RCUBE_INPUT_POST, true);
             $comparators = get_input_value('_rule_comp', RCUBE_INPUT_POST);
             $act_types = get_input_value('_action_type', RCUBE_INPUT_POST, true);
//.........这里部分代码省略.........
开发者ID:npk,项目名称:roundcubemail,代码行数:101,代码来源:managesieve.php

示例11: import_events

 /**
  *
  */
 function import_events($silent = false)
 {
     // Upload progress update
     if (!empty($_GET['_progress'])) {
         rcube_upload_progress();
     }
     @set_time_limit(0);
     // process uploaded file if there is no error
     $err = $_FILES['_data']['error'];
     if (!$err && $_FILES['_data']['tmp_name']) {
         $calendar = get_input_value('calendar', RCUBE_INPUT_GPC);
         $driver = $this->get_driver_by_cal($calendar);
         $rangestart = $_REQUEST['_range'] ? date_create("now -" . intval($_REQUEST['_range']) . " months") : 0;
         $user_email = $this->rc->user->get_username();
         $ical = $this->get_ical();
         $errors = !$ical->fopen($_FILES['_data']['tmp_name']);
         $count = $i = 0;
         foreach ($ical as $event) {
             if (isset($event['recurrence']['EXCEPTIONS'])) {
                 foreach ($event['recurrence']['EXCEPTIONS'] as $idx => $exception) {
                     $event['recurrence']['EXCEPTIONS'][$idx]['uid'] = $event['uid'];
                 }
             }
             // End mod by Rosali
             // keep the browser connection alive on long import jobs
             if (++$i > 100 && $i % 100 == 0) {
                 echo "<!-- -->";
                 ob_flush();
             }
             // TODO: correctly handle recurring events which start before $rangestart
             if ($event['end'] && $event['end'] < $rangestart && (!$event['recurrence'] || $event['recurrence']['until'] && $event['recurrence']['until'] < $rangestart)) {
                 continue;
             }
             $event['_owner'] = $user_email;
             $event['calendar'] = $calendar;
             if ($driver->new_event($event)) {
                 $count++;
             } else {
                 $errors++;
             }
         }
         // Begin mod by Rosali
         if ($silent) {
             return;
         }
         // End mod by Rosali
         if ($count) {
             $this->rc->output->command('display_message', $this->gettext(array('name' => 'importsuccess', 'vars' => array('nr' => $count))), 'confirmation');
             $this->rc->output->command('plugin.import_success', array('source' => $calendar, 'refetch' => true));
         } else {
             if (!$errors) {
                 $this->rc->output->command('display_message', $this->gettext('importnone'), 'notice');
                 $this->rc->output->command('plugin.import_success', array('source' => $calendar));
             } else {
                 $this->rc->output->command('plugin.import_error', array('message' => $this->gettext('importerror') . ($msg ? ': ' . $msg : '')));
             }
         }
     } else {
         if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
             $msg = rcube_label(array('name' => 'filesizeerror', 'vars' => array('size' => show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
         } else {
             $msg = rcube_label('fileuploaderror');
         }
         $this->rc->output->command('plugin.import_error', array('message' => $msg));
         $this->rc->output->command('plugin.unlock_saving', false);
     }
     $this->rc->output->send('iframe');
 }
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:71,代码来源:calendar.php

示例12: max_upload_size

 /**
  * Get maximum upload size
  *
  * @return int Maximum size in bytes
  */
 public static function max_upload_size()
 {
     // find max filesize value
     $max_filesize = parse_bytes(ini_get('upload_max_filesize'));
     $max_postsize = parse_bytes(ini_get('post_max_size'));
     if ($max_postsize && $max_postsize < $max_filesize) {
         $max_filesize = $max_postsize;
     }
     return $max_filesize;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:15,代码来源:rcube_utils.php

示例13: export

 /**
  * Export events to iCalendar format
  *
  * @param  array   Events as array
  * @param  string  VCalendar method to advertise
  * @param  boolean Directly send data to stdout instead of returning
  * @param  callable Callback function to fetch attachment contents, false if no attachment export
  * @return string  Events in iCalendar format (http://tools.ietf.org/html/rfc5545)
  */
 public function export($objects, $method = null, $write = false, $get_attachment = false, $recurrence_id = null)
 {
     $memory_limit = parse_bytes(ini_get('memory_limit'));
     $this->method = $method;
     // encapsulate in VCALENDAR container
     $vcal = VObject\Component::create('VCALENDAR');
     $vcal->version = '2.0';
     $vcal->prodid = $this->prodid;
     $vcal->calscale = 'GREGORIAN';
     if (!empty($method)) {
         $vcal->METHOD = $method;
     }
     // TODO: include timezone information
     // write vcalendar header
     if ($write) {
         echo preg_replace('/END:VCALENDAR[\\r\\n]*$/m', '', $vcal->serialize());
     }
     foreach ($objects as $object) {
         $this->_to_ical($object, !$write ? $vcal : false, $get_attachment);
     }
     if ($write) {
         echo "END:VCALENDAR\r\n";
         return true;
     } else {
         return $vcal->serialize();
     }
 }
开发者ID:haision,项目名称:myroundcube,代码行数:36,代码来源:libvcalendar.php

示例14: vcard_convert

 |                                                                       |
 +-----------------------------------------------------------------------+
 | Author: Thomas Bruederli <thomas@brotherli.ch>                        |
 +-----------------------------------------------------------------------+
*/
// suppress php notices
@ini_set('error_reporting', E_ALL & ~E_NOTICE);
// include the converter class file
require_once 'vcard_convert.php';
require_once 'utils.php';
if (!empty($_FILES['_vcards'])) {
    // instantiate a parser object
    $conv = new vcard_convert(array('mailonly' => !empty($_POST['_mailonly']), 'phoneonly' => !empty($_POST['_phoneonly']), 'accesscode' => preg_replace('/[^1-9]/', '', $_POST['_accesscode'])));
    // check for errors
    if ($err = $_FILES['_vcards']['error']) {
        $GLOBALS['error_msg'] = $err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE ? "The uploaded file was too big! Maximum file size allowed: " . show_bytes(parse_bytes(ini_get('upload_max_filesize'))) : "Upload failed, please try again";
    } else {
        if ($conv->fromFile($_FILES['_vcards']['tmp_name'])) {
            $ext = $_POST['_format'] == 'gmail' ? 'csv' : ($_POST['_format'] == 'img' ? 'zip' : $_POST['_format']);
            $fname = asciiwords(preg_replace('/\\.[a-z]+$/i', '', $_FILES['_vcards']['name']));
            header(sprintf('Content-Type: text/%s', $ext));
            header(sprintf('Content-Disposition: attachment; filename="%s.%s"', $fname, $ext));
            if ($_POST['_format'] == 'ldif') {
                print $conv->toLdif();
                exit;
            } else {
                if ($_POST['_format'] == 'ldap') {
                    // Clean the input dn modifier from dangerous chars
                    $dnID = substr(preg_replace('/[^\\da-z=,_ -]/i', '', $_POST['_dn']), 0, 255);
                    print $conv->toLdif($dnID ? $dnID : "", null, $_POST['_encoding']);
                    exit;
开发者ID:golfgaga,项目名称:vcfconvert,代码行数:31,代码来源:index.php

示例15: save

 function save()
 {
     // Init plugin and handle managesieve connection
     $error = $this->start();
     // get request size limits (#1488648)
     $max_post = max(array(ini_get('max_input_vars'), ini_get('suhosin.request.max_vars'), ini_get('suhosin.post.max_vars')));
     $max_depth = max(array(ini_get('suhosin.request.max_array_depth'), ini_get('suhosin.post.max_array_depth')));
     // check request size limit
     if ($max_post && count($_POST, COUNT_RECURSIVE) >= $max_post) {
         rcube::raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Request size limit exceeded (one of max_input_vars/suhosin.request.max_vars/suhosin.post.max_vars)"), true, false);
         $this->rc->output->show_message('managesieve.filtersaveerror', 'error');
     } else {
         if ($max_depth && count($_POST['_header']) > $max_depth) {
             rcube::raise_error(array('code' => 500, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Request size limit exceeded (one of suhosin.request.max_array_depth/suhosin.post.max_array_depth)"), true, false);
             $this->rc->output->show_message('managesieve.filtersaveerror', 'error');
         } else {
             if (!empty($_POST['_newset'])) {
                 $name = rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true);
                 $copy = rcube_utils::get_input_value('_copy', rcube_utils::INPUT_POST, true);
                 $from = rcube_utils::get_input_value('_from', rcube_utils::INPUT_POST);
                 $exceptions = $this->rc->config->get('managesieve_filename_exceptions');
                 $kolab = $this->rc->config->get('managesieve_kolab_master');
                 $name_uc = mb_strtolower($name);
                 $list = $this->list_scripts();
                 if (!$name) {
                     $this->errors['name'] = $this->plugin->gettext('cannotbeempty');
                 } else {
                     if (mb_strlen($name) > 128) {
                         $this->errors['name'] = $this->plugin->gettext('nametoolong');
                     } else {
                         if (!empty($exceptions) && in_array($name, (array) $exceptions)) {
                             $this->errors['name'] = $this->plugin->gettext('namereserved');
                         } else {
                             if (!empty($kolab) && in_array($name_uc, array('MASTER', 'USER', 'MANAGEMENT'))) {
                                 $this->errors['name'] = $this->plugin->gettext('namereserved');
                             } else {
                                 if (in_array($name, $list)) {
                                     $this->errors['name'] = $this->plugin->gettext('setexist');
                                 } else {
                                     if ($from == 'file') {
                                         // from file
                                         if (is_uploaded_file($_FILES['_file']['tmp_name'])) {
                                             $file = file_get_contents($_FILES['_file']['tmp_name']);
                                             $file = preg_replace('/\\r/', '', $file);
                                             // for security don't save script directly
                                             // check syntax before, like this...
                                             $this->sieve->load_script($file);
                                             if (!$this->save_script($name)) {
                                                 $this->errors['file'] = $this->plugin->gettext('setcreateerror');
                                             }
                                         } else {
                                             // upload failed
                                             $err = $_FILES['_file']['error'];
                                             if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
                                                 $msg = $this->rc->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $this->rc->show_bytes(parse_bytes(ini_get('upload_max_filesize'))))));
                                             } else {
                                                 $this->errors['file'] = $this->plugin->gettext('fileuploaderror');
                                             }
                                         }
                                     } else {
                                         if (!$this->sieve->copy($name, $from == 'set' ? $copy : '')) {
                                             $error = 'managesieve.setcreateerror';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
                 if (!$error && empty($this->errors)) {
                     // Find position of the new script on the list
                     $list[] = $name;
                     asort($list, SORT_LOCALE_STRING);
                     $list = array_values($list);
                     $index = array_search($name, $list);
                     $this->rc->output->show_message('managesieve.setcreated', 'confirmation');
                     $this->rc->output->command('parent.managesieve_updatelist', 'setadd', array('name' => $name, 'index' => $index));
                 } else {
                     if ($msg) {
                         $this->rc->output->command('display_message', $msg, 'error');
                     } else {
                         if ($error) {
                             $this->rc->output->show_message($error, 'error');
                         }
                     }
                 }
             } else {
                 if (isset($_POST['_name'])) {
                     $name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true));
                     $fid = trim(rcube_utils::get_input_value('_fid', rcube_utils::INPUT_POST));
                     $join = trim(rcube_utils::get_input_value('_join', rcube_utils::INPUT_POST));
                     // and arrays
                     $headers = rcube_utils::get_input_value('_header', rcube_utils::INPUT_POST);
                     $cust_headers = rcube_utils::get_input_value('_custom_header', rcube_utils::INPUT_POST);
                     $ops = rcube_utils::get_input_value('_rule_op', rcube_utils::INPUT_POST);
                     $sizeops = rcube_utils::get_input_value('_rule_size_op', rcube_utils::INPUT_POST);
                     $sizeitems = rcube_utils::get_input_value('_rule_size_item', rcube_utils::INPUT_POST);
                     $sizetargets = rcube_utils::get_input_value('_rule_size_target', rcube_utils::INPUT_POST);
                     $targets = rcube_utils::get_input_value('_rule_target', rcube_utils::INPUT_POST, true);
                     $mods = rcube_utils::get_input_value('_rule_mod', rcube_utils::INPUT_POST);
//.........这里部分代码省略.........
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:101,代码来源:rcube_sieve_engine.php


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