*

Recent

Author Topic: Deleting games  (Read 8064 times)

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Deleting games
« on: October 02, 2011, 07:57:55 PM »
Well im deleting alot of games off my site that i dont want. and i was wondering if when i delete the game off the site does it also delete the file from my host or do i have to do that myself?

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #1 on: October 02, 2011, 08:54:13 PM »
From what I see it does not.
I should put that in the next version though.

If you want, gimme like mmm half hour at most and I will post the code you need to edit and add.

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #2 on: October 02, 2011, 09:15:30 PM »
This code is not tested, but it looks perfectly fine to me.

ftp or ssh your way into /pages/admin/
and edit the file: managegames.php

Find the function: delete
and replace it with this:

Code: [Select]
function delete(){
global $directorypath, $gamesfolder;
$ID = abs((int) $_GET['ID']);

$query = mysql_query("SELECT `file` FROM `dd_games` WHERE `ID`='$ID'");
$row = mysql_fetch_array($query);

if($row['type'] == "1"){
unlink("$directorypath/$gamesfolder/".$row['file']."");
}

mysql_query(sprintf('DELETE FROM dd_games WHERE ID=\'%u\'', $ID));
echo '<div class=\'msg\'>Game Deleted.
<br />
<A href="#" onclick="history.go(-1)">Back</a></div>';
}

just gotta make sure you have your permissions set to allow this to work. Don't anyone yell at me :P lol
I say set everything to 777
others don't like to.. they say its a security issue and blah blah blah  ::)
If you're afraid of all that just set the games directory to 777 and leave everything else to your settings, thats fine.

EDIT: Before editing anything, back it up.
EDIT2: Fixed a mistake in the code
« Last Edit: October 02, 2011, 09:35:03 PM by Adam LaCombe »

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #3 on: October 02, 2011, 09:36:25 PM »
Missed the if($row['type'] == 1) lol sorry about that. its fixed now though so go ahead and use that code I posted above

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Deleting games
« Reply #4 on: October 03, 2011, 01:55:37 PM »
Thanks for the help!

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #5 on: October 03, 2011, 03:21:18 PM »
Not a problem :-)

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Deleting games
« Reply #6 on: October 03, 2011, 05:02:06 PM »
Nice one Adam - Can't wait for the Beta2 to see what else you have created or added.

;)

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #7 on: October 03, 2011, 10:05:07 PM »
Yeah we need to get that thing finished like now lol its long over due.
But I am glad we haven't released it just yet because I got some other ideas to add in.
I think I am gunna re-do the language files a little different also. Its such a pain but I suppose it needs to be done :P lol

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Deleting games
« Reply #8 on: October 03, 2011, 10:25:53 PM »
Sorry Adam - I can't get your script to work? :(

Try this by replacing the whole of the delete function.

Code: [Select]
function delete(){
global $domain, $db, $gamesfolder, $thumbsfolder, $template, $directorypath;

$ID = abs((int) $_GET['ID']);
$query = mysql_query("select * FROM `dd_games` WHERE `ID`='$ID'");
$row = mysql_fetch_array($query);

if($row["type"] == "1")
{

$file = $row["file"];

$myFile = "$domain/$directorypath/$gamesfolder/$file";
unlink($myFile);
}

if($row["type"] == "1")
{

$thumb = $row["thumb"];

$myThumb = "$domain/$directorypath/$thumbsfolder/$thumb";
unlink($myThumb);
}

mysql_query(sprintf('DELETE FROM dd_games WHERE ID=\'%u\'', $ID));

echo '
<div class=\'msg\'>Game Deleted <a href="javascript:void(0)" onclick="history.go(-1)"> Go Back</a></div>

';
}



Edit: Shortened up the script and renamed a VAR.
Edit 2: Replaced ./../ with $domain because of seo problems.
« Last Edit: November 01, 2011, 03:54:55 PM by mort »

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #9 on: October 04, 2011, 09:50:57 AM »
Oh yeah I forgot about the thumbnail.
Dunno why you used: ./../ ?
Your directory path var is all you need I would think.
What did you set for the directory path?

Internet is being shut off I guess for me. Not enough money to pay for it so I will be gone again. Hopefully not for too long.

Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Deleting games
« Reply #10 on: October 04, 2011, 04:21:31 PM »
Oh yeah I forgot about the thumbnail.
Dunno why you used: ./../ ?
Your directory path var is all you need I would think.
What did you set for the directory path?

Internet is being shut off I guess for me. Not enough money to pay for it so I will be gone again. Hopefully not for too long.

I used ./../ because the process is being called from two levels down and one has to get back to the root. Real path -> http:// ($domain) is not allowed.

My dir path is "/arcade" because I re-wrote every file to include all the missing global db strings, and fixed up all the missing/wrong path variables so that the programme is not forced to  be in the root only.

As for delete not working - This is more likely the problem. ;)

unlink("$directorypath/$gamesfolder/".$row['file']."");

Quote
Hopefully not for too long.

You probably have plenty to do to FAS as it is. And while we have XAMPP etc - I doubt that you will just be doing nothing. :P

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Deleting games
« Reply #11 on: October 04, 2011, 05:18:54 PM »
Your dir path should look something like: /var/www/arcade.com/htdocs

You start from the root of the server and go into the www directory to where the fas script is installed.

Quote
You probably have plenty to do to FAS as it is. And while we have XAMPP etc - I doubt that you will just be doing nothing. :P
We who? lol I don't use XAMPP.. and I mean gone like from the internet for week or more. Any min now Comcast is gunna shut off the phone tv and internet :(

Dillon

  • Developer
  • Sr. Member
  • ******
  • Posts: 340
  • Force: +3/-0
    • Arcade Freak
Re: Deleting games
« Reply #12 on: November 01, 2011, 12:42:08 PM »
Ok well i couldnt get either of yours to work without sql errors and i just now finally got around to making it delete and give no errors. Heres the code.

Code: [Select]
function delete(){
global $domain, $db, $gamesfolder, $thumbsfolder, $template, $directorypath;

$ID = abs((int) $_GET['ID']);
$query = mysql_query("select * FROM `dd_games` WHERE `ID`='$ID'");
$row = mysql_fetch_array($query);

if($row["type"] == "1")
{

$file = $row["file"];

$myFile = "$directorypath/$gamesfolder/$file";
unlink($myFile);
}

if($row["type"] == "1")
{

$thumb = $row["thumb"];

$myThumb = "$directorypath/$thumbsfolder/$thumb";
unlink($myThumb);
}

mysql_query(sprintf('DELETE FROM dd_games WHERE ID=\'%u\'', $ID));

echo '
<div class=\'msg\'>Game Deleted <a href="javascript:void(0)" onclick="history.go(-1)"> Go Back</a></div>

';
}



Frank

  • Sr. Member
  • ****
  • Posts: 257
  • Force: +4/-0
Re: Deleting games
« Reply #13 on: November 01, 2011, 04:03:14 PM »
I think that this was the real problem?

Edit 2: Replaced ./../ with $domain because of seo problems.

Thanks for fixing it up, because I found other path problems when testing seo and had to replace all of the Unix paths I had created. ;)

« Last Edit: November 01, 2011, 04:05:34 PM by mort »