Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions htdocs/ovh/admin/ovh_click2dial.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
dol_include_once("/ovh/lib/ovh.lib.php");
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP

require __DIR__ . '/../includes/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client as GClient;
dol_include_once('/ovh/class/doliovhapi.class.php');


$action=GETPOST('action', 'aZ09');
Expand Down
5 changes: 1 addition & 4 deletions htdocs/ovh/admin/ovh_importinvoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@
require_once DOL_DOCUMENT_ROOT . "/core/class/html.formfile.class.php";
require_once NUSOAP_PATH . '/nusoap.php'; // Include SOAP

require __DIR__ . '/../includes/autoload.php';

use \Ovh\Api;
use GuzzleHttp\Client as GClient;
dol_include_once('/ovh/class/doliovhapi.class.php');


$langs->load("ovh@ovh");
Expand Down
18 changes: 2 additions & 16 deletions htdocs/ovh/admin/ovh_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
dol_include_once("/ovh/lib/ovh.lib.php");
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP

require __DIR__ . '/../includes/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client as GClient;
dol_include_once('/ovh/class/doliovhapi.class.php');

// Load traductions files requiredby by page
$langs->load("admin");
Expand Down Expand Up @@ -171,19 +169,7 @@ function traitementErreur($code, $message, $fichier, $ligne, $contexte)
dol_syslog("Request credential to endpoint ".$endpoint);
dol_syslog("applicationKey=".$applicationKey." applicationSecret=".$applicationKey." redirect_uri=".$redirect_uri);

if ('guzzle7.3' == 'guzzle7.3') {
$arrayconfig = array(
'connect_timeout'=>(empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?20:$conf->global->MAIN_USE_CONNECT_TIMEOUT),
'timeout'=>(empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT)
);
$http_client = new GClient($arrayconfig);
} else {
$http_client = new GClient();
$http_client->setDefaultOption('connect_timeout', empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?20:$conf->global->MAIN_USE_CONNECT_TIMEOUT); // Timeout by default of OVH is 5 and it is not enough
$http_client->setDefaultOption('timeout', empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT);
}

$conn = new Api($applicationKey, $applicationSecret, $endpoint, null, $http_client); // consumer_key is not set to force to get a new one
$conn = new DoliOvhApi($applicationKey, $applicationSecret, $endpoint, null); // consumer_key is not set to force to get a new one
$credentials = $conn->requestCredentials($rights, $redirect_uri);

$_SESSION['ovh_consumer_key']=$credentials["consumerKey"];
Expand Down
4 changes: 1 addition & 3 deletions htdocs/ovh/admin/ovh_sms_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@
dol_include_once("/ovh/lib/ovh.lib.php");
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP

require __DIR__ . '/../includes/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client as GClient;
dol_include_once('/ovh/class/doliovhapi.class.php');


// Load traductions files requiredby by page
Expand Down
4 changes: 1 addition & 3 deletions htdocs/ovh/admin/ovh_smsrecap.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@
dol_include_once("/ovh/class/ovhsms.class.php");
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP

require __DIR__ . '/../includes/autoload.php';
use \Ovh\Api;
use GuzzleHttp\Client as GClient;
dol_include_once('/ovh/class/doliovhapi.class.php');


// Load traductions files requiredby by page
Expand Down
116 changes: 116 additions & 0 deletions htdocs/ovh/build/buildzip.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
<?php

$list = [
'admin',
'ChangeLog.md',
'class',
'composer.json',
'composer.lock',
'COPYING',
'core',
'doc',
'img',
'importovhinvoice.php',
'includes',
'langs',
'lib',
'ovh_listinfoserver.php',
'README.md',
'README-update-ovh-lib-with-composer.txt',
'scripts',
'sms_member.php',
'sms_thirdparty.php',
'sql',
'wrapper.php',
];

$tab = glob("../core/modules/mod*.class.php");
if (count($tab) == 1) {
$file = $tab[0];
$mod = "";
$pattern = "/.*mod(?<mod>.*)\.class\.php/";
if (preg_match_all($pattern, $file, $matches)) {
$mod = strtolower(reset($matches['mod']));
}

echo "file = $file\n";
echo "mod = $mod\n";
if (!file_exists($file) || $mod == "") {
echo "Erreur de détection du fichier et/ou du code du module ...";
exit -1;
}
} else {
echo "Erreur il semblerait qu'il y ait plusieurs fichiers mod* dans le répertoire ...";
exit -1;
}

