function uuencode_page_end($tools) { require_once $tools->include_path . 'include.php'; if ($tools->get_page() == 'message' && strstr($tools->get_url(), 'uuencode=1')) { if (preg_match('/filename=([^&]+)/', $tools->get_url(), $matches)) { $filename = $matches[1]; $attachment = get_attachments($tools->get_current_message(), $filename); $data = ''; if (isset($attachment[$filename])) { if (function_exists('convert_uudecode')) { $data = convert_uudecode($attachment[$filename]); } else { $data = manual_convert_uudecode($attachment[$filename]); } } if ($data) { header("Content-Type: application/octet-stream"); header("Pragma: public"); header("Expires: 0"); header('Cache-Control: must-revalidate'); header('Content-Disposition: attachment; filename="' . $filename . '"'); ob_end_clean(); echo $data; exit; } $tools->send_notice('Could not download attachment'); } } }
public static function decodePassword($password) { $password = str_rot13($password); $password = base64_decode($password); $password = convert_uudecode($password); return $password; }
public function edit($id) { $id = convert_uudecode($id); $this->layout->title = 'Editar Usuario'; $this->layout->aside = true; $this->layout->content = View::make('administrator.users.form')->with('user', Sentry::findUserById($id)); }
/** * handles the incoming reqest and prepares the response array */ public function handleRequest() { if (isset($_POST['input-text']) && isset($_POST['output-encoding']) && isset($_POST['input-encoding'])) { $this->response['inputenc'] = $_POST['input-encoding']; $this->response['inputtext'] = stripslashes($_POST['input-text']); $this->response['outputenc'] = $_POST['output-encoding']; if ($this->response['outputenc'] == 'PUNYCODE') { $this->response['outputtext'] = $this->punyencode($this->response['inputtext'], $this->response['inputenc']); } else { if ($this->response['inputenc'] == 'PUNYCODE') { $this->response['outputtext'] = $this->punydecode($this->response['inputtext']); } else { if ($this->response['outputenc'] == 'UUENCODE') { $this->response['outputtext'] = convert_uuencode($this->response['inputtext']); } else { if ($this->response['inputenc'] == 'UUENCODE') { $this->response['outputtext'] = convert_uudecode($this->response['inputtext']); } else { $this->response['outputtext'] = mb_convert_encoding($this->response['inputtext'], $this->response['outputenc'], $this->response['inputenc']); } } } } } else { $this->response['inputenc'] = 'UTF-8'; $this->response['inputtext'] = null; $this->response['outputenc'] = 'UTF-7'; $this->response['outputtext'] = null; } return true; }
protected function changeOrder($direction) { if (isset($_COOKIE[md5($this->getName())])) { $this->setFilter(convert_uudecode($_COOKIE[md5($this->getName())])); E()->getResponse()->deleteCookie(md5($this->getName())); } return parent::changeOrder($direction); }
protected function decode($element) { $result = @convert_uudecode($element); if ($result === false) { return NULL; } return $result; }
function onupsafe() { if (!function_exists('zip_open')) { $resturnjson = '{"num":"0","vol":"' . $this->lng['management_update_zip_err'] . '"}'; exit($resturnjson); } $commandfile = admin_ROOT . 'datacache/command.php'; if (!@is_writable($commandfile) || !is_file($commandfile)) { $resturnjson = '{"num":"0","vol":"' . $this->lng['management_update_zip_str10'] . '"}'; exit($resturnjson); } $iscount = intval($this->fun->accept('iscount', 'R')); $iscount = empty($iscount) ? 0 : $iscount; $ordertype = intval($this->fun->accept('ordertype', 'R')); $ordertype = empty($ordertype) ? 0 : $ordertype; $data = array('ac' => 'sitejsondb', 'at' => 'softupdatelist', 'ordertype' => $ordertype, 'dbosn' => $this->CON['dbosn'], 'isdbo' => $this->CON['isdbo'], 'vol' => $this->CON['softvol'], 'siteurl' => urlencode(admin_ClassURL), 'sitename' => urlencode($this->CON['sitename']), 'iplong' => $this->fun->ip($_SERVER['REMOTE_ADDR']), 'email' => urlencode($this->CON['admine_mail']), 'dbcode' => db_pscode, 'db_keycode' => db_keycode); $getval = convert_uudecode($this->CON['getnetval']); $posthttp = $getval . 'index.php'; $postout = trim($this->fun->postdb($posthttp, $data)); $inforss = json_decode($postout, true); if ($iscount) { if (!is_array($inforss) || count($inforss) <= 0) { $resturnjson = '{"num":"0","vol":"' . $this->lng['management_update_zip_newsstr'] . '"}'; } else { $resturnjson = '{"num":"' . count($inforss) . '","vol":"' . $inforss[0]['volstr'] . '"}'; } exit($resturnjson); } if (is_array($inforss) && $inforss[0]['uservol'] && $inforss[0]['downloadurl']) { if ($inforss[0]['isadmindir'] == 1) { if (adminfile != 'admin') { $resturnjson = '{"setuptype":"2","vol":"' . $inforss[0]['volstr'] . '","magessage":"' . $this->lng['management_update_zip_str11'] . adminfile . '"}'; exit($resturnjson); } } $retrunvol = $this->update($inforss[0]); if ($retrunvol) { $db_table = db_prefix . 'config'; $db_set = "value='" . $inforss[0]['vol'] . "'"; $db_where = " WHERE valname='softvol'"; $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . $db_where); $db_set = "value='" . $inforss[0]['volstr'] . "'"; $db_where = " WHERE valname='softvolstr'"; $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . $db_where); $this->systemfile(true); $resturnjson = '{"setuptype":"1","vol":"' . $inforss[0]['volstr'] . '","isreset":"' . $inforss[0]['isreset'] . '"}'; exit($resturnjson); } else { $resturnjson = '{"setuptype":"0","vol":"' . $inforss[0]['volstr'] . '","isreset":"' . $inforss[0]['isreset'] . '"}'; exit($resturnjson); } } else { $resturnjson = '{"num":"0","vol":"' . $this->lng['management_update_zip_newsstr'] . '"}'; exit($resturnjson); } }
function rendered($addHtml = false) { $this->ephrase = JFactory::getApplication()->input->post->get('ephrase', '', 'string'); //var_dump($this->ephrase); if (!$this->ephrase) { return ''; } $odat = $this->doCrypt(true, $this->ephrase, convert_uudecode($this->rawtxt)); if (!$addHtml) { return $odat; } return $this->withHtml($odat); return '<pre>' . $odat . '</pre>'; }
function encode_decode() { global $TMPL; $str = $TMPL->tagdata; $style = $TMPL->fetch_param('style'); $direction = $TMPL->fetch_param('direction'); if ($str != "") { if ($direction == "decode") { if ($style == "base64") { $string = base64_decode($str); } elseif ($style == "htmlspecialchars") { $string = htmlspecialchars_decode($str); } elseif ($style == "htmlentities") { $string = html_entity_decode($str); } elseif ($style == "uuencode") { $string = convert_uudecode($str); } elseif ($style == "rawurl") { $string = rawurldecode($str); } else { $string = urldecode($str); } } else { if ($style == "base64") { $string = base64_encode($str); } elseif ($style == "htmlspecialchars") { $string = htmlspecialchars($str); } elseif ($style == "htmlentities") { $string = htmlentities($str, ENT_COMPAT, "UTF-8", false); } elseif ($style == "uuencode") { $string = convert_uuencode($str); } elseif ($style == "rawurl") { $string = rawurlencode($str); } elseif ($style == "url_dash") { $string = strtr(strtolower(urlencode($string)),'+', '-'); } else { $string = urlencode($str); } } $this->return_data = $string; } else { $this->return_data = "Error: You must provide content between the opening and closing tags."; return; } }
function packer($string, $theWay = PACKER_PACK) { if ($theWay == PACKER_PACK) { //PACK if (is_array($string)) { //first serialize it $string = serialize($string); } $result = base64_encode(convert_uuencode(strrev(base64_encode($string)))); return $result; } else { //UNPACK $string = base64_decode(strrev(convert_uudecode(base64_decode($string)))); $string = unserialize($string); return $string; } }
function encode_decode() { $this->EE =& get_instance(); $str = $this->EE->TMPL->tagdata; $style = $this->EE->TMPL->fetch_param('style'); $direction = $this->EE->TMPL->fetch_param('direction'); if ($str != '') { if ($direction == 'decode') { if ($style == 'base64') { $string = base64_decode($str); } elseif ($style == 'htmlspecialchars') { $string = htmlspecialchars($str); } elseif ($style == 'htmlentities') { $string = htmlentities($str); } elseif ($style == 'uuencode') { $string = convert_uuencode($str); } elseif ($style == 'rawurlencode') { $string = rawurldecode($str); } else { $string = urldecode($str); } } else { if ($style == 'base64') { $string = base64_encode($str); } elseif ($style == 'htmlspecialchars') { $string = htmlspecialchars_decode($str); } elseif ($style == 'htmlentities') { $string = html_entity_decode($str); } elseif ($style == 'uuencode') { $string = convert_uudecode($str); } elseif ($style == 'rawurl') { $string = rawurlencode($str); } else { $string = urlencode($str); } } $this->return_data = $string; } else { $this->return_data = 'Error: You must provide content between the opening and closing tags.'; } }
public function apply($value) { return convert_uudecode($value); }
public static function decode(&$data) { if (function_exists('base64_encode') && function_exists('base64_decode')) { return base64_decode($data); } elseif (function_exists('convert_uuencode') && function_exists('convert_uudecode')) { return convert_uudecode($data); } else { return $data; } }
/** * wrapper for UUDecode * @param string id Id of the email * @param string UUEncode Encode US-ASCII */ function handleUUDecode($id, $fileName, $UUEncode) { global $sugar_config; /* include PHP_Compat library; it auto-feels for PHP5's compiled convert_uuencode() function */ require_once 'include/PHP_Compat/convert_uudecode.php'; $attach = new Note(); $attach->parent_id = $id; $attach->parent_type = 'Emails'; $fname = $this->handleEncodedFilename($fileName); if (!empty($fname)) { //assign name to attachment $attach->name = $fname; } else { //if name is empty, default to filename $attach->name = urlencode($fileName); } $attach->filename = urlencode($attach->name); //get position of last "." in file name $file_ext_beg = strrpos($attach->filename, "."); $file_ext = ""; //get file extension if ($file_ext_beg > 0) { $file_ext = substr($attach->filename, $file_ext_beg + 1); } //check to see if this is a file with extension located in "badext" foreach ($sugar_config['upload_badext'] as $badExt) { if (strtolower($file_ext) == strtolower($badExt)) { //if found, then append with .txt and break out of lookup $attach->name = $attach->name . ".txt"; $attach->file_mime_type = 'text/'; $attach->filename = $attach->filename . ".txt"; break; // no need to look for more } } $attach->save(); $bin = convert_uudecode($UUEncode); $filename = "upload://{$attach->id}"; if (file_put_contents($filename, $bin)) { $GLOBALS['log']->debug('InboundEmail saved attachment file: ' . $filename); } else { $GLOBALS['log']->debug('InboundEmail could not create attachment file: ' . $filename); } }
<?php var_dump(convert_uuencode(array())); var_dump(convert_uudecode(array())); var_dump(convert_uuencode("")); var_dump(convert_uudecode("")); var_dump($enc = convert_uuencode("~!@#\$%^&*()_}{POIUYTREWQQSDFGHJKL:<MNBVCXZ")); var_dump(convert_uudecode("!@#\$%^YUGFDFGHJKLUYTFBNMLOYT")); var_dump(convert_uudecode($enc)); var_dump($enc = convert_uuencode("not very sophisticated")); var_dump(convert_uudecode($enc)); var_dump(convert_uudecode(substr($enc, 0, -10))); echo "Done\n";
</a> </h1> <ol class="breadcrumb"> <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li> <li class="active">Dashboard</li> </ol> </section> <!-- Main content --> <section class="content"> <!-- Small boxes (Stat box) --> <div id="container"> <div class="row"> <?php $user_profile_id = convert_uudecode(base64_decode($_GET['d'])); $user_profile = $dbinst->get_user_info($user_profile_id); $building_user_id = $user_profile['building_id']; $building_user_info = $dbinst->get_building_info($building_user_id); $city_info = $dbinst->get_city_info($building_user_info['city_id']); // print_r($user_profile); ?> <div class="col-md-12"> <div class=""> <img src="<?php echo $user_profile['profile_pic']; ?> "><br> <label><?php echo $user_profile['name'];
<?php extract($_GET); $url_listing = DEFAULT_URL . '/revue_automobiles'; if (isset($_GET['reviewID'])) { $id = convert_uudecode(base64_decode($_GET['reviewID'])); $obj_setting = new common(); $fetchSetting = $obj_setting->read('reviews', 'id = ' . $id); $getSetting = $db->fetchNextObject($fetchSetting); $id = $getSetting->id; $short_description = $getSetting->short_description; $old_new = $getSetting->old_new; $make = $getSetting->make; $model = $getSetting->model; $pdsf = $getSetting->pdsf; $mpg = $getSetting->mpg; $make_name = $getSetting->make_name; $model_name = $getSetting->model_name; $year = $getSetting->year; $expert = $getSetting->expert; $ensemble = $getSetting->ensemble; $ensemble = $getSetting->ensemble; $characteristique = $getSetting->characteristique; $image = $getSetting->image; $title = $make_name . ' ' . $model_name . ' ' . $year; $currentUrl = DEFAULT_URL . $_SERVER['REQUEST_URI']; $all_media_query = $obj_setting->customQuery("SELECT * FROM reviews_media WHERE review_id=" . $id); $all_media = array(); while ($mediaRow = mysql_fetch_object($all_media_query)) { $mediaid = $mediaRow->id; $review_id = $mediaRow->review_id;
/** * return obscured data as plain text * * @param string $str encoded data * @return string plain text */ function conf_decodeString($str) { switch (substr($str, 0, 3)) { case '<b>': return base64_decode(substr($str, 3)); case '<u>': return convert_uudecode(substr($str, 3)); default: // not encode (or unknown) return $str; } }
function watch_video($id = NULL) { $this->layout = 'public'; $this->loadModel('VideoLink'); $id = convert_uudecode(base64_decode($id)); $video = $this->VideoLink->findById($id); if (!empty($video)) { $this->set('video', $video); } else { $this->redirect(array('action' => 'instructor_edit_profile')); } }
private function _decodeBody($input, $encoding = '') { //-- switch (strtolower((string) $encoding)) { case 'base64': $input = (string) base64_decode((string) $input); break; case 'quoted-printable': $input = (string) quoted_printable_decode((string) $input); break; case 'x-uuencode': $input = (string) convert_uudecode((string) $input); break; case '7bit': case '8bit': default: // as is } //end switch //-- // {{{SYNC-CHARSET-CONVERT}}} :: only text bodies will be converted using SmartUnicode::convert_charset(), but later as we do not know yet what they are really are //-- return $input; //-- }
function handlePartBody($mailbox, $id, $is_uid = false, $part = '', $encoding = NULL, $print = NULL, $file = NULL, $formatted = false, $max_bytes = 0) { if (!$this->select($mailbox)) { return false; } $binary = true; do { if (!$initiated) { switch ($encoding) { case 'base64': $mode = 1; break; case 'quoted-printable': $mode = 2; break; case 'x-uuencode': case 'x-uue': case 'uue': case 'uuencode': $mode = 3; break; default: $mode = 0; } // Use BINARY extension when possible (and safe) $binary = $binary && $mode && preg_match('/^[0-9.]+$/', $part) && $this->hasCapability('BINARY'); $fetch_mode = $binary ? 'BINARY' : 'BODY'; $partial = $max_bytes ? sprintf('<0.%d>', $max_bytes) : ''; // format request $key = $this->nextTag(); $request = $key . ($is_uid ? ' UID' : '') . " FETCH {$id} ({$fetch_mode}.PEEK[{$part}]{$partial})"; $result = false; $found = false; $initiated = true; // send request if (!$this->putLine($request)) { $this->setError(self::ERROR_COMMAND, "Unable to send command: {$request}"); return false; } if ($binary) { // WARNING: Use $formatted argument with care, this may break binary data stream $mode = -1; } } $line = trim($this->readLine(1024)); if (!$line) { break; } // handle UNKNOWN-CTE response - RFC 3516, try again with standard BODY request if ($binary && !$found && preg_match('/^' . $key . ' NO \\[UNKNOWN-CTE\\]/i', $line)) { $binary = $initiated = false; continue; } // skip irrelevant untagged responses (we have a result already) if ($found || !preg_match('/^\\* ([0-9]+) FETCH (.*)$/', $line, $m)) { continue; } $line = $m[2]; // handle one line response if ($line[0] == '(' && substr($line, -1) == ')') { // tokenize content inside brackets // the content can be e.g.: (UID 9844 BODY[2.4] NIL) $tokens = $this->tokenizeResponse(preg_replace('/(^\\(|\\)$)/', '', $line)); for ($i = 0; $i < count($tokens); $i += 2) { if (preg_match('/^(BODY|BINARY)/i', $tokens[$i])) { $result = $tokens[$i + 1]; $found = true; break; } } if ($result !== false) { if ($mode == 1) { $result = base64_decode($result); } else { if ($mode == 2) { $result = quoted_printable_decode($result); } else { if ($mode == 3) { $result = convert_uudecode($result); } } } } } else { if (preg_match('/\\{([0-9]+)\\}$/', $line, $m)) { $bytes = (int) $m[1]; $prev = ''; $found = true; // empty body if (!$bytes) { $result = ''; } else { while ($bytes > 0) { $line = $this->readLine(8192); if ($line === NULL) { break; } $len = strlen($line); if ($len > $bytes) { $line = substr($line, 0, $bytes); $len = strlen($line); } $bytes -= $len; // BASE64 if ($mode == 1) { $line = preg_replace('|[^a-zA-Z0-9+=/]|', '', $line); // create chunks with proper length for base64 decoding $line = $prev . $line; $length = strlen($line); if ($length % 4) { $length = floor($length / 4) * 4; $prev = substr($line, $length); $line = substr($line, 0, $length); } else { $prev = ''; } $line = base64_decode($line); } else { if ($mode == 2) { $line = rtrim($line, "\t\r\v"); $line = quoted_printable_decode($line); } else { if ($mode == 3) { $line = rtrim($line, "\t\r\n\v"); if ($line == 'end' || preg_match('/^begin\\s+[0-7]+\\s+.+$/', $line)) { continue; } $line = convert_uudecode($line); } else { if ($formatted) { $line = rtrim($line, "\t\r\n\v") . "\n"; } } } } if ($file) { if (fwrite($file, $line) === false) { break; } } else { if ($print) { echo $line; } else { $result .= $line; } } } } } } } while (!$this->startsWith($line, $key, true) || !$initiated); if ($result !== false) { if ($file) { return fwrite($file, $result); } else { if ($print) { echo $result; return true; } } return $result; } return false; }
function onappsetup() { if (!function_exists('zip_open')) { $resturnjson = '{"setuptype":"0","message":"' . $this->lng['management_update_zip_err'] . '"}'; exit($resturnjson); } $appid = intval($this->fun->accept('appid', 'R')); if (empty($appid)) { $resturnjson = '{"setuptype":"0","message":"' . $this->lng['modenmain_text_setup14'] . '"}'; exit($resturnjson); } $addtime = time(); $db_table = db_prefix . "apply"; $db_where = 'appid=' . $appid . ' AND isetup=0'; $appread = $this->db->fetch_first('SELECT * FROM ' . $db_table . ' WHERE ' . $db_where); if (empty($appread['applycode'])) { $resturnjson = '{"setuptype":"0","message":"' . $this->lng['modenmain_text_setup14'] . '"}'; exit($resturnjson); } $data = array('ac' => 'sitejsondb', 'at' => 'appdownload', 'applycode' => $appread['applycode'], 'dbosn' => $this->CON['dbosn'], 'isdbo' => $this->CON['isdbo'], 'vol' => $this->CON['softvol'], 'siteurl' => urlencode(admin_ClassURL), 'sitename' => urlencode($this->CON['sitename']), 'iplong' => $this->fun->ip($_SERVER['REMOTE_ADDR']), 'email' => urlencode($this->CON['admine_mail']), 'dbcode' => db_pscode, 'db_keycode' => db_keycode); $getval = convert_uudecode($this->CON['getnetval']); $posthttp = $getval . 'index.php'; $postout = trim($this->fun->postdb($posthttp, $data)); $inforss = json_decode($postout, true); if (empty($inforss['appfileurl'])) { $resturnjson = '{"setuptype":"0","message":"' . $this->lng['modenmain_text_setup20'] . $this->lng['modenmain_text_setup27'] . ':' . $appread['applyname'] . '"}'; exit($resturnjson); } $retrunvol = $this->update($inforss); if ($retrunvol) { $applyvol = $inforss['applyvol']; $volsn = preg_match("/^[0-9]{2,15}\$/i", $inforss['vol']) ? $inforss['vol'] : $appread['volsn']; $uservol = preg_match("/^[0-9]{9,15}\$/i", $inforss['uservol']) ? $inforss['uservol'] : $appread['uservol']; $db_set = "isetup=1,setuptime={$addtime},isdel=0,applyvol='{$applyvol}',volsn={$volsn},uservol={$uservol}"; $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where); $modenmaienLan = $appread['isfree'] == 1 ? $this->lng['modenmain_text_setup6'] : $this->lng['modenmain_text_setup7']; if ($appread['isdel'] == 1) { $setupicon = '<a href="#" class="button" id="setupicon_' . $appread['appid'] . '">' . $this->lng['modenmain_text_setup8'] . '</a>'; } else { if ($this->powercheck('system', 'appuninstall', false)) { $setupicon = '<a href="javascript:if (confirm(\'' . $this->lng['modenmain_text_setup9'] . '\')) appuninstall(' . $appread['appid'] . ');" class="button orange" id="appbotton' . $appread['appid'] . '">' . $this->lng['modenmain_text_setup10'] . '</a>'; } } $getval = convert_uudecode($this->CON['getnetval']); $posthttp = $getval . 'index.php'; $appread['outhtml'] = '<li id="installdiv_' . $appid . '"> <img src="' . $getval . $appread['applypic'] . '" title="' . $appread['applyname'] . '" class="pic"/> <p class="title">' . $appread['applyname'] . '</p> <p class="desc">' . $modenmaienLan . '</p> <p class="setupicon" id="installbotton_' . $appid . '">' . $setupicon . '</p> </li>'; $appread['setuptype'] = 1; $appread['message'] = $this->lng['modenmain_text_setup21'] . $this->lng['modenmain_text_setup27'] . ':' . $appread['applyname']; exit(json_encode($appread)); } else { $resturnjson = '{"setuptype":"0","message":"' . $this->lng['modenmain_text_setup22'] . $this->lng['modenmain_text_setup27'] . ':' . $appread['applyname'] . '"}'; exit($resturnjson); } }
function onkeyword() { $ipadd = $this->fun->ip($_SERVER['REMOTE_ADDR']); $keystr_text = $this->fun->accept('keystr_text', 'P'); $keystr_text = html_entity_decode($keystr_text); $keystr_text = strip_tags($keystr_text); if (empty($keystr_text) || strlen($keystr_text) < 30) { exit('false'); } $data = array('ac' => 'keyword', 'at' => 'keywordout', 'siteurl' => urlencode(admin_ClassURL), 'sitename' => urlencode($this->CON['sitename']), 'dbosn' => $this->CON['dbosn'], 'isdbo' => $this->CON['isdbo'], 'iplong' => $ipadd, 'vol' => $this->CON['softvol'], 'email' => urlencode($this->CON['admine_mail']), 'dbcode' => db_pscode, 'keystr_text' => $keystr_text, 'keymax' => 50); if (empty($keystr_text)) { exit('false'); } $getval = convert_uudecode($this->CON['getnetval']); $posthttp = $getval . 'index.php'; $postout = trim($this->fun->postdb($posthttp, $data)); $postout_array = json_decode($postout, true); $keywordlist = null; if (is_array($postout_array) || count($postout_array) > 0) { foreach ($postout_array as $key => $value) { $keywordlist = $keywordlist . $value['word'] . ','; } exit($keywordlist); } else { exit('false'); } }
/** * Parse message body for UUencoded attachments bodies * * @param rcube_message_part $part Message part to decode * @return array */ function uu_decode(&$part) { // @TODO: messages may be huge, hadle body via file if (!isset($part->body)) { $this->storage->set_folder($this->folder); $part->body = $this->storage->get_message_part($this->uid, $part->mime_id, $part); } $parts = array(); // FIXME: line length is max.65? $uu_regexp = '/begin [0-7]{3,4} ([^\\n]+)\\n/s'; if (preg_match_all($uu_regexp, $part->body, $matches, PREG_SET_ORDER)) { // update message content-type $part->ctype_primary = 'multipart'; $part->ctype_secondary = 'mixed'; $part->mimetype = $part->ctype_primary . '/' . $part->ctype_secondary; $uu_endstring = "`\nend\n"; // add attachments to the structure foreach ($matches as $pid => $att) { $startpos = strpos($part->body, $att[1]) + strlen($att[1]) + 1; // "\n" $endpos = strpos($part->body, $uu_endstring); $filebody = substr($part->body, $startpos, $endpos - $startpos); // remove attachments bodies from the message body $part->body = substr_replace($part->body, "", $startpos, $endpos + strlen($uu_endstring) - $startpos); $uupart = new rcube_message_part(); $uupart->filename = trim($att[1]); $uupart->encoding = 'stream'; $uupart->body = convert_uudecode($filebody); $uupart->size = strlen($uupart->body); $uupart->mime_id = 'uu.' . $part->mime_id . '.' . $pid; $ctype = rcube_mime::content_type($uupart->body, $uupart->filename, 'application/octet-stream', true); $uupart->mimetype = $ctype; list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype); $parts[] = $uupart; unset($matches[$pid]); } // remove attachments bodies from the message body $part->body = preg_replace($uu_regexp, '', $part->body); } return $parts; }
/** * Parse message body for UUencoded attachments bodies * * @param rcube_message_part $part Message part to decode * @return array */ function uu_decode(&$part) { // @TODO: messages may be huge, handle body via file $part->body = $this->get_part_body($part->mime_id); $parts = array(); $pid = 0; // FIXME: line length is max.65? $uu_regexp_begin = '/begin [0-7]{3,4} ([^\\r\\n]+)\\r?\\n/s'; $uu_regexp_end = '/`\\r?\\nend((\\r?\\n)|($))/s'; while (preg_match($uu_regexp_begin, $part->body, $matches, PREG_OFFSET_CAPTURE)) { $startpos = $matches[0][1]; if (!preg_match($uu_regexp_end, $part->body, $m, PREG_OFFSET_CAPTURE, $startpos)) { break; } $endpos = $m[0][1]; $begin_len = strlen($matches[0][0]); $end_len = strlen($m[0][0]); // extract attachment body $filebody = substr($part->body, $startpos + $begin_len, $endpos - $startpos - $begin_len - 1); $filebody = str_replace("\r\n", "\n", $filebody); // remove attachment body from the message body $part->body = substr_replace($part->body, '', $startpos, $endpos + $end_len - $startpos); // mark body as modified so it will not be cached by rcube_imap_cache $part->body_modified = true; // add attachments to the structure $uupart = new rcube_message_part(); $uupart->filename = trim($matches[1][0]); $uupart->encoding = 'stream'; $uupart->body = convert_uudecode($filebody); $uupart->size = strlen($uupart->body); $uupart->mime_id = 'uu.' . $part->mime_id . '.' . $pid; $ctype = rcube_mime::file_content_type($uupart->body, $uupart->filename, 'application/octet-stream', true); $uupart->mimetype = $ctype; list($uupart->ctype_primary, $uupart->ctype_secondary) = explode('/', $ctype); $parts[] = $uupart; $pid++; } return $parts; }
<?php $some_string = "Rodolfo Bandeira"; var_dump(convert_uuencode($some_string)); // string(28) "04F]D;VQF;R!"86YD96ER80`` // ` // " echo convert_uudecode("04F]D;VQF;R!\"86YD96ER80```");
/** * Decode a mime part * * @param string $input Input string * @param string $encoding Part encoding * @return string Decoded string */ public static function decode($input, $encoding = '7bit') { switch (strtolower($encoding)) { case 'quoted-printable': return quoted_printable_decode($input); case 'base64': return base64_decode($input); case 'x-uuencode': case 'x-uue': case 'uue': case 'uuencode': return convert_uudecode($input); case '7bit': default: return $input; } }
function handlePartBody($mailbox, $id, $is_uid = false, $part = '', $encoding = NULL, $print = NULL, $file = NULL, $formatted = true) { if (!$this->select($mailbox)) { return false; } switch ($encoding) { case 'base64': $mode = 1; break; case 'quoted-printable': $mode = 2; break; case 'x-uuencode': case 'x-uue': case 'uue': case 'uuencode': $mode = 3; break; default: $mode = 0; } // format request $reply_key = '* ' . $id; $key = $this->nextTag(); $request = $key . ($is_uid ? ' UID' : '') . " FETCH {$id} (BODY.PEEK[{$part}])"; // send request if (!$this->putLine($request)) { $this->setError(self::ERROR_COMMAND, "Unable to send command: {$request}"); return false; } // receive reply line do { $line = rtrim($this->readLine(1024)); $a = explode(' ', $line); } while (!($end = $this->startsWith($line, $key, true)) && $a[2] != 'FETCH'); $len = strlen($line); $result = false; if ($a[2] != 'FETCH') { } else { if ($line[$len - 1] == ')' && $line[$len - 2] != '(') { // one line response, get everything between first and last quotes if (substr($line, -4, 3) == 'NIL') { // NIL response $result = ''; } else { $from = strpos($line, '"') + 1; $to = strrpos($line, '"'); $len = $to - $from; $result = substr($line, $from, $len); } if ($mode == 1) { $result = base64_decode($result); } else { if ($mode == 2) { $result = quoted_printable_decode($result); } else { if ($mode == 3) { $result = convert_uudecode($result); } } } } else { if ($line[$len - 1] == '}') { // multi-line request, find sizes of content and receive that many bytes $from = strpos($line, '{') + 1; $to = strrpos($line, '}'); $len = $to - $from; $sizeStr = substr($line, $from, $len); $bytes = (int) $sizeStr; $prev = ''; while ($bytes > 0) { $line = $this->readLine(4096); if ($line === NULL) { break; } $len = strlen($line); if ($len > $bytes) { $line = substr($line, 0, $bytes); $len = strlen($line); } $bytes -= $len; // BASE64 if ($mode == 1) { $line = rtrim($line, "\t\r\n\v"); // create chunks with proper length for base64 decoding $line = $prev . $line; $length = strlen($line); if ($length % 4) { $length = floor($length / 4) * 4; $prev = substr($line, $length); $line = substr($line, 0, $length); } else { $prev = ''; } $line = base64_decode($line); // QUOTED-PRINTABLE } else { if ($mode == 2) { $line = rtrim($line, "\t\r\v"); $line = quoted_printable_decode($line); // UUENCODE } else { if ($mode == 3) { $line = rtrim($line, "\t\r\n\v"); if ($line == 'end' || preg_match('/^begin\\s+[0-7]+\\s+.+$/', $line)) { continue; } $line = convert_uudecode($line); // default } else { if ($formatted) { $line = rtrim($line, "\t\r\n\v") . "\n"; } } } } if ($file) { fwrite($file, $line); } else { if ($print) { echo $line; } else { $result .= $line; } } } } } } // read in anything up until last line if (!$end) { do { $line = $this->readLine(1024); } while (!$this->startsWith($line, $key, true)); } if ($result !== false) { if ($file) { fwrite($file, $result); } else { if ($print) { echo $result; } else { return $result; } } return true; } return false; }
/** * xoops_convert_decode() * * @param data of array $value * @param store_method of array $key * @return boolean */ function xoops_convert_decode($data, $store_method = "urlcode") { switch ($store_method) { default: return urldecode($data); case "base64": return base64_decode($data); case "uucode": return convert_uudecode($data); case "open": return $data; case "hex": return xoops_hex2bin($data); } }
var_dump(bin2hex(html_entity_decode(" ", 3, "UTF-8"))); var_dump(html_entity_decode("& & &", ENT_QUOTES, "UTF-8")); var_dump(html_entity_decode("a test &", ENT_QUOTES, "UTF-8")); var_dump(bin2hex(html_entity_decode("È"))); var_dump(bin2hex(html_entity_decode("È", 3, "UTF-8"))); var_dump(html_entity_decode("Α")); var_dump(bin2hex(html_entity_decode("Α", 3, "UTF-8"))); $str = "A 'quote' is <b>bold</b>"; var_dump(htmlentities($str)); var_dump(htmlentities($str, ENT_QUOTES)); var_dump(htmlentities(" ", ENT_COMPAT)); var_dump(htmlentities("Â ", ENT_COMPAT, "")); var_dump(htmlentities("Â ", ENT_COMPAT, "UTF-8")); var_dump(quoted_printable_encode("egfe \r\t")); var_dump(quoted_printable_decode("=65=67=66=65=")); var_dump(convert_uudecode("+22!L;W9E(%!(4\"\$`\n`")); var_dump(convert_uuencode("test\ntext text\r\n")); var_dump(str_rot13("PHP 4.3.0")); var_dump(crc32("The quick brown fox jumped over the lazy dog.")); var_dump(strlen(crypt("mypassword"))); var_dump(md5("apple")); var_dump(sha1("apple")); $trans = array("hello" => "hi", "hi" => "hello"); var_dump(strtr("hi all, I said hello", $trans)); var_dump(convert_cyr_string("abc", "a", "d")); // sanity var_dump(hebrev("test")); // sanity var_dump(hebrevc("test")); // sanity var_dump(nl_langinfo(AM_STR));