diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000..1b94b60f --- /dev/null +++ b/.htaccess @@ -0,0 +1,18 @@ +Options -Multiviews +RewriteEngine On + +RewriteCond %{HTTPS} off +RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] + +RewriteBase / + +# si fichier ou dossier existe → ne pas toucher +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d + +# envoyer vers CodeIgniter +RewriteRule ^(.*)$ index.php/$1 [L] + +# php -- BEGIN cPanel-generated handler, do not edit +# This domain inherits the “PHP” package. +# php -- END cPanel-generated handler, do not edit \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/crm_commun.iml b/.idea/crm_commun.iml new file mode 100644 index 00000000..af456439 --- /dev/null +++ b/.idea/crm_commun.iml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 00000000..0d9d557f --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,36 @@ + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 00000000..5a695d95 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..58ae56a7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/php.xml b/.idea/php.xml new file mode 100644 index 00000000..d7ee62d4 --- /dev/null +++ b/.idea/php.xml @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpspec.xml b/.idea/phpspec.xml new file mode 100644 index 00000000..33107fdc --- /dev/null +++ b/.idea/phpspec.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/phpunit.xml b/.idea/phpunit.xml new file mode 100644 index 00000000..bff365d8 --- /dev/null +++ b/.idea/phpunit.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/.idea/sshConfigs.xml b/.idea/sshConfigs.xml new file mode 100644 index 00000000..17217387 --- /dev/null +++ b/.idea/sshConfigs.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..83067447 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/webServers.xml b/.idea/webServers.xml new file mode 100644 index 00000000..d1104d8c --- /dev/null +++ b/.idea/webServers.xml @@ -0,0 +1,35 @@ + + + + + + \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..a732e4a2 --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "description": "The CodeIgniter framework", + "name": "codeigniter/framework", + "type": "project", + "homepage": "https://codeigniter.com", + "license": "MIT", + "support": { + "forum": "http://forum.codeigniter.com/", + "wiki": "https://github.com/bcit-ci/CodeIgniter/wiki", + "slack": "https://codeigniterchat.slack.com", + "source": "https://github.com/bcit-ci/CodeIgniter" + }, + "require": { + "php": ">=5.3.7", + "google/apiclient": "^2.0" + }, + "suggest": { + "paragonie/random_compat": "Provides better randomness in PHP 5.x" + }, + "require-dev": { + "mikey179/vfsstream": "1.1.*", + "phpunit/phpunit": "4.* || 5.*" + }, + "autoload": { + "psr-4": { + "Common\\": "Common/", + "SmartUI\\": "lib/smartui/" + } + } + +} diff --git a/credentials.json b/credentials.json new file mode 100644 index 00000000..bce8651f --- /dev/null +++ b/credentials.json @@ -0,0 +1 @@ +{"web":{"client_id":"757586711309-lmhhl49m6o1kfs3qdm6ruhkudik3nk46.apps.googleusercontent.com","project_id":"backup-astral1","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"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","javascript_origins":["https://ms1crmdev.progiweb.net"]}} \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 00000000..68399a2e --- /dev/null +++ b/index.php @@ -0,0 +1,323 @@ +=')) + { + error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED); + } + else + { + error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE); + } + break; + + default: + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); + echo 'The application environment is not set correctly.'; + exit(1); // EXIT_ERROR +} + +/* + *--------------------------------------------------------------- + * SYSTEM DIRECTORY NAME + *--------------------------------------------------------------- + * + * This variable must contain the name of your "system" directory. + * Set the path if it is not in the same directory as this file. + */ + $system_path = 'system'; + +/* + *--------------------------------------------------------------- + * APPLICATION DIRECTORY NAME + *--------------------------------------------------------------- + * + * If you want this front controller to use a different "application" + * directory than the default one you can set its name here. The directory + * can also be renamed or relocated anywhere on your server. If you do, + * use an absolute (full) server path. + * For more info please see the user guide: + * + * https://codeigniter.com/user_guide/general/managing_apps.html + * + * NO TRAILING SLASH! + */ + $application_folder = 'application'; + +/* + *--------------------------------------------------------------- + * VIEW DIRECTORY NAME + *--------------------------------------------------------------- + * + * If you want to move the view directory out of the application + * directory, set the path to it here. The directory can be renamed + * and relocated anywhere on your server. If blank, it will default + * to the standard location inside your application directory. + * If you do move this, use an absolute (full) server path. + * + * NO TRAILING SLASH! + */ + $view_folder = ''; + + +/* + * -------------------------------------------------------------------- + * DEFAULT CONTROLLER + * -------------------------------------------------------------------- + * + * Normally you will set your default controller in the routes.php file. + * You can, however, force a custom routing by hard-coding a + * specific controller class/function here. For most applications, you + * WILL NOT set your routing here, but it's an option for those + * special instances where you might want to override the standard + * routing in a specific front controller that shares a common CI installation. + * + * IMPORTANT: If you set the routing here, NO OTHER controller will be + * callable. In essence, this preference limits your application to ONE + * specific controller. Leave the function name blank if you need + * to call functions dynamically via the URI. + * + * Un-comment the $routing array below to use this feature + */ + // The directory name, relative to the "controllers" directory. Leave blank + // if your controller is not in a sub-directory within the "controllers" one + // $routing['directory'] = ''; + + // The controller class file name. Example: mycontroller + // $routing['controller'] = ''; + + // The controller function you wish to be called. + // $routing['function'] = ''; + + +/* + * ------------------------------------------------------------------- + * CUSTOM CONFIG VALUES + * ------------------------------------------------------------------- + * + * The $assign_to_config array below will be passed dynamically to the + * config class when initialized. This allows you to set custom config + * items or override any default config values found in the config.php file. + * This can be handy as it permits you to share one application between + * multiple front controller files, with each file containing different + * config values. + * + * Un-comment the $assign_to_config array below to use this feature + */ + // $assign_to_config['name_of_config_item'] = 'value of config item'; + + + +// -------------------------------------------------------------------- +// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE +// -------------------------------------------------------------------- + +/* + * --------------------------------------------------------------- + * Resolve the system path for increased reliability + * --------------------------------------------------------------- + */ + + // Set the current directory correctly for CLI requests + if (defined('STDIN')) + { + chdir(dirname(__FILE__)); + } + + if (($_temp = realpath($system_path)) !== FALSE) + { + $system_path = $_temp.DIRECTORY_SEPARATOR; + } + else + { + // Ensure there's a trailing slash + $system_path = strtr( + rtrim($system_path, '/\\'), + '/\\', + DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR + ).DIRECTORY_SEPARATOR; + } + + // Is the system path correct? + if ( ! is_dir($system_path)) + { + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); + echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME); + exit(3); // EXIT_CONFIG + } + +/* + * ------------------------------------------------------------------- + * Now that we know the path, set the main path constants + * ------------------------------------------------------------------- + */ + // The name of THIS file + define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME)); + + // Path to the system directory + define('BASEPATH', $system_path); + + // Path to the front controller (this file) directory + define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR); + + // Name of the "system" directory + define('SYSDIR', basename(BASEPATH)); + + // The path to the "application" directory + if (is_dir($application_folder)) + { + if (($_temp = realpath($application_folder)) !== FALSE) + { + $application_folder = $_temp; + } + else + { + $application_folder = strtr( + rtrim($application_folder, '/\\'), + '/\\', + DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR + ); + } + } + elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR)) + { + $application_folder = BASEPATH.strtr( + trim($application_folder, '/\\'), + '/\\', + DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR + ); + } + else + { + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); + echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF; + exit(3); // EXIT_CONFIG + } + + define('APPPATH', $application_folder.DIRECTORY_SEPARATOR); + + // The path to the "views" directory + if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR)) + { + $view_folder = APPPATH.'views'; + } + elseif (is_dir($view_folder)) + { + if (($_temp = realpath($view_folder)) !== FALSE) + { + $view_folder = $_temp; + } + else + { + $view_folder = strtr( + rtrim($view_folder, '/\\'), + '/\\', + DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR + ); + } + } + elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR)) + { + $view_folder = APPPATH.strtr( + trim($view_folder, '/\\'), + '/\\', + DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR + ); + } + else + { + header('HTTP/1.1 503 Service Unavailable.', TRUE, 503); + echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF; + exit(3); // EXIT_CONFIG + } + + define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR); + +/* + * -------------------------------------------------------------------- + * LOAD THE BOOTSTRAP FILE + * -------------------------------------------------------------------- + * + * And away we go... + */ + +require_once BASEPATH.'core/CodeIgniter.php'; + diff --git a/init.php b/init.php new file mode 100644 index 00000000..ba9d3c7d --- /dev/null +++ b/init.php @@ -0,0 +1,73 @@ + $value) { + if ($value) $argv[] = $value; + } +} + +if (Common\Util::is_cli()) { + $document_root = realpath(isset($argv[1]) && is_dir($argv[1]) ? $argv[1] : dirname(__DIR__)); + $server_name = gethostname(); + $request_uri = str_replace(DS, '/', substr($_SERVER['PHP_SELF'], strlen($document_root))); +} else { + $document_root = realpath($_SERVER['DOCUMENT_ROOT']); + $server_name = $_SERVER['HTTP_HOST']; + $request_uri = $_SERVER['REQUEST_URI']; +} + +$document_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ? 'https' : 'http').'://'.$server_name; + +$app_path = $document_root; +$app_url = $document_url; + +if (strpos(__DIR__, $document_root) === 0) { + $app_uri = substr(__DIR__, strlen($document_root)); + $app_path .= $app_uri; + $app_url .= str_replace(DS, '/', $app_uri); +} + +define('DOCUMENT_ROOT', $document_root); +define('SERVER_NAME', $server_name); +define('SERVER_URL', $document_url); +define('SERVER_REQUEST', $document_url.$request_uri); + +define('APP_PATH', $app_path); +define('APP_URL', $app_url); + +//Assets URL, location of your css, img, js, etc. files +define('ASSETS_URL', APP_URL); +define('ASSETS_PATH', APP_PATH); + +// configure global constants +// define('APP_TMP_PATH', APP_PATH.DS.'tmp'); +// define('APP_TMP_URL', APP_URL.'/tmp'); + +// global functions +require_once __DIR__.'/lib/func.php'; +require_once __DIR__.'/lib/config.php'; + +// configure SmartUI +\SmartUI\UI::$icon_source = 'fa'; + +// register our UI plugins +\SmartUI\UI::register('widget', 'SmartUI\Components\Widget'); +\SmartUI\UI::register('datatable', 'SmartUI\Components\DataTable'); +\SmartUI\UI::register('button', 'SmartUI\Components\Button'); +\SmartUI\UI::register('tab', 'SmartUI\Components\Tab'); +\SmartUI\UI::register('accordion', 'SmartUI\Components\Accordion'); +\SmartUI\UI::register('carousel', 'SmartUI\Components\Carousel'); +\SmartUI\UI::register('smartform', 'SmartUI\Components\SmartForm'); +\SmartUI\UI::register('nav', 'SmartUI\Components\Nav'); + +$_ui = new \SmartUI\UI(); \ No newline at end of file diff --git a/init.web.php b/init.web.php new file mode 100644 index 00000000..96047115 --- /dev/null +++ b/init.web.php @@ -0,0 +1,145 @@ + "URL"); +$breadcrumbs = array( + "Home" => APP_URL +); + +/*navigation array config + +ex: +"dashboard" => array( + "title" => "Display Title", + "url" => "http://yoururl.com", + "url_target" => "_self", + "icon" => "fa-home", + "label_htm" => "Add your custom label/badge html here", + "sub" => array() //contains array of sub items with the same format as the parent +) + +*/ + +$page_nav = array( + "dash1" => array( + "title" => "Tableaux de bord", + "icon" => "fa-dashboard", + "url" => APP_URL."/index.php/Home" + + ), + "dash5" => array( + "title" => "Tâches", + "icon" => "fa-square", + "url" => APP_URL."/index.php/projets/list_taches" + + ), + "dash4" => array( + "title" => "Tâches Projets", + "icon" => "fa-square", + "url" => APP_URL."/index.php/TachesProjets" + + ), + "dash3" => array( + "title" => "Départs à venir", + "icon" => "fa-square", + "url" => APP_URL."/index.php/projets/depart" + + ), + + "vide" => array( + "title" => "" + + ), + "clients" => array( + "title" => "Clients", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/index.php/clients" + +), + "fournisseurs" => array( + "title" => "Fournisseurs", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/index.php/fournisseurs" + + ), + "fournisseursprojets" => array( + "title" => "Fournisseurs / Projets", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/index.php/Fournisseursprojets" + + ), + "produits" => array( + "title" => "Produits", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/index.php/produits" + + ), + "vide2" => array( + "title" => "" + + ), + "projets" => array( + "title" => "Projets", + "icon" => "fa-suitcase", + "url" => APP_URL."/index.php/projets" + + ) +, + "paiement" => array( + "title" => "Paiements", + "icon" => " fa-dollar", + "url" => APP_URL."/index.php/paiements" + + ) +, + + + "lot" => array( + "title" => "Lot", + "icon" => "fa-envelope-o", + "url" => APP_URL."/index.php/lots" + + ) +, + + + "user" => array( + "title" => "Utilisateur", + "icon" => "fa-user", + "url" => APP_URL."/index.php/user" + + ) + +, + + + "inventaireitem" => array( + "title" => "items", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/v4/dynamic/list/inventaire" + + ) +, + + + "inventaire" => array( + "title" => "items Par Localication", + "icon" => "fa-pencil-square-o", + "url" => APP_URL."/v4/dynamic/list/inventaire_stock" + + ) +); + +//configuration variables +$page_title = ""; +$page_css = array(); +$no_main_header = false; //set true for lock.php and login.php +$page_body_prop = array(); //optional properties for +$page_html_prop = array(); //optional properties for +?> \ No newline at end of file diff --git a/phpinfo.php b/phpinfo.php new file mode 100644 index 00000000..952fc633 --- /dev/null +++ b/phpinfo.php @@ -0,0 +1,8 @@ +`_ page. + +************************** +Changelog and New Features +************************** + +You can find a list of all changes for each release in the `user +guide change log `_. + +******************* +Server Requirements +******************* + +PHP version 5.6 or newer is recommended. + +It should work on 5.3.7 as well, but we strongly advise you NOT to run +such old versions of PHP, because of potential security and performance +issues, as well as missing features. + +************ +Installation +************ + +Please see the `installation section `_ +of the CodeIgniter User Guide. + +******* +License +******* + +Please see the `license +agreement `_. + +********* +Resources +********* + +- `User Guide `_ +- `Language File Translations `_ +- `Community Forums `_ +- `Community Wiki `_ +- `Community Slack Channel `_ + +Report security issues to our `Security Panel `_ +or via our `page on HackerOne `_, thank you. + +*************** +Acknowledgement +*************** + +The CodeIgniter team would like to thank EllisLab, all the +contributors to the CodeIgniter project and you, the CodeIgniter user. diff --git a/session_test.php b/session_test.php new file mode 100644 index 00000000..71a1c079 --- /dev/null +++ b/session_test.php @@ -0,0 +1,2 @@ + + + +
+ "url"), leave url empty if no url + //$breadcrumbs["New Crumb"] => "http://url.com" + $breadcrumbs["SmartAdmin Intel"] = ""; + include("inc/ribbon.php"); + ?> + + +
+ + +
+ + +
+

