Пример #1
0
 function CString()
 {
     $this->ent_replace = array('<', '>', '&', '"', ' ', '¡', '¢', '£', '¤', '¥', '¦', '§', '¨', '©', 'ª', '«', '¬', '­', '®', '¯', '°', '±', '²', '³', '´', 'µ', '¶', '·', '¸', '¹', 'º', '»', '¼', '½', '¾', '¿', 'À', '&Acute;', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', '×', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', '÷', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ÿ', '—', '’');
     $this->ent_with = array('<', '>', '&', '"', _byte_chr(160), _byte_chr(161), _byte_chr(162), _byte_chr(163), _byte_chr(164), _byte_chr(165), _byte_chr(166), _byte_chr(167), _byte_chr(168), _byte_chr(169), _byte_chr(170), _byte_chr(171), _byte_chr(172), _byte_chr(173), _byte_chr(174), _byte_chr(175), _byte_chr(176), _byte_chr(177), _byte_chr(178), _byte_chr(179), _byte_chr(180), _byte_chr(181), _byte_chr(182), _byte_chr(183), _byte_chr(184), _byte_chr(185), _byte_chr(186), _byte_chr(187), _byte_chr(188), _byte_chr(189), _byte_chr(190), _byte_chr(191), _byte_chr(192), _byte_chr(193), _byte_chr(194), _byte_chr(195), _byte_chr(196), _byte_chr(197), _byte_chr(198), _byte_chr(199), _byte_chr(200), _byte_chr(201), _byte_chr(202), _byte_chr(203), _byte_chr(204), _byte_chr(205), _byte_chr(206), _byte_chr(207), _byte_chr(208), _byte_chr(209), _byte_chr(210), _byte_chr(211), _byte_chr(212), _byte_chr(213), _byte_chr(214), _byte_chr(215), _byte_chr(216), _byte_chr(217), _byte_chr(218), _byte_chr(219), _byte_chr(220), _byte_chr(221), _byte_chr(222), _byte_chr(223), _byte_chr(224), _byte_chr(225), _byte_chr(226), _byte_chr(227), _byte_chr(228), _byte_chr(229), _byte_chr(230), _byte_chr(231), _byte_chr(232), _byte_chr(233), _byte_chr(234), _byte_chr(235), _byte_chr(236), _byte_chr(237), _byte_chr(238), _byte_chr(239), _byte_chr(240), _byte_chr(241), _byte_chr(242), _byte_chr(243), _byte_chr(244), _byte_chr(245), _byte_chr(246), _byte_chr(247), _byte_chr(248), _byte_chr(249), _byte_chr(250), _byte_chr(251), _byte_chr(252), _byte_chr(253), _byte_chr(254), _byte_chr(255), '-', '`');
     for ($c = 1; $c < 256; $c++) {
         array_push($this->ent_replace, '&#' . $c . ';');
         array_push($this->ent_with, _byte_chr($c));
     }
 }
 /**
  * Returns part of number $num, starting at bit
  * position $start with length $length
  *
  * @param gmp resource $num
  * @param int start
  * @param int length
  * @return gmp resource
  * @access public
  */
 function subint($num, $start, $length)
 {
     $start_byte = intval($start / 8);
     $start_bit = $start % 8;
     $byte_length = intval($length / 8);
     $bit_length = $length % 8;
     if ($bit_length) {
         $byte_length++;
     }
     $bi = new Math_BigInteger($num, 10);
     $divider = new Math_BigInteger(1 << $start_bit);
     $res = $bi->divide($divider);
     $bi = $res[0];
     $tmp = _byte_strrev(_byte_substr($bi->toBytes(), $start_byte, $byte_length));
     $tmp = str_pad($tmp, $byte_length, "");
     $tmp = _byte_substr_replace($tmp, $tmp[$byte_length - 1] & _byte_chr(0xff >> 8 - $bit_length), $byte_length - 1, 1);
     return $this->bin2int($tmp);
 }
Пример #3
0
 /**
  * Crypt_Blowfish Constructor
  * Initializes the Crypt_Blowfish object, and sets the secret key
  *
  * @param string $key
  * @param string $mode operating mode 'ecb', 'cbc'...
  * @param string $iv initialization vector
  * @access public
  */
 function Crypt_Blowfish_MCrypt($key = null, $mode = 'ecb', $iv = null)
 {
     $this->_iv = $iv . (_byte_strlen($iv) < 8 ? str_repeat(_byte_chr(0), 8 - _byte_strlen($iv)) : '');
     $this->_td = mcrypt_module_open(MCRYPT_BLOWFISH, '', $mode, '');
     if (is_null($iv)) {
         $this->_iv = mcrypt_create_iv(8, MCRYPT_RAND);
     }
     switch (_ml_strtolower($mode)) {
         case 'ecb':
             $this->_iv_required = false;
             break;
         case 'cbc':
         default:
             $this->_iv_required = true;
             break;
     }
     $this->setKey($key, $this->_iv);
 }
Пример #4
0
 /**
  * Returns part of number $num, starting at bit
  * position $start with length $length
  *
  * @param gmp resource $num
  * @param int start
  * @param int length
  * @return gmp resource
  * @access public
  */
 function subint($num, $start, $length)
 {
     $start_byte = intval($start / 8);
     $start_bit = $start % 8;
     $byte_length = intval($length / 8);
     $bit_length = $length % 8;
     if ($bit_length) {
         $byte_length++;
     }
     $num = gmp_div($num, 1 << $start_bit);
     $tmp = _byte_substr($this->int2bin($num), $start_byte, $byte_length);
     $tmp = str_pad($tmp, $byte_length, "");
     $tmp = _byte_substr_replace($tmp, $tmp[$byte_length - 1] & _byte_chr(0xff >> 8 - $bit_length), $byte_length - 1, 1);
     return $this->bin2int($tmp);
 }
Пример #5
0
 /**
  * Generates a new user password.
  *
  * @param string $email -  user e-mail
  * @return array
  */
 function generateNewAdminPassword($email)
 {
     global $application;
     $tables = $this->getTables();
     $table = 'admin';
     $columns = $tables[$table]['columns'];
     $newPassword = '';
     for ($i = 0; $i < 8; $i++) {
         $symbol = '';
         do {
             $symbol = _byte_chr(rand(48, 122));
         } while (!preg_match("/[0-9a-zA-Z]/", $symbol));
         $newPassword .= $symbol;
     }
     $query = new DB_Update($table);
     $query->addUpdateValue($columns['password'], md5($newPassword));
     $query->addUpdateExpression($columns['modified'], $query->fNow());
     $query->WhereValue($columns['email'], DB_EQ, $email);
     $application->db->getDB_Result($query);
     $this->letterAboutNewPassword($email, $newPassword);
 }
 function out_SearchLettersList()
 {
     $items = array(array('display' => getMsg('CA', 'LBL_ALL'), 'value' => ''));
     for ($i = 65; $i <= 90; $i++) {
         $items[] = array('display' => '&nbsp;<b>' . _byte_chr($i) . '</b>&nbsp;', 'value' => _ml_strtolower(_byte_chr($i)));
     }
     $html_code = '';
     foreach ($items as $item_info) {
         $html_code .= '';
         if ($this->search_filter['type'] == 'letter' and $this->search_filter['search_string'] == $item_info['value']) {
             $html_code .= '<li class="active"><a href="javascript:void(0);">' . $item_info['display'] . '</a>';
         } else {
             $html_code .= '<li><a href="customers.php?filter=letter&search_string=' . $item_info['value'] . '">' . $item_info['display'] . '</a>';
         }
         $html_code .= '</li>';
     }
     return $html_code;
 }
Пример #7
0
 /**
  * Decrypts an encrypted string
  *
  * The value was padded with NUL characters when encrypted. You may
  * need to trim the result or cast its type.
  *
  * @param string $cipherText
  * @return string|PEAR_Error Returns plain text on success, PEAR_Error on failure
  * @access public
  */
 function decrypt($cipherText)
 {
     if (!is_string($cipherText)) {
         return PEAR::raiseError('Cipher text must be a string', 1);
     }
     if (empty($this->_P)) {
         return PEAR::raiseError('The key is not initialized.', 8);
     }
     $plainText = '';
     $len = _byte_strlen($cipherText);
     $cipherText .= str_repeat(_byte_chr(0), (8 - $len % 8) % 8);
     for ($i = 0; $i < $len; $i += 8) {
         list(, $Xl, $Xr) = unpack('N2', _byte_substr($cipherText, $i, 8));
         $this->_decipher($Xl, $Xr);
         $plainText .= pack('N2', $Xl, $Xr);
     }
     return $plainText;
 }
 /**
  * @ describe the function ManageOrders->.
  */
 function getTag($tag)
 {
     global $application;
     $value = null;
     switch ($tag) {
         case 'SearchCustomers':
             $application->registerAttributes(array('CustomersSearchByField', 'CustomersSearchByFieldValue', 'CustomersSearchByLetter'));
             $value = $this->TemplateFiller->fill("checkout/customers/", "search.tpl.html", array());
             break;
         case 'CustomersSearchByLetter':
             $value = "<td style='vertical-align: bottom'><a href='customers.php?asc_action=CustomersSearchByLetter&letter='>" . $this->MessageResources->getMessage('CUSTOMERS_SEARCH_ALL') . "</a></td><td>";
             for ($i = 65; $i <= 90; $i++) {
                 $letter = _byte_chr($i);
                 if ($this->_filter['search_by'] == 'letter' && !empty($this->_filter['letter'])) {
                     if (_byte_chr($i + 32) == $this->_filter['letter']) {
                         $letter = "<span class='required'>" . _byte_chr($i) . "</span>";
                     }
                 }
                 $value .= "<a href='customers.php?asc_action=CustomersSearchByLetter&letter=" . _byte_chr($i + 32) . "'><b>" . $letter . "</b></a>&nbsp;";
             }
             $value .= "</td>";
             break;
         case 'CustomersSearchByField':
             $value = "<OPTION value='name'>" . $this->MessageResources->getMessage("CUSTOMERS_SEARCH_BY_NAME") . "</OPTION>";
             if ($this->_filter['search_by'] == 'field' && !empty($this->_filter['field_name']) && $this->_filter['field_name'] == 'Email') {
                 $value .= "<OPTION value='Email' selected>" . $this->MessageResources->getMessage("CUSTOMERS_SEARCH_BY_EMAIL") . "</OPTION>";
             } else {
                 $value .= "<OPTION value='Email'>" . $this->MessageResources->getMessage("CUSTOMERS_SEARCH_BY_EMAIL") . "</OPTION>";
             }
             break;
         case 'CustomersSearchByFieldValue':
             $value = '';
             if ($this->_filter['search_by'] == 'field' && !empty($this->_filter['field_name']) && !empty($this->_filter['field_value'])) {
                 $value = $this->_filter['field_value'];
             }
             break;
         case 'SearchResults':
             if (count($this->_customers) == 0) {
                 $value = $this->TemplateFiller->fill("checkout/customers/", "empty.tpl.html", array());
             } else {
                 $value = $this->TemplateFiller->fill("checkout/customers/", "results.tpl.html", array());
             }
             break;
         case 'Items':
             $value = $this->getCustomers();
             break;
         case 'CustomerId':
             $value = getKeyIgnoreCase('Id', $this->_customer);
             break;
         case 'ResultCount':
             $from = modApiFunc("Paginator", "getCurrentPaginatorOffset") + 1;
             $to = modApiFunc("Paginator", "getCurrentPaginatorOffset") + modApiFunc("Paginator", "getPaginatorRowsPerPage", "Checkout_Customers");
             $total = modApiFunc("Paginator", "getCurrentPaginatorTotalRows");
             if ($to > $total) {
                 $to = $total;
             }
             if ($total <= modApiFunc("Paginator", "getPaginatorRowsPerPage", "Checkout_Customers")) {
                 $value = $this->MessageResources->getMessage(new ActionMessage(array("CUSTOMERS_RESULTS_LESS_THEN_ROWS_PER_PAGE_FOUND", $total)));
             } else {
                 $value = $this->MessageResources->getMessage(new ActionMessage(array("CUSTOMERS_RESULTS_MORE_THEN_ROWS_PER_PAGE_FOUND", $from, $to, $total)));
             }
             break;
         case 'CustomerTotalOrders':
             $value = getKeyIgnoreCase('TotalOrders', $this->_customer);
             break;
         case 'CustomerTotalAmount':
             $value = modApiFunc("Localization", "currency_format", getKeyIgnoreCase('TotalAmount', $this->_customer));
             break;
         case 'PaginatorLine':
             $obj =& $application->getInstance($tag);
             $value = $obj->output("Checkout_Customers", "Customers");
             break;
             #                               PaginatorRows
         #                               PaginatorRows
         case 'PaginatorRows':
             $obj =& $application->getInstance($tag);
             $value = $obj->output("Checkout_Customers", 'Customers', 'PGNTR_CUST_ITEMS');
             break;
         case 'CustomerRegStatus':
             $customerInfo = getKeyIgnoreCase('Customer', $this->_customer);
             $email = getKeyIgnoreCase('Email', $customerInfo['attr']);
             if (modApiFunc('Customer_Account', 'doesAccountExists', $email['value'])) {
                 $value = 'reg';
             } else {
                 $value = 'not-reg';
             }
             break;
         default:
             list($entity, $tag) = getTagName($tag);
             if ($entity == 'customer') {
                 $customerInfo = getKeyIgnoreCase('Customer', $this->_customer);
                 if (!($tagvalue = getKeyIgnoreCase($tag, $customerInfo['attr']))) {
                     break;
                 }
                 $value = $tagvalue['value'];
             }
             break;
     }
     return $value;
 }
Пример #9
0
 /**
  * Converts bytes to 32-bit integers
  *
  * @param String $x
  * @return Integer
  * @access private
  */
 function _bytes2int($x)
 {
     $temp = unpack('Nint', str_pad($x, 4, _byte_chr(0), STR_PAD_LEFT));
     return $temp['int'];
 }
Пример #10
0
 /**
  * Crypt_Blowfish_PHP Constructor
  * Initializes the Crypt_Blowfish object, and sets
  * the secret key
  *
  * @param string $key
  * @param string $mode operating mode 'ecb' or 'cbc'
  * @param string $iv initialization vector
  * @access protected
  */
 function __construct($key = null, $iv = null)
 {
     $this->_iv = $iv . (_byte_strlen($iv) < $this->_iv_size ? str_repeat(_byte_chr(0), $this->_iv_size - _byte_strlen($iv)) : '');
     if (!is_null($key)) {
         $this->setKey($key, $this->_iv);
     }
 }
 /**
  *
  */
 function html_replace($text)
 {
     $search = array("'<script[^>]*?>.*?</script>'si", "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&#(\\d+);'e");
     //                      php-
     $format = modApiFunc('Settings', 'getParamValue', 'EMAIL_NOTIFICATION_SETTINGS', 'EMAIL_NOTIFICATION_FORMAT');
     if ($format != 'HTML') {
         $search = array_merge($search, array("'<[\\/\\!]*?[^<>]*?>'si", "'&(quot|#34);'i"));
     }
     $replace = array("", "", "\"", "&", "<", ">", " ", _byte_chr(161), _byte_chr(162), _byte_chr(163), _byte_chr(169), "chr(\\1)");
     return preg_replace($search, $replace, $text);
 }
Пример #12
0
 function _striptext($document)
 {
     // I didn't use preg eval (//e) since that is only available in PHP 4.0.
     // so, list your entities one by one here. I included some of the
     // more common ones.
     $search = array("'<script[^>]*?>.*?</script>'si", "'<[\\/\\!]*?[^<>]*?>'si", "'([\r\n])[\\s]+'", "'&(quot|#34|#034|#x22);'i", "'&(amp|#38|#038|#x26);'i", "'&(lt|#60|#060|#x3c);'i", "'&(gt|#62|#062|#x3e);'i", "'&(nbsp|#160|#xa0);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'&(reg|#174);'i", "'&(deg|#176);'i", "'&(#39|#039|#x27);'", "'&(euro|#8364);'i", "'&a(uml|UML);'", "'&o(uml|UML);'", "'&u(uml|UML);'", "'&A(uml|UML);'", "'&O(uml|UML);'", "'&U(uml|UML);'", "'&szlig;'i");
     $replace = array("", "", "\\1", "\"", "&", "<", ">", " ", _byte_chr(161), _byte_chr(162), _byte_chr(163), _byte_chr(169), _byte_chr(174), _byte_chr(176), _byte_chr(39), _byte_chr(128), " ", " ", " ", " ", " ", " ", " ");
     $text = preg_replace($search, $replace, $document);
     return $text;
 }
Пример #13
0
 /**
  * creates an image resource from given .BMP file
  *
  * @param unknown_type $filename
  * @return unknown
  */
 function ImageCreateFromBMP($filename)
 {
     if (!($f1 = fopen($filename, "rb"))) {
         return FALSE;
     }
     $FILE = unpack("vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread($f1, 14));
     if ($FILE['file_type'] != 19778) {
         return FALSE;
     }
     $BMP = unpack('Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . '/Vvert_resolution/Vcolors_used/Vcolors_important', fread($f1, 40));
     $BMP['colors'] = pow(2, $BMP['bits_per_pixel']);
     if ($BMP['size_bitmap'] == 0) {
         $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset'];
     }
     $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8;
     $BMP['bytes_per_pixel2'] = ceil($BMP['bytes_per_pixel']);
     $BMP['decal'] = $BMP['width'] * $BMP['bytes_per_pixel'] / 4;
     $BMP['decal'] -= floor($BMP['width'] * $BMP['bytes_per_pixel'] / 4);
     $BMP['decal'] = 4 - 4 * $BMP['decal'];
     if ($BMP['decal'] == 4) {
         $BMP['decal'] = 0;
     }
     $PALETTE = array();
     if ($BMP['colors'] < 16777216) {
         $PALETTE = unpack('V' . $BMP['colors'], fread($f1, $BMP['colors'] * 4));
     }
     $IMG = fread($f1, $BMP['size_bitmap']);
     $VIDE = _byte_chr(0);
     $res = imagecreatetruecolor($BMP['width'], $BMP['height']);
     $P = 0;
     $Y = $BMP['height'] - 1;
     while ($Y >= 0) {
         $X = 0;
         while ($X < $BMP['width']) {
             if ($BMP['bits_per_pixel'] == 24) {
                 $COLOR = unpack("V", _byte_substr($IMG, $P, 3) . $VIDE);
             } elseif ($BMP['bits_per_pixel'] == 16) {
                 $COLOR = unpack("n", _byte_substr($IMG, $P, 2));
                 $COLOR[1] = $PALETTE[$COLOR[1] + 1];
             } elseif ($BMP['bits_per_pixel'] == 8) {
                 $COLOR = unpack("n", $VIDE . _byte_substr($IMG, $P, 1));
                 $COLOR[1] = $PALETTE[$COLOR[1] + 1];
             } elseif ($BMP['bits_per_pixel'] == 4) {
                 $COLOR = unpack("n", $VIDE . _byte_substr($IMG, floor($P), 1));
                 if ($P * 2 % 2 == 0) {
                     $COLOR[1] = $COLOR[1] >> 4;
                 } else {
                     $COLOR[1] = $COLOR[1] & 0xf;
                 }
                 $COLOR[1] = $PALETTE[$COLOR[1] + 1];
             } elseif ($BMP['bits_per_pixel'] == 1) {
                 $COLOR = unpack("n", $VIDE . _byte_substr($IMG, floor($P), 1));
                 if ($P * 8 % 8 == 0) {
                     $COLOR[1] = $COLOR[1] >> 7;
                 } elseif ($P * 8 % 8 == 1) {
                     $COLOR[1] = ($COLOR[1] & 0x40) >> 6;
                 } elseif ($P * 8 % 8 == 2) {
                     $COLOR[1] = ($COLOR[1] & 0x20) >> 5;
                 } elseif ($P * 8 % 8 == 3) {
                     $COLOR[1] = ($COLOR[1] & 0x10) >> 4;
                 } elseif ($P * 8 % 8 == 4) {
                     $COLOR[1] = ($COLOR[1] & 0x8) >> 3;
                 } elseif ($P * 8 % 8 == 5) {
                     $COLOR[1] = ($COLOR[1] & 0x4) >> 2;
                 } elseif ($P * 8 % 8 == 6) {
                     $COLOR[1] = ($COLOR[1] & 0x2) >> 1;
                 } elseif ($P * 8 % 8 == 7) {
                     $COLOR[1] = $COLOR[1] & 0x1;
                 }
                 $COLOR[1] = $PALETTE[$COLOR[1] + 1];
             } else {
                 return FALSE;
             }
             imagesetpixel($res, $X, $Y, $COLOR[1]);
             $X++;
             $P += $BMP['bytes_per_pixel'];
         }
         $Y--;
         $P += $BMP['decal'];
     }
     fclose($f1);
     return $res;
 }