Make search a config option
Make search a config option

--- a/config/gitphp.conf.php.example
+++ b/config/gitphp.conf.php.example
@@ -148,6 +148,12 @@
 //$gitphp_conf['magicdb'] = "C:\\wamp\\php\\extras\\magic";  // Windows
 
 /*
+ * search
+ * Set this to false or comment it out to disable searching
+ */
+$gitphp_conf['search'] = TRUE;
+
+/*
  * git_projects
  * Two-dimensional array list of projects
  * First array index is the name of the category the projects

--- a/include/display.git_search.php
+++ b/include/display.git_search.php
@@ -12,7 +12,14 @@
 
 function git_search($projectroot, $project, $hash, $search, $searchtype, $page = 0)
 {
-	global $tpl;
+	global $tpl,$gitphp_conf;
+
+	if (!$gitphp_conf['search']) {
+		$tpl->clear_all_assign();
+		$tpl->assign("message","Search has been disabled");
+		$tpl->display("message.tpl");
+		return;
+	}
 
 	if (!isset($search) || (strlen($search) < 2)) {
 		$tpl->clear_all_assign();

file:a/index.php -> file:b/index.php
--- a/index.php
+++ b/index.php
@@ -161,6 +161,8 @@
 		$tpl->assign("hash",$_GET['hb']);
 	else if (isset($_GET['h']))
 		$tpl->assign("hash",$_GET['h']);
+	if ($gitphp_conf['search'])
+		$tpl->assign("enablesearch",TRUE);
 	 $tpl->display("header.tpl");
  }
 

--- a/templates/header.tpl
+++ b/templates/header.tpl
@@ -30,6 +30,7 @@
   {if $action}
     / {$action}
   {/if}
+  {if $enablesearch}
 <form method="get" action="index.php" enctype="application/x-www-form-urlencoded">
 <div class="search">
 <input type="hidden" name="p" value="{$project}" />
@@ -42,6 +43,7 @@
 </select> search: <input type="text" name="s" {if $search}value="{$search}"{/if} />
 </div>
 </form>
+  {/if}
 {/if}
 </div>
 

comments