浏览代码

Restructuration dossiers, config

Mathieu Moulin 3 年之前
父节点
当前提交
66afeef90d

+ 7 - 22
src/bootstrap.inc.php

@@ -1,19 +1,14 @@
 <?php
 
-define('VAR_PATH', ROOT_PATH.'/var');
-define('VENDOR_PATH', ROOT_PATH.'/vendor');
+require_once CFG_PATH.'/config_defaults.inc.php';
 
-// SRC
-define('CLASS_PATH', SRC_PATH.'/class');
-define('VIEWMODEL_PATH', SRC_PATH.'/viewmodel');
-define('TEMPLATE_PATH', SRC_PATH.'/template');
-define('TABLE_PATH', SRC_PATH.'/table');
-define('ORM_PATH', SRC_PATH.'/orm');
-define('MODEL_PATH', SRC_PATH.'/model');
-define('CONTROLLER_PATH', SRC_PATH.'/controller');
+// DB
 
 require_once CLASS_PATH.'/db/mysqli.php';
 require_once CLASS_PATH.'/logger/base.php';
+require_once SRC_PATH.'/functions.inc.php';
+require_once SRC_PATH.'/db.inc.php';
+require_once SYNC_PATH.'/sync.inc.php';
 
 $db = new \db\mysqli(DB_HOST, DB_USER, DB_PASS, DB_BASE);
 //echo 'db : '; var_dump($db);
@@ -23,19 +18,9 @@ $db_p->set_charset('utf8mb4');
 $db_d = new \db\mysqli(DB_D_HOST, DB_D_USER, DB_D_PASS, DB_D_BASE);
 $db_d->set_charset('utf8mb4');
 
-$logger = new \logger\base();
-
-define('DEBUG_ALL', true);
-//define('DEBUG_SQL', true);
-//define('DEBUG_SYNCHRO', true);
-//define('DEBUG_WS', true);
-if (!defined('DEBUG_SQL'))
-	define('DEBUG_SQL', DEBUG_ALL);
-if (!defined('DEBUG_SYNCHRO'))
-	define('DEBUG_SYNCHRO', DEBUG_ALL);
-if (!defined('DEBUG_WS'))
-	define('DEBUG_WS', DEBUG_ALL);
+// DEBUG
 
+$logger = new \logger\base();
 ini_set("xdebug.var_display_max_children", '-1');
 ini_set("xdebug.var_display_max_data", '-1');
 ini_set("xdebug.var_display_max_depth", '-1');

+ 0 - 0
src/sync/db.inc.php → src/db.inc.php


+ 36 - 0
src/functions.inc.php

@@ -0,0 +1,36 @@
+<?php
+
+function sync_error($message, $e=NULL)
+{
+	echo '<p>ERREUR :</p>';
+	echo '<p>'.$message.'</p>';
+	if ($e)
+		var_dump($e);
+	//die(json_encode(['message'=>$message]));
+	notify($message, $e);
+}
+
+function notify($message, $e=NULL)
+{
+	$message = '<p>'.$message.'</p>';
+	if ($e) {
+		$dump = ob_var_dump($e);
+		$message .= '<br />'.$dump;
+		$content_type = 'text/html';
+	}
+	else {
+		$content_type = 'text/plain';
+	}
+	
+	mail(DEBUG_EMAIL_TO, 'Erreur Synchro DoliPresta', $message, 'From: '.DEBUG_EMAIL_FROM."\r\n".'Content-Type: '.$content_type.'; charset="UTF-8"');
+}
+
+function ob_var_dump($e)
+{
+	ob_start();
+	var_dump($e);
+	$dump = ob_get_contents();
+	ob_end_clean();
+	
+	return $dump;
+}

+ 0 - 12
src/sync/common.inc.php

@@ -1,15 +1,3 @@
 <?php
 
-define('SYNC_PATH', SRC_PATH.'/sync');
-
-function sync_error($message)
-{
-	//header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
-	mail(DEBUG_EMAIL_TO, 'Erreur Synchro DoliPresta', $message, 'From: '.DEBUG_EMAIL_FROM);
-	echo '<p>ERREUR :</p>';
-	var_dump($message);
-	//die(json_encode(['message'=>$message]));
-}
-
-require_once('db.inc.php');
 require_once('sync.inc.php');

+ 6 - 8
src/sync/sync.inc.php