$contents = file_get_contents($file);
$pattern = "/^.*this->version\s*=\s*'(?<version>.*)'\s*;.*\$/m";

// search, and store all matching occurences in $matches
$version = '';
if (preg_match_all($pattern, $contents, $matches)) {
$version = reset($matches['version']);
}

$zipfile = "module_" . $mod . "-" . $version . ".zip";

function delTree($dir)
{
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}

function rcopy($src, $dst)
{
if (is_dir($src)) {
// Make the destination directory if not exist
@mkdir($dst);
// open the source directory
$dir = opendir($src);

// Loop through the files in source directory
while ($file = readdir($dir)) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
// Recursively calling custom copy function
// for sub directory
rcopy($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
} elseif (is_file($src)) {
copy($src, $dst);
} else {
print "erreur pour *$src*\n";
}
}

$tmpdir = tempnam('/tmp', $mod . "-module");
unlink($tmpdir);
mkdir($tmpdir);
$dst = $tmpdir . "/htdocs/";
mkdir($dst);
$dst .= $mod;
mkdir($dst);

echo "copy to $dst...\n";

foreach ($list as $l) {
rcopy("../" . $l, $dst . '/' . $l);
}

chdir($tmpdir);
shell_exec("zip -r $zipfile htdocs");
if (file_exists($zipfile)) {
rename($zipfile, "/tmp/" . $zipfile);
delTree($tmpdir);
}

echo "fichier dispo /tmp/$zipfile ...\n";
114 changes: 114 additions & 0 deletions htdocs/ovh/build/buildzip.php~
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

$list = [
'admin',
'backport',
'ChangeLog.md',
'class',
'composer.json',
'COPYING',
'core',
'img',
'langs',
'lib',
'modulebuilder.txt',
'public',
'README.md',
'sql',
'vendor',
'stancerindex.php',
'stancer_payments_list.php',
'stancer_payouts_list.php',
'stancer_thirdparty.php'
];

$tab = glob("../core/modules/mod*.class.php");
if (count($tab) == 1) {
$file = $tab[0];
$mod = "";
$pattern = "/.*mod(?<mod>.*)\.class\.php/";
if (preg_match_all($pattern, $file, $matches)) {
$mod = strtolower(reset($matches['mod']));
}

echo "file = $file\n";
echo "mod = $mod\n";
if (!file_exists($file) || $mod == "") {
echo "Erreur de détection du fichier et/ou du code du module ...";
exit -1;
}
} else {
echo "Erreur il semblerait qu'il y ait plusieurs fichiers mod* dans le répertoire ...";
exit -1;
}

$contents = file_get_contents($file);
$pattern = "/^.*this->version\s*=\s*'(?<version>.*)'\s*;.*\$/m";

// search, and store all matching occurences in $matches
$version = '';
if (preg_match_all($pattern, $contents, $matches)) {
$version = reset($matches['version']);
}

$zipfile = "module_" . $mod . "-" . $version . ".zip";

function delTree($dir)
{
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}

function rcopy($src, $dst)
{
if (is_dir($src)) {
// Make the destination directory if not exist
@mkdir($dst);
// open the source directory
$dir = opendir($src);

// Loop through the files in source directory
while ($file = readdir($dir)) {
if (($file != '.') && ($file != '..')) {
if (is_dir($src . '/' . $file)) {
// Recursively calling custom copy function
// for sub directory
rcopy($src . '/' . $file, $dst . '/' . $file);
} else {
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
} elseif (is_file($src)) {
copy($src, $dst);
} else {
print "erreur pour *$src*\n";
}
}

$tmpdir = tempnam('/tmp', $mod . "-module");
unlink($tmpdir);
mkdir($tmpdir);
$dst = $tmpdir . "/htdocs/";
mkdir($dst);
$dst .= $mod;
mkdir($dst);

echo "copy to $dst...\n";

foreach ($list as $l) {
rcopy("../" . $l, $dst . '/' . $l);
}

chdir($tmpdir);
shell_exec("zip -r $zipfile htdocs");
if (file_exists($zipfile)) {
rename($zipfile, "/tmp/" . $zipfile);
delTree($tmpdir);
}

echo "fichier dispo /tmp/$zipfile ...\n";
Loading
Loading