Refactor value handling in multiple classes to improve data processing and maintainability
This commit is contained in:
BIN
autoload/.DS_Store
vendored
Normal file
BIN
autoload/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -27,7 +27,17 @@ class Articles
|
||||
public static function article_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania artykułu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Articles::article_save(
|
||||
$values['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_table_of_contents'], $values['show_date_add'], $values['date_add'], $values['show_date_modify'], $values['date_modify'], $values['seo_link'], $values['meta_title'],
|
||||
|
||||
@@ -15,7 +15,17 @@ class Banners
|
||||
public static function banner_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania baneru wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $banner_id = \admin\factory\Banners::banner_save( $values['id'], $values['name'], $values['status'], $values['date_start'], $values['date_end'],
|
||||
$values['home_page'], $values['src'], $values['url'], $values['html'], $values['text'] ) )
|
||||
|
||||
@@ -18,7 +18,17 @@ class Dictionaries {
|
||||
static public function unit_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania jednostki miary wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Dictionaries::unit_save( $values['id'], $values['text']) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Jednostka miary została zapisana.', 'id' => $id ];
|
||||
|
||||
@@ -14,8 +14,17 @@ class Languages
|
||||
public static function language_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania języka wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( \admin\factory\Languages::language_save(
|
||||
$values['id'], $values['name'], $values['status'],
|
||||
@@ -51,7 +60,17 @@ class Languages
|
||||
public static function translation_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania tłumaczenia wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
$languages_list = \admin\factory\Languages::languages_list();
|
||||
if ( is_array( $languages_list ) and !empty( $languages_list ) ) foreach ( $languages_list as $language )
|
||||
|
||||
@@ -14,7 +14,17 @@ class Layouts
|
||||
public static function layout_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania szablonu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Layouts::layout_save( $values['id'], $values['name'], $values['status'], $values['pages'], $values['html'], $values['css'], $values['js'], $values['m_html'],
|
||||
$values['m_css'], $values['m_js'], $values['categories'], $values['categories_default'] )
|
||||
|
||||
@@ -27,7 +27,17 @@ class Newsletter
|
||||
public static function settings_save()
|
||||
{
|
||||
$settings = \admin\factory\Settings::settings_details();
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
\admin\factory\Settings::settings_update( 'newsletter_footer', $values['newsletter_footer'] );
|
||||
\admin\factory\Settings::settings_update( 'newsletter_header', $values['newsletter_header'] );
|
||||
@@ -81,7 +91,17 @@ class Newsletter
|
||||
public static function template_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Newsletter::template_save( $values['id'], $values['name'], $values['text'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Zmiany zostały zapisane.', 'id' => $id ];
|
||||
|
||||
@@ -46,7 +46,17 @@ class Pages
|
||||
public static function page_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania strony wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Pages::page_save(
|
||||
$values['id'], $values['title'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['menu_id'], $values['parent_id'], $values['page_type'],
|
||||
@@ -74,7 +84,17 @@ class Pages
|
||||
public static function menu_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania menu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( \admin\factory\Pages::menu_save( $values['id'], $values['name'], $values['status'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Menu zostało zapisane.' ];
|
||||
|
||||
@@ -14,7 +14,17 @@ class Scontainers
|
||||
public static function container_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kontenera wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Scontainers::container_save( $values['id'], $values['title'], $values['text'], $values['status'], $values['show_title'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Kontener został zapisany.', 'id' => $id ];
|
||||
|
||||
@@ -5,7 +5,18 @@ class Settings
|
||||
{
|
||||
public static function settings_save()
|
||||
{
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
$settings = \admin\factory\Settings::settings_details( true );
|
||||
|
||||
$response = \admin\factory\Settings::settings_save(
|
||||
|
||||
@@ -17,7 +17,17 @@ class ShopAttribute
|
||||
static public function values_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wartości atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
;
|
||||
if ( $id = \admin\factory\ShopAttribute::values_save( (int) \S::get( 'attribute_id' ), $values['name'], $values['value'], $values['ids'], $values['default_value'], $values['impact_on_the_price'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Wartości atrybutu zostały zapisane.', 'id' => $id ];
|
||||
@@ -47,7 +57,17 @@ class ShopAttribute
|
||||
public static function attribute_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopAttribute::attribute_save( (int) $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, (int) $values['type'], (int) $values['o'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Atrybut został zapisany.', 'id' => $id ];
|
||||
|
||||
@@ -32,7 +32,17 @@ class ShopCategory
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kategorii wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopCategory::save(
|
||||
$values['id'], $values['title'], $values['text'], $values['text_hidden'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['parent_id'], $values['status'],
|
||||
|
||||
@@ -15,7 +15,17 @@ class ShopCoupon
|
||||
public static function coupon_save()
|
||||
{
|
||||
$response = ['status' => 'error', 'msg' => 'Podczas zapisywania kuponu wystąpił błąd. Proszę spróbować ponownie.'];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $values['categories'] != null )
|
||||
$categories = is_array( $values['categories'] ) ? json_encode( $values['categories'] ) : json_encode( [ $values['categories'] ] );
|
||||
|
||||
@@ -13,7 +13,17 @@ class ShopProducer
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania producenta wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $producer_id = \admin\factory\ShopProducer::save( $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, $values['img'], $values['description'], $values['meta_title'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Producent został zapisany.', 'id' => $producer_id ];
|
||||
|
||||
@@ -180,7 +180,17 @@ class ShopProduct
|
||||
public static function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania produktu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopProduct::save(
|
||||
$values['id'], $values['name'], $values['short_description'], $values['description'], $values['status'], $values['meta_description'], $values['meta_keywords'], $values['seo_link'],
|
||||
|
||||
@@ -16,7 +16,17 @@ class ShopProductSets
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kompletu produktów wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopProductSet::save(
|
||||
(int)$values['id'], $values['name'], (string) $values['status'], $values['set_products_id']
|
||||
|
||||
@@ -17,7 +17,17 @@ class ShopPromotion
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania promocji wystąpił błąd. Proszę spróbować ponownie' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopPromotion::save(
|
||||
$values['id'],
|
||||
|
||||
@@ -7,7 +7,17 @@ class ShopStatuses {
|
||||
public static function status_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania statusu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopStatuses::status_save( $values['id'], $values['color'], $values['apilo_status_id'], $values['sellasist_status_id'], $values['baselinker_status_id'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Status został zapisany.', 'id' => $id ];
|
||||
|
||||
@@ -5,7 +5,17 @@ class ShopTransport
|
||||
public static function transport_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania rodzaju transportu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\ShopTransport::transport_save(
|
||||
$values['id'], $values['name'], $values['name_visible'], $values['description'], $values['status'], $values['cost'], $values['payment_methods'], $values['max_wp'], $values['default'], $values['apilo_carrier_account_id'], $values['sellasist_shipment_method_id'], $values['delivery_free']
|
||||
|
||||
@@ -13,7 +13,18 @@ class Users
|
||||
|
||||
public static function user_save()
|
||||
{
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
$response = \admin\factory\Users::user_save( $values['id'], $values['login'], $values['status'], $values['password'], $values['password_re'], $values['admin'] );
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
|
||||
@@ -1014,7 +1014,7 @@ class ShopProduct
|
||||
else
|
||||
$new_seo_link = \S::seo( 'p-' . $product_id . '-' . $name[$key] );
|
||||
|
||||
if ( $new_seo_link !== $current_seo_link )
|
||||
if ( $new_seo_link !== $current_seo_link and $current_seo_link != '' )
|
||||
{
|
||||
if ( !$mdb -> count( 'pp_redirects', [ 'from' => $current_seo_link, 'to' => $new_seo_link, 'lang_id' => $key, 'product_id' => $product_id ] ) )
|
||||
{
|
||||
|
||||
@@ -1,6 +1,54 @@
|
||||
<?php
|
||||
class S
|
||||
{
|
||||
public static function set_array_value(&$array, $keys, $value)
|
||||
{
|
||||
$key = array_shift($keys);
|
||||
if (count($keys) == 0)
|
||||
{
|
||||
if ($key === '')
|
||||
{
|
||||
$array[] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Jeśli klucz już istnieje i jest tablicą, zamieniamy go na tablicę wartości
|
||||
if (isset($array[$key]) && !is_array($array[$key]))
|
||||
{
|
||||
$array[$key] = [$array[$key]];
|
||||
}
|
||||
if (isset($array[$key]) && is_array($array[$key]))
|
||||
{
|
||||
$array[$key][] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$array[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($key === '')
|
||||
{
|
||||
$array[] = [];
|
||||
$key = count($array) - 1;
|
||||
}
|
||||
if (!isset($array[$key]) || !is_array($array[$key]))
|
||||
{
|
||||
$array[$key] = [];
|
||||
}
|
||||
self::set_array_value($array[$key], $keys, $value);
|
||||
}
|
||||
}
|
||||
|
||||
static public function parse_name($name)
|
||||
{
|
||||
$name = rtrim($name, ']');
|
||||
$parts = explode('[', $name);
|
||||
return $parts;
|
||||
}
|
||||
|
||||
static function canAddRedirect( $from, $to )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
48
autoload/curl.class.php
Normal file
48
autoload/curl.class.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// ------------------------------------------------
|
||||
// This is a cURL Object
|
||||
// Created by: Gilberto C.
|
||||
// InteractiveUtopia.com
|
||||
// ------------------------------------------------
|
||||
|
||||
class CurlServer
|
||||
{
|
||||
private $access_token;
|
||||
|
||||
function __construct( $token )
|
||||
{
|
||||
$this->access_token = $token;
|
||||
}
|
||||
|
||||
function post_request($url, $submitJson, $debug = false )
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $submitJson);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->access_token, 'Content-Type: application/json'));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$serverReponseObject = json_decode($server_output);
|
||||
|
||||
// Debug
|
||||
if ( $debug )
|
||||
print_r($serverReponseObject);
|
||||
}
|
||||
function get_request($url)
|
||||
{
|
||||
$ch = curl_init();
|
||||
curl_setopt($ch, CURLOPT_URL, $url);
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $this->access_token));
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
$server_output = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
$serverReponseObject = json_decode($server_output);
|
||||
|
||||
// Debug
|
||||
//print_r ( $server_output );
|
||||
print_r($serverReponseObject);
|
||||
}
|
||||
}
|
||||
BIN
autoload/front/.DS_Store
vendored
Normal file
BIN
autoload/front/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -18,6 +18,8 @@ class ShopOrder
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
file_put_contents( 'tpay.txt', print_r( $_POST, true ) . print_r( $_GET, true ), FILE_APPEND );
|
||||
|
||||
if ( \S::get( 'tr_status' ) == 'TRUE' and \S::get( 'tr_crc' ) )
|
||||
{
|
||||
$order = new \shop\Order( 0, \S::get( 'tr_crc' ) );
|
||||
|
||||
@@ -26,7 +26,17 @@ class ShopProduct
|
||||
{
|
||||
global $lang_id;
|
||||
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$values_tmp = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$values = [];
|
||||
|
||||
foreach ( $values_tmp as $item )
|
||||
{
|
||||
$name = $item['name'];
|
||||
$value = $item['value'];
|
||||
$keys = \S::parse_name( $name );
|
||||
\S::set_array_value( $values, $keys, $value );
|
||||
}
|
||||
|
||||
foreach( $values as $key => $val )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user