<?php /* Options +FollowSymlinks RewriteEngine On RewriteRule ^([a-z]+)(/([-_a-z]+))?$ index.php?module=$1&action=$3 [L] */ // require CONTROLEURS.'shared/routes.php'; echo "# NE PAS MODIFIER MANUELLEMENT !<br />\n# CE FICHIER EST GENERE DYNAMIQUEMENT A L'ADRESSE : sandbox/rewritegenerator\n<br /><br /><br />\nOptions +FollowSymlinks<br />\nRewriteEngine On"; echo "<br /><br />RewriteRule ^([a-z]+)(/([-_a-zA-Z0-9]+))?\$ index.php?module=\$1&action=\$3 [L]"; foreach ($modules as $module) { if (file_exists(CONTROLEURS . $module . '/actions.php')) { require CONTROLEURS . $module . '/actions.php'; foreach ($actions as $action) { if ($params = fetchParams([$module, $action])) { echo "<br /><strong>#Action : {$module} -> {$action}</strong>"; $url = "{$module}/{$action}"; $rewrite = "module={$module}&action={$action}"; $n = 2; foreach ($params as $param) { $url .= "(/([-_a-zA-Z0-9]+))?"; $rewrite .= '&' . $param . '=$' . $n; $n += 2; } echo "<br />RewriteRule ^{$url}\$ index.php?{$rewrite} [L]"; } } } }
function getLink($page = []) { // $page = [$module, $action, $param1, $param2] $rewrite = True; if ($rewrite) { $link = APP_ROOT; if (count($page) > 2) { fetchParams($page); } $link .= implode('/', $page); // foreach($page as $key => $valeurParametre) { // } return $link; } else { $link = '?'; $parametresLien = []; // array qui contiendra les paramètres et leurs valeurs $nomsParametres = ['module', 'action']; //fetch dans la config du module pour les noms des params suivants // Si on a passé des paramètres supplémentaires if (count($page) > 2) { $nomsParametres = array_merge($nomsParametres, fetchParams($page)); } // on construit le lien avec les bons paramètres : foreach ($page as $key => $valeurParametre) { $parametresLien[] = $nomsParametres[$key] . '=' . $valeurParametre; } // Concaténation des paramètres avec leur valeur derrière le lien $link = $link . implode('&', $parametresLien); return $link; } }
<?php require_once 'log.php'; require_once 'bitbucket.php'; // Load config: include 'config.php'; include_once 'Main.php'; // Let's go: initLog(); // Initalize log variables initPayload(); // Get posted data fetchParams(); // Get parameters from bitbucket payload (REPO) checkPaths(); // Check repository and project paths; create them if neccessary placeVerboseInfo(); // Place verbose log information if specified in config fetchRepository(); // Fetch or clone repository checkoutProject(); // Checkout project into target folder