unlink () for lavalair gallery

Started on the old forum in May 2009 · view the original in the archive · old links redirect here

13 replies · 1,023 views · started 17 years ago · 1 min read

6 participants
hypetype Developer · 128 posts #1

i have been trying to use the unlink on my site but all i get is error and more errors.

can some1 help me.

i wanna use the unlink because sometimes a user may upload porn in the gallery but i dont allow things like that at my site. so i wanna use the unlink that when i delete the photo it is also deleted from my server and take up valuabe space.

hypetype Developer · 128 posts #2

THIS IS THE CODE BELOW

else if($action=="delgal")
{
    $gid = $_GET["gid"];
  addonline(getuid_sid($sid),"Deleting Gallery Photo","");
  echo "<card id=\"main\" title=\"Delete Photo\">";
  echo "<p align=\"center\">";
  $itemowner = mysql_fetch_array(mysql_query("SELECT uid FROM ibwf_gallery WHERE id='".$gid."'"));
  if(ismod(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0])
  {
    $res = mysql_query("DELETE FROM ibwf_gallery WHERE id='".$gid."'");
$res2 = mysql_query("DELETE FROM ibwf_galcomments WHERE pid='".$gid."'");
$res3 = mysql_query("DELETE FROM ibwf_prate WHERE pid='".$gid."'");

$itemurl = mysql_fetch_array(mysql_query("SELECT itemurl FROM ibwf_gallery WHERE id='".$gid."'"));

$file = $itemurl[0];
if(is_file("$file")) {
unlink("$file");
}

    if($res||res2||res3)
        {
            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Photo Deleted From Gallery<br/>";
        }else{
          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";
        }
  }else{
    echo "<img src=\"images/notok.gif\" alt=\"X\"/>You can't delete this Photo";
  }
  echo "<br/><br/>";
  echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home [".getnumonline()."]</a>";

  echo "</p>";
echo "</card>";

}
hypetype Developer · 128 posts #3

am not sure how to do the unlink,

$file = $itemurl[0];
if(is_file("$file")) {
unlink("$file");
}

thats the coding i think am gettin wrong

metulj Super moderator Principal · 1,726 posts #4

hypetype wrote: am not sure how to do the unlink,

$file = $itemurl[0];
if(is_file("$file")) {
unlink("$file");
}

thats the coding i think am gettin wrong

DL script here http://coding-talk.com/31482-post1.html and check.. unlink has been done in that script 🙂

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

something else Fellow · 2,296 posts #5

if you are trying to delete files that are not in the same directory you will need to change directorys first and change back to your current working directory eg:

$old = getcwd(); chdir(gallery); $res = unlink($file); chdir($old);

Anshul Senior · 296 posts #6

this will work check you are deleting the gid from gallery before unlink the image so itemurl variable will have NULL or GARBAGE value

$itemurl = mysql_fetch_array(mysql_query("SELECT itemurl FROM ibwf_gallery WHERE id='".$gid."'"));

$file = $itemurl[0];
if(is_file("$file")) unlink("$file");

$res = mysql_query("DELETE FROM ibwf_gallery WHERE id='".$gid."'");
something else Fellow · 2,296 posts #7

