function convert_utf8_dc64_to_dc($data) { if (substr($data, 0, 3) > 126 && substr($data, 0, 3) < 191) { global $Dc_to_Base64; $dcarray = explode_escaped(',', $data); // print_r($dcarray); $dcarray_size = count($dcarray); // echo $dcarray_size; $counter = 0; $dcb64 = ''; while ($counter < $dcarray_size) { //echo $Dc_to_Base64[$dcarray[$counter]]; $dcb64 = $dcb64 . $Dc_to_Base64[$dcarray[$counter]]; $counter++; } //echo $dcb64; return dce_convert(base64_decode($dcb64), 'utf8', 'dc'); } else { error_add('<font color="red">Error! This document is not stored using the specified format.</font>'); return 'This document is not stored using the specified format.'; } }
function base64_3_01a_to_unicode($data) { global $Dc_to_Base64; $dcarray = explode_escaped(',', $data); // print_r($dcarray); $dcarray_size = count($dcarray); // echo $dcarray_size; $counter = 0; $dcb64 = ''; while ($counter < $dcarray_size) { //echo $Dc_to_Base64[$dcarray[$counter]]; $dcb64 = $dcb64 . $Dc_to_Base64[$dcarray[$counter]]; $counter++; } //echo $dcb64; return base64_decode($dcb64); }
<?php // Connect to Daemon $socket = socket_create(AF_INET, SOCK_STREAM, 0); $connect = connect_to_daemon($socket, $_COOKIE['ddclient_host'], $_COOKIE['ddclient_port'], $_COOKIE['ddclient_passwd'], $_COOKIE['ddclient_enc'], 5); // Site Vars $err_message = ''; $dlist = ''; send_all($socket, "DDP DL LIST"); recv_all($socket, $dlist); $dlist = explode("\n", $dlist); for ($i = 0; $i < count($dlist); $i++) { $curr_line = explode_escaped('|', $dlist[$i]); if ($curr_line[0] == "PACKAGE" && $curr_line[1] == $_GET['pkg_id']) { $tpl_vars['OLD_PKG_NAME'] = $curr_line[2]; $tpl_vars['OLD_PKG_PASS'] = $curr_line[3]; } } $tpl_vars['PKG_ID'] = $_GET["pkg_id"]; $tpl_vars['DL_ID'] = $_GET["id"];
function convert_utf8_dc64_to_dc($data) { global $Dc_to_Base64; $dcarray = explode_escaped(',', $data); // print_r($dcarray); $dcarray_size = count($dcarray); // echo $dcarray_size; $counter = 0; $dcb64 = ''; while ($counter < $dcarray_size) { //echo $Dc_to_Base64[$dcarray[$counter]]; $dcb64 = $dcb64 . $Dc_to_Base64[$dcarray[$counter]]; $counter++; } //echo $dcb64; return dce_convert(base64_decode($dcb64), 'utf8', 'dc'); }
function dce_convert($data, $input_format, $output_format) { $html_opening = '<html><head><title></title></head><body>'; $html_closing = '</body></html>'; $onestep = false; $final = ''; //echo $output_format; /* if ($output_format == 'utf32') { header('Content-type: text/plain; charset=utf-32'); } else { header('Content-type: text/plain'); } */ //Ideally how this works: Convert the input into an array of Dc IDs, and then write that out using the selected translator. /* Input formats: dc, dce, 3_0a, utf32, utf8, cdce, legacy_cdce Output formats: dc, dce, 3_0a, utf32, utf8, html, cdce, legacy_cdce */ switch ($input_format) { case 'dc': $dc = $data; break; case 'dce': $hex = strtolower(bin2hex($data)); if (substr($hex, 0, 12) !== '444345650201') { return 'This document is not stored using a supported format.'; break; } switch (get_dce_version($data)) { //This next block is the old method. /*case '3_0a': //###################################################### //This is a DCE 3.0a file. It doesn't need to be updated. This case will though! global $dce3_0a_core; $counter = 14; $txt = ''; while ($counter < strlen($hex)) { $txt = $txt . $dce3_0a_core[hexdec(substr($hex, $counter, 2)) ]; if (substr($hex, $counter, 4) == 'fd03') { break; } $counter = $counter + 2; } r: return $txt; $data = $data; break; */ case '3_0a': //###################################################### //This is a DCE 3.0a file. global $DcMap_dce3_0a_Core; $counter = 14; $txt = ''; while ($counter < strlen($hex)) { $txt = $txt . $DcMap_dce3_0a_Core[strtoupper(substr($hex, $counter, 2))] . ','; //echo $txt; //$txt=$txt; if (substr($hex, $counter, 4) == 'fd03') { break; } $counter = $counter + 2; } //echo $txt; //echo '<br>'; //echo '<br>'; $txt = substr($txt, 3, strlen($txt) - 6); //echo $txt;echo '<br>';echo '<br>'; // return $txt; $dc = $txt; break; default: return 'This document is not stored using a supported version of DCE.'; break; } break; case 'utf32': $unicode = iconv('UTF-32BE', 'UTF-8', $data); return dce_convert($unicode, 'utf8', $output_format); break; case 'utf8': ini_set("display_errors", 0); $unicode = iconv('UTF-8', 'UTF-32BE', $data); $hex = bin2hex($unicode); //echo $hex; global $DcMap_Unicode_Lossy; $counter = 0; $txt = ''; while ($counter < strlen($hex)) { // $byte=strtoupper(ltrim(substr($hex, $counter, 8),'0')); // echo'<br>';echo $byte;echo'<br>'; //echo $txt; //echo '<br>'; //echo $counter; if (strlen($DcMap_Unicode_Lossy[strtoupper(ltrim(substr($hex, $counter, 8), '0'))]) != 0) { $append = $DcMap_Unicode_Lossy[strtoupper(ltrim(substr($hex, $counter, 8), '0'))] . ','; } else { $append = ''; } // $txt = $txt . $DcMap_Unicode_Lossy[strtoupper(ltrim(substr($hex, $counter, 8), '0')) ] . ','; $txt = $txt . $append; //echo $txt; //$txt=$txt; if (substr($hex, $counter, 4) == 'fd03') { break; } $counter = $counter + 8; } //echo $txt; //echo '<br>'; //echo '<br>'; //$txt = substr($txt, 3, (strlen($txt) - 6)); //echo $txt;echo '<br>';echo '<br>'; // return $txt; $dc = $txt; break; case 'cdce': break; case 'legacy_cdce': // global $output_format; // global $onestep; // global $finished; // global $html_opening; // global $html_closing; switch ($output_format) { case 'html': // global $onestep; // global $finished; $onestep = 1; $finished = $html_opening . legacy_cdce_to_html_snippet($data) . $html_closing; echo $onestep; echo $finished; echo $html_opening; case 'html_snippet': // global $onestep; // global $finished; // global $html_opening; // global $html_closing; $onestep = 1; $finished = legacy_cdce_to_html_snippet($data); default: //$dc=$txt; } $dc = ''; break; default: $dc = ''; return 'Unknown input format: ' . $input_format . '. Available: dc, dce, 3_0a, utf8, utf32'; break; } //global $onestep; //$onestep="meuou"; //echo $onestep; if ($onestep == "1") { return $finished; //echo 'test'; echo 'doom'; } else { // echo 'doom 2'; $dc = preg_replace('/,\\Z/', '', $dc); $dc = str_replace(',,', ',0,', $dc); // echo '<br>'; // echo $dc; // echo '<br>'; $dc_array = explode_escaped(',', $dc); // print_r($dc_array); // echo '<br>'; $dc_size = count($dc_array); // echo $dc_size; // echo '<br>'; switch ($output_format) { case 'dc': return $dc; break; case 'dce': return dce_convert($dc, 'dc', '3_0a'); break; case '3_0a': global $DcMapSend_dce3_0a; $counter = 0; $txt = '44434565020101fd'; // echo '<br>'; while ($counter < $dc_size) { $txt = $txt . strtolower($DcMapSend_dce3_0a[$dc_array[$counter]]); // echo $counter; // echo ': '; // echo $txt; //$txt=$txt; // echo '<br>'; $counter++; } $txt = $txt . 'fd03'; //$txt = substr($txt, 0, (strlen($txt) - 1)); return hex2bin($txt); // $dc = $txt; break; case 'utf8': global $DcMapSend_Unicode; $counter = 0; $txt = ''; // echo '<br>'; while ($counter < $dc_size) { $txt = $txt . str_pad(strtolower($DcMapSend_Unicode[$dc_array[$counter]]), 8, "0", STR_PAD_LEFT); //echo '<br>'; //echo $dc_array[$counter] . ': ' . $txt; //echo '<br>'; // echo $counter; // echo ': '; // echo $txt; //$txt=$txt; // echo '<br>'; $counter++; } // $txt = $txt . 'fd03'; //$txt = substr($txt, 0, (strlen($txt) - 1)); return iconv('UTF-32BE', 'utf8', hex2bin($txt)); // $dc = $txt; // break; // return dce2txt($data); break; case 'utf32': $unicode = bin2hex(iconv('UTF-8', 'UTF-32BE', dce_convert($dc, 'dc', 'utf8'))); //echo dce_convert($dc, 'dc', 'utf8'); //echo $unicode; return hex2bin($unicode); break; case 'html': break; case 'cdce': break; case 'legacy_cdce': break; default: global $output_format; return 'Unknown output format: ' . $output_format . '. Available: dc, dce, 3_0a, utf8, html'; } } function x2dce($data, $format) { } function dce2x($data, $format) { //$hex=bin2hex($data); switch ($format) { case 'txt': return dce2txt($data); break; } } function get_dce_version($data) { $hex = strtolower(bin2hex($data)); if (substr($hex, 0, 12) !== '444345650201') { return 'This document is not stored using a supported format.'; break; } switch (substr($hex, 12, 2)) { case 01: //This is a DCE 3.0a file return '3_0a'; break; default: return 'This document is not stored using a supported version of DCE.'; } } function dce2txt($data) { $hex = strtolower(bin2hex($data)); // echo '<br>'; // echo $hex; // echo '<br>'; // echo substr($hex, 12, 2); // echo substr($hex, 0, 12); if (substr($hex, 0, 12) !== '444345650201') { return 'This document is not stored using a supported format.'; break; } switch (get_dce_version($data)) { case '3_0a': //This is a DCE 3.0a file global $dce3_0a_core; $counter = 14; $txt = ''; while ($counter < strlen($hex)) { $txt = $txt . $dce3_0a_core[hexdec(substr($hex, $counter, 2))]; if (substr($hex, $counter, 4) == 'fd03') { break; } $counter = $counter + 2; } r: return $txt; break; default: return 'This document is not stored using a supported version of DCE.'; } } }
function convert_dc_to_utf8_output($data) { //TODO //LOSSY! Provides no encapsulation support. $dc_array = explode_escaped(',', $data); $dc_size = count($dc_array); global $DcMapSend_Unicode; $counter = 0; $txt = ''; while ($counter < $dc_size) { if (str_pad(strtolower($DcMapSend_Unicode[$dc_array[$counter]]), 8, "0", STR_PAD_LEFT) != '00000000') { $txt = $txt . str_pad(strtolower($DcMapSend_Unicode[$dc_array[$counter]]), 8, "0", STR_PAD_LEFT); } else { if (!($dc_array[$counter] == '114' || $dc_array[$counter] == '115')) { $txt = $txt . '0000FFFD'; } } $counter++; } return iconv('UTF-32BE', 'utf8', hex2bin($txt)); }
function convert_dc_to_binary_raw($data) { global $Dc_to_Base64; $dcarray = str_replace('203,', '', str_replace(',204', '', explode_escaped(',', $data))); $dcarray_size = count($dcarray); $counter = 0; $dcb64 = ''; while ($counter < $dcarray_size) { $dcb64 = $dcb64 . $Dc_to_Base64[$dcarray[$counter]]; $counter++; } return base64_decode($dcb64); }
if (substr($buf, 0, 3) != "100") { $err_message .= msg_generate($LANG['ERR_EDIT'], 'error'); } break; default: break; } } $list = ""; send_all($socket, "DDP DL LIST"); recv_all($socket, $list); $download_index[] = array(); $download_index = explode("\n", $list); $exp_dls[] = array(); for ($i = 0; $i < count($download_index); $i++) { $exp_dls[$i] = explode_escaped('|', $download_index[$i]); } for ($i = 0; $i < count($exp_dls); $i++) { if ($exp_dls[$i][0] == "") { continue; } if ($exp_dls[$i][0] == "PACKAGE") { $tpl_manage_vars = array('T_Activate_Button' => '', 'T_DelFile_Button' => '', 'T_TR_CLASS' => 'pkg', 'T_PKG_ID' => $exp_dls[$i][1], 'T_DL_ID' => '', 'T_DL_Date' => '', 'T_DL_Title' => $exp_dls[$i][2], 'T_DL_Title_short' => $exp_dls[$i][2], 'T_DL_URL' => '', 'T_DL_URL_short' => '', 'T_DL_Class' => '', 'T_DL_Status' => '', 'T_SITE_URL' => $tpl_vars['T_SITE_URL'], 'L_Activate' => '" style="visibility:hidden', 'L_Delete' => '', 'L_Move' => $LANG['Move'], 'L_Delete_File' => '', 'T_EDIT_SITE' => 'pkg_edit'); if ($exp_dls[$i][3] != "") { $tpl_manage_vars['T_DL_Title'] = "<img src=\"" . $tpl_vars['T_SITE_URL'] . "/templates/default/css/images/key.png\" alt=\"" . $LANG['L_PASS_SET'] . "\" \n\t\t\t\t\t\t\t\t title=\"" . $LANG['L_PASS_SET'] . "\" />" . $exp_dls[$i][2]; } $dl_list .= template_parse('manage_line', $tpl_manage_vars); continue; } //Alternating <tr> Colors if ($i % 2 == 0) {