+ + + SmartAdmin Pre-built Skins
+ Don't like the default look of SmartAdmin? Not a problem! SmartAdmin comes with 6 prebuilt skins to choose from. +

+ +
+ + +
+ + + + + +
+ + + +
+ + +
+ +
+
+ Skin name "Glass"
+ Add the following class to body tag .smart-style-5 +
+ +
+
+
+ +
+
+ Skin name "Google"
+ Add the following class to body tag .smart-style-3 +
+ +
+
+ +
+ +
+ + +
+ +
+
+ Skin name "PixelSmash"
+ Add the following class to body tag .smart-style-4 +
+ +
+
+
+ +
+
+ Skin name "Dark Elegance"
+ Add the following class to body tag .smart-style-1 +
+ +
+
+ +
+ +
+ + +
+ +
+
+ Skin name "Default"
+ Add the following class to body tag .smart-style-0 +
+ +
+
+
+ +
+
+ Skin name "Ultra Light"
+ Add the following class to body tag .smart-style-2 +
+ +
+
+ +
+ + +
+ + + +
+ + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/sl.php b/sl.php new file mode 100644 index 00000000..94ce9b99 --- /dev/null +++ b/sl.php @@ -0,0 +1,130 @@ + + + + + Font Awesome 4.1 – Liste fournie + + + + + + + +

