** Note: I am in no way an expert PHP coder. I managed to make a mod for my site that worked and decided to share in case anyone else would find it useful. If anyone finds any errors or knows how to improve something, please let me know so the appropriate changes can be made 🙂 Thanks! **
Description: Allows admins to search ALL users by penname and e-mail address.
Requirements: eFiction 3.2
Demo: http://www.gcfanfics.com/memsearch.php
Username: test
Password: test
Go to Admin > Search to access search page. Just to clarify, the "test" account is set as a level 4 admin and I have set the search panel to Level 4 (unlike my instructions) so you will be able to see how the mod functions. On your site, admins will be able to see the usual navigation links plus the search link in the admin area.
Instructions:
1. Copy and paste the following into a new file:
<?php
if($_POST['submit'] || $_GET['offset']) $current = "searchresults";
else $current = "search";
include ("header.php");
if(file_exists("$skindir/default.tpl")) $tpl = new TemplatePower( "$skindir/default.tpl" );
else $tpl = new TemplatePower("default_tpls/default.tpl");
include("includes/pagesetup.php");
if(!isADMIN) accessDenied( );
$searchtype = (isset($_REQUEST['searchtype']) ? $_REQUEST['searchtype'] : "main");
$searchterm = (isset($_REQUEST['searchterm']) ? escapestring($_REQUEST['searchterm']) : false);
if(isset($_POST['submit']) || (isset($_GET['offset']) && $offset > 0)) {
$output .= "<div id="pagetitle">"._RESULTS." for $searchterm</div>";
$output .="<ol>";
if($searchtype == "penname") {
$authorquery = dbquery("SELECT uid, penname FROM ".TABLEPREFIX."fanfiction_authors WHERE penname LIKE '%$searchterm%'");
while($author = dbassoc($authorquery)) {
$output .="<li><a href=""viewuser.php?uid=";"
$output .=$author['uid'];
$output .="">".$author['penname']."</a></li>";
}
$tpl->assign("output", $output);
}
else if ($searchtype == "email") {
$authorquery = dbquery("SELECT uid, penname FROM ".TABLEPREFIX."fanfiction_authors WHERE email LIKE '%$searchterm%'");
while($author = dbassoc($authorquery)) {
$output .="<li><a href=""viewuser.php?uid=";"
$output .= $author['uid'];
$output .="">".$author['penname']."</a></li>";
}
$tpl->assign("output", $output);
}
$output .="</ol>";
}
else {
$output .= "<div id="pagetitle">"._MEMBER." "._SEARCH."</div><div style='text-align: center;'><form method="post" enctype="multipart/form-data" action="memsearch.php">
<div class="tblborder" style="width: 320px; padding: 5px; margin: 0 auto;">
<select name="searchtype">
<option value="penname">"._PENNAME."</option>
<option value="email">"._EMAIL."</option>";
if($store == "mysql")
$output .= "<option value="fulltext">"._FULLTEXT."</option>";
$output .= "</select> <INPUT type="text=" class="textbox" name="searchterm" size="20"> ";
$output .= "<INPUT type="submit" class="button" name="submit" value=""._SUBMIT."" size="20"></div></form>";
$tpl->assign("output", $output);
}
$tpl->printToScreen();
?>
2. Save as memsearch.php and upload to your main eFiction folder.
3. Create a new panel (Admin > Panels > Add New Panel) with the following details:

Note: You may change the level if you wish.
Level 1 - Only level 1 admins can access.
Level 2 - Level 1 and 2 admins can access.
Level 3 - Level 1, 2, & 3 admins can access.
Level 4 - All levels of admin can access.
4. That's it! Go to Admin > Search to locate the search page.
Instead of mysql_fetch_array, I would use the "dbassoc" to match your use of "dbquery".
Fixed. Thanks Tammy.
Just wanted to say thanks for this because I just had someone give me their email and ask if I could search them out and I had to open up the core of my site to do so but now it's no longer that hard. Thanks You!!!
I've updated the code to work with version 3.3.
I love this mod because 1) I don't have to log into the server to search by email in the database when people forget their username (this happens at least once a week) and 2) because it searches all members, which is enormously helpful when I'm looking for someone specific, since with over 10,000 members it takes forever to browse for someone. I'm so glad you updated it for 3.3. Thanks so much!
You are THE awesome. Worked like a charm and will be SO handy.
Thank you!
No problem. I'm glad it still works!
