init
This commit is contained in:
234
WSDL/1.php
Normal file
234
WSDL/1.php
Normal file
@@ -0,0 +1,234 @@
|
||||
<?php
|
||||
|
||||
define("MYSQL_API_HOST", "localhost");
|
||||
define("MYSQL_API_PORT", "80");
|
||||
define("MYSQL_API_USER", "root");
|
||||
define("MYSQL_API_PASSWORD", "sgpmk777");
|
||||
define("MYSQL_API_DATABASE", "crm");
|
||||
define("MYSQL_API_COLLATE", "UTF8");
|
||||
|
||||
|
||||
|
||||
echo "TEST";
|
||||
|
||||
function ecm_add_order_from_shop($user_name, $password, $order, $presta, $user, $a, $b, $c, $d) {
|
||||
|
||||
|
||||
$x = "";
|
||||
$x = "S";
|
||||
$y = "false";
|
||||
|
||||
|
||||
|
||||
if(!empty($order)) {
|
||||
|
||||
$y = "ok";
|
||||
|
||||
|
||||
try {
|
||||
|
||||
$order = unserialize(base64_decode($order));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//return print_r($order);
|
||||
if(!empty($order) && is_array($order)) {
|
||||
|
||||
|
||||
|
||||
if($order['Order-Header']['OrderNumber'] == "ORDERTEST1234")
|
||||
return "IDTEST1234";
|
||||
|
||||
else {
|
||||
require_once("modules/EcmSales/EcmSale.php");
|
||||
$focus=new EcmSale();
|
||||
|
||||
|
||||
$template_id="97700b0d-fbe9-e366-4016-4b260f058a47";
|
||||
|
||||
$db = new PDODB("mysql:host=".MYSQL_API_HOST.";dbname=".MYSQL_API_DATABASE.";port=".MYSQL_API_PORT,MYSQL_API_USER,MYSQL_API_PASSWORD);
|
||||
|
||||
|
||||
|
||||
|
||||
$focus->template_id=$template_id;
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($GLOBALS['db']->query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
//$query = $db->executeQuery(query("select name from ecmdocumenttemplates where id='".$template_id."'"));
|
||||
|
||||
$row = $db->fetchFirstRow("select name from ecmdocumenttemplates where id='".$template_id."'");
|
||||
$focus->template_name=$row['name'];
|
||||
$focus->setTemplate();
|
||||
$focus->number=$focus->generateNumber();
|
||||
$focus->document_no=$focus->formatNumber();
|
||||
$focus->currency_id="PLN";
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->status="s10";
|
||||
$focus->type="sales_order";
|
||||
$focus->modified_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->created_by="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
|
||||
$pr=$order['Order-Lines'];
|
||||
$x = "ok";
|
||||
include_once("modules/Accounts/Account.php");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where b2clogin ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$ww=$GLOBALS['db']->query("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
$row = $db->fetchFirstRow("select count(*) as c from accounts where `id` ='".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$rr=$GLOBALS['db']->fetchByAssoc($ww);
|
||||
$focus->parent_id="getmir";
|
||||
$focus->description=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Description']);
|
||||
|
||||
|
||||
// if($rr['c']==0){
|
||||
// $account=new Account();
|
||||
$account->ownership="getmir";
|
||||
// $account->name=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Name']);
|
||||
// $account->b2clogin=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['Login']);
|
||||
// $account->billing_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['StreetAndNumber']);
|
||||
// $account->billing_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['PostalCode']);
|
||||
// $account->billing_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['Buyer']['CityName']);
|
||||
// $account->shipping_address_street=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['StreetAndNumber']);
|
||||
// $account->shipping_address_postalcode=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['PostalCode']);
|
||||
// $account->shipping_address_city=iconv("ISO-8859-2","UTF-8",$order['Order-Parties']['DeliveryPoint']['CityName']);
|
||||
// $focus->parent_id=create_guid_2();
|
||||
// $GLOBALS['db']->query("insert into accounts set id='".$focus->parent_id."',name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."', b2clogin='".$account->b2clogin."'");
|
||||
// }
|
||||
// else{
|
||||
|
||||
|
||||
//$w=$GLOBALS['db']->query("select id from accounts where b2clogin = '".$order['Order-Parties']['Buyer']['Login']."' and deleted='0'");
|
||||
//$w=$GLOBALS['db']->query("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
$row = $db->fetchFirstRow("select `id` from `accounts` where `id` = '".$order['Order-Parties']['Buyer']['Login']."' and `deleted`='0'");
|
||||
//$r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$account=new Account();
|
||||
//update account, maybe sth. change
|
||||
|
||||
// $GLOBALS['db']->query("update accounts set name='".$account->name."',billing_address_street='".$account->billing_address_street."',billing_address_postalcode='".$account->billing_address_postalcode."',billing_address_city='".$account->billing_address_city."'"."',shipping_address_street='".$account->shipping_address_street."',shipping_address_postalcode='".$account->shipping_address_postalcode."',shipping_address_city='".$account->shipping_address_city."'where id='".$r['id']."'");
|
||||
|
||||
// $account->retrieve($r['id']);
|
||||
$focus->parent_id=$row['id'];
|
||||
//}
|
||||
$focus->assigned_user_id="d09b87cf-efff-2f7c-a859-4ba38402488f";
|
||||
$focus->register_date=$order['Order-Header']['OrderDate'];
|
||||
$focus->delivery_date=$order['Order-Header']['ExpectedDeliveryDate'];
|
||||
//$focus->supplier_code=3442;
|
||||
$focus->order_no=$order['Order-Header']['OrderNumber'];
|
||||
$focus->ecmlanguage="pl_pl";
|
||||
$focus->ecmpaymentcondition_id=$order['Order-Parties']['Buyer']['PaymentConditionId'];
|
||||
|
||||
$focus->parent_name=$row["name"];//$account->name;
|
||||
$focus->parent_address_street=$a;//$account->shipping_address_street;
|
||||
$focus->parent_address_city=$b;//$account->shipping_address_city;
|
||||
$focus->parent_address_postalcode=$c;//$account->shipping_address_postalcode;
|
||||
$focus->parent_address_country=$d;//$account->shipping_address_country;
|
||||
|
||||
$ra=array();
|
||||
$total=0;
|
||||
|
||||
|
||||
|
||||
if(count($pr)>0){
|
||||
foreach($pr as $prod){
|
||||
$product_id="";
|
||||
//$w=$GLOBALS['db']->query("select id as ecmproduct_id from ecmproducts where code='".$prod['Line']['Line-Item']['CODE']."' and deleted='0' and code NOT LIKE '%_w' and code NOT LIKE '%_z' and code NOT LIKE '%_W' and code NOT LIKE '%_Z'");
|
||||
//$w=$GLOBALS['db']->query("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
$row = $db->fetchFirstRow("select `id` as `ecmproduct_id` from `ecmproducts` where `id`='".$prod['Line']['Line-Item']['CODE']."' and `deleted`='0' and `code` NOT LIKE '%_w' and `code` NOT LIKE '%_z' and `code` NOT LIKE '%_W' and `code` NOT LIKE '%_Z'");
|
||||
// $r=$GLOBALS['db']->fetchByAssoc($w);
|
||||
$product_id=$row['ecmproduct_id'];
|
||||
|
||||
$wp=$GLOBALS['db']->query("select * from `ecmproducts` where `id`='".$product_id."'");
|
||||
$rppp=$GLOBALS['db']->fetchByAssoc($wp);
|
||||
$product_code=$rppp['code'];
|
||||
$product_name=$rppp['name'];
|
||||
$vat_id=$rppp['vat_id'];
|
||||
$vat_name=$rppp['vat_name'];
|
||||
$vat_value=$rppp['vat_value'];
|
||||
|
||||
$return_array['id'] = $product_id;
|
||||
$return_array['code'] = $product_code;
|
||||
$return_array['name'] = $product_name;
|
||||
$return_array['quantity'] = $prod['Line']['Line-Item']['OrderedQuantity'];
|
||||
$return_array['price'] = $prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['discount'] = 0;
|
||||
$return_array['total'] = $prod['Line']['Line-Item']['OrderedQuantity']*$prod['Line']['Line-Item']['OrderedUnitNetPrice'];
|
||||
$return_array['unit_id'] = 1;
|
||||
$return_array['unit_name'] = 'szt.';
|
||||
$return_array['vat_id'] = $vat_id;
|
||||
$return_array['vat_name'] = $vat_name;
|
||||
$return_array['vat_value'] = $vat_value;
|
||||
$return_array['currency_id'] = 'PLN';
|
||||
$return_array['recipient_code'] = $prod['Line']['Line-Item']['BuyerItemCode'];
|
||||
$total+=$return_array['quantity']*$return_array['price']*(1+$vat_value/100);
|
||||
$ra[]=$return_array;
|
||||
}
|
||||
}
|
||||
$focus->position_list = $ra;
|
||||
$return_id=$focus->save_from_shop($presta, $user);
|
||||
$GLOBALS['db']->query("update `ecmsales` set `total`='".$total."' where `id`='".$return_id."'");
|
||||
|
||||
|
||||
return $return_id;
|
||||
|
||||
|
||||
//return print_r(mysql_error()."mm", true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch(Exception $e) {}
|
||||
|
||||
}
|
||||
|
||||
return $y;
|
||||
|
||||
|
||||
}
|
||||
|
||||
$order_lines = array();
|
||||
$line= array(
|
||||
'Line' => array(
|
||||
'Line-Item' => array(
|
||||
'LineNumber' => 1,
|
||||
'CODE' => 33,
|
||||
'EAN' => '',
|
||||
'BuyerItemCode' => '',
|
||||
'SupplierItemCode' => '',
|
||||
'ItemDescription' => "produkt",
|
||||
'ItemType' => 'CU',
|
||||
'OrderedQuantity' => "1",
|
||||
'OrderedUnitPacksize' => 1,
|
||||
'UnitOfMeasure' => 'PCE',
|
||||
'OrderedUnitNetPrice' => 99,
|
||||
'PackageNumber' => '',
|
||||
),
|
||||
),
|
||||
);
|
||||
$order_lines[] = $line;
|
||||
|
||||
|
||||
$order = array();
|
||||
$order['Order-Summary'] = array(
|
||||
'TotalLines' => 1-1,
|
||||
'TotalOrderedAmount' => "5000",
|
||||
);
|
||||
$order['Order-Lines'] = $order_lines; // ilosc wierszy w zamowieniu
|
||||
|
||||
// echo print_r($order);
|
||||
//exit;
|
||||
|
||||
$order['Order-Parties']['Buyer']['Login'] = "777"; // login uzytkownika
|
||||
$order['Order-Parties']['Buyer']['Description'] = ""; // opis
|
||||
$order['Order-Header']['OrderDate'] = date("Y-m-d");
|
||||
$order['Order-Header']['ExpectedDeliveryDate'] = date("Y-m-d");
|
||||
|
||||
$order['Order-Header']['OrderNumber'] = "brak"; // numer zamowienia
|
||||
$order['Order-Parties']['Buyer']['PaymentConditionId'] = "23d19aa9-d63a-dd99-568c-4dff0bbc7f40"; // 7 dni na zaplate
|
||||
|
||||
$getReference = "HKKMLOPMX";
|
||||
|
||||
$order['Order-Header']['Presta'] = $getReference;
|
||||
|
||||
|
||||
|
||||
?>
|
||||
27
WSDL/inc.error.php
Normal file
27
WSDL/inc.error.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
////
|
||||
// Error handling
|
||||
////
|
||||
|
||||
error_reporting( E_ERROR );
|
||||
function handleError($errno, $errstr,$error_file,$error_line) { throw new Exception("Error [$errno]: $errstr - $error_file:$error_line"); }
|
||||
set_error_handler("handleError");
|
||||
|
||||
error_reporting(0);
|
||||
set_error_handler('myErrorHandler');
|
||||
register_shutdown_function('fatalErrorShutdownHandler');
|
||||
function myErrorHandler($code, $message, $file, $line)
|
||||
{
|
||||
die("Fatal Error: [$code] $message - $file:$line");
|
||||
}
|
||||
|
||||
function fatalErrorShutdownHandler()
|
||||
{
|
||||
$last_error = error_get_last();
|
||||
if ($last_error['type'] === E_ERROR)
|
||||
{
|
||||
// fatal error
|
||||
myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
141
WSDL/inc.functions.php
Normal file
141
WSDL/inc.functions.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php
|
||||
|
||||
|
||||
function DateTimeToString($dt)
|
||||
{
|
||||
$_dt = new DateTime($dt);
|
||||
return $_dt->format(DateTime::ATOM);
|
||||
}
|
||||
|
||||
function StartTimer()
|
||||
{
|
||||
$time = microtime();$time = explode(' ', $time);$time = $time[1] + $time[0];$start = $time;
|
||||
return $start;
|
||||
}
|
||||
|
||||
function StopTimer($start)
|
||||
{
|
||||
$time = microtime();$time = explode(' ', $time);$time = $time[1] + $time[0];$finish = $time; //$total_time = round(($finish - $start), 4);
|
||||
return round(($finish - $start), 4);
|
||||
}
|
||||
|
||||
function startsWith($haystack, $needle)
|
||||
{
|
||||
return !strncmp($haystack, $needle, strlen($needle));
|
||||
}
|
||||
|
||||
function endsWith($haystack, $needle)
|
||||
{
|
||||
$length = strlen($needle);
|
||||
if ($length == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return (substr($haystack, -$length) === $needle);
|
||||
}
|
||||
|
||||
function strrtrim($message, $strip) {
|
||||
// break message apart by strip string
|
||||
$lines = explode($strip, $message);
|
||||
$last = '';
|
||||
// pop off empty strings at the end
|
||||
do {
|
||||
$last = array_pop($lines);
|
||||
} while (empty($last) && (count($lines)));
|
||||
// re-assemble what remains
|
||||
return implode($strip, array_merge($lines, array($last)));
|
||||
}
|
||||
|
||||
|
||||
function full_url()
|
||||
{
|
||||
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
|
||||
$sp = strtolower($_SERVER["SERVER_PROTOCOL"]);
|
||||
$protocol = substr($sp, 0, strpos($sp, "/")) . $s;
|
||||
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
|
||||
return $protocol . "://" . $_SERVER['SERVER_NAME'] . $port . $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
|
||||
function md5_hash_encode($source)
|
||||
{
|
||||
$base_string = md5($source); // kodowanie stringa standardowym MD5()
|
||||
|
||||
// dzielenie stringa na 3 kawałki
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 4,20);
|
||||
$end = substr($base_string, 20, strlen($base_string));
|
||||
|
||||
$base_string = $begin.rand(0,8).$in.rand(0,8).$end; // dodawanie dodatkowego hasha
|
||||
$base_string = strrev($base_string); // odwracanie kolejności znaków w stringu
|
||||
|
||||
return $base_string;
|
||||
}
|
||||
|
||||
function md5_hash_decode($source)
|
||||
{
|
||||
$base_string = strrev($source); // odwracanie kolejności znaków w stringu
|
||||
|
||||
// pobieranie prawidłowych elementów stringa
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 5, 20);
|
||||
$end = substr($base_string, 30, strlen($base_string));
|
||||
|
||||
$base_string = $begin.$in.$end;
|
||||
|
||||
return $base_string;
|
||||
}
|
||||
|
||||
function base64_hash_encode($source, $base = false)
|
||||
{
|
||||
if ($base) $base_string = base64_encode($source); else $base_string = $source;
|
||||
|
||||
if (strlen($source) > 24) {
|
||||
// dzielenie stringa na 3 kawałki
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 4,20);
|
||||
$end = substr($base_string, 24, strlen($base_string));
|
||||
|
||||
$base_string = $begin.rand(0, 8).$in.rand(0, 8).$end; // dodawanie dodatkowego hasha
|
||||
}
|
||||
|
||||
$base_string = strrev($base_string); // odwracanie kolejności znaków w stringu
|
||||
|
||||
for ($i = 0; $i < strlen($base_string); $i++) $base_string[$i] = chr(ord($base_string[$i]) + ($i * 3));
|
||||
|
||||
// zamiana treści na HEX
|
||||
$encode_result = "";
|
||||
foreach(str_split($base_string) as $c) $encode_result .= sprintf("%02X", ord($c));
|
||||
|
||||
return strtolower($encode_result);
|
||||
|
||||
}
|
||||
|
||||
function base64_hash_decode($source, $base = false)
|
||||
{
|
||||
// odwracanie treści z HEX
|
||||
$source_decode = "";
|
||||
foreach(explode("\n", trim(chunk_split(strtoupper($source), 2))) as $h) $source_decode .= chr(hexdec($h));
|
||||
|
||||
for ($i = 0; $i < strlen($source_decode); $i++) $source_decode[$i] = chr(ord($source_decode[$i]) - ($i * 3));
|
||||
|
||||
$base_string = strrev($source_decode); // odwracanie kolejności znaków w stringu
|
||||
|
||||
if (strlen($base_string) > 24) {
|
||||
// pobieranie prawidłowych elementów stringa
|
||||
$begin = substr($base_string, 0, 4);
|
||||
$in = substr($base_string, 5, 20);
|
||||
$end = substr($base_string, 26, strlen($base_string));
|
||||
|
||||
$base_string = $begin.$in.$end;
|
||||
}
|
||||
|
||||
if ($base) $base_string = base64_decode($base_string);
|
||||
|
||||
return $base_string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// echo md5('passowrd!!!!787').'<BR>';
|
||||
// echo md5_hash_decode('912e198bd3876d387bd8846228375303036951').'<BR>';
|
||||
?>
|
||||
13
WSDL/inc.mysqli.config.php
Normal file
13
WSDL/inc.mysqli.config.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
define("MYSQL_API_HOST", "localhost");
|
||||
define("MYSQL_API_PORT", "80");
|
||||
define("MYSQL_API_USER", "root");
|
||||
define("MYSQL_API_PASSWORD", "5z#JaL");
|
||||
define("MYSQL_API_DATABASE", "crm");
|
||||
define("MYSQL_API_COLLATE", "UTF8");
|
||||
|
||||
define("sugarEntry", "true");
|
||||
|
||||
|
||||
?>
|
||||
100
WSDL/inc.mysqli.php
Normal file
100
WSDL/inc.mysqli.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
// Wrapper do łatwej obsługi MySQL poprzez mysqli
|
||||
|
||||
|
||||
class Database {
|
||||
|
||||
public $link = NULL;
|
||||
public $errors = array();
|
||||
|
||||
public function __construct($server = '',$user='',$pass='',$port='',$dbname='',$collation='') {
|
||||
|
||||
if(!empty($server)) $this->connect($server, $user, $pass, $port, $dbname, $collation);
|
||||
|
||||
}
|
||||
|
||||
public function __destruct() {
|
||||
|
||||
$this->close();
|
||||
|
||||
}
|
||||
|
||||
public function connect($server, $user, $pass, $port, $dbname, $collation) {
|
||||
|
||||
$this->link = mysqli_connect($server, $user, $pass, $dbname, $port) or $errors[] = 'Database Error: '.mysqli_connect_error();
|
||||
$this->link->set_charset($collation);
|
||||
//$this->nonquery("SET NAMES 'utf8';");
|
||||
|
||||
}
|
||||
|
||||
public function close() {
|
||||
|
||||
//$this->link->close();
|
||||
|
||||
}
|
||||
|
||||
public function info() {
|
||||
|
||||
return mysqli_get_host_info($this->link);
|
||||
|
||||
}
|
||||
|
||||
public function es($text) {
|
||||
|
||||
return $this->link->real_escape_string($text);
|
||||
|
||||
}
|
||||
|
||||
function prepareQuery($string, $vars = array()) {
|
||||
|
||||
if(!is_array($vars)) $vars = array_slice(func_get_args(),1);
|
||||
|
||||
foreach($vars as $var) {
|
||||
if(!isset($v)) $v = 0;
|
||||
++$v;
|
||||
$string = str_replace('{'.$v.'}',$this->es($var),$string);
|
||||
}
|
||||
return $string;
|
||||
|
||||
}
|
||||
|
||||
public function query($command) {
|
||||
|
||||
$result = $this->link->query($command);
|
||||
if ($result == NULL) throw new Exception("Query Error: ".$this->link->error." Query:".$command."");
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function nonquery($command) {
|
||||
|
||||
if ($this->link->query($command) == NULL) throw new Exception("NonQuery Error: ".$this->link->error." Query:".$command."");
|
||||
|
||||
}
|
||||
|
||||
public function fetchfirst($command) {
|
||||
|
||||
$result = $this->fetcharray($command);
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function fetcharray($command) {
|
||||
|
||||
$query = $this->link->query($command);
|
||||
$result = $query->fetch_array(MYSQLI_BOTH);
|
||||
$query->close();
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
public function LastInsertId() {
|
||||
|
||||
$result = $this->fetchfirst("SELECT LAST_INSERT_ID();");
|
||||
return $result[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
7
WSDL/inc.variables.php
Normal file
7
WSDL/inc.variables.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
define("WEBSERVICE_NAME", "WSDL");
|
||||
define("DEBUG", false);
|
||||
define("ROOT_URL", "https://e5.2dev.pl/");
|
||||
|
||||
?>
|
||||
1042
WSDL/inc.ws.methods.php
Normal file
1042
WSDL/inc.ws.methods.php
Normal file
File diff suppressed because it is too large
Load Diff
25
WSDL/inc.ws.types.php
Normal file
25
WSDL/inc.ws.types.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
function Register_Types($server) {
|
||||
|
||||
$server->wsdl->addComplexType('UpdateOrder','complexType','struct','sequence','',
|
||||
array (
|
||||
|
||||
'outputInfo' => array('type' => 'tns:OutputInfo')
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
$server->wsdl->addComplexType('Aktualizuj','complexType','struct','sequence','',
|
||||
array (
|
||||
|
||||
'data'=>array('name'=>'data','type'=>'xsd:int'),
|
||||
|
||||
'outputInfo' => array('type' => 'tns:OutputInfo')
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
159
WSDL/pdo.db.php
Normal file
159
WSDL/pdo.db.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
class PDODB extends PDO
|
||||
{
|
||||
private $error;
|
||||
private $lastQuery;
|
||||
private $numRows;
|
||||
|
||||
|
||||
public function __construct($dsn, $user="", $passwd="", $timeout=30000)
|
||||
{
|
||||
$options = array(
|
||||
//PDO::ATTR_PERSISTENT => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||
PDO::ATTR_TIMEOUT => $timeout,
|
||||
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8' );
|
||||
|
||||
try
|
||||
{
|
||||
parent::__construct($dsn, $user, $passwd, $options);
|
||||
$this->error = null;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public function getLastQuery()
|
||||
{
|
||||
return $this->lastQuery;
|
||||
}
|
||||
|
||||
public function getError()
|
||||
{
|
||||
return $this->error;
|
||||
}
|
||||
public function rowCount()
|
||||
{
|
||||
return $this->numRows;
|
||||
}
|
||||
|
||||
|
||||
public function executeQuery($query, $params=array())
|
||||
{
|
||||
try
|
||||
{
|
||||
$_query = $this->prepare($query);
|
||||
$_query->execute($params);
|
||||
$this->numRows = $_query->rowCount();
|
||||
$this->error = null;
|
||||
$this->lastQuery = $_query->queryString;
|
||||
return $_query;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeReader($executed_query)
|
||||
{
|
||||
try
|
||||
{
|
||||
$results = $executed_query->fetchAll(PDO::FETCH_BOTH);
|
||||
$this->error = null;
|
||||
return $results;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchFirstRow($query, $params=array())
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
$executed_query = $this->executeQuery($query, $params);
|
||||
$this->lastQuery = $query;
|
||||
|
||||
$results = $executed_query->fetch(PDO::FETCH_BOTH);
|
||||
$this->error = null;
|
||||
return $results;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function executeNonQuery($query)
|
||||
{
|
||||
try
|
||||
{
|
||||
$_rows = $this->exec($query);
|
||||
$this->error = null;
|
||||
$this->lastQuery = $query;
|
||||
return $_rows;
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
$this->error = $e->getMessage();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
// nonquery
|
||||
//$query = $db->executeQuery("INSERT INTO pdo_test VALUES (null,now(), :v);",array('v' => 'ABC'.rand().'X'));
|
||||
$query = $db->executeQuery("INSERT INTO pdo_test VALUES (null,now(), ?);",array('ABC'.rand().'X'));
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><br>");
|
||||
print("inserted id: ".$db->lastInsertId()."<hr>");
|
||||
|
||||
// select
|
||||
$query = $db->executeQuery("SELECT * FROM pdo_test WHERE val like :v LIMIT 10;",array('v'=>'%5%'));
|
||||
foreach($db->executeReader($query) as $row)
|
||||
{
|
||||
echo "ROW: ".$row['created']." ".$row['val']."<br>";
|
||||
}
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
|
||||
//procedura
|
||||
$query = $db->executeQuery("CALL `pdo_test_proc`();");
|
||||
foreach($db->executeReader($query) as $row)
|
||||
{
|
||||
echo "ROW: ".$row['result']."<br>";
|
||||
}
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
//procedura drugi raz
|
||||
$firstRow = $db->fetchFirstRow("CALL `pdo_test_proc`();");
|
||||
echo "ROW: ".$firstRow['result']."<br>";
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
|
||||
|
||||
//prosty select
|
||||
$firstRow = $db->fetchFirstRow("SELECT count(*) FROM `pdo_test`;");
|
||||
echo "ROW: ".$firstRow[0]."<br>";
|
||||
print("<pre>getLastQuery: ".$db->getLastQuery()."\nError: ".$db->GetError()."</pre><hr>");
|
||||
*
|
||||
* */
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user