3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php /* Plugin Name: JM Integração com SAP Plugin URI: Description: Jeronimo Martins - Integração com SAP Version: 20170602 Author: Xpand-it License: GPL2 License URI: https://www.gnu.org/licenses/gpl-2.0.html Text Domain: wporg Domain Path: /languages {Plugin Name} is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. {Plugin Name} 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. You should have received a copy of the GNU General Public License along with {Plugin Name}. If not, see {License URI}. */ /** * @SWG\Swagger( * host="localhost:88", * basePath="/wp-json/api" * ) */ /** * @SWG\Info(title="Jeronimo Martins API", version="2.0") */ global $jm_sapintegration_db_version; $jm_sapintegration_db_version = '1.2'; require_once( 'utils/RegisterRoutes.php' ); require_once( 'controllers/ProductsControllers.php' ); use JM_leaflets\Controllers as Ctrl; // Hook for adding admin menus //add_action('admin_menu', 'jm_leaflets_add_menu'); // Action to create DB when plugin is installed register_activation_hook( __FILE__, 'jm_sapintegration_create_db' ); //add_action('admin_enqueue_scripts', 'registerLeafletsScripts' ); add_action( 'rest_api_init', 'register_routes_api' ); function register_routes_api(){ $routesRestCtrl = new RoutesRestRegister(); $routesRestCtrl->register_routes(); } function jm_sapintegration_create_db(){ global $wpdb; //global $db_version; $table_name = $wpdb->prefix . 'jm_leaflets_prods'; $charset_collate = $wpdb->get_charset_collate(); require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); $sql = "CREATE TABLE IF NOT EXISTS $table_name ( IdSap BIGINT(9) NOT NULL, Area varchar(254) DEFAULT '' NULL, Divisao varchar(254) DEFAULT '' NULL, Familia varchar(254) DEFAULT '' NULL, Categoria varchar(254) DEFAULT '' NULL, DescricaoCartaz varchar(254) DEFAULT '' NULL, DescricaoFolheto varchar(254) DEFAULT '' NULL, UMV varchar(254) DEFAULT '' NOT NULL, ProductImage varchar(254) DEFAULT '', CategoriesCodes varchar(254) DEFAULT '', IncrementUnit decimal(12 , 2) NULL, MarcaPropria varchar(254) DEFAULT '' NULL, DescrWordpress varchar(254) DEFAULT '' NULL, Embalagem varchar(254) DEFAULT '' NULL, Marca varchar(254) DEFAULT '' NULL, createdBy varchar(254) DEFAULT '' , createdDate datetime DEFAULT '0000-00-00 00:00:00' , updatedBy varchar(254) DEFAULT '', updatedDate datetime DEFAULT '0000-00-00 00:00:00', PRIMARY KEY (IdSap) ) $charset_collate;"; dbDelta( $sql ); /* $sql = "ALTER TABLE $table_name DROP PVP"; $wpdb->query( $sql );*/ /*$sql = "ALTER TABLE $table_name ADD Embalagem varchar(254) DEFAULT '' "; $wpdb->query( $sql ); */ $table_name = $wpdb->prefix . 'jm_leaflets_promotion'; $sql = "CREATE TABLE IF NOT EXISTS $table_name ( IdSap BIGINT(9) NOT NULL, /*Promotion*/ IDPromocaoGlobal BIGINT(9) NOT NULL, DescricaoPromocaoGlobal varchar(254) DEFAULT '' NULL, DataInicio datetime DEFAULT '0000-00-00 00:00:00' NULL, DataFim datetime DEFAULT '0000-00-00 00:00:00' NULL, PVPAccao decimal(5 , 2) NULL, Mecanica varchar(254) DEFAULT '' NULL, Icone varchar(254) DEFAULT '' NULL, MixLXPY varchar(254) DEFAULT '' NULL, LimiteQtd decimal(12 , 2) NULL, PmPVPAccao decimal(12 , 2) NULL, PmDesconto decimal(12 , 2) NULL, PmMecanica varchar(254) DEFAULT '' NULL, PmLimiteQtd decimal(12 , 2) NULL, PmMix varchar(254) DEFAULT '' NULL, TipoComunicacao varchar(254) DEFAULT '' NULL, IdentificadorGama varchar(254) DEFAULT '' NULL, ImagemEmFolheto varchar(254) DEFAULT '' NULL, DestaquePVP varchar(254) DEFAULT '' NULL, Status varchar(254) DEFAULT '' NULL, createdBy varchar(254) DEFAULT '' , createdDate datetime DEFAULT '0000-00-00 00:00:00' , updatedBy varchar(254) DEFAULT '', updatedDate datetime DEFAULT '0000-00-00 00:00:00', GeneratedImageProduct varchar(254) DEFAULT '', GeneratedImageBadge varchar(254) DEFAULT '', NeedsToBeUpdated boolean DEFAULT FALSE, BadgeImageH varchar(254) DEFAULT '', BadgeImageV varchar(254) DEFAULT '', ProductWithError boolean DEFAULT FALSE, UnitPrice decimal(12 , 2) NULL, PVP decimal( 12 , 2 ) NULL, PRIMARY KEY (IdSap, IDPromocaoGlobal) ) $charset_collate;"; dbDelta( $sql ); /* $sql = "ALTER TABLE $table_name ADD PVP decimal( 12 , 2 ) NULL "; $wpdb->query( $sql );*/ $table_name = $wpdb->prefix . 'jm_leaflets_prods_historic'; /*$wpdb->query("DROP TABLE IF EXISTS $table_name");*/ $sql="CREATE TABLE IF NOT EXISTS $table_name ( id BIGINT(9) NOT NULL AUTO_INCREMENT, idSap BIGINT(9) NOT NULL, idPromotion BIGINT(9) NOT NULL, field varchar(254) DEFAULT '' NOT NULL, lastValue varchar(254) DEFAULT '' NOT NULL, fieldType varchar(254) DEFAULT '' NOT NULL, createdBy varchar(254) DEFAULT '' , createdDate datetime DEFAULT '0000-00-00 00:00:00' , updatedBy varchar(254) DEFAULT '', updatedDate datetime DEFAULT '0000-00-00 00:00:00', PRIMARY KEY ( id ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_store'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( idLeafletProd BIGINT(9) NOT NULL, idPromotion BIGINT(9) NOT NULL, idLoja BIGINT(9) NOT NULL, folheto varchar(254) DEFAULT '', sortido varchar(254) DEFAULT '', createdBy varchar(254) DEFAULT '' , createdDate datetime DEFAULT '0000-00-00 00:00:00' , updatedBy varchar(254) DEFAULT '', updatedDate datetime DEFAULT '0000-00-00 00:00:00', PRIMARY KEY ( idLeafletProd, idLoja, idPromotion ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_changes'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( IdSap BIGINT(9) NOT NULL, IdPromotion BIGINT(9) NOT NULL, Field varchar(254) DEFAULT '' NOT NULL, FieldValue varchar(254) DEFAULT '' NOT NULL, FieldType varchar(254) DEFAULT '' NOT NULL, createdBy varchar(254) DEFAULT '' , createdDate datetime DEFAULT '0000-00-00 00:00:00' , updatedBy varchar(254) DEFAULT '', updatedDate datetime DEFAULT '0000-00-00 00:00:00', PRIMARY KEY ( IdSap, IdPromotion, Field ) ) CHARSET = utf8 COLLATE = utf8_unicode_ci;"; dbDelta($sql); //Delete old Market Structure Tables //Market Structure Tables $table_name = $wpdb->prefix . 'jm_leaflets_prods_categories'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( id BIGINT(9) NOT NULL AUTO_INCREMENT, Name varchar(254) DEFAULT '' NOT NULL, MenuOrder INT NULL DEFAULT '0', Icone varchar(254) DEFAULT '', PRIMARY KEY ( id ) ) $charset_collate;"; dbDelta($sql); /* $sql = "ALTER TABLE $table_name ADD MenuOrder INT NULL DEFAULT '0' "; $wpdb->query( $sql ); $sql = "ALTER TABLE $table_name ADD Icone varchar(254) DEFAULT '' "; $wpdb->query( $sql ); */ $table_name = $wpdb->prefix . 'jm_leaflets_prods_sub_categories'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( id BIGINT(9) NOT NULL AUTO_INCREMENT, Name varchar(254) DEFAULT '' NOT NULL, idCategory BIGINT(9) NOT NULL, PRIMARY KEY ( id ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_codes'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( id BIGINT(9) NOT NULL AUTO_INCREMENT, Code varchar(254) DEFAULT '' NOT NULL, PRIMARY KEY ( id ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_sub_categories_codes'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( idCode BIGINT(9) NOT NULL, idSubCategory BIGINT(9) NOT NULL, PRIMARY KEY ( idCode, idSubCategory ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_cross_selling'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( idProd BIGINT(9) NOT NULL, idProdCross BIGINT(9) NOT NULL, IdPromotion BIGINT(9) NOT NULL, PRIMARY KEY ( idProd, idProdCross ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_leaflets_prods_invalid'; $sql="CREATE TABLE IF NOT EXISTS $table_name ( id BIGINT(9) NOT NULL AUTO_INCREMENT, idProd BIGINT(9) NOT NULL, field varchar(254) DEFAULT '' NOT NULL, description varchar(254) DEFAULT '' NOT NULL, PRIMARY KEY ( id ) ) $charset_collate;"; dbDelta($sql); $table_name = $wpdb->prefix . 'jm_sapIntegrations_logs'; $wpdb->query("DROP TABLE IF EXISTS $table_name"); add_option( 'jm_sapintegration_db_version', $jm_sapintegration_db_version ); } function validateProductsCronJob() { error_log("validate Prods CronJob Run"); $ProdCtrl = new Ctrl\SapProductsController(); error_log("create Ctrl Validate"); $ProdCtrl->approveProducts(); error_log("End Prods CronJob Run"); } register_deactivation_hook(__FILE__, 'jm_SapIntegration_deactivate'); function jm_SapIntegration_deactivate() { /*wp_clear_scheduled_hook('jm_sapintegration_validate_prods');*/ } ?>
Output for 7.1.6
Warning: require_once(): open_basedir restriction in effect. File(utils/RegisterRoutes.php) is not within the allowed path(s): (/tmp/) in /in/OfFgQ on line 43 Warning: require_once(utils/RegisterRoutes.php): failed to open stream: Operation not permitted in /in/OfFgQ on line 43 Fatal error: require_once(): Failed opening required 'utils/RegisterRoutes.php' (include_path='.:') in /in/OfFgQ on line 43
Process exited with code 255.