<?php
	function setPageLine1(string $action, string $name): string {
		$txt = '';

		switch ($action) {
			case "article":
			case "news":
			case "faq":
			case "product":
			case "book":
				$txt .= 'RewriteRule ^' . $name . '\.html$								' . $action . '.php'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '_([0-9]+)\.html$						' . $action . '.php?p=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '([0-9]+)\.html$						' . $action . '.php?id=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '([0-9]+)_([0-9]+)\.html$				' . $action . '.php?id=$1&p=$2'.PHP_EOL;
				if ($action === "article") {
					$txt .= 'RewriteRule ^' . $name . '-([a-zA-Z0-9\-_]+)\.html$			' . $action . '-detail.php?path=$1'.PHP_EOL;
				} else {
					$txt .= 'RewriteRule ^' . $name . '-([0-9]+)\.html$						' . $action . '-detail.php?id=$1'.PHP_EOL;
				}
				break;
			case "contact":
			case "order":
				$txt .= 'RewriteRule ^' . $name . '\.html$								' . $action . '.php'.PHP_EOL;
				if ($action === "contact") $txt .= 'RewriteRule ^' . $name . '-([0-9]+)\.html$						' . $action . '.php?id=$1'.PHP_EOL;
				break;
		}
		return $txt;
	}
	function setPageLine2(string $action, string $name): string {
		$txt = '';

		switch ($action) {
			case "article":
			case "news":
			case "faq":
			case "product":
			case "book":
				$txt .= 'RewriteRule ^' . $name . '/$									' . $action . '.php'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '/page/(\d+)/$						' . $action . '.php?p=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '/cate/([^\/]+)/$						' . $action . '.php?c=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '/cate/([^\/]+)/page/(\d+)/$			' . $action . '.php?c=$1&p=$2'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '/([^\/]+)/$							' . $action . '-detail.php?path=$1'.PHP_EOL;
				break;
			case "contact":
			case "order":
				$txt .= 'RewriteRule ^' . $name . '/$									' . $action . '.php'.PHP_EOL;
				if ($action === "contact") $txt .= 'RewriteRule ^' . $name . '/([^\/]+)/$							' . $action . '.php?path=$1'.PHP_EOL;
				break;
		}
		return $txt;
	}
	function setPageLine3(string $action, string $name): string {
		$txt = '';

		switch ($action) {
			case "article":
			case "news":
			case "faq":
			case "product":
			case "book":
				$txt .= 'RewriteRule ^' . $name . '\.html$								' . $action . '.php'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '_([0-9]+)\.html$						' . $action . '.php?p=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '([0-9]+)\.html$						' . $action . '.php?id=$1'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '([0-9]+)_([0-9]+)\.html$				' . $action . '.php?id=$1&p=$2'.PHP_EOL;
				$txt .= 'RewriteRule ^' . $name . '-([a-zA-Z0-9\-_]+)\.html$			' . $action . '-detail.php?path=$1'.PHP_EOL;
				break;
			case "contact":
			case "order":
				$txt .= 'RewriteRule ^' . $name . '\.html$								' . $action . '.php'.PHP_EOL;
				if ($action === "contact") $txt .= 'RewriteRule ^' . $name . '-([0-9]+)\.html$						' . $action . '.php?id=$1'.PHP_EOL;
				break;
		}
		return $txt;
	}
?>