Location: PHPKode > projects > AdaptBB > plugins/mod_rewrite.php
<?php
$protect = "yes";
$plugin_name = "Mod Rewrite";
$plugin_url = "admin.php?view=plugins&do=load&plugin=".strtolower(str_replace(" ", "_", $plugin_name));
$plugin_version = "1.0";
$url = strtolower(str_replace(" ", "_", $plugin_name)).".php";

$apage = basename($_SERVER['PHP_SELF']);
$siteurl = "http://".$_SERVER['HTTP_HOST'].str_replace($apage, "", $_SERVER['PHP_SELF']);
$url = $_GET['url'];

if ($_GET['check'] == "status") {
echo 1;
}

if ($module == "install_".$url) {
$tot = 0;
if (mysql_num_rows(mysql_query("SELECT * FROM ".$pre."plugins WHERE name = '".$plugin_name."'")) > 1) {
echo "<b>".$plugin_name."</b> Plugin already installed. <a href='admin.php?view=plugins&do=install'>Return</a>";
} else {
echo "Beginning to install the <b>".$plugin_name."</b> Plugin...<br /><br />";
$query1 = mysql_query("INSERT INTO ".$pre."plugins VALUES (null, '".$plugin_name."', '".$_GET['url']."', '".$plugin_version."', 'On')");
if ($query1 == TRUE) {
$tot = $tot + 1;
echo "`".$pre."plugins` MySQL data row Inserted? <font color='green'>True</font><br />";
} else {
echo "`".$pre."plugins` MySQL data row Inserted? <font color='red'>False</font><br />";
}
if ($tot == 1) {
echo "<br /><b>".$plugin_name."</b> Plugin installed <font color='green'>Sucessfully!</font>. <a href='".$plugin_url."'>".$plugin_name." Plugin</a>";
} else {
echo "<br /><b>".$plugin_name."</b> Plugin installed <font color='red'>Un-Sucessfully!</font>. Please check mysql settings and if need be, please submit a <a href='admin.php?view=support'>support ticket</a>.";
}
}
}

if ($module == "uninstall_".$url) {
$tot = 0;
if (mysql_num_rows(mysql_query("SELECT * FROM ".$pre."plugins WHERE name = '".$plugin_name."'")) > 1) {
echo "<b>".$plugin_name."</b> Plugin already un-installed, or not yet installed. <a href='admin.php?view=plugins&do=install'>Return</a>";
} else {
echo "Beginning to un-install the <b>".$plugin_name."</b> Plugin...<br /><br />";
$query1 = mysql_query("DELETE FROM ".$pre."plugins WHERE name = '".$plugin_name."'");
if ($query1 == TRUE) {
$tot = $tot + 1;
echo "`".$pre."plugins` MySQL data row Deleted? <font color='green'>True</font><br />";
} else {
echo "`".$pre."plugins` MySQL data row Deleted? <font color='red'>False</font><br />";
}
if ($tot == 1) {
echo "<br /><b>".$plugin_name."</b> Plugin un-installed <font color='green'>Sucessfully!</font>. <a href='admin.php?view=plugins'>Plugins</a>";
echo $data;
} else {
echo "<br /><b>".$plugin_name."</b> Plugin un-installed <font color='red'>Un-Sucessfully!</font>. Please check mysql settings and if need be, please submit a <a href='admin.php?view=support'>support ticket</a>.";
echo $data;
}
}
}

if (basename($_SERVER['PHP_SELF']) == "admin.php") {
if ($module == "") {
echo "<b>Directory</b>&nbsp;&nbsp;-&nbsp;&nbsp;<a href='admin.php?view=plugins'>Plugins</a> / <a href='".$plugin_url."'>".$plugin_name." Plugin</a><br /><br /><br />";

echo "<form action='".$plugin_url."&module=submit' method='post'><table cellpadding='5' cellspacing='0' border='0' width='90%' align='center' style='border: 2px solid #dddddd'><tr style='background:url(".$siteurl."inc/images/topbg.jpg) repeat-x;'><td><td><b>Mod Rewrite</b></td></tr>";

$handle = fopen($sitepath.".htaccess", "r");
$contents = fread($handle, filesize($sitepath.".htaccess"));
fclose($handle);

echo "<tr><td><b>.htaccess File</b></td><td><textarea name='contents' cols='65' rows='20' class='input'>".$contents."</textarea></td></tr><tr><td><input type='submit' value='Update File' class='input'></td><td>&nbsp;</td></tr></table></form>";
}

if ($module == "submit") {
if ($p[0]) {
echo "<b>Directory</b>&nbsp;&nbsp;-&nbsp;&nbsp;<a href='admin.php?view=plugins'>Plugins</a> / <a href='".$plugin_url."'>".$plugin_name." Plugin</a><br /><br /><br />";

$handle = fopen($sitepath.".htaccess", 'w');
fwrite($handle, stripslashes($_POST['contents']));
fclose($handle);

if ($handle == TRUE) {
echo re_direct("1500", "admin.php?view=tools");
echo "The .htaccess file was modified. <a href='".$plugin_url."'>Return</a>";
} else {
echo reporterror(urlencode($siteurl).$cpage, mysql_error(@mysql_connect($dbhost, $dbuser, $dbpass)), $domain);
echo "The .htaccess file was not modified. This error has been sent to the <b>AdaptBB</b> support team and you will be contacted soon.";
}

}
}

}

if (basename($_SERVER['PHP_SELF']) == "index.php") {
if ($module == strtolower(str_replace(" ", "_", $plugin_name))) {
echo 1;
}
}
?>
Return current item: AdaptBB