Font Awesome 4.1 – Icônes (liste fournie)

+ +
+ fa-automobile
+ fa-bank
+ fa-behance
+ fa-behance-square
+ fa-bomb
+ fa-building
+ fa-cab
+ fa-car
+ fa-child
+ fa-circle-o-notch
+ fa-circle-thin
+ fa-codepen
+ fa-cube
+ fa-cubes
+ fa-database
+ fa-delicious
+ fa-deviantart
+ fa-digg
+ fa-drupal
+ fa-empire
+ fa-envelope-square
+ fa-fax
+ fa-file-archive-o
+ fa-file-audio-o
+ fa-file-code-o
+ fa-file-excel-o
+ fa-file-image-o
+ fa-file-movie-o
+ fa-file-pdf-o
+ fa-file-photo-o
+ fa-file-picture-o
+ fa-file-powerpoint-o
+ fa-file-sound-o
+ fa-file-video-o
+ fa-file-word-o
+ fa-file-zip-o
+ fa-ge
+ fa-git
+ fa-git-square
+ fa-google
+ fa-graduation-cap
+ fa-hacker-news
+ fa-header
+ fa-history
+ fa-institution
+ fa-joomla
+ fa-jsfiddle
+ fa-language
+ fa-life-bouy
+ fa-life-ring
+ fa-life-saver
+ fa-mortar-board
+ fa-openid
+ fa-paper-plane
+ fa-paper-plane-o
+ fa-paragraph
+ fa-paw
+ fa-pied-piper
+ fa-pied-piper-alt
+ fa-pied-piper-square
+ fa-qq
+ fa-ra
+ fa-rebel
+ fa-recycle
+ fa-reddit
+ fa-reddit-square
+ fa-send
+ fa-send-o
+ fa-share-alt
+ fa-share-alt-square
+ fa-slack
+ fa-sliders
+ fa-soundcloud
+ fa-space-shuttle
+ fa-spoon
+ fa-spotify
+ fa-steam
+ fa-steam-square
+ fa-stumbleupon
+ fa-stumbleupon-circle
+ fa-support
+ fa-taxi
+ fa-tencent-weibo
+ fa-tree
+ fa-university
+ fa-vine
+ fa-wechat
+ fa-weixin
+ fa-wordpress
+ fa-yahoo
+
+ + + diff --git a/t.php b/t.php new file mode 100644 index 00000000..75cb95c2 --- /dev/null +++ b/t.php @@ -0,0 +1,161 @@ + +setAuthConfig('credentials.json'); + $client->addScope([ + Google_Service_Drive::DRIVE, + 'https://www.googleapis.com/auth/documents' + ]); + $client->setRedirectUri('https://ms1crmdev.progiweb.net/t.php'); + $client->setAccessType('offline'); + $client->setPrompt('select_account consent'); + + // Authentification OAuth + if (isset($_GET['code'])) { + $token = $client->fetchAccessTokenWithAuthCode($_GET['code']); + if (isset($token['error'])) { + echo "Erreur Google: " . htmlspecialchars($token['error_description'] ?? $token['error']); + exit; + } + $_SESSION['access_token'] = $token; + header('Location: ' . filter_var($client->getRedirectUri(), FILTER_SANITIZE_URL)); + exit; + } + + if (isset($_SESSION['access_token']) + && is_array($_SESSION['access_token']) + && isset($_SESSION['access_token']['access_token']) + ) { + $client->setAccessToken($_SESSION['access_token']); + } else { + $authUrl = $client->createAuthUrl(); + header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); + exit; + } + + if ($client->isAccessTokenExpired()) { + unset($_SESSION['access_token']); + $authUrl = $client->createAuthUrl(); + header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); + exit; + } + + return $client; +} + +// ========== TEST ========== +// 1. La première fois, laisse $docIdTest = ""; pour créer le doc et afficher son ID +// 2. Ensuite, copie cet ID ici, dans $docIdTest, pour mettre à jour ce doc existant uniquement +$docIdTest = "106klQ1hXpQkq5VJwmWFQ74kvx6bg1KX1XZtS9Dv3s34"; // <-- Colle ici l'ID après la première création pour la mise à jour + +if (isset($_POST['create_shortcut'])) { + $client = getClient(); + $driveService = new Google_Service_Drive($client); + + $folderId = '1BJPxQ2XPWqBRYxINgI-9TKJ_iPz7Dltb'; + $titre = "Raccourci infos course"; + $description= "zz2Consultez les résultats de l’événement. Pour toute question, contactez notre équipe."; + $lienTexte = "Lien vers les résultats du 24h Tremblant"; + $lienURL = "https://ms1timing.com/index.php?code=results&id=631"; + $contactTel = "Téléphone : 1-855-999-5555"; + + $texteDoc = $titre . "\n\n" . $description . "\n\n" . $lienTexte . "\n\n" . $contactTel; + $titreLen = strlen($titre); + $descLen = strlen($description); + $lienLen = strlen($lienTexte); + $lienStart = $titreLen + 2 + $descLen + 2; + $lienEnd = $lienStart + $lienLen; + + $docsService = new Google_Service_Docs($client); + + if (empty($docIdTest)) { + // Création du doc la première fois + $fileMetadata = new Google_Service_Drive_DriveFile([ + 'name' => $titre, + 'mimeType' => 'application/vnd.google-apps.document', + 'parents' => [$folderId], + ]); + $file = $driveService->files->create($fileMetadata, [ + 'supportsAllDrives' => true, + ]); + $docId = $file->id; + + // Affiche l'ID à stocker pour la prochaine fois + echo "DOCUMENT CRÉÉ :
"; + echo "Colle cet ID dans \$docIdTest pour les prochaines mises à jour :
"; + echo "" . htmlspecialchars($docId) . "