by the looks of your coding it looks to me like your using full url`s in your gallery sql if so you will need to edit that so you just get the file name eg:

$itemurl = mysql_fetch_array(mysql_query("SELECT itemurl FROM ibwf_gallery WHERE id='".$gid."'"));

   $file = explode("/",$itemurl[0]);
   $old = getcwd();
   chdir(../gallery);
   if(is_file("$file[4]")){
   $res = unlink($file[4]);
   }
   chdir($old);
   if($res){
   $res = mysql_query("DELETE FROM ibwf_gallery WHERE id='".$gid."'");
   }
hypetype Developer · 128 posts #8

ok i got it to work perfectly.

else if($action=="delgal")
{
    $gid = $_GET["gid"];
  addonline(getuid_sid($sid),"Deleting Gallery Photo","");
  echo "<card id=\"main\" title=\"Delete Photo\">";
  echo "<p align=\"center\">";
  $itemowner = mysql_fetch_array(mysql_query("SELECT uid FROM htp_gallery WHERE id='".$gid."'"));
  if(ismod(getuid_sid($sid))||getuid_sid($sid)==$itemowner[0])
  {
$itemurl = mysql_fetch_array(mysql_query("SELECT itemurl FROM htp_gallery WHERE id='".$gid."'"));
$item = $itemurl[0];
$img = "$item[0]$item[1]$item[2]$item[3]$item[4]$item[5]$item[6]";

if($img=="gallery")
{

$resz = unlink($itemurl[0]);
if($resz){

	$res = mysql_query("DELETE FROM htp_gallery WHERE id='".$gid."'");
	$res2 = mysql_query("DELETE FROM htp_galcomments WHERE pid='".$gid."'");
	$res3 = mysql_query("DELETE FROM htp_prate WHERE pid='".$gid."'");
	 }else{
    echo "<img src=\"images/notok.gif\" alt=\"X\"/>Photo not deleted. Something seems to be wrong!";
	 }
    if($res||res2||res3)
        {
            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Photo Deleted From Gallery<br/>";

        }else{
          echo "<img src=\"images/notok.gif\" alt=\"x\"/>Database Error!<br/>";
        }
}else{
	$res = mysql_query("DELETE FROM htp_gallery WHERE id='".$gid."'");
	$res2 = mysql_query("DELETE FROM htp_galcomments WHERE pid='".$gid."'");
	$res3 = mysql_query("DELETE FROM htp_prate WHERE pid='".$gid."'");
            echo "<img src=\"images/ok.gif\" alt=\"o\"/>Photo Deleted From Gallery<br/>";
}
  }else{
    echo "<img src=\"images/notok.gif\" alt=\"X\"/>You can't delete this Photo";
  }
  echo "<br/><br/>";
  echo "<a href=\"index.php?action=main&sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
echo "Home [".getnumonline()."]</a>";

  echo "</p>";
echo "</card>";

}
hypetype Developer · 128 posts #9

I also wanna unlink the photo from another folder. can help with that also

example i unlink for htportal.net/forum/gallery/photos/img.jpg

i wanna also unlink from htportal.mobi/forum/gallery/photos/img.jpg

something else Fellow · 2,296 posts #10

same way as iv posted above but change: chdir(../gallery); to: chdir(photos);

also your $res = $res2 = $re3 =

in the coding above you may want to change to:

$res = $res.= $res.=

if($res) 🙂

Loony Senior · 258 posts #11

ummmm

hypetype wrote: I also wanna unlink the photo from another folder. can help with that also

example i unlink for htportal.net/forum/gallery/photos/img.jpg

i wanna also unlink from htportal.mobi/forum/gallery/photos/img.jpg

there difrent urls so what something else said wont work. umm i had something like this in 1 of my scripts i will look and see if i can find it.

Creator of Epix.Mobi

Keep an Eye on us Big things coming soon!!!! Need something for your site hit me up here http://coding-talk.com/forum/main-forums/marketplace/153110-free-features-for-your-wapsite

ori Lead · 512 posts #12

u cant unlink files on another domain

something else Fellow · 2,296 posts #13

oh i didnt notice the 2 differnt domains lol*

it can be easily done with Curl* or i should imagine gum will probably have the script do it via ftp* curl is probably safer for hypetype tho :)*

or an alternative way would be to use: $page = "http://domain.com/?file=$file"; $ page = (file_get_contents($page)); if(substr_count($page,"file deleted")>0){ print 'file deleted'; }

then on other server have* $file = $_GET["file"]; $ref = $_SERVER['HTTP_REFERER']; if(substr_count($ref,"domain.com")>0){ *$res = unlink($file) if($res){ print 'file deleted'; }}

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close