Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Clean up and modernize
Browse files Browse the repository at this point in the history
  • Loading branch information
ecartz committed Dec 24, 2020
1 parent acd0a80 commit 2ed7026
Show file tree
Hide file tree
Showing 9 changed files with 311 additions and 309 deletions.
234 changes: 113 additions & 121 deletions admin/categories.php

Large diffs are not rendered by default.

130 changes: 71 additions & 59 deletions admin/geo_zones.php

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions admin/languages.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@
break;
}

tep_db_query("DELETE FROM categories_description WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM products_description WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM products_options WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM products_options_values WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM manufacturers_info WHERE languages_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM orders_status WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM customer_data_groups WHERE language_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM languages WHERE languages_id = '" . (int)$lID . "'");
tep_db_query("DELETE FROM categories_description WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM products_description WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM products_options WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM products_options_values WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM manufacturers_info WHERE languages_id = " . (int)$lID);
tep_db_query("DELETE FROM orders_status WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM customer_data_groups WHERE language_id = " . (int)$lID);
tep_db_query("DELETE FROM languages WHERE languages_id = " . (int)$lID);

$OSCOM_Hooks->call('languages', 'deleteConfirmAction');

Expand All @@ -89,7 +89,7 @@
case 'delete':
$lID = tep_db_prepare_input($_GET['lID']);

$lng_query = tep_db_query("SELECT code FROM languages WHERE languages_id = '" . (int)$lID . "'");
$lng_query = tep_db_query("SELECT code FROM languages WHERE languages_id = " . (int)$lID);
$lng = tep_db_fetch_array($lng_query);

$remove_language = true;
Expand Down Expand Up @@ -137,12 +137,12 @@
</thead>
<tbody>
<?php
$languages_query_raw = "select * from languages order by sort_order";
$languages_query_raw = "SELECT * FROM languages ORDER BY sort_order";
$languages_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $languages_query_raw, $languages_query_numrows);
$languages_query = tep_db_query($languages_query_raw);