"; + + // Continue la création et remplissage du doc + } else { + $docId = $docIdTest; + } + + // Insère ou remplace le contenu + try { + // Tente d'effacer tout le contenu existant (si le doc existait déjà) + $doc = $docsService->documents->get($docId); + $contentLength = 0; + if (isset($doc->body->content) && is_array($doc->body->content)) { + foreach ($doc->body->content as $el) { + if (isset($el->endIndex)) { + $contentLength = max($contentLength, $el->endIndex); + } + } + } + $requests = []; + // On efface le contenu SEULEMENT s'il y a quelque chose à effacer (>2) + if ($contentLength > 2) { + $requests[] = [ + 'deleteContentRange' => [ + 'range' => [ + 'startIndex' => 1, + 'endIndex' => $contentLength - 1 + ] + ] + ]; + } + $requests[] = [ + 'insertText' => [ + 'location' => ['index' => 1], + 'text' => $texteDoc + ] + ]; + $requests[] = [ + 'updateTextStyle' => [ + 'range' => [ + 'startIndex' => $lienStart, + 'endIndex' => $lienEnd + ], + 'textStyle' => [ + 'link' => ['url' => $lienURL] + ], + 'fields' => 'link' + ] + ]; + $batchUpdateRequest = new Google_Service_Docs_BatchUpdateDocumentRequest([ + 'requests' => $requests + ]); + $docsService->documents->batchUpdate($docId, $batchUpdateRequest); + + // Affiche le lien du Google Doc modifié ou créé + $docUrl = 'https://docs.google.com/document/d/' . $docId . '/edit'; + echo "Raccourci Google Doc créé ou mis à jour !
"; + echo "Ouvrir le raccourci dans Google Drive"; + exit; + } catch (Exception $e) { + echo "Erreur lors de la mise à jour du document : " . htmlspecialchars($e->getMessage()); + exit; + } +} +?> + +
+ +
diff --git a/t2.php b/t2.php new file mode 100644 index 00000000..9329049d --- /dev/null +++ b/t2.php @@ -0,0 +1,98 @@ +setAuthConfig('credentials.json'); + $client->addScope(Google_Service_Drive::DRIVE); + $client->setRedirectUri('https://ms1crmdev.progiweb.net/t2.php'); + $client->setAccessType('offline'); + $client->setPrompt('select_account consent'); + if (isset($_GET['code'])) { + $token = $client->fetchAccessTokenWithAuthCode($_GET['code']); + if (isset($token['error'])) { + echo "Erreur Google: " . htmlspecialchars($token['error_description'] ?? $token['error']); + exit; + } + $_SESSION['access_token'] = $token; + header('Location: ' . filter_var($client->getRedirectUri(), FILTER_SANITIZE_URL)); + exit; + } + if (isset($_SESSION['access_token']) + && is_array($_SESSION['access_token']) + && isset($_SESSION['access_token']['access_token']) + ) { + $client->setAccessToken($_SESSION['access_token']); + } else { + $authUrl = $client->createAuthUrl(); + header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); + exit; + } + if ($client->isAccessTokenExpired()) { + unset($_SESSION['access_token']); + $authUrl = $client->createAuthUrl(); + header('Location: ' . filter_var($authUrl, FILTER_SANITIZE_URL)); + exit; + } + return $client; +} + +$parentFolderId = '1BJPxQ2XPWqBRYxINgI-9TKJ_iPz7Dltb'; // Dossier parent +$driveId = '0AChhcY8763myUk9PVA'; + +$client = getClient(); +$driveService = new Google_Service_Drive($client); + +$selectedFolderId = $_POST['folder_id'] ?? null; + +// Récupère SEULEMENT les dossiers enfants +$query = sprintf( + "'%s' in parents and trashed = false and mimeType = 'application/vnd.google-apps.folder'", + $parentFolderId +); + +$folders = []; +$pageToken = null; +do { + $params = [ + 'q' => $query, + 'fields' => 'nextPageToken, files(id, name, mimeType)', + 'supportsAllDrives' => true, + 'includeItemsFromAllDrives' => true, + 'corpora' => 'drive', + 'driveId' => $driveId, + 'pageSize' => 1000, + ]; + if ($pageToken) { + $params['pageToken'] = $pageToken; + } + $results = $driveService->files->listFiles($params); + foreach ($results->files as $file) { + $folders[] = $file; + } + $pageToken = $results->getNextPageToken(); +} while ($pageToken); + +// Debug : Affiche le compte connecté +$about = $driveService->about->get(['fields' => 'user']); +echo "Connecté comme : " . htmlspecialchars($about->user->displayName) . " (" . htmlspecialchars($about->user->emailAddress) . ")

