PDF rausgenommen
This commit is contained in:
218
msd2/myoos/includes/functions/function_address.php
Normal file
218
msd2/myoos/includes/functions/function_address.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: general.php,v 1.212 2003/02/17 07:55:54 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* address
|
||||
*
|
||||
* @link https://www.oos-shop.de
|
||||
* @package oos_address
|
||||
* @version $Revision: 1.1 $ - changed by $Author: r23 $ on $Date: 2007/06/12 16:49:27 $
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Returns the zone (State/Province) code
|
||||
*
|
||||
* @param $country_id
|
||||
* @param $zone_id
|
||||
* @param $default_zone
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_zone_code($country_id, $zone_id, $default_zone) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$zonestable = $oostable['zones'];
|
||||
$zone = $dbconn->Execute("SELECT zone_code FROM $zonestable WHERE zone_country_id = '" . intval($country_id) . "' AND zone_id = '" . intval($zone_id) . "'");
|
||||
if ($zone->RecordCount() > 0) {
|
||||
return $zone->fields['zone_code'];
|
||||
} else {
|
||||
return $default_zone;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the address_format_id for the given country
|
||||
*
|
||||
* @param $country_id
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_address_format_id($country_id) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$countriestable = $oostable['countries'];
|
||||
$address_format = $dbconn->Execute("SELECT address_format_id AS format_id FROM $countriestable WHERE countries_id = '" . intval($country_id) . "'");
|
||||
if ($address_format->RecordCount() > 0) {
|
||||
return $address_format->fields['format_id'];
|
||||
} else {
|
||||
return '1';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted address
|
||||
*
|
||||
* @param $address_format_id
|
||||
* @param $address
|
||||
* @param $html
|
||||
* @param $boln
|
||||
* @param $eoln
|
||||
* @return string
|
||||
*/
|
||||
function oos_address_format($address_format_id, $address, $html, $boln, $eoln) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$address_formattable = $oostable['address_format'];
|
||||
$address_format_result = $dbconn->Execute("SELECT address_format AS format FROM $address_formattable WHERE address_format_id = '" . intval($address_format_id) . "'");
|
||||
$address_format = $address_format_result->fields;
|
||||
|
||||
$company = addslashes($address['company']);
|
||||
$firstname = addslashes($address['firstname']);
|
||||
$lastname = addslashes($address['lastname']);
|
||||
$street = addslashes($address['street_address']);
|
||||
$city = addslashes($address['city']);
|
||||
$state = addslashes($address['state']);
|
||||
$country_id = $address['country_id'];
|
||||
$zone_id = $address['zone_id'];
|
||||
$postcode = addslashes($address['postcode']);
|
||||
$zip = $postcode;
|
||||
$country = oos_get_country_name($country_id);
|
||||
$state = oos_get_zone_code($country_id, $zone_id, $state);
|
||||
|
||||
if ($html) {
|
||||
// HTML Mode
|
||||
$HR = '<hr>';
|
||||
$hr = '<hr>';
|
||||
if ( ($boln == '') && ($eoln == "\n") ) { // Values not specified, use rational defaults
|
||||
$CR = '<br />';
|
||||
$cr = '<br />';
|
||||
$eoln = $cr;
|
||||
} else { // Use values supplied
|
||||
$CR = $eoln . $boln;
|
||||
$cr = $CR;
|
||||
}
|
||||
} else {
|
||||
// Text Mode
|
||||
$CR = $eoln;
|
||||
$cr = $CR;
|
||||
$HR = '----------------------------------------';
|
||||
$hr = '----------------------------------------';
|
||||
}
|
||||
|
||||
$statecomma = '';
|
||||
$streets = $street;
|
||||
if ($firstname == '') $firstname = addslashes($address['name']);
|
||||
if ($country == '') $country = addslashes($address['country']);
|
||||
if ($state != '') $statecomma = $state . ', ';
|
||||
|
||||
$fmt = $address_format['format'];
|
||||
eval("\$address = \"$fmt\";");
|
||||
$address = stripslashes($address);
|
||||
|
||||
if ( (ACCOUNT_COMPANY == 'true') && (oos_is_not_null($company)) ) {
|
||||
$address = $company . $cr . $address;
|
||||
}
|
||||
|
||||
return $boln . $address . $eoln;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a formatted address
|
||||
*
|
||||
* @param $customers_id
|
||||
* @param $address_id
|
||||
* @param $html
|
||||
* @param $boln
|
||||
* @param $eoln
|
||||
* @param $address
|
||||
* @param $html
|
||||
* @param $boln
|
||||
* @param $eoln
|
||||
*/
|
||||
function oos_address_label($customers_id, $address_id = 1, $html = FALSE, $boln = '', $eoln = "\n") {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$address_booktable = $oostable['address_book'];
|
||||
$query = "SELECT entry_firstname AS firstname, entry_lastname AS lastname, entry_company AS company,
|
||||
entry_street_address AS street_address, entry_city AS city,
|
||||
entry_postcode AS postcode, entry_state AS state, entry_zone_id AS zone_id,
|
||||
entry_country_id AS country_id
|
||||
FROM $address_booktable
|
||||
WHERE customers_id = '" . intval($customers_id) . "' AND
|
||||
address_book_id = '" . intval($address_id) . "'";
|
||||
$address = $dbconn->GetRow($query);
|
||||
|
||||
$format_id = oos_get_address_format_id($address['country_id']);
|
||||
|
||||
return oos_address_format($format_id, $address, $html, $boln, $eoln);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Counts the customer address book entries
|
||||
*
|
||||
* @param string $id
|
||||
* @param bool $check_session
|
||||
* @return int
|
||||
*/
|
||||
function oos_count_customer_address_book_entries($id = '', $check_session = TRUE) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
if (is_numeric($id) == FALSE) {
|
||||
if ($_SESSION['customer_id']) {
|
||||
$id = $_SESSION['customer_id'];
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ($check_session == TRUE) {
|
||||
if ( ($_SESSION['customer_id'] == FALSE) || ($id != $_SESSION['customer_id']) ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
$address_booktable = $oostable['address_book'];
|
||||
$addresses_query = "SELECT COUNT(*) AS total
|
||||
FROM $address_booktable
|
||||
WHERE customers_id = " . intval($id);
|
||||
$addresses = $dbconn->Execute($addresses_query);
|
||||
|
||||
return $addresses->fields['total'];
|
||||
}
|
221
msd2/myoos/includes/functions/function_compatibility.php
Normal file
221
msd2/myoos/includes/functions/function_compatibility.php
Normal file
@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: compatibility.php,v 1.22 2004/07/22 16:36:22 hpdl
|
||||
compatibility.php,v 1.18 2003/02/11 01:31:01 hpdl
|
||||
compatibility.php 1498 2007-03-29 14:04:50Z hpdl $
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2007 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* For compatibility
|
||||
*
|
||||
* @package core
|
||||
* @access public
|
||||
*
|
||||
* @author r23 <info@r23.de>
|
||||
* @since OOS 1.3.1
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* Forcefully disable register_globals if enabled
|
||||
*
|
||||
* Based from work by Richard Heyes (http://www.phpguru.org)
|
||||
*/
|
||||
if ((int)ini_get('register_globals') > 0) {
|
||||
if (isset($_REQUEST['GLOBALS'])) {
|
||||
die('GLOBALS overwrite attempt detected');
|
||||
}
|
||||
|
||||
$noUnset = array('GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES');
|
||||
|
||||
$input = array_merge($_GET, $_POST, $_COOKIE, $_SERVER, $_ENV, $_FILES, isset($_SESSION) && is_array($_SESSION) ? $_SESSION : array());
|
||||
|
||||
foreach ($input as $k => $v) {
|
||||
if (!in_array($k, $noUnset) && isset($GLOBALS[$k])) {
|
||||
$GLOBALS[$k] = NULL;
|
||||
unset($GLOBALS[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
unset($noUnset);
|
||||
unset($input);
|
||||
unset($k);
|
||||
unset($v);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forcefully disable magic_quotes_gpc if enabled
|
||||
*
|
||||
* @link https://www.oos-shop.dedoc/php_manual_de/html/security.magicquotes.disabling.html
|
||||
*/
|
||||
if (get_magic_quotes_gpc()) {
|
||||
function stripslashes_deep($value)
|
||||
{
|
||||
$value = is_array($value) ?
|
||||
array_map('stripslashes_deep', $value) :
|
||||
stripslashes($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
$_POST = array_map('stripslashes_deep', $_POST);
|
||||
$_GET = array_map('stripslashes_deep', $_GET);
|
||||
$_COOKIE = array_map('stripslashes_deep', $_COOKIE);
|
||||
$_REQUEST = array_map('stripslashes_deep', $_REQUEST);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fix for PHP as CGI hosts that set SCRIPT_FILENAME to
|
||||
* something ending in php.cgi for all requests
|
||||
*/
|
||||
if (strpos(php_sapi_name(), 'cgi') !== FALSE) {
|
||||
// $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fix for Dreamhost and other PHP as CGI hosts
|
||||
*/
|
||||
if (strpos($_SERVER['SCRIPT_NAME'], 'php.cgi') !== FALSE) {
|
||||
unset($_SERVER['PATH_INFO']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Replace file_get_contents()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.file_get_contents
|
||||
* @author Aidan Lister <aidan - php - net>
|
||||
* @version $Revision: 1.12 $
|
||||
* @internal resource_context is not supported
|
||||
* @since PHP 5
|
||||
*/
|
||||
if (!function_exists('file_get_contents')) {
|
||||
function file_get_contents($filename, $incategory = FALSE, $resource_context = null) {
|
||||
if (false === $fh = fopen($filename, 'rb', $incategory)) {
|
||||
user_error('file_get_contents() failed to open stream: No such file or directory', E_USER_WARNING);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
clearstatcache();
|
||||
if ($fsize = @filesize($filename)) {
|
||||
$data = fread($fh, $fsize);
|
||||
} else {
|
||||
$data = '';
|
||||
while (!feof($fh)) {
|
||||
$data .= fread($fh, 8192);
|
||||
}
|
||||
}
|
||||
|
||||
fclose($fh);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* checkdnsrr() not implemented on Microsoft Windows platforms
|
||||
*/
|
||||
if (!function_exists('checkdnsrr')) {
|
||||
function checkdnsrr($host, $type) {
|
||||
if(!empty($host) && !empty($type)) {
|
||||
@exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output);
|
||||
|
||||
foreach ($output as $k => $line) {
|
||||
if(preg_match('/^' . $host . '/i', $line)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('http_response_code')) {
|
||||
function http_response_code($code = NULL) {
|
||||
|
||||
if ($code !== NULL) {
|
||||
|
||||
switch ($code) {
|
||||
case 100: $text = 'Continue'; break;
|
||||
case 101: $text = 'Switching Protocols'; break;
|
||||
case 200: $text = 'OK'; break;
|
||||
case 201: $text = 'Created'; break;
|
||||
case 202: $text = 'Accepted'; break;
|
||||
case 203: $text = 'Non-Authoritative Information'; break;
|
||||
case 204: $text = 'No Content'; break;
|
||||
case 205: $text = 'Reset Content'; break;
|
||||
case 206: $text = 'Partial Content'; break;
|
||||
case 300: $text = 'Multiple Choices'; break;
|
||||
case 301: $text = 'Moved Permanently'; break;
|
||||
case 302: $text = 'Moved Temporarily'; break;
|
||||
case 303: $text = 'See Other'; break;
|
||||
case 304: $text = 'Not Modified'; break;
|
||||
case 305: $text = 'Use Proxy'; break;
|
||||
case 400: $text = 'Bad Request'; break;
|
||||
case 401: $text = 'Unauthorized'; break;
|
||||
case 402: $text = 'Payment Required'; break;
|
||||
case 403: $text = 'Forbidden'; break;
|
||||
case 404: $text = 'Not Found'; break;
|
||||
case 405: $text = 'Method Not Allowed'; break;
|
||||
case 406: $text = 'Not Acceptable'; break;
|
||||
case 407: $text = 'Proxy Authentication Required'; break;
|
||||
case 408: $text = 'Request Time-out'; break;
|
||||
case 409: $text = 'Conflict'; break;
|
||||
case 410: $text = 'Gone'; break;
|
||||
case 411: $text = 'Length Required'; break;
|
||||
case 412: $text = 'Precondition Failed'; break;
|
||||
case 413: $text = 'Request Entity Too Large'; break;
|
||||
case 414: $text = 'Request-URI Too Large'; break;
|
||||
case 415: $text = 'Unsupported Media Type'; break;
|
||||
case 500: $text = 'Internal Server Error'; break;
|
||||
case 501: $text = 'Not Implemented'; break;
|
||||
case 502: $text = 'Bad Gateway'; break;
|
||||
case 503: $text = 'Service Unavailable'; break;
|
||||
case 504: $text = 'Gateway Time-out'; break;
|
||||
case 505: $text = 'HTTP Version not supported'; break;
|
||||
default:
|
||||
exit('Unknown http status code "' . htmlentities($code) . '"');
|
||||
break;
|
||||
}
|
||||
|
||||
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
|
||||
|
||||
header($protocol . ' ' . $code . ' ' . $text);
|
||||
|
||||
$GLOBALS['http_response_code'] = $code;
|
||||
|
||||
} else {
|
||||
|
||||
$code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200);
|
||||
|
||||
}
|
||||
|
||||
return $code;
|
||||
|
||||
}
|
||||
}
|
130
msd2/myoos/includes/functions/function_coupon.php
Normal file
130
msd2/myoos/includes/functions/function_coupon.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: gv_sent.php,v 1.1 2003/02/18 00:18:50 wilt
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2002 - 2003 osCommerce
|
||||
|
||||
Credit Class GV/Discount Coupon v5.03
|
||||
Copyright (c) 2001 - 2003 Ian C Wilson
|
||||
http://www.phesis.org
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Credit Class GV/Discount Coupon
|
||||
*
|
||||
* @link https://www.oos-shop.de
|
||||
* @package Credit Class GV/Discount Coupon
|
||||
* @version $Revision: 1.1 $ - changed by $Author: r23 $ on $Date: 2007/06/12 16:49:27 $
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Create a Coupon Code. length may be between 1 and 16 Characters
|
||||
*
|
||||
* @param $salt
|
||||
* @param $length
|
||||
* @return string
|
||||
*/
|
||||
function oos_create_coupon_code($salt="secret", $length = SECURITY_CODE_LENGTH) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$ccid = md5(uniqid("","salt"));
|
||||
$ccid .= md5(uniqid("","salt"));
|
||||
$ccid .= md5(uniqid("","salt"));
|
||||
$ccid .= md5(uniqid("","salt"));
|
||||
srand((double)microtime()*1000000); // seed the random number generator
|
||||
$random_start = @rand(0, (128-$length));
|
||||
$good_result = 0;
|
||||
while ($good_result == 0) {
|
||||
$id1 = substr($ccid, $random_start,$length);
|
||||
$couponstable = $oostable['coupons'];
|
||||
$sql = "SELECT coupon_code
|
||||
FROM $couponstable
|
||||
WHERE coupon_code = '" . oos_db_input($id1) . "'";
|
||||
$query = $dbconn->Execute($sql);
|
||||
if ($query->RecordCount() == 0) $good_result = 1;
|
||||
}
|
||||
return $id1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update the Customers GV account
|
||||
*
|
||||
* @param $customer_id
|
||||
* @param $gv_id
|
||||
*/
|
||||
function oos_gv_account_update($customer_id, $gv_id) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
|
||||
$sql = "SELECT amount
|
||||
FROM $coupon_gv_customertable
|
||||
WHERE customer_id = '" . intval($customer_id) . "'";
|
||||
$customer_gv_result = $dbconn->Execute($sql);
|
||||
|
||||
$couponstable = $oostable['coupons'];
|
||||
$sql = "SELECT coupon_amount
|
||||
FROM $couponstable
|
||||
WHERE coupon_id = '" . oos_db_input($gv_id) . "'";
|
||||
$coupon_amount = $dbconn->GetOne($sql);
|
||||
|
||||
if ($customer_gv_result->RecordCount() > 0) {
|
||||
$customer_gv = $customer_gv_result->fields;
|
||||
$new_gv_amount = $customer_gv['amount'] + $coupon_amount;
|
||||
|
||||
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
|
||||
$gv_result = $dbconn->Execute("UPDATE $coupon_gv_customertable
|
||||
SET amount = '" . oos_db_input($new_gv_amount) . "'");
|
||||
} else {
|
||||
$coupon_gv_customertable = $oostable['coupon_gv_customer'];
|
||||
$gv_result = $dbconn->Execute("INSERT INTO $coupon_gv_customertable
|
||||
(customer_id,
|
||||
amount) VALUES ('" . intval($customer_id) . "',
|
||||
'" . oos_db_input($coupon_amount) . "')");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get tax rate from tax description
|
||||
*
|
||||
* @param $tax_desc
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_tax_rate_from_desc($tax_desc) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$tax_ratestable = $oostable['tax_rates'];
|
||||
$sql = "SELECT tax_rate
|
||||
FROM $tax_ratestable
|
||||
WHERE tax_description = '" . oos_db_input($tax_desc) . "'";
|
||||
$tax = $dbconn->Execute($sql);
|
||||
return $tax->fields['tax_rate'];
|
||||
}
|
||||
|
||||
|
252
msd2/myoos/includes/functions/function_db.php
Normal file
252
msd2/myoos/includes/functions/function_db.php
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: pnAPI.php,v 1.81.2.14 2002/05/17 16:50:12 byronmhome
|
||||
----------------------------------------------------------------------
|
||||
POST-NUKE Content Management System
|
||||
Copyright (C) 2001 by the Post-Nuke Development Team.
|
||||
http://www.postnuke.com/
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
PHP-NUKE Web Portal System - http://phpnuke.org/
|
||||
Thatware - http://thatware.org/
|
||||
----------------------------------------------------------------------
|
||||
|
||||
File: database.php,v 1.21 2002/06/05 11:16:25 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
|
||||
LICENSE
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License (GPL)
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file: Jim McDonald
|
||||
Purpose of file: The PostNuke API
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* ADODB Database Abstraction Layer API Helpers
|
||||
*
|
||||
* @package database
|
||||
* @copyright (C) 2013 by the MyOOS Development Team.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link https://www.oos-shop.de
|
||||
* @subpackage adodb
|
||||
*/
|
||||
|
||||
/**
|
||||
* Initializes the database connection.
|
||||
*
|
||||
* This function loads up ADODB and starts the database
|
||||
* connection using the required parameters then it sets
|
||||
* the table prefixes and xartables up and returns true
|
||||
*
|
||||
* @access protected
|
||||
* @global object db database connection object
|
||||
* @global integer ADODB_FETCH_MODE array fectching by associative or numeric keyed arrays
|
||||
* @global array oosDB_tables database tables used by MyOOS [Shopsystem]
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
function oosDBInit() {
|
||||
// Get database parameters
|
||||
$dbtype = OOS_DB_TYPE;
|
||||
$dbhost = OOS_DB_SERVER;
|
||||
$dbname = OOS_DB_DATABASE;
|
||||
|
||||
// Decode encoded DB parameters
|
||||
if (OOS_ENCODED == '1') {
|
||||
$dbuname = base64_decode(OOS_DB_USERNAME);
|
||||
$dbpass = base64_decode(OOS_DB_PASSWORD);
|
||||
} else {
|
||||
$dbuname = OOS_DB_USERNAME;
|
||||
$dbpass = OOS_DB_PASSWORD;
|
||||
}
|
||||
|
||||
// Start connection
|
||||
global $ADODB_CACHE_DIR;
|
||||
$ADODB_CACHE_DIR = oos_get_local_path(OOS_TEMP_PATH . 'adodb_cache/');
|
||||
|
||||
$dbconn = ADONewConnection($dbtype);
|
||||
if (!$dbconn->Connect($dbhost, $dbuname, $dbpass, $dbname)) {
|
||||
$dbpass = "****";
|
||||
$dbuname = "****";
|
||||
die("$dbtype://$dbuname:$dbpass@$dbhost/$dbname failed to connect " . $dbconn->ErrorMsg());
|
||||
}
|
||||
|
||||
global $ADODB_FETCH_MODE;
|
||||
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
|
||||
|
||||
$GLOBALS['oosDB_connections'][0] = $dbconn;
|
||||
$GLOBALS['oosDB_tables'] = array();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of database connections
|
||||
*
|
||||
* @access public
|
||||
* @global array xarDB_connections array of database connection objects
|
||||
* @return array array of database connection objects
|
||||
*/
|
||||
function &oosDBGetConn() {
|
||||
|
||||
// we only want to return the first connection here
|
||||
// perhaps we'll add linked list capabilities to this soon
|
||||
return $GLOBALS['oosDB_connections'][0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array of database tables
|
||||
*
|
||||
* @access public
|
||||
* @global array oosDB_tables array of database tables
|
||||
* @return array array of database tables
|
||||
*/
|
||||
function &oosDBGetTables() {
|
||||
return $GLOBALS['oosDB_tables'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Import module tables in the array of known tables
|
||||
*
|
||||
* @access protected
|
||||
* @global oostable array
|
||||
*/
|
||||
function oosDB_importTables($tables) {
|
||||
// assert('is_array($tables)');
|
||||
$GLOBALS['oosDB_tables'] = array_merge($GLOBALS['oosDB_tables'], $tables);
|
||||
}
|
||||
|
||||
function oos_db_input($sStr) {
|
||||
|
||||
if (function_exists('mysqli::escape_string ')) {
|
||||
return mysqli::escape_string ($sStr);
|
||||
}
|
||||
|
||||
return addslashes($sStr);
|
||||
}
|
||||
|
||||
function oos_db_perform($table, $data, $action = 'INSERT', $parameters = '') {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
|
||||
reset($data);
|
||||
if ($action == 'INSERT') {
|
||||
$query = 'INSERT INTO ' . $table . ' (';
|
||||
foreach ( array_keys($data) as $columns ) {
|
||||
$query .= $columns . ', ';
|
||||
}
|
||||
$query = substr($query, 0, -2) . ') values (';
|
||||
reset($data);
|
||||
foreach ($data as $value) {
|
||||
switch ((string)$value) {
|
||||
case 'now()':
|
||||
$query .= 'now(), ';
|
||||
break;
|
||||
|
||||
case 'null':
|
||||
$query .= 'null, ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$query .= '\'' . oos_db_input($value) . '\', ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$query = substr($query, 0, -2) . ')';
|
||||
} elseif ($action == 'UPDATE') {
|
||||
$query = 'UPDATE ' . $table . ' set ';
|
||||
foreach($data as $columns => $value) {
|
||||
switch ((string)$value) {
|
||||
case 'now()':
|
||||
$query .= $columns . ' = now(), ';
|
||||
break;
|
||||
|
||||
case 'null':
|
||||
$query .= $columns .= ' = null, ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$query .= $columns . ' = \'' . oos_db_input($value) . '\', ';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$query = substr($query, 0, -2) . ' where ' . $parameters;
|
||||
}
|
||||
return $dbconn->Execute($query);
|
||||
}
|
||||
|
||||
function oos_db_prepare_input($sStr) {
|
||||
if (is_string($sStr)) {
|
||||
return trim(stripslashes($sStr));
|
||||
} elseif (is_array($sStr)) {
|
||||
reset($sStr);
|
||||
foreach($sStr as $key => $value) {
|
||||
|
||||
$sStr[$key] = oos_db_prepare_input($value);
|
||||
}
|
||||
return $sStr;
|
||||
} else {
|
||||
return $sStr;
|
||||
}
|
||||
}
|
||||
|
||||
function oosDBOutput($sStr) {
|
||||
if (get_magic_quotes_gpc()) {
|
||||
return mysqli::escape_string (stripslashes($sStr));
|
||||
} else {
|
||||
return mysqli::escape_string ($sStr);
|
||||
}
|
||||
}
|
||||
|
||||
function dosql($table, $flds) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$dict = NewDataDictionary($dbconn);
|
||||
|
||||
$taboptarray = array('mysql' => 'ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;', 'REPLACE');
|
||||
|
||||
$sqlarray = $dict->createTableSQL($table, $flds, $taboptarray);
|
||||
$dict->executeSqlArray($sqlarray);
|
||||
|
||||
}
|
||||
|
||||
function idxsql($idxname, $table, $idxflds) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$dict = NewDataDictionary($dbconn);
|
||||
|
||||
$sqlarray = $dict->CreateIndexSQL($idxname, $table, $idxflds);
|
||||
$dict->executeSqlArray($sqlarray);
|
||||
}
|
||||
|
||||
|
103
msd2/myoos/includes/functions/function_default.php
Normal file
103
msd2/myoos/includes/functions/function_default.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: general.php,v 1.212 2003/02/17 07:55:54 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Generate a path to categories
|
||||
*
|
||||
* @param $current_category_id
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_path($current_category_id = '', $parent_id = '', $gparent_id = '') {
|
||||
global $aCategoryPath;
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
if (!empty($current_category_id)) {
|
||||
$cp_size = count($aCategoryPath);
|
||||
if ($cp_size == 0) {
|
||||
$sCategoryNew = $current_category_id;
|
||||
} else {
|
||||
$sCategoryNew = '';
|
||||
if (oos_empty($parent_id) || oos_empty($gparent_id) ) {
|
||||
$categoriestable = $oostable['categories'];
|
||||
$query = "SELECT c.parent_id, p.parent_id as gparent_id
|
||||
FROM $categoriestable AS c,
|
||||
$categoriestable AS p
|
||||
WHERE c.categories_id = '" . intval($aCategoryPath[($cp_size-1)]) . "'
|
||||
AND p.categories_id = '" . intval($current_category_id) . "'";
|
||||
$parent_categories = $dbconn->GetRow($query);
|
||||
|
||||
$gparent_id = $parent_categories['gparent_id'];
|
||||
$parent_id = $parent_categories['parent_id'];
|
||||
}
|
||||
if ($parent_id == $gparent_id) {
|
||||
for ($i=0; $i < ($cp_size - 1); $i++) {
|
||||
$sCategoryNew .= '_' . $aCategoryPath[$i];
|
||||
}
|
||||
} else {
|
||||
for ($i=0; $i < $cp_size; $i++) {
|
||||
$sCategoryNew .= '_' . $aCategoryPath[$i];
|
||||
}
|
||||
}
|
||||
$sCategoryNew .= '_' . $current_category_id;
|
||||
|
||||
if (substr($sCategoryNew, 0, 1) == '_') {
|
||||
$sCategoryNew = substr($sCategoryNew, 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sCategoryNew = implode('_', $aCategoryPath);
|
||||
}
|
||||
|
||||
return $sCategoryNew;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of products in a category
|
||||
*
|
||||
* @param $category_id
|
||||
* @param $include_inactive
|
||||
* @return string
|
||||
*/
|
||||
function oos_total_products_in_category($category_id) {
|
||||
|
||||
$products_count = 0;
|
||||
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$productstable = $oostable['products'];
|
||||
$products_to_categoriestable = $oostable['products_to_categories'];
|
||||
$products = $dbconn->Execute("SELECT COUNT(*) AS total FROM $productstable p, $products_to_categoriestable p2c WHERE p.products_id = p2c.products_id AND p.products_setting = '2' AND p2c.categories_id = '" . intval($category_id) . "'");
|
||||
|
||||
$products_count += $products->fields['total'];
|
||||
|
||||
return $products_count;
|
||||
}
|
||||
|
||||
|
||||
|
225
msd2/myoos/includes/functions/function_encoded.php
Normal file
225
msd2/myoos/includes/functions/function_encoded.php
Normal file
@ -0,0 +1,225 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* Decode string encoded with htmlspecialchars()
|
||||
*
|
||||
* @param $sStr
|
||||
* @return string
|
||||
*/
|
||||
function oos_decode_special_chars($sStr){
|
||||
$sStr = str_replace('>', '>', $sStr);
|
||||
$sStr = str_replace('<', '<', $sStr);
|
||||
$sStr = str_replace(''', "'", $sStr);
|
||||
$sStr = str_replace('"', "\"", $sStr);
|
||||
$sStr = str_replace('&', '&', $sStr);
|
||||
|
||||
return $sStr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* string encoded
|
||||
*
|
||||
* @param $sStr
|
||||
* @return string
|
||||
*/
|
||||
function oos_make_filename($sStr) {
|
||||
|
||||
static $aFrom = array(
|
||||
' ',
|
||||
|
||||
'Ä',
|
||||
'ä',
|
||||
|
||||
'Ö',
|
||||
'ö',
|
||||
|
||||
'Ü',
|
||||
'ü',
|
||||
|
||||
'ß',
|
||||
|
||||
'é',
|
||||
'è',
|
||||
'ê',
|
||||
|
||||
'í',
|
||||
'ì',
|
||||
'î',
|
||||
|
||||
'á',
|
||||
'à',
|
||||
'â',
|
||||
'å',
|
||||
|
||||
'ó',
|
||||
'ò',
|
||||
'ô',
|
||||
'õ',
|
||||
|
||||
'ú',
|
||||
'ù',
|
||||
'û',
|
||||
|
||||
'ç',
|
||||
'Ç',
|
||||
|
||||
'ñ',
|
||||
|
||||
'ý');
|
||||
|
||||
static $aTo = array(
|
||||
'-',
|
||||
|
||||
'AE',
|
||||
'ae',
|
||||
|
||||
'OE',
|
||||
'oe',
|
||||
|
||||
'UE',
|
||||
'ue',
|
||||
|
||||
'ss',
|
||||
|
||||
'e',
|
||||
'e',
|
||||
'e',
|
||||
|
||||
'i',
|
||||
'i',
|
||||
'i',
|
||||
|
||||
'a',
|
||||
'a',
|
||||
'a',
|
||||
'a',
|
||||
|
||||
'o',
|
||||
'o',
|
||||
'o',
|
||||
'o',
|
||||
|
||||
'u',
|
||||
'u',
|
||||
'u',
|
||||
|
||||
'c',
|
||||
'C',
|
||||
|
||||
'n',
|
||||
|
||||
'y');
|
||||
// Replace international chars not detected by every locale
|
||||
$sStr = str_replace($aFrom, $aTo, $sStr);
|
||||
|
||||
$special_chars = array("?",
|
||||
"[",
|
||||
"]",
|
||||
"/",
|
||||
"\\",
|
||||
"=",
|
||||
"<",
|
||||
">",
|
||||
":",
|
||||
";",
|
||||
",",
|
||||
"'",
|
||||
"\"",
|
||||
"&",
|
||||
"$",
|
||||
"#",
|
||||
"*",
|
||||
"(",
|
||||
")",
|
||||
"|",
|
||||
"~",
|
||||
"`",
|
||||
"!",
|
||||
"{",
|
||||
"}",
|
||||
"%",
|
||||
"+",
|
||||
chr(0));
|
||||
//strip html tags from text
|
||||
$sStr = strip_tags($sStr);
|
||||
|
||||
// Nuke chars not allowed in our URI
|
||||
$sStr = preg_replace('#[^0-9a-z\.\_!;,\+\-]#i', '', $sStr);
|
||||
|
||||
// Recover delimiters as spaces
|
||||
$sStr = str_replace("\x01", " ", $sStr);
|
||||
|
||||
$sStr = preg_replace( "#\x{00a0}#siu", '', $sStr );
|
||||
$sStr = str_replace( $special_chars, '', $sStr );
|
||||
$sStr = str_replace( array( '%20', '+' ), '-', $sStr );
|
||||
$sStr = preg_replace( '/[\r\n\t -]+/', '-', $sStr );
|
||||
$sStr = trim( $sStr, '.-_' );
|
||||
$sStr = strtolower($sStr);
|
||||
|
||||
return $sStr;
|
||||
}
|
||||
|
||||
/**
|
||||
* string encoded
|
||||
*
|
||||
* @param $sStr
|
||||
* @return string
|
||||
*/
|
||||
function oos_html_to_xml($sStr) {
|
||||
|
||||
//Taken from Reverend's Jim feedparser
|
||||
//http://revjim.net/code/feedParser/feedParser-0.5.phps
|
||||
|
||||
static $aEntities = array(
|
||||
' ' => " ", '¡' => "¡", '¢' => "¢",
|
||||
'£' => "£", '¤' => "¤", '¥' => "¥",
|
||||
'¦' => "¦", '§' => "§", '¨' => "¨",
|
||||
'©' => "©", 'ª' => "ª", '«' => "«",
|
||||
'¬' => "¬", '­' => "­", '®' => "®",
|
||||
'¯' => "¯", '°' => "°", '±' => "±",
|
||||
'²' => "²", '³' => "³", '´' => "´",
|
||||
'µ' => "µ", '¶' => "¶", '·' => "·",
|
||||
'¸' => "¸", '¹' => "¹", 'º' => "º",
|
||||
'»' => "»", '¼' => "¼", '½' => "½",
|
||||
'¾' => "¾", '¿' => "¿", 'À' => "À",
|
||||
'Á' => "Á", 'Â' => "Â", 'Ã' => "Ã",
|
||||
'Ä' => "Ä", 'Å' => "Å", 'Æ' => "Æ",
|
||||
'Ç' => "Ç", 'È' => "È", 'É' => "É",
|
||||
'Ê' => "Ê", 'Ë' => "Ë", 'Ì' => "Ì",
|
||||
'Í' => "Í", 'Î' => "Î", 'Ï' => "Ï",
|
||||
'Ð' => "Ð", 'Ñ' => "Ñ", 'Ò' => "Ò",
|
||||
'Ó' => "Ó", 'Ô' => "Ô", 'Õ' => "Õ",
|
||||
'Ö' => "Ö", '×' => "×", 'Ø' => "Ø",
|
||||
'Ù' => "Ù", 'Ú' => "Ú", 'Û' => "Û",
|
||||
'Ü' => "Ü", 'Ý' => "Ý", 'Þ' => "Þ",
|
||||
'ß' => "ß", 'à' => "à", 'á' => "á",
|
||||
'â' => "â", 'ã' => "ã", 'ä' => "ä",
|
||||
'å' => "å", 'æ' => "æ", 'ç' => "ç",
|
||||
'è' => "è", 'é' => "é", 'ê' => "ê",
|
||||
'ë' => "ë", 'ì' => "ì", 'í' => "í",
|
||||
'î' => "î", 'ï' => "ï", 'ð' => "ð",
|
||||
'ñ' => "ñ", 'ò' => "ò", 'ó' => "ó",
|
||||
'ô' => "ô", 'õ' => "õ", 'ö' => "ö",
|
||||
'÷' => "÷", 'ø' => "ø", 'ù' => "ù",
|
||||
'ú' => "ú", 'û' => "û", 'ü' => "ü",
|
||||
'ý' => "ý", 'þ' => "þ", 'ÿ' => "ÿ"
|
||||
);
|
||||
$sStr = strtr($sStr, $aEntities);
|
||||
|
||||
return $sStr;
|
||||
}
|
||||
|
70
msd2/myoos/includes/functions/function_featured.php
Normal file
70
msd2/myoos/includes/functions/function_featured.php
Normal file
@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Sets the status of a featured product
|
||||
*/
|
||||
function oos_set_featured_status($nFeaturedId, $status) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$featuredtable = $oostable['featured'];
|
||||
return $dbconn->Execute("UPDATE $featuredtable
|
||||
SET status = '" . oos_db_input($status) . "',
|
||||
date_status_change = now()
|
||||
WHERE featured_id = '" . intval($nFeaturedId) . "'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Auto expire featured products
|
||||
*/
|
||||
function oos_expire_featured() {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$featuredtable = $oostable['featured'];
|
||||
$sql = "SELECT featured_id
|
||||
FROM $featuredtable
|
||||
WHERE status = '1'
|
||||
AND now() >= expires_date
|
||||
AND expires_date > 0";
|
||||
if (USE_CACHE == 'true') {
|
||||
$featured_result = $dbconn->CacheExecute(15, $sql);
|
||||
} else {
|
||||
$featured_result = $dbconn->Execute($sql);
|
||||
}
|
||||
if (!$featured_result) {return;}
|
||||
|
||||
if ($featured_result->RecordCount() > 0) {
|
||||
while ($featured = $featured_result->fields) {
|
||||
oos_set_featured_status($featured['featured_id'], '0');
|
||||
// Move that ADOdb pointer!
|
||||
$featured_result->MoveNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
190
msd2/myoos/includes/functions/function_global.php
Normal file
190
msd2/myoos/includes/functions/function_global.php
Normal file
@ -0,0 +1,190 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* global
|
||||
*
|
||||
* @package global
|
||||
* @copyright (C) 2016 by the MyOOS Development Team.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link https://www.oos-shop.de
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* Output a raw date string in the selected locale date format
|
||||
* $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @param $raw_date
|
||||
* @return string
|
||||
*/
|
||||
function oos_date_long($raw_date) {
|
||||
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return FALSE;
|
||||
|
||||
$year = intval(substr($raw_date, 0, 4));
|
||||
$month = intval(substr($raw_date, 5, 2));
|
||||
$day = intval(substr($raw_date, 8, 2));
|
||||
$hour = intval(substr($raw_date, 11, 2));
|
||||
$minute = intval(substr($raw_date, 14, 2));
|
||||
$second = intval(substr($raw_date, 17, 2));
|
||||
|
||||
return strftime(DATE_FORMAT_LONG, mktime($hour,$minute,$second,$month,$day,$year));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output a raw date string in the selected locale date format
|
||||
* $raw_date needs to be in this format: YYYY-MM-DD HH:MM:SS
|
||||
*
|
||||
* @param $raw_date
|
||||
* @return string
|
||||
*/
|
||||
function oos_date_short($raw_date) {
|
||||
if ( ($raw_date == '0000-00-00 00:00:00') || ($raw_date == '') ) return FALSE;
|
||||
|
||||
$year = substr($raw_date, 0, 4);
|
||||
$month = intval(substr($raw_date, 5, 2));
|
||||
$day = intval(substr($raw_date, 8, 2));
|
||||
$hour = intval(substr($raw_date, 11, 2));
|
||||
$minute = intval(substr($raw_date, 14, 2));
|
||||
$second = intval(substr($raw_date, 17, 2));
|
||||
|
||||
if (@date('Y', mktime($hour, $minute, $second, $month, $day, $year)) == $year) {
|
||||
return date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, $year));
|
||||
} else {
|
||||
return preg_match('/2037' . '$/', $year, date(DATE_FORMAT, mktime($hour, $minute, $second, $month, $day, 2037)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a local directory path (without trailing slash)
|
||||
*
|
||||
* @param $sPath
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_local_path($sPath) {
|
||||
if (substr($sPath, -1) == '/') $sPath = substr($sPath, 0, -1);
|
||||
|
||||
return $sPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a product ID from a product ID with attributes
|
||||
*
|
||||
* @param $uprid
|
||||
* @return string
|
||||
*/
|
||||
function oos_get_product_id($uprid) {
|
||||
$pieces = explode('{', $uprid);
|
||||
|
||||
if (is_numeric($pieces[0])) {
|
||||
return $pieces[0];
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function oos_is_not_null($value) {
|
||||
if (is_array($value)) {
|
||||
if (!empty($value)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
if (($value != '') && (strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function oos_empty($value) {
|
||||
if (is_array($value)) {
|
||||
if (sizeof($value) > 0) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
} else {
|
||||
if ((strtolower($value) != 'null') && (strlen(trim($value)) > 0)) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a random value
|
||||
*
|
||||
* @param $min
|
||||
* @param $max
|
||||
* @return string
|
||||
*/
|
||||
function oos_rand($min = null, $max = null) {
|
||||
static $seeded;
|
||||
|
||||
if (!isset($seeded)) {
|
||||
mt_srand((double)microtime()*1000000);
|
||||
$seeded = TRUE;
|
||||
}
|
||||
|
||||
if (isset($min) && isset($max)) {
|
||||
if ($min >= $max) {
|
||||
return $min;
|
||||
} else {
|
||||
return mt_rand($min, $max);
|
||||
}
|
||||
} else {
|
||||
return mt_rand();
|
||||
}
|
||||
}
|
||||
|
||||
function oos_create_random_value($length, $type = 'mixed') {
|
||||
if ( ($type != 'mixed') && ($type != 'chars') && ($type != 'digits')) return FALSE;
|
||||
|
||||
$rand_value = '';
|
||||
while (strlen($rand_value) < $length) {
|
||||
if ($type == 'digits') {
|
||||
$char = oos_rand(0,9);
|
||||
} else {
|
||||
$char = chr(oos_rand(0,255));
|
||||
}
|
||||
if ($type == 'mixed') {
|
||||
if (preg_match('!^[a-z0-9]$!', $char)) $rand_value .= $char;
|
||||
} elseif ($type == 'chars') {
|
||||
if (preg_match('!^[a-z]$!', $char)) $rand_value .= $char;
|
||||
} elseif ($type == 'digits') {
|
||||
if (preg_match('!^[0-9]$!', $char)) $rand_value .= $char;
|
||||
}
|
||||
}
|
||||
|
||||
return $rand_value;
|
||||
}
|
||||
|
141
msd2/myoos/includes/functions/function_input.php
Normal file
141
msd2/myoos/includes/functions/function_input.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
Id: pnAPI.php,v 1.41 2003/07/12 21:44:40 markwest Exp
|
||||
----------------------------------------------------------------------
|
||||
PostNuke Content Management System
|
||||
Copyright (C) 2001 by the Post-Nuke Development Team.
|
||||
http://www.postnuke.com/
|
||||
----------------------------------------------------------------------
|
||||
LICENSE
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License (GPL)
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||
----------------------------------------------------------------------
|
||||
Original Author of file: Jim McDonald
|
||||
Purpose of file: The PostNuke API
|
||||
----------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* security
|
||||
*
|
||||
* @link http://www.postnuke.com/
|
||||
* @package security
|
||||
* @version $Revision: 1.2 $ - changed by $Author: r23 $ on $Date: 2008/08/15 16:28:30 $
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Protects better diverse attempts of Cross-Site Scripting
|
||||
* attacks, thanks to webmedic, Timax, larsneo.
|
||||
*
|
||||
* Lets validate the current php version and set globals
|
||||
* accordingly.
|
||||
* Do not change this value unless you know what you are
|
||||
* doing you have been warned!
|
||||
*/
|
||||
function oos_secure_input() {
|
||||
|
||||
$aContents = oos_get_content();
|
||||
|
||||
# Cross-Site Scripting attack defense - Sent by larsneo
|
||||
# some syntax checking against injected javascript
|
||||
# extended by Neo
|
||||
|
||||
/**
|
||||
* Lets now sanitize the GET vars
|
||||
*/
|
||||
if (count($_GET) > 0) {
|
||||
foreach ($_GET as $secvalue) {
|
||||
if (!is_array($secvalue)) {
|
||||
if ((preg_match("/<[^>]*script*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/.*[[:space:]](or|and)[[:space:]].*(=|like).*/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*style*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*window.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*alert*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*document.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*cookie*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/\"/i", $secvalue))
|
||||
) {
|
||||
oos_redirect(oos_href_link($aContents['home']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lets now sanitize the POST vars
|
||||
*/
|
||||
if (count($_POST) > 0) {
|
||||
foreach ($_POST as $secvalue) {
|
||||
if (!is_array($secvalue)) {
|
||||
if ((preg_match("/<[^>]*script*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*window.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*alert*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*document.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*cookie*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue))
|
||||
) {
|
||||
oos_redirect(oos_href_link($aContents['home']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Lets now sanitize the COOKIE vars
|
||||
*/
|
||||
if (count($_COOKIE) > 0) {
|
||||
foreach ($_COOKIE as $secvalue) {
|
||||
if (!is_array($secvalue)) {
|
||||
if ((preg_match("/<[^>]*script*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/.*[[:space:]](or|and)[[:space:]].*(=|like).*/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*object*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*iframe*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*applet*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*meta*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*style*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*form*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*window.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*alert*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*document.*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*cookie*\"?[^>]*>/i", $secvalue)) ||
|
||||
(preg_match("/<[^>]*img*\"?[^>]*>/i", $secvalue))
|
||||
) {
|
||||
oos_redirect(oos_href_link($aContents['home']));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
1345
msd2/myoos/includes/functions/function_kernel.php
Normal file
1345
msd2/myoos/includes/functions/function_kernel.php
Normal file
File diff suppressed because it is too large
Load Diff
48
msd2/myoos/includes/functions/function_key_generate.php
Normal file
48
msd2/myoos/includes/functions/function_key_generate.php
Normal file
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: key_generate.php
|
||||
----------------------------------------------------------------------
|
||||
osCommerce Shipping Management Module
|
||||
Copyright (c) 2002 - Oliver Baelde
|
||||
http://www.francecontacts.com
|
||||
dev@francecontacts.com
|
||||
- eCommerce Solutions development and integration -
|
||||
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2002 - 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
function RandomPassword( $passwordLength ) {
|
||||
$newkey2 = "";
|
||||
for ($index = 1; $index <= $passwordLength; $index++) {
|
||||
// Pick random number between 1 and 62
|
||||
$randomNumber = rand(1, 62);
|
||||
// Select random character based on mapping.
|
||||
if ($randomNumber < 11)
|
||||
$newkey2 .= chr($randomNumber + 48 - 1); // [ 1,10] => [0,9]
|
||||
elseif ($randomNumber < 37)
|
||||
$newkey2 .= chr($randomNumber + 65 - 10); // [11,36] => [A,Z]
|
||||
else
|
||||
$newkey2 .= chr($randomNumber + 97 - 36); // [37,62] => [a,z]
|
||||
}
|
||||
return $newkey2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
54
msd2/myoos/includes/functions/function_listing.php
Normal file
54
msd2/myoos/includes/functions/function_listing.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: general.php,v 1.212 2003/02/17 07:55:54 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* listing
|
||||
*
|
||||
* @link https://www.oos-shop.de
|
||||
* @package listing
|
||||
* @version $Revision: 1.1 $ - changed by $Author: r23 $ on $Date: 2007/06/12 16:49:27 $
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Return table heading with sorting capabilities
|
||||
*
|
||||
* @param $sortby
|
||||
* @param $colnum,
|
||||
* @param $heading
|
||||
* @return string
|
||||
*/
|
||||
function oos_create_sort_heading($sortby, $colnum, $heading) {
|
||||
global $sContent, $aLang;
|
||||
|
||||
$sort_prefix = '';
|
||||
$sort_suffix = '';
|
||||
|
||||
if ($sortby) {
|
||||
$sort_prefix = '<a href="' . oos_href_link($sContent, oos_get_all_get_parameters(array('page', 'info', 'sort')) . 'page=1&sort=' . $colnum . ($sortby == $colnum . 'a' ? 'd' : 'a')) . '" title="' . $aLang['text_sort_products'] . ($sortby == $colnum . 'd' || substr($sortby, 0, 1) != $colnum ? $aLang['text_ascendingly'] : $aLang['text_descendingly']) . $aLang['text_by'] . $heading . '">' ;
|
||||
$sort_suffix = (substr($sortby, 0, 1) == $colnum ? (substr($sortby, 1, 1) == 'a' ? '+' : '-') : '') . '</a>';
|
||||
}
|
||||
|
||||
return $sort_prefix . $heading . $sort_suffix;
|
||||
}
|
||||
|
||||
|
305
msd2/myoos/includes/functions/function_output.php
Normal file
305
msd2/myoos/includes/functions/function_output.php
Normal file
@ -0,0 +1,305 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: html_output.php,v 1.49 2003/02/11 01:31:02 hpdl
|
||||
html_output.php 1498 2007-03-29 14:04:50Z hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* html output
|
||||
*
|
||||
* @link https://www.oos-shop.de
|
||||
* @package html output
|
||||
* @version $Revision: 1.3 $ - changed by $Author: r23 $ on $Date: 2008/08/14 10:24:05 $
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* The HTML href link wrapper function
|
||||
*
|
||||
* @param $modul
|
||||
* @param $page
|
||||
* @param $parameters
|
||||
* @param $add_session_id
|
||||
* @param $search_engine_safe
|
||||
* @return string
|
||||
*/
|
||||
function oos_href_link($page = '', $parameters = '', $add_session_id = TRUE, $search_engine_safe = TRUE) {
|
||||
global $session, $oEvent, $spider_flag;
|
||||
|
||||
$page = oos_output_string($page);
|
||||
|
||||
$link = OOS_HTTPS_SERVER . OOS_SHOP;
|
||||
|
||||
if (oos_is_not_null($parameters)) {
|
||||
$link .= 'index.php?content=' . $page . '&' . oos_output_string($parameters);
|
||||
} else {
|
||||
$link .= 'index.php?content=' . $page;
|
||||
}
|
||||
|
||||
$separator = '&';
|
||||
|
||||
while ( (substr($link, -5) == '&') || (substr($link, -1) == '?') ) {
|
||||
if (substr($link, -1) == '?') {
|
||||
$link = substr($link, 0, -1);
|
||||
} else {
|
||||
$link = substr($link, 0, -5);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_SESSION)) {
|
||||
|
||||
// Add the session ID when moving from HTTP and HTTPS servers or when SID is defined
|
||||
if ($add_session_id == TRUE) {
|
||||
$_sid = $session->getName() . '=' . $session->getId();
|
||||
}
|
||||
|
||||
if ( $spider_flag === FALSE) $_sid = NULL;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if ( ($search_engine_safe == TRUE) && $oEvent->installed_plugin('sefu') ) {
|
||||
$link = str_replace(array('?', '&', '='), '/', $link);
|
||||
|
||||
$separator = '?';
|
||||
|
||||
$pos = strpos ($link, 'action');
|
||||
if ($pos === FALSE) {
|
||||
$url_rewrite = new url_rewrite;
|
||||
$link = $url_rewrite->transform_uri($link);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_sid)) {
|
||||
$link .= $separator . oos_output_string($_sid);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The HTML image wrapper function
|
||||
*
|
||||
* @param $src
|
||||
* @param $title
|
||||
* @param $width
|
||||
* @param $height
|
||||
* @param $parameters
|
||||
* @return string
|
||||
*/
|
||||
function oos_image($src, $title = null, $width = 0, $height = 0, $parameters = null) {
|
||||
if (empty($src) || ($src == OOS_IMAGES)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$image = '<img class="img-fluid" src="' . oos_output_string($src) . '" border="0" alt="' . oos_output_string($title) . '"';
|
||||
|
||||
if (!empty($title)) {
|
||||
$image .= ' title="' . oos_output_string($title) . '"';
|
||||
}
|
||||
|
||||
if (!empty($parameters)) {
|
||||
$image .= ' ' . oos_output_string($parameters);
|
||||
}
|
||||
|
||||
$image .= ' />';
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output a form input field
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
* @param $type
|
||||
* @param $reinsert_value
|
||||
* @return string
|
||||
*/
|
||||
function oos_draw_input_field($name, $value = '', $parameters = '', $type = 'text', $reinsert_value = TRUE) {
|
||||
|
||||
$field = '<input type="' . oos_output_string($type) . '" name="' . oos_output_string($name) . '"';
|
||||
|
||||
if ( ($reinsert_value == TRUE) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
|
||||
if (isset($_GET[$name]) && is_string($_GET[$name])) {
|
||||
$value = stripslashes($_GET[$name]);
|
||||
} elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
|
||||
$value = stripslashes($_POST[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (oos_is_not_null($value)) {
|
||||
$field .= ' value="' . oos_output_string($value) . '"';
|
||||
}
|
||||
|
||||
if (oos_is_not_null($parameters)) {
|
||||
$field .= ' ' . $parameters;
|
||||
}
|
||||
|
||||
$field .= ' />';
|
||||
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output a selection field - alias function for oos_draw_checkbox_field() and oos_draw_radio_field()
|
||||
*
|
||||
* @param $name
|
||||
* @param $type
|
||||
* @param $value
|
||||
* @param $checked
|
||||
* @param $parameters
|
||||
* @return string
|
||||
*/
|
||||
function oos_draw_select_field($name, $type, $value = null, $checked = FALSE, $parameters = null)
|
||||
{
|
||||
|
||||
$selection = '<input type="' . oos_output_string($type) . '" name="' . oos_output_string($name) . '"';
|
||||
|
||||
if (!empty( $value )) $selection .= ' value="' . oos_output_string($value) . '"';
|
||||
|
||||
if ( ($checked == TRUE) || (isset($_GET[$name]) && is_string($_GET[$name]) && (($_GET[$name] == 'on') || (stripslashes($_GET[$name]) == $value)))
|
||||
|| (isset($_POST[$name]) && is_string($_POST[$name]) && (($_POST[$name] == 'on') || (stripslashes($_POST[$name]) == $value)))
|
||||
) {
|
||||
$selection .= ' checked="checked"';
|
||||
}
|
||||
|
||||
if (!empty( $parameters ) && is_string( $parameters ) ) {
|
||||
$selection .= ' ' . $parameters;
|
||||
}
|
||||
|
||||
|
||||
$selection .= ' />';
|
||||
|
||||
return $selection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output a form checkbox field
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $checked
|
||||
* @param $parameters
|
||||
*/
|
||||
function oos_draw_checkbox_field($name, $value = '', $checked = FALSE, $parameters = '') {
|
||||
return oos_draw_select_field($name, 'checkbox', $value, $checked, $parameters);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Output a form radio field
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $checked
|
||||
* @param $parameters
|
||||
*/
|
||||
function oos_draw_radio_field($name, $value = '', $checked = FALSE, $parameters = '') {
|
||||
return oos_draw_select_field($name, 'radio', $value, $checked, $parameters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output a form hidden field
|
||||
*
|
||||
* @param $name
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*/
|
||||
function oos_draw_hidden_field($name, $value = '', $parameters = '')
|
||||
{
|
||||
$field = '<input type="hidden" name="' . oos_output_string($name) . '"';
|
||||
|
||||
|
||||
if (strlen($value) > 0) {
|
||||
$field .= ' value="' . oos_output_string($value) . '"';
|
||||
} elseif ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) {
|
||||
if ( (isset($_GET[$name]) && is_string($_GET[$name])) ) {
|
||||
$field .= ' value="' . oos_output_string(stripslashes($_GET[$name])) . '"';
|
||||
} elseif ( (isset($_POST[$name]) && is_string($_POST[$name])) ) {
|
||||
$field .= ' value="' . oos_output_string(stripslashes($_POST[$name])) . '"';
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($parameters)) {
|
||||
$field .= ' ' . $parameters;
|
||||
}
|
||||
|
||||
$field .= ' />';
|
||||
|
||||
return $field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output a form pull down menu
|
||||
*
|
||||
* @param $$name
|
||||
* @param $values
|
||||
* @param $default
|
||||
* @param $parameters
|
||||
* @param $required
|
||||
*/
|
||||
function oos_draw_pull_down_menu($name, $values, $default = null, $parameters = null, $required = FALSE)
|
||||
{
|
||||
|
||||
$field = '<select name="' . oos_output_string($name) . '"';
|
||||
|
||||
if (!empty( $parameters ) && is_string( $parameters ) ) $field .= ' ' . $parameters;
|
||||
|
||||
$field .= '>';
|
||||
|
||||
if (empty($default) && ( (isset($_GET[$name]) && is_string($_GET[$name])) || (isset($_POST[$name]) && is_string($_POST[$name])) ) ) {
|
||||
if (isset($_GET[$name]) && is_string($_GET[$name])) {
|
||||
$default = stripslashes($_GET[$name]);
|
||||
} elseif (isset($_POST[$name]) && is_string($_POST[$name])) {
|
||||
$default = stripslashes($_POST[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for ($i=0, $n=count($values); $i<$n; $i++) {
|
||||
$field .= '<option value="' . oos_output_string($values[$i]['id']) . '"';
|
||||
if ($default == $values[$i]['id']) {
|
||||
$field .= ' selected="selected"';
|
||||
}
|
||||
|
||||
$field .= '>' . oos_output_string($values[$i]['text']) . '</option>';
|
||||
}
|
||||
$field .= '</select>';
|
||||
|
||||
if ($required == TRUE) $field .= TEXT_FIELD_REQUIRED;
|
||||
|
||||
return $field;
|
||||
}
|
63
msd2/myoos/includes/functions/function_password.php
Normal file
63
msd2/myoos/includes/functions/function_password.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: password_funcs.php,v 1.10 2003/02/11 01:31:02 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* This funstion validates a plain text password with an
|
||||
* encrpyted password
|
||||
*
|
||||
* @param $sPlain
|
||||
* @param $sEncrypted
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_validate_password($sPlain, $sEncrypted) {
|
||||
|
||||
if (oos_is_not_null($sPlain) && oos_is_not_null($sEncrypted)) {
|
||||
if (!class_exists('PasswordHash')) {
|
||||
require_once MYOOS_INCLUDE_PATH . '/includes/lib/phpass/PasswordHash.php';
|
||||
}
|
||||
|
||||
$oHasher = new PasswordHash( 8, TRUE );
|
||||
|
||||
return $oHasher->CheckPassword($sPlain, $sEncrypted);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function makes a new password from a plaintext password.
|
||||
*
|
||||
* @param $sPlain
|
||||
* @return string
|
||||
*/
|
||||
function oos_encrypt_password($sPlain) {
|
||||
|
||||
if (!class_exists('PasswordHash')) {
|
||||
require_once MYOOS_INCLUDE_PATH . '/includes/lib/phpass/PasswordHash.php';
|
||||
}
|
||||
|
||||
$oHasher = new PasswordHash( 8, TRUE );
|
||||
|
||||
return $oHasher->HashPassword($sPlain);
|
||||
}
|
347
msd2/myoos/includes/functions/function_search.php
Normal file
347
msd2/myoos/includes/functions/function_search.php
Normal file
@ -0,0 +1,347 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: general.php,v 1.212 2003/02/17 07:55:54 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Return all subcategory IDs
|
||||
*
|
||||
* @param $aSubcategories
|
||||
* @param $nParentId
|
||||
*/
|
||||
function oos_get_subcategories(&$aSubcategories, $nParentId = 0) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$categoriestable = $oostable['categories'];
|
||||
$query = "SELECT categories_id
|
||||
FROM $categoriestable
|
||||
WHERE parent_id = '" . intval($nParentId) . "'";
|
||||
$result = $dbconn->Execute($query);
|
||||
|
||||
while ($subcategories = $result->fields) {
|
||||
$aSubcategories[count($aSubcategories)] = $subcategories['categories_id'];
|
||||
if ($subcategories['categories_id'] != $nParentId) {
|
||||
oos_get_subcategories($aSubcategories, $subcategories['categories_id']);
|
||||
}
|
||||
|
||||
// Move that ADOdb pointer!
|
||||
$result->MoveNext();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse search string into indivual objects
|
||||
*
|
||||
* @param $search_str
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_parse_search_string($sSearch = '', &$objects) {
|
||||
$sSearch = trim(strtolower($sSearch));
|
||||
|
||||
// Break up $sSearch on whitespace; quoted string will be reconstructed later
|
||||
$pieces = preg_split('/[[:space:]]+/', $sSearch);
|
||||
$objects = array();
|
||||
$tmpstring = '';
|
||||
$flag = '';
|
||||
|
||||
for ($k=0; $k<count($pieces); $k++) {
|
||||
while (substr($pieces[$k], 0, 1) == '(') {
|
||||
$objects[] = '(';
|
||||
if (strlen($pieces[$k]) > 1) {
|
||||
$pieces[$k] = substr($pieces[$k], 1);
|
||||
} else {
|
||||
$pieces[$k] = '';
|
||||
}
|
||||
}
|
||||
|
||||
$post_objects = array();
|
||||
|
||||
while (substr($pieces[$k], -1) == ')') {
|
||||
$post_objects[] = ')';
|
||||
if (strlen($pieces[$k]) > 1) {
|
||||
$pieces[$k] = substr($pieces[$k], 0, -1);
|
||||
} else {
|
||||
$pieces[$k] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Check individual words
|
||||
|
||||
if ( (substr($pieces[$k], -1) != '"') && (substr($pieces[$k], 0, 1) != '"') ) {
|
||||
$objects[] = trim($pieces[$k]);
|
||||
|
||||
for ($j=0; $j<count($post_objects); $j++) {
|
||||
$objects[] = $post_objects[$j];
|
||||
}
|
||||
} else {
|
||||
|
||||
/*
|
||||
This means that the $piece is either the beginning or the end of a string.
|
||||
So, we'll slurp up the $pieces and stick them together until we get to the
|
||||
end of the string or run out of pieces.
|
||||
*/
|
||||
|
||||
// Add this word to the $tmpstring, starting the $tmpstring
|
||||
$tmpstring = trim(preg_match('/"/', ' ', $pieces[$k]));
|
||||
|
||||
// Check for one possible exception to the rule. That there is a single quoted word.
|
||||
if (substr($pieces[$k], -1 ) == '"') {
|
||||
// Turn the flag off for future iterations
|
||||
$flag = 'off';
|
||||
|
||||
$objects[] = trim($pieces[$k]);
|
||||
|
||||
for ($j=0; $j<count($post_objects); $j++) {
|
||||
$objects[] = $post_objects[$j];
|
||||
}
|
||||
|
||||
unset($tmpstring);
|
||||
|
||||
// Stop looking for the end of the string and move onto the next word.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, turn on the flag to indicate no quotes have been found attached to this word in the string.
|
||||
$flag = 'on';
|
||||
|
||||
// Move on to the next word
|
||||
$k++;
|
||||
|
||||
// Keep reading until the end of the string as long as the $flag is on
|
||||
|
||||
while ( ($flag == 'on') && ($k < count($pieces)) ) {
|
||||
while (substr($pieces[$k], -1) == ')') {
|
||||
$post_objects[] = ')';
|
||||
if (strlen($pieces[$k]) > 1) {
|
||||
$pieces[$k] = substr($pieces[$k], 0, -1);
|
||||
} else {
|
||||
$pieces[$k] = '';
|
||||
}
|
||||
}
|
||||
|
||||
// If the word doesn't end in double quotes, append it to the $tmpstring.
|
||||
if (substr($pieces[$k], -1) != '"') {
|
||||
// Tack this word onto the current string entity
|
||||
$tmpstring .= ' ' . $pieces[$k];
|
||||
|
||||
// Move on to the next word
|
||||
$k++;
|
||||
continue;
|
||||
} else {
|
||||
/*
|
||||
If the $piece ends in double quotes, strip the double quotes, tack the
|
||||
$piece onto the tail of the string, push the $tmpstring onto the $haves,
|
||||
kill the $tmpstring, turn the $flag "off", and return.
|
||||
*/
|
||||
$sTmp = preg_replace('/"/', ' ', $pieces[$k]);
|
||||
$tmpstring .= ' ' . trim($sTmp);
|
||||
|
||||
|
||||
// Push the $tmpstring onto the array of stuff to search for
|
||||
$objects[] = trim($tmpstring);
|
||||
|
||||
for ($j=0; $j<count($post_objects); $j++) {
|
||||
$objects[] = $post_objects[$j];
|
||||
}
|
||||
|
||||
unset($tmpstring);
|
||||
|
||||
// Turn off the flag to exit the loop
|
||||
$flag = 'off';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add default logical operators if needed
|
||||
$temp = array();
|
||||
for($i=0; $i<(count($objects)-1); $i++) {
|
||||
$temp[count($temp)] = $objects[$i];
|
||||
|
||||
if ( ($objects[$i] != 'and') &&
|
||||
($objects[$i] != 'or') &&
|
||||
($objects[$i] != '(') &&
|
||||
($objects[$i] != ')') &&
|
||||
($objects[$i+1] != 'and') &&
|
||||
($objects[$i+1] != 'or') &&
|
||||
($objects[$i+1] != '(') &&
|
||||
($objects[$i+1] != ')') ) {
|
||||
$temp[count($temp)] = ADVANCED_SEARCH_DEFAULT_OPERATOR;
|
||||
}
|
||||
}
|
||||
$temp[count($temp)] = $objects[$i];
|
||||
$objects = $temp;
|
||||
|
||||
$keyword_count = 0;
|
||||
$operator_count = 0;
|
||||
$balance = 0;
|
||||
for($i=0; $i<count($objects); $i++) {
|
||||
if ($objects[$i] == '(') $balance --;
|
||||
if ($objects[$i] == ')') $balance ++;
|
||||
if ( ($objects[$i] == 'and') || ($objects[$i] == 'or') ) {
|
||||
$operator_count ++;
|
||||
} elseif ( ($objects[$i]) && ($objects[$i] != '(') && ($objects[$i] != ')') ) {
|
||||
$keyword_count ++;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ($operator_count < $keyword_count) && ($balance == 0) ) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check date
|
||||
*
|
||||
* @param $date_to_check
|
||||
* @param $format_string
|
||||
* @param $date_array
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_checkdate($date_to_check, $format_string, &$date_array) {
|
||||
$separator_idx = -1;
|
||||
|
||||
$separators = array('-', ' ', '/', '.');
|
||||
$month_abbr = array('jan','feb','mar','apr','may','jun','jul','aug','sep','oct','nov','dec');
|
||||
$no_of_days = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
|
||||
|
||||
$format_string = strtolower($format_string);
|
||||
|
||||
if (strlen($date_to_check) != strlen($format_string)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$size = count($separators);
|
||||
for ($i=0; $i<$size; $i++) {
|
||||
$pos_separator = strpos($date_to_check, $separators[$i]);
|
||||
if ($pos_separator != FALSE) {
|
||||
$date_separator_idx = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0; $i<$size; $i++) {
|
||||
$pos_separator = strpos($format_string, $separators[$i]);
|
||||
if ($pos_separator != FALSE) {
|
||||
$format_separator_idx = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($date_separator_idx != $format_separator_idx) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($date_separator_idx != -1) {
|
||||
$format_string_array = explode( $separators[$date_separator_idx], $format_string );
|
||||
if (count($format_string_array) != 3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$date_to_check_array = explode( $separators[$date_separator_idx], $date_to_check );
|
||||
if (count($date_to_check_array) != 3) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$size = count($format_string_array);
|
||||
for ($i=0; $i<$size; $i++) {
|
||||
if ($format_string_array[$i] == 'mm' || $format_string_array[$i] == 'mmm') $month = $date_to_check_array[$i];
|
||||
if ($format_string_array[$i] == 'dd') $day = $date_to_check_array[$i];
|
||||
if ( ($format_string_array[$i] == 'yyyy') || ($format_string_array[$i] == 'aaaa') ) $year = $date_to_check_array[$i];
|
||||
}
|
||||
} else {
|
||||
if (strlen($format_string) == 8 || strlen($format_string) == 9) {
|
||||
$pos_month = strpos($format_string, 'mmm');
|
||||
if ($pos_month != FALSE) {
|
||||
$month = substr( $date_to_check, $pos_month, 3 );
|
||||
$size = count($month_abbr);
|
||||
for ($i=0; $i<$size; $i++) {
|
||||
if ($month == $month_abbr[$i]) {
|
||||
$month = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$month = substr($date_to_check, strpos($format_string, 'mm'), 2);
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$day = substr($date_to_check, strpos($format_string, 'dd'), 2);
|
||||
$year = substr($date_to_check, strpos($format_string, 'yyyy'), 4);
|
||||
}
|
||||
|
||||
if (strlen($year) != 4) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!settype($year, 'integer') || !settype($month, 'integer') || !settype($day, 'integer')) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($month > 12 || $month < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($day < 1) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (oos_is_leap_year($year)) {
|
||||
$no_of_days[1] = 29;
|
||||
}
|
||||
|
||||
if ($day > $no_of_days[$month - 1]) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$date_array = array($year, $month, $day);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if year is a leap year
|
||||
*
|
||||
* @param $year
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_is_leap_year($year) {
|
||||
if ($year % 100 == 0) {
|
||||
if ($year % 400 == 0) return TRUE;
|
||||
} else {
|
||||
if (($year % 4) == 0) return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
239
msd2/myoos/includes/functions/function_server.php
Normal file
239
msd2/myoos/includes/functions/function_server.php
Normal file
@ -0,0 +1,239 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: xarServer.php 1.62 03/10/28 19:11:18+01:00 mikespub
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* HTTP Protocol Server/Request/Response utilities
|
||||
*
|
||||
* @package server
|
||||
* @copyright (C) 2002 by the Xaraya Development Team.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link http://www.xaraya.com
|
||||
* @author Marco Canini <marco@xaraya.com>
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Gets a server variable
|
||||
*
|
||||
* Returns the value of $name server variable.
|
||||
* Accepted values for $name are exactly the ones described by the
|
||||
* {@link http://www.php.net/manual/en/reserved.variables.html#reserved.variables.server PHP manual}.
|
||||
* If the server variable doesn't exist void is returned.
|
||||
*
|
||||
* Last Editor: Author: r23
|
||||
* @author Marco Canini <marco@xaraya.com>, Michel Dalle
|
||||
* @access public
|
||||
* @param name string the name of the variable
|
||||
* @return mixed value of the variable
|
||||
*/
|
||||
function oos_server_get_var($sKey) {
|
||||
if (isset($_SERVER[$sKey])) {
|
||||
return $_SERVER[$sKey];
|
||||
}
|
||||
if (isset($_ENV[$sKey])) {
|
||||
return $_ENV[$sKey];
|
||||
}
|
||||
|
||||
if ($val = getenv($sKey)) {
|
||||
return $val;
|
||||
}
|
||||
return; // we found nothing here
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Has a server variable
|
||||
*
|
||||
* @author r23 <info@r23.de>
|
||||
* @access public
|
||||
* @param string
|
||||
* @return mixed
|
||||
*/
|
||||
function oos_server_has_var($sKey) {
|
||||
if (isset($_SERVER[$sKey])) {
|
||||
return TRUE;
|
||||
}
|
||||
return (bool)getenv($sKey);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the host name
|
||||
*
|
||||
* Returns the server host name fetched from HTTP headers when possible.
|
||||
* The host name is in the canonical form (host + : + port) when the port is different than 80.
|
||||
*
|
||||
* Last Editor: Author: r23
|
||||
* @author Marco Canini <marco@xaraya.com>
|
||||
* @access public
|
||||
* @return string HTTP host name
|
||||
*/
|
||||
function oos_server_get_host() {
|
||||
$sServer = oos_server_get_var('HTTP_HOST');
|
||||
if (empty($sServer)) {
|
||||
// HTTP_HOST is reliable only for HTTP 1.1
|
||||
$sServer = oos_server_get_var('SERVER_NAME');
|
||||
$port = oos_server_get_var('SERVER_PORT');
|
||||
if ($port != '80') $sServer .= ":$port";
|
||||
}
|
||||
return $sServer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the current protocol
|
||||
*
|
||||
* Returns the HTTP protocol used by current connection, it could be 'http' or 'https'.
|
||||
*
|
||||
* Last Editor: Author: r23
|
||||
* @author Marco Canini <marco@xaraya.com>
|
||||
* @access public
|
||||
* @return string current HTTP protocol
|
||||
*/
|
||||
function oos_server_get_protocol() {
|
||||
$sProtocol = 'http';
|
||||
if (strtolower(oos_server_has_var('HTTPS')) == 'on'
|
||||
|| oos_server_has_var('SSL_PROTOCOL')) {
|
||||
$sProtocol = 'https';
|
||||
}
|
||||
|
||||
return $sProtocol . '://';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get base URI for oos
|
||||
*
|
||||
* @access public
|
||||
* @return string base URI for oos
|
||||
*/
|
||||
function oos_server_get_base_uri() {
|
||||
|
||||
// Get the name of this URI
|
||||
$sPath = oos_server_get_var('REQUEST_URI');
|
||||
|
||||
if (empty($sPath)) {
|
||||
// REQUEST_URI was empty or pointed to a path
|
||||
// adapted patch from Chris van de Steeg for IIS
|
||||
// Try SCRIPT_NAME
|
||||
$sPath = oos_server_get_var('SCRIPT_NAME');
|
||||
if (empty($sPath)) {
|
||||
// No luck there either
|
||||
// Try looking at PATH_INFO
|
||||
$sPath = oos_server_get_var('PATH_INFO');
|
||||
}
|
||||
}
|
||||
|
||||
$sPath = preg_replace('/[#\?].*/', '', $sPath);
|
||||
|
||||
$sPath = preg_replace('/\.php\/.*$/', '', $sPath);
|
||||
if (substr($sPath, -1, 1) == '/') {
|
||||
$sPath .= 'dummy';
|
||||
}
|
||||
$sPath = dirname($sPath);
|
||||
|
||||
if (preg_match('!^[/\\\]*$!', $sPath)) {
|
||||
$sPath = '';
|
||||
}
|
||||
|
||||
return $sPath;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get base URL for OOS
|
||||
*
|
||||
* @access public
|
||||
* @return string base URL for OOS
|
||||
*/
|
||||
function oos_server_get_base_url() {
|
||||
static $sBaseurl = null;
|
||||
|
||||
if (isset($sBaseurl)) return $sBaseurl;
|
||||
|
||||
$sServer = oos_server_get_host();
|
||||
$sProtocol = oos_server_get_protocol();
|
||||
$sPath = oos_server_get_base_uri();
|
||||
|
||||
$sBaseurl = trim($sProtocol . $sServer . $sPath . '/');
|
||||
return $sBaseurl;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get top level domain
|
||||
*
|
||||
* @copyright (C) 2003 by osCommerce.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link http://www.oscommerce.com
|
||||
* @access public
|
||||
* @param $sUrl
|
||||
* @return mixed
|
||||
*/
|
||||
function oos_server_get_top_level_domain($sUrl) {
|
||||
if (strpos($sUrl, '://')) {
|
||||
$sUrl = parse_url($sUrl);
|
||||
$sUrl = $sUrl['host'];
|
||||
}
|
||||
|
||||
$aDomain = explode('.', $sUrl);
|
||||
$nDomainSize = count($aDomain);
|
||||
|
||||
if ($nDomainSize > 1) {
|
||||
if (is_numeric($aDomain[$nDomainSize-2]) && is_numeric($aDomain[$nDomainSize-1])) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return $aDomain[$nDomainSize-2] . '.' . $aDomain[$nDomainSize-1];
|
||||
}
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get client ip
|
||||
*
|
||||
* @copyright (C) 2003 by osCommerce.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link http://www.oscommerce.com
|
||||
* @access public
|
||||
* @return string client ip
|
||||
*/
|
||||
function oos_server_get_remote() {
|
||||
if (isset($_SERVER)) {
|
||||
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
|
||||
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
} elseif (isset($_SERVER['HTTP_CLIENT_IP'])) {
|
||||
$ip = $_SERVER['HTTP_CLIENT_IP'];
|
||||
} else {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
} else {
|
||||
if (getenv('HTTP_X_FORWARDED_FOR')) {
|
||||
$ip = getenv('HTTP_X_FORWARDED_FOR');
|
||||
} elseif (getenv('HTTP_CLIENT_IP')) {
|
||||
$ip = getenv('HTTP_CLIENT_IP');
|
||||
} else {
|
||||
$ip = getenv('REMOTE_ADDR');
|
||||
}
|
||||
}
|
||||
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
78
msd2/myoos/includes/functions/function_spezials.php
Normal file
78
msd2/myoos/includes/functions/function_spezials.php
Normal file
@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: general.php,v 1.231 2003/07/09 01:15:48 hpdl
|
||||
general.php,v 1.212 2003/02/17 07:55:54 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* Sets the status of a special product
|
||||
*
|
||||
* @param $specials_id
|
||||
* @param $status
|
||||
*/
|
||||
function oos_set_specials_status($nSpecialsId, $status) {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$specialstable = $oostable['specials'];
|
||||
return $dbconn->Execute("UPDATE $specialstable
|
||||
SET status = '" . oos_db_input($status) . "',
|
||||
date_status_change = now()
|
||||
WHERE specials_id = '" . intval($nSpecialsId) . "'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Auto expire products on special
|
||||
*/
|
||||
function oos_expire_spezials() {
|
||||
|
||||
// Get database information
|
||||
$dbconn =& oosDBGetConn();
|
||||
$oostable =& oosDBGetTables();
|
||||
|
||||
$specialstable = $oostable['specials'];
|
||||
$query = "SELECT specials_id
|
||||
FROM $specialstable
|
||||
WHERE status = '1'
|
||||
AND now() >= expires_date
|
||||
AND expires_date > 0";
|
||||
if (USE_CACHE == 'true') {
|
||||
$result = $dbconn->CacheExecute(3600, $query);
|
||||
} else {
|
||||
$result = $dbconn->Execute($query);
|
||||
}
|
||||
if (!$result) {return;}
|
||||
|
||||
if ($result->RecordCount() > 0) {
|
||||
while ($specials = $result->fields) {
|
||||
oos_set_specials_status($specials['specials_id'], '0');
|
||||
|
||||
// Move that ADOdb pointer!
|
||||
$result->MoveNext();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
98
msd2/myoos/includes/functions/function_validate_vatid.php
Normal file
98
msd2/myoos/includes/functions/function_validate_vatid.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* VALID VAT NUMBER
|
||||
*
|
||||
* @package VATChecker
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link http://www.oos-shop.de
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
|
||||
/**
|
||||
* Send request to VIES site and retrieve results
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return mixed
|
||||
*/
|
||||
function load_data($url){
|
||||
$url = parse_url($url);
|
||||
|
||||
if (!in_array($url['scheme'],array('','http'))) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$fp = fsockopen ($url['host'], ($url['port'] > 0 ? $url['port'] : 80), $errno, $errstr, 2);
|
||||
if (!$fp){
|
||||
return FALSE;
|
||||
} else {
|
||||
fputs ($fp, "GET ".$url['path']. (isSet($url['query']) ? '?'.$url['query'] : '')." HTTP/1.0\r\n");
|
||||
fputs ($fp, "Host: ".$url['host']."\r\n");
|
||||
fputs($fp, "Connection: close\r\n\r\n");
|
||||
|
||||
$data = '';
|
||||
stream_set_blocking($fp,false);
|
||||
stream_set_timeout($fp, 4);
|
||||
$status = socket_get_status($fp);
|
||||
while(!feof($fp) && !$status['timed_out']) {
|
||||
$data .= fgets($fp, 1000);
|
||||
$status = socket_get_status($fp);
|
||||
}
|
||||
|
||||
if ( $status['timed_out'] ) {
|
||||
return FALSE;
|
||||
}
|
||||
fclose ($fp);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send & request to VIES site and interprets results
|
||||
*
|
||||
* @access public
|
||||
* @param string
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_validate_is_vatid($sVatno){
|
||||
|
||||
$sVatno = trim($sVatno);
|
||||
$sVatno = strtoupper($sVatno);
|
||||
|
||||
$aRemove = array(' ', '-', '/', '.', ':', ',', ';', '#');
|
||||
for ($i=0, $n=count($aRemove); $i<$n; $i++) {
|
||||
$sVatno = str_replace($aRemove[$i], '', $sVatno);
|
||||
}
|
||||
|
||||
$sViesMS = substr($sVatno, 0, 2);
|
||||
$sVatno = substr($sVatno, 2);
|
||||
|
||||
$urlVies = 'http://ec.europa.eu/taxation_customs/vies/cgi-bin/viesquer/?VAT='. $sVatno . '&MS=' . $sViesMS . '&Lang=EN';
|
||||
|
||||
$DataHTML = load_data($urlVies);
|
||||
if (!$DataHTML) return FALSE;
|
||||
|
||||
$ViesOk = 'YES, VALID VAT NUMBER';
|
||||
$ViesEr = 'NO, INVALID VAT NUMBER';
|
||||
|
||||
$DataHTML = '#' . strtoupper($DataHTML);
|
||||
|
||||
return ((strPos($DataHTML,$ViesOk) > 0) ? true : false);
|
||||
}
|
||||
|
||||
|
64
msd2/myoos/includes/functions/function_validations.php
Normal file
64
msd2/myoos/includes/functions/function_validations.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
MyOOS [Shopsystem]
|
||||
https://www.oos-shop.de
|
||||
|
||||
Copyright (c) 2003 - 2019 by the MyOOS Development Team.
|
||||
----------------------------------------------------------------------
|
||||
Based on:
|
||||
|
||||
File: validations.php,v 1.11 2003/02/11 01:31:02 hpdl
|
||||
----------------------------------------------------------------------
|
||||
osCommerce, Open Source E-Commerce Solutions
|
||||
http://www.oscommerce.com
|
||||
|
||||
Copyright (c) 2003 osCommerce
|
||||
----------------------------------------------------------------------
|
||||
Released under the GNU General Public License
|
||||
---------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* validations
|
||||
*
|
||||
* @package validations
|
||||
* @copyright (C) 2013 by the MyOOS Development Team.
|
||||
* @license GPL <http://www.gnu.org/licenses/gpl.html>
|
||||
* @link https://www.oos-shop.de
|
||||
*/
|
||||
|
||||
/** ensure this file is being included by a parent file */
|
||||
defined( 'OOS_VALID_MOD' ) OR die( 'Direct Access to this location is not allowed.' );
|
||||
|
||||
/**
|
||||
* Valid e-Mail - Addresses
|
||||
*
|
||||
* @param $value
|
||||
* @return boolean
|
||||
*/
|
||||
function oos_validate_is_email($value) {
|
||||
|
||||
if (!is_string($value)) return FALSE;
|
||||
|
||||
//Reject line breaks in addresses; it's valid RFC5322, but not RFC5321
|
||||
if (strpos($value, "\n") !== FALSE or strpos($value, "\r") !== FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
return (boolean)filter_var($value, FILTER_VALIDATE_EMAIL);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* test if a value is a valid URL
|
||||
*
|
||||
* @param string $sUrl the value being tested
|
||||
*/
|
||||
function oos_validate_is_url($sUrl) {
|
||||
if (strlen($sUrl) == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return preg_match('!^http(s)?://[\w-]+\.[\w-]+(\S+)?$!i', $sUrl);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user