Heya, i just coded this for some dood as a favour and thought it would be rude not to share so here it is
Just add all this code bofore the ?> at the end of the funcs.php file
Then open your admin/index.php and find your navigation block and add the link
Meh.. enjoy
Just add all this code bofore the ?> at the end of the funcs.php file
PHP:
function admin_edit_sites(){
global $pg,$limit,$page,$go,$q,$id;
$mode = $_GET['mode'];
switch($mode){
case '':
default:
//For Showing all sites
$query = "SELECT * FROM wcddl_sites LIMIT ".$pg.",".$limit;
$query = mysql_query($query);
$fetched = mysql_num_rows($query); // pagination
$out = '<table width="100%">';
$out .= "<tr><td>Sitename</td><td>Email</td><td>Rating</td></tr>";
while($row = mysql_fetch_assoc($query)){
$out .= "<tr>
<td>
<a href=\"?go=".$go."&mode=edit&id=".(int)$row['id']."\">".$row['name']."</a></td>
<td><a href=\"mailto:".$row['email']."\">".$row['email']."</a></td>
</tr>";
}
$out .= "</table>";
//Just some fast pagination for you :D
$out .= '<div>';
if($page > 1){$out .= '<a href="?go='.$go.'&page='.($page-1).'">« Prev</a> ';}
$out .= '<strong>('.$page.')</strong>'; // current page
if($fetched >= $limit){ $out .= '<a href="?go='.$go.'&page='.($page+1).'">Next »</a> ';}
$out .= '</div>';
echo $out;
break;
case 'edit':
//Edit Mode
if(isset($id)){
$query = "SELECT * FROM wcddl_sites WHERE id = ".mysql_real_escape_string($id);
$site_data = mysql_fetch_assoc(mysql_query($query)); // single row
if($site_data !== false){ // Make sure we have download
$template = '<table width="100%">';
$template .= '<form method="post" action="?go='.$go.'&mode=save&id='.$id.'">';
//Indepth form items
$template .= '<input type="hidden" name="update" value="true" />';
$template .= "<tr><td>Site name</td><td><input type=\"text\" name=\"name\"
value=\"".$site_data['name']."\" /></td></tr>";
$template .= "<tr><td>Site url</td><td><input type=\"text\" name=\"url\"
value=\"".$site_data['url']."\" /></td></tr>";
$template .= "<tr><td>Site email</td><td><input type=\"text\" name=\"email\"
value=\"".$site_data['email']."\" /></td></tr>";
$template .= '<tr><td colspan="2"><input type="submit" value="Update" /></td></tr>';
$template .= "</form>";
$template .= "</table>";
echo $template;
}else{
echo "Hmmmm, Download (".$id.") does not exists!";
}
}else{
echo "Unable to get id from url!";
}
break;
case 'save':
if($id > 0 && isset($_POST)){
$query = "UPDATE wcddl_sites SET name = '%s', url = '%s', email = '%s', WHERE id = %d";
$query = sprintf($query,mysql_real_escape_string($_POST['name']),mysql_real_escape_string($_POST['url'])
,mysql_real_escape_string($_POST['email']),(int)$id);
$check = @mysql_query($query);
if($check === false){
echo 'For some reason we was unable to update the database! no changes were made';
}else{
echo '('.$_POST["name"].') Updated!, <a href="?go='.$go.'">Go back to editor!</a>';
}
}else{
echo 'There was an error, please make sure you came here for the edit form';
}
break;
}
echo '<div style="clear:both;font-waight:bold;text-align:center">Site editor by Litewarez</div>';
}
Then open your admin/index.php and find your navigation block and add the link
Code:
<a href="index.php?go=edit_sites">Edit Sites</a> |
Meh.. enjoy