unlink () for lavalair gallery

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    unlink () for lavalair gallery

    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.

    #2
    THIS IS THE CODE BELOW

    PHP Code:
    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&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
    echo 
    "Home [".getnumonline()."]</a>";

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


    Comment


      #3
      am not sure how to do the unlink,

      PHP Code:
      $file $itemurl[0];
      if(
      is_file("$file")) {
      unlink("$file");

      thats the coding i think am gettin wrong

      Comment


        #4
        Originally posted by hypetype View Post
        am not sure how to do the unlink,

        PHP Code:
        $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ノ刀ノイリ!

        Comment


          #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);
          Last edited by something else; 31.05.09, 23:51. Reason: stars

          Comment


            #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

            PHP Code:
            $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."'"); 

            Comment


              #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:
              Code:
              $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."'");
                 }
              Last edited by something else; 01.06.09, 09:15. Reason: stars

              Comment


                #8
                ok i got it to work perfectly.
                PHP Code:
                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&amp;sid=$sid\"><img src=\"images/home.gif\" alt=\"*\"/>";
                echo 
                "Home [".getnumonline()."]</a>";

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


                Comment


                  #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

                  Comment


                    #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)

                    Comment


                      #11
                      ummmm

                      Originally posted by hypetype View Post
                      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-fo...r-your-wapsite

                      Comment


                        #12
                        u cant unlink files on another domain

                        Comment


                          #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';
                          }}
                          Last edited by something else; 03.06.09, 09:11. Reason: missing clossing tag

                          Comment


                            #14
                            i got it to work. thanks.

                            PHP Code:
                            $file ="../htportal.mobi/forum/$itemurl[0]";

                            $resz2 unlink($file); 

                            Comment

                            Working...
                            X