"; + +// Affiche le select +echo '
'; +echo ' '; +echo ''; +echo '
'; + +// Affiche l'ID du dossier sélectionné (pour démo) +if ($selectedFolderId) { + echo '

ID du dossier sélectionné :

' . htmlspecialchars($selectedFolderId) . '
'; +} +?> diff --git a/t3.php b/t3.php new file mode 100644 index 00000000..a387cced --- /dev/null +++ b/t3.php @@ -0,0 +1,173 @@ +' . $ticket['key'] . ' - ' . $ticket['summary'] . ' (' . $ticket['status'] . ')
'; + } +} else { + echo 'Erreur : ' . $liste['message']; +} + +/** + * Recherche tous les tickets JIRA ouverts d’un utilisateur selon son courriel (ou accountId) + * Compatible avec le nouvel endpoint /rest/api/3/search/jql + */ +function jira_get_tickets_by_email($email) +{ + $jiraDomain = 'https://progiwebinc.atlassian.net'; + $userEmail = 'stephan@progiweb.ca'; + $apiToken = 'ATATT3xFfGF0DuhOhRUxFlj2hFpLuzYGapJIrhMETB35NnLFi1TyxDszp3tTa8MaadTpT72GfDk9FOpDm07m6HbdXoQ9plDeRvB6OwRnD19VrIqA8M3HmDGgf_MWR7Pwk5731ahbgb4UBdRgj-ICBqt9A0SjJPnnoTfu4ECVh51HjM0RsekOmeM=908B030C'; + + $projectKey = 'SM'; + + // 1) Résoudre l'accountId à partir de l'email + $accountId = jira_find_account_id_by_email($jiraDomain, $userEmail, $apiToken, $email); + + // 2) Construire le ou les JQL à tester (accountId en priorité) + $jqls = []; + if ($accountId) { + $jqls[] = 'project = ' . $projectKey . ' AND reporter = ' . $accountId . ' ORDER BY created DESC'; + } + $jqls[] = 'project = ' . $projectKey . ' AND reporter = "' . addslashes($email) . '" ORDER BY created DESC'; + + // 3) Interroger le nouvel endpoint /rest/api/3/search/jql (POST) + $headers = [ + 'Authorization: Basic ' . base64_encode("$userEmail:$apiToken"), + 'Content-Type: application/json', + 'Accept: application/json' + ]; + + $fieldsWanted = ["summary","status"]; + $maxPerPage = 100; + $tickets = []; + $usedJql = null; + $lastErr = null; + + foreach ($jqls as $jql) { + $tickets = []; + $usedJql = $jql; + $nextPageToken = null; + + do { + $payload = [ + "jql" => $jql, + "maxResults" => $maxPerPage, + "fields" => $fieldsWanted + ]; + if ($nextPageToken) { + $payload["nextPageToken"] = $nextPageToken; + } + + $ch = curl_init($jiraDomain . '/rest/api/3/search/jql'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE)); + + $response = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + $curlErr = curl_error($ch); + curl_close($ch); + + if ($httpcode !== 200) { + $lastErr = "HTTP $httpcode - " . ($response ?: $curlErr ?: 'Erreur inconnue'); + $tickets = []; + break; + } + + $data = json_decode($response, true); + if (!isset($data['issues'])) { + $lastErr = 'Réponse inattendue du service de recherche.'; + $tickets = []; + break; + } + + foreach ($data['issues'] as $issue) { + $tickets[] = [ + 'key' => $issue['key'], + 'summary' => $issue['fields']['summary'] ?? '', + 'status' => $issue['fields']['status']['name'] ?? '', + 'url' => $jiraDomain . '/browse/' . $issue['key'] + ]; + } + + // pagination nouvelle API : token ou fin de résultats + $nextPageToken = $data['nextPageToken'] ?? null; + + } while ($nextPageToken); + + if (!empty($tickets)) { + break; + } + } + + if (!empty($tickets)) { + return ['success' => true, 'tickets' => $tickets]; + } + + return [ + 'success' => false, + 'message' => $lastErr ?: "Aucun ticket trouvé (JQL testé : $usedJql)" + ]; +} + +/** + * Recherche l’accountId d’un utilisateur à partir de son email. + */ +function jira_find_account_id_by_email($jiraDomain, $userEmail, $apiToken, $email) +{ + $headers = [ + 'Authorization: Basic ' . base64_encode("$userEmail:$apiToken"), + 'Accept: application/json' + ]; + $url = $jiraDomain . '/rest/api/3/user/search?query=' . urlencode($email); + + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + + $response = curl_exec($ch); + $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + curl_close($ch); + + if ($httpcode !== 200) { + return null; + } + + $users = json_decode($response, true); + if (is_array($users) && count($users) > 0) { + foreach ($users as $u) { + if (!empty($u['emailAddress']) && strcasecmp($u['emailAddress'], $email) === 0) { + return $u['accountId'] ?? null; + } + } + return $users[0]['accountId'] ?? null; + } + + return null; +} + +/** + * (Optionnel) Exemple pour lister les projets disponibles. + */ +function jira_get_projects() +{ + $jiraDomain = 'https://progiwebinc.atlassian.net'; + $userEmail = 'stephan@progiweb.ca'; + $apiToken = 'ATATT...'; + + $ch = curl_init($jiraDomain . '/rest/api/3/project/search'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_HTTPHEADER, [ + 'Authorization: Basic ' . base64_encode("$userEmail:$apiToken"), + 'Content-Type: application/json' + ]); + + $response = curl_exec($ch); + curl_close($ch); + + return json_decode($response, true); +} diff --git a/test.php b/test.php new file mode 100644 index 00000000..2dc20666 --- /dev/null +++ b/test.php @@ -0,0 +1,71 @@ + + + +
+ "url"), leave url empty if no url + //$breadcrumbs["New Crumb"] => "http://url.com" + $breadcrumbs["Misc"] = ""; + include("inc/ribbon.php"); + ?> + + +
+ +
+ + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/test_autoload.php b/test_autoload.php new file mode 100644 index 00000000..fa02adea --- /dev/null +++ b/test_autoload.php @@ -0,0 +1,29 @@ +"; + +if (!class_exists('Common\Util')) { + echo "❌ La classe Common\\Util n'est pas chargée." . PHP_EOL; + echo "📁 Chemin courant : " . __DIR__ . PHP_EOL; + echo "📄 Autoloader chargé : " . (file_exists(__DIR__ . '/vendor/autoload.php') ? 'oui' : 'non') . PHP_EOL; + echo "🧠 Liste partielle des classes déclarées : " . PHP_EOL; + print_r(array_filter(get_declared_classes(), fn($c) => str_starts_with($c, 'Common'))); + exit; +} + +echo "✅ Classe Common\\Util chargée." . PHP_EOL; + +if (method_exists('Common\Util', 'is_cli')) { + echo "✅ Méthode is_cli() détectée." . PHP_EOL; + + if (Util::is_cli()) { + echo "🖥️ Exécuté en CLI." . PHP_EOL; + } else { + echo "🌐 Exécuté via navigateur web." . PHP_EOL; + } +} else { + echo "❌ Méthode is_cli() non trouvée."; +} diff --git a/test_calendar_sa.php b/test_calendar_sa.php new file mode 100644 index 00000000..fdc98011 --- /dev/null +++ b/test_calendar_sa.php @@ -0,0 +1,135 @@ + true, + CURLOPT_POST => true, + CURLOPT_HTTPHEADER => ['Content-Type: application/x-www-form-urlencoded'], + CURLOPT_POSTFIELDS => http_build_query($fields), + CURLOPT_TIMEOUT => 30, + ]); + $res = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($res === false) { + throw new Exception('cURL error: ' . curl_error($ch)); + } + curl_close($ch); + return [$code, $res]; +} + +function http_get_auth($url, $bearer) +{ + $ch = curl_init($url); + curl_setopt_array($ch, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $bearer], + CURLOPT_TIMEOUT => 30, + ]); + $res = curl_exec($ch); + $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($res === false) { + throw new Exception('cURL error: ' . curl_error($ch)); + } + curl_close($ch); + return [$code, $res]; +} + +// ---- 1) Charger la clé de service ---- +if (!file_exists($jsonPath)) die("Fichier JSON introuvable: $jsonPath\n"); +$creds = json_decode(file_get_contents($jsonPath), true); +if (!$creds) die("Impossible de parser le JSON\n"); + +$client_email = $creds['client_email']; +$private_key = $creds['private_key']; +$token_uri = isset($creds['token_uri']) ? $creds['token_uri'] : 'https://oauth2.googleapis.com/token'; + +// ---- 2) Construire le JWT (RS256) ---- +// Scopes minimum lecture/écriture d’événements: +$scope = 'https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events'; + +$now = time(); +$exp = $now + 3600; // 1h +$iss = $client_email; +$sub = $impersonate; // <- impersonation (DWD) +$aud = $token_uri; + +$header = ['alg' => 'RS256', 'typ' => 'JWT']; +$claim = [ + 'iss' => $iss, + 'scope' => $scope, + 'aud' => $aud, + 'exp' => $exp, + 'iat' => $now, + 'sub' => $sub +]; + +$jwt_unsigned = b64url(json_encode($header)) . '.' . b64url(json_encode($claim)); + +// Signer avec la clé privée +$signature = ''; +$ok = openssl_sign($jwt_unsigned, $signature, $private_key, 'sha256WithRSAEncryption'); +if (!$ok) { + die("Échec openssl_sign(). Vérifie la private_key.\n"); +} +$jwt = $jwt_unsigned . '.' . b64url($signature); + +// ---- 3) Échanger le JWT contre un access_token ---- +list($code, $body) = http_post_json($token_uri, [ + 'grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', + 'assertion' => $jwt +]); + +if ($code !== 200) { + echo "Échec token ($code): $body\n"; + exit(1); +} +$tok = json_decode($body, true); +$access_token = $tok['access_token'] ?? null; +if (!$access_token) { + die("Pas d'access_token dans la réponse.\n"); +} + +echo "OK token reçu.\n"; + +// ---- 4) Appel test non destructif : lister les agendas de l'utilisateur ---- +$url = 'https://www.googleapis.com/calendar/v3/users/me/calendarList'; +list($code2, $body2) = http_get_auth($url, $access_token); + +echo "GET calendarList => HTTP $code2\n"; +echo $body2 . "\n"; +// ---- 5) Créer un petit événement de test (dans primary) ---- +$event = [ + 'summary' => 'Test CRM↔Google', + 'description' => 'Évènement de validation DWD', + 'start' => ['dateTime' => date('c', time()+3600)], // +1h + 'end' => ['dateTime' => date('c', time()+7200)], // +2h +]; + +$ch = curl_init('https://www.googleapis.com/calendar/v3/calendars/primary/events'); +curl_setopt_array($ch, [ + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_HTTPHEADER => [ + 'Authorization: Bearer '.$access_token, + 'Content-Type: application/json' + ], + CURLOPT_POSTFIELDS => json_encode($event), + CURLOPT_TIMEOUT => 30, +]); +$resp = curl_exec($ch); +$code = curl_getinfo($ch, CURLINFO_HTTP_CODE); +curl_close($ch); + +echo "POST event => HTTP $code\n$resp\n"; diff --git a/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoDocumentContext.php b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoDocumentContext.php new file mode 100644 index 00000000..38e56ffd --- /dev/null +++ b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoDocumentContext.php @@ -0,0 +1,62 @@ +content = $content; + } + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + /** + * @param string + */ + public function setPageIdentifier($pageIdentifier) + { + $this->pageIdentifier = $pageIdentifier; + } + /** + * @return string + */ + public function getPageIdentifier() + { + return $this->pageIdentifier; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoDocumentContext::class, 'Google_Service_DiscoveryEngine_GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoDocumentContext'); diff --git a/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveAnswer.php b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveAnswer.php new file mode 100644 index 00000000..e338e5ab --- /dev/null +++ b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveAnswer.php @@ -0,0 +1,62 @@ +content = $content; + } + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + /** + * @param string + */ + public function setPageIdentifier($pageIdentifier) + { + $this->pageIdentifier = $pageIdentifier; + } + /** + * @return string + */ + public function getPageIdentifier() + { + return $this->pageIdentifier; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveAnswer::class, 'Google_Service_DiscoveryEngine_GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveAnswer'); diff --git a/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveSegment.php b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveSegment.php new file mode 100644 index 00000000..f8d98579 --- /dev/null +++ b/vendor/google/apiclient-services/src/DiscoveryEngine/GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveSegment.php @@ -0,0 +1,62 @@ +content = $content; + } + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + /** + * @param string + */ + public function setPageIdentifier($pageIdentifier) + { + $this->pageIdentifier = $pageIdentifier; + } + /** + * @return string + */ + public function getPageIdentifier() + { + return $this->pageIdentifier; + } +} + +// Adding a class alias for backwards compatibility with the previous class name. +class_alias(GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveSegment::class, 'Google_Service_DiscoveryEngine_GoogleCloudDiscoveryengineV1betaAnswerQueryRequestSearchSpecSearchResultListSearchResultUnstructuredDocumentInfoExtractiveSegment');