while ($languages = tep_db_fetch_array($languages_query)) {
if ((!isset($_GET['lID']) || (isset($_GET['lID']) && ($_GET['lID'] == $languages['languages_id']))) && !isset($lInfo) && (substr($action, 0, 3) != 'new')) {
if (!isset($lInfo) && (!isset($_GET['lID']) || ($_GET['lID'] == $languages['languages_id'])) && (substr($action, 0, 3) != 'new')) {
$lInfo = new objectInfo($languages);
}

Expand Down Expand Up @@ -230,7 +230,7 @@

if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
echo '<div class="col-12 col-sm-4">';
$box = new box;
$box = new box();
echo $box->infoBox($heading, $contents);
echo '</div>';
}
Expand Down
17 changes: 8 additions & 9 deletions includes/apps/paypal/modules/DP/cfg_params/status.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
*/

class OSCOM_PayPal_DP_Cfg_status {
var $default = '1';
var $title;
var $description;
var $sort_order = 100;

public $default = '1';
public $title;
public $description;
public $sort_order = 100;

function __construct() {
global $OSCOM_PayPal;
Expand All @@ -25,9 +26,8 @@ function __construct() {

function getSetField() {
global $OSCOM_PayPal;

$input = null;
$input .= '<div class="custom-control custom-radio custom-control-inline">';

$input = '<div class="custom-control custom-radio custom-control-inline">';
$input .= '<input type="radio" class="custom-control-input" id="statusSelectionLive" name="status" value="1"' . (OSCOM_APP_PAYPAL_DP_STATUS == '1' ? ' checked="checked"' : '') . '>';
$input .= '<label class="custom-control-label" for="statusSelectionLive">' . $OSCOM_PayPal->getDef('cfg_dp_status_live') . '</label>';
$input .= '</div>';
Expand All @@ -44,10 +44,9 @@ function getSetField() {
<h5>{$this->title}</h5>
<p>{$this->description}</p>
<div class="mb-3" id="statusSelection">{$input}</div>
<div class="mb-3" id="statusSelection">{$input}</div>
EOT;

return $result;
}
}
?>
49 changes: 28 additions & 21 deletions includes/classes/category_tree.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<?php
/**
* osCommerce Online Merchant
*
*
* @copyright Copyright (c) 2018 osCommerce; http://www.oscommerce.com
* @license GNU General Public License; http://www.oscommerce.com/gpllicense.txt
*/

class category_tree {
protected $_data = array();
protected $_data = [];

var $root_category_id = 0,
public
$root_category_id = 0,
$max_level = 0,
$root_start_string = '',
$root_end_string = '',
Expand All @@ -25,7 +26,7 @@ class category_tree {
$spacer_string = '',
$spacer_multiplier = 1,
$follow_cpath = false,
$cpath_array = array(),
$cpath_array = [],
$cpath_start_string = '',
$cpath_end_string = '';

Expand All @@ -39,11 +40,13 @@ public function __construct() {
$categories_query = tep_db_query("select c.categories_id, c.parent_id, c.categories_image, cd.categories_name, cd.categories_description, cd.categories_seo_description, cd.categories_seo_title from categories c, categories_description cd where c.categories_id = cd.categories_id and cd.language_id = '" . (int)$_SESSION['languages_id']. "' order by c.parent_id, c.sort_order, cd.categories_name");

while ( $categories = tep_db_fetch_array($categories_query) ) {
$this->_data[$categories['parent_id']][$categories['categories_id']] = array('name' => $categories['categories_name'],
'image' => $categories['categories_image'],
'description' => $categories['categories_description'],
'seo_description' => $categories['categories_seo_description'],
'seo_title' => $categories['categories_seo_title']);
$this->_data[$categories['parent_id']][$categories['categories_id']] = [
'name' => $categories['categories_name'],
'image' => $categories['categories_image'],
'description' => $categories['categories_description'],
'seo_description' => $categories['categories_seo_description'],
'seo_title' => $categories['categories_seo_title'],
];
}

$_category_tree_data = $this->_data;
Expand Down Expand Up @@ -100,8 +103,8 @@ protected function _buildBranch($parent_id, $level = 0) {
$result .= $this->_buildBranch($category_id, $level+1);
}
}
$result .= $this->child_end_string;

$result .= $this->child_end_string;
}
}

Expand All @@ -112,7 +115,7 @@ protected function _buildBranch($parent_id, $level = 0) {

function buildBranchArray($parent_id, $level = 0, $result = '') {
if (empty($result)) {
$result = array();
$result = [];
}

if (isset($this->_data[$parent_id])) {
Expand All @@ -123,9 +126,11 @@ function buildBranchArray($parent_id, $level = 0, $result = '') {
$category_link = $category_id;
}

$result[] = array('id' => $category_link,
'image' => $category['image'],
'title' => str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . $category['name']);
$result[] = [
'id' => $category_link,
'image' => $category['image'],
'title' => str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . $category['name'],
];

if (isset($this->_data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
if ($this->follow_cpath === true) {
Expand Down Expand Up @@ -206,7 +211,7 @@ function exists($id) {
return false;
}

function getChildren($category_id, &$array = array()) {
function getChildren($category_id, &$array = []) {
foreach ($this->_data as $parent => $categories) {
if ($parent == $category_id) {
foreach ($categories as $id => $info) {
Expand All @@ -232,11 +237,13 @@ public function getData($id, $key = null) {
foreach ( $this->_data as $parent => $categories ) {
foreach ( $categories as $category_id => $info ) {
if ( $id == $category_id ) {
$data = array('id' => $id,
'name' => $info['name'],
'parent_id' => $parent,
'image' => $info['image']);

$data = [
'id' => $id,
'name' => $info['name'],
'parent_id' => $parent,
'image' => $info['image'],
];

$data['description'] = $info['description'];
$data['seo_description'] = $info['seo_description'];
$data['seo_title'] = $info['seo_title'];
Expand Down
12 changes: 6 additions & 6 deletions includes/functions/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function tep_sanitize_string($string) {
function tep_random_select($query) {
$random_product = '';
$random_query = tep_db_query($query);
$num_rows = tep_db_num_rows($random_query);
$num_rows = mysqli_num_rows($random_query);
if ($num_rows > 0) {
$random_row = tep_rand(0, ($num_rows - 1));
tep_db_data_seek($random_query, $random_row);
Expand Down Expand Up @@ -222,7 +222,7 @@ function tep_get_country_name($country_id) {
// TABLES: zones
function tep_get_zone_name($country_id, $zone_id, $default_zone) {
$zone_query = tep_db_query("SELECT zone_name FROM zones WHERE zone_country_id = " . (int)$country_id . " AND zone_id = " . (int)$zone_id);
if (tep_db_num_rows($zone_query)) {
if (mysqli_num_rows($zone_query)) {
$zone = tep_db_fetch_array($zone_query);
return $zone['zone_name'];
} else {
Expand Down Expand Up @@ -282,7 +282,7 @@ function tep_get_tax_rate($class_id, $country_id = -1, $zone_id = -1) {

if (!isset($tax_rates[$class_id][$country_id][$zone_id]['rate'])) {
$tax_query = tep_db_query("SELECT sum(tax_rate) AS tax_rate FROM tax_rates tr LEFT JOIN zones_to_geo_zones za ON (tr.tax_zone_id = za.geo_zone_id) LEFT JOIN geo_zones tz ON (tz.geo_zone_id = tr.tax_zone_id) WHERE (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = " . (int)$country_id . ") AND (za.zone_id is null or za.zone_id = '0' or za.zone_id = " . (int)$zone_id . ") AND tr.tax_class_id = " . (int)$class_id . " group by tr.tax_priority");
if (tep_db_num_rows($tax_query)) {
if (mysqli_num_rows($tax_query)) {
$tax_multiplier = 1.0;
while ($tax = tep_db_fetch_array($tax_query)) {
$tax_multiplier *= 1.0 + ($tax['tax_rate'] / 100);
Expand All @@ -305,7 +305,7 @@ function tep_get_tax_description($class_id, $country_id, $zone_id) {

if (!isset($tax_rates[$class_id][$country_id][$zone_id]['description'])) {
$tax_query = tep_db_query("SELECT tax_description FROM tax_rates tr LEFT JOIN zones_to_geo_zones za ON (tr.tax_zone_id = za.geo_zone_id) LEFT JOIN geo_zones tz ON (tz.geo_zone_id = tr.tax_zone_id) WHERE (za.zone_country_id is null or za.zone_country_id = '0' or za.zone_country_id = " . (int)$country_id . ") AND (za.zone_id is null or za.zone_id = '0' or za.zone_id = " . (int)$zone_id . ") AND tr.tax_class_id = " . (int)$class_id . " ORDER BY tr.tax_priority");
if (tep_db_num_rows($tax_query)) {
if (mysqli_num_rows($tax_query)) {
$tax_description = '';
while ($tax = tep_db_fetch_array($tax_query)) {
$tax_description .= $tax['tax_description'] . ' + ';
Expand Down Expand Up @@ -599,7 +599,7 @@ function tep_get_product_path($products_id) {
$cPath = '';

$category_query = tep_db_query("SELECT p2c.categories_id FROM products p, products_to_categories p2c WHERE p.products_id = " . (int)$products_id . " AND p.products_status = 1 AND p.products_id = p2c.products_id LIMIT 1");
if (tep_db_num_rows($category_query)) {
if (mysqli_num_rows($category_query)) {
$category = tep_db_fetch_array($category_query);

$categories = [];
Expand Down Expand Up @@ -985,7 +985,7 @@ function tep_form_processing_is_valid() {
function tep_require_login($parameters = null) {
if (!isset($_SESSION['customer_id'])) {
$_SESSION['navigation']->set_snapshot($parameters);
tep_redirect(tep_href_link('login.php', '', 'SSL'));
tep_redirect(tep_href_link('login.php'));
}
}

Expand Down
Loading

0 comments on commit 2ed7026

Please sign in to comment.