@@ -160,10 +160,10 @@ public static function _class($type, $sens)
 		require_once(SYNC_PATH.'/'.$type.'/common.inc.php');
 	} catch(Throwable $e) {
 		var_dump($e);
-		sync_error("Could not load common sync class for type ".$type);
+		sync_error("Could not load common sync class for type ".$type, $e);
 	} catch(Exception $e) {
 		var_dump($e);
-		sync_error("Could not load common sync class for type ".$type);
+		sync_error("Could not load common sync class for type ".$type, $e);
 	}
 	
 	// Load specific direction model class
@@ -171,10 +171,10 @@ public static function _class($type, $sens)
 		require_once(SYNC_PATH.'/'.$type.'/'.$sens.'.inc.php');
 	} catch(Throwable $e) {
 		var_dump($e);
-		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens);
+		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens, $e);
 	} catch(Exception $e) {
 		var_dump($e);
-		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens);
+		sync_error("Could not load controller sync class for type ".$type.', sens '.$sens, $e);
 	}
 	
 	return $classname = 'sync_'.$type.'_'.$sens;
@@ -190,11 +190,9 @@ public static function _action($type, $sens, $action, $otype, $oid)
 		$method = 'execute_'.$action;
 		$r = $controller->$method($otype, $oid);
 	} catch(Throwable $e) {
-		var_dump($e);
-		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')');
+		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')', $e);
 	} catch(Exception $e) {
-		var_dump($e);
-		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')');
+		sync_error('Error executing controller '.$classname.'::'.$method.'('.$otype.','.$oid.')', $e);
 	}
 	
 	if (!empty($r))

+ 1 - 1
web/bootstrap.inc.php

@@ -2,7 +2,7 @@
 
 define('WEB_PATH', realpath(dirname(__FILE__)));
 define('ROOT_PATH', realpath(WEB_PATH.'/..'));
-define('APP_PATH', ROOT_PATH.'/app');
+//define('APP_PATH', ROOT_PATH.'/app'); // Inutile ?
 define('SRC_PATH', ROOT_PATH.'/src');
 define('CFG_PATH', ROOT_PATH.'/config');
 

+ 0 - 1
web/clean.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['product', 'product_attribute', 'product_lot', 'product_pack', 'supplier_price', 'stock'];
 

+ 0 - 1
web/install.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address'];
 

+ 0 - 1
web/list.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['products'];
 

+ 0 - 1
web/manual.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['supplier', 'product', 'product_lot', 'supplier_price', 'customer', 'address', 'order'];
 

+ 0 - 1
web/repair.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'shipping'];
 

+ 0 - 1
web/resync.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address', 'stock'];
 

+ 0 - 1
web/send.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['devis_form'];
 

+ 0 - 1
web/sync.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 foreach($_GET as $i=>&$j) {
 	if (!isset($_POST[$i]))

+ 3 - 1
web/address.php → web/sync_address.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_address.php";
 

+ 3 - 1
web/model.php → web/sync_admin_model.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_product.php";
 

+ 3 - 1
web/p_table.php → web/sync_admin_p_table.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CLASS_PATH."/controller/p_table.php";
 

+ 3 - 1
web/table.php → web/sync_admin_table.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CLASS_PATH."/controller/table.php";
 

+ 3 - 1
web/customer.php → web/sync_customer.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_customer.php";
 

+ 3 - 1
web/order.php → web/sync_order.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_order.php";
 

+ 3 - 1
web/product.php → web/sync_product.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_product.php";
 

+ 3 - 1
web/stock.php → web/sync_stock.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_stock.php";
 

+ 3 - 1
web/supplier.php → web/sync_supplier.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_supplier.php";
 

+ 3 - 1
web/supplier_price.php → web/sync_supplier_price.php

@@ -1,7 +1,9 @@
 <?php
 
 require_once "bootstrap.inc.php";
-//echo 'bootstrap loaded';
+
+if (! NEWSYNC_ENABLE)
+	die('New Sync method disabled');
 
 require_once CONTROLLER_PATH."/synchro_supplier_price.php";
 

+ 0 - 1
web/update.php

@@ -1,7 +1,6 @@
 <?php
 
 require_once "bootstrap.inc.php";
-require_once('../src/sync/common.inc.php');
 
 $options = ['supplier', 'product', 'img', 'product_lot', 'supplier_price', 'order', 'customer', 'address'];