Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    210
    Rep Power
    14

    Lightbulb relatively easy money?


    hello,

    i have been lurking on this community for some time , and have found the tutorials/forums to be excellent.
    I do not feel i have sufficient understanding in any of the subjects to become an outspoken member of the community, but would like to extend a genuine offer for work.

    I am currently developing an online collaborative music project, which of course has certain copyright issues that need to be addressed.
    I am looking for an autonomous script that can run the users' uploading and downloading, and logs these transactions. Perhaps similar to some FTP sites.

    I am aware from hacking freeware scripts that this is not the most challenging of offers, and would be interested in any ideas you might have to improve the script, but as a non-profit art project, functionality is our main concern.

    If you are genuinely interested and capable, please get in touch with us; info@directionsincollaborativeaudio.org


    We are not looking for freebies, and payment will not be an issue.

    Thanks in advance


    chris

    http://www.directionsincollaborativeaudio.org
  2. #2
  3. Wacky hack
    Devshed Novice (500 - 999 posts)

    Join Date
    Apr 2001
    Location
    London, England
    Posts
    513
    Rep Power
    14
    Fantastic domain by the way!

    I'm surprised you couldn't find an open source / free / freeware script of that description knocking about!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    210
    Rep Power
    14

    Talking


    thanks!

    there are various upload scripts that if emalgamated would do what i require. Unfortunately, i am still learning perl and my code hacking is not good enough to be reliable. This is a major issue for the project.

    Essentially, the script needs to;

    (i) Parse form data and write to database with date/time, IP, filename etc

    (ii) Check if file type is .MP3 and under 1Mb.

    (iii) upload file to designated directory.

    (iv) email me to alert of new upload

    pretty simple i know, but i figure what id be paying for was the reliability.

    any input would be appreciated,

    thanks again
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    4
    Rep Power
    0
    Contact me and I could whip up a script for ya to do just want ya want to do


    Jeremy
    webmaster@phprank.com
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2001
    Posts
    210
    Rep Power
    14

    Exclamation


    I dont know if i made this clear in previous posts, but im looking for scripts in perl/CGI.
    Thanks for getting in touch Jeremy, but PHP is not the best option with my server. If nothing else comes up though, i'll probably be getting back to you 'bout that script

    Keep em comin'
  10. #6
  11. Ole` Timer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Location
    N.W. Iowa
    Posts
    472
    Rep Power
    15

    Thumbs up


    Originally posted by the_pedestrian
    I dont know if i made this clear in previous posts, but im looking for scripts in perl/CGI.
    Thanks for getting in touch Jeremy, but PHP is not the best option with my server. If nothing else comes up though, i'll probably be getting back to you 'bout that script

    Keep em comin'
    I think we could handle your request guiet nicely. We main program with Perl and using the CGI.pm module would make this a pretty simple task

    Feel free to contact me and I'd be happy to dicuss this in more detail with you. You may review the many Programming Services we offer here.

    Look forward to hearing from you soon,

    Mike(mickalo)Blezien

    Thunder Rain Internet Publishing

    Custom Programming & Database development
    Providing Personal/Business
    Internet Solutions that work!
  12. #7
  13. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    How nice...

    After such a long time [ infect I think this would be first time ] Someone asking for help and ready to roll out that green bucks instead of that credit, link to your site and other blah blah.

    You are going to get GREAT response !!
    [ my self going to mail you !! ]

    JD
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  14. #8
  15. No Profile Picture
    Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Location
    Boston Ma.
    Posts
    1,529
    Rep Power
    0
    Hi


    Here is a quick script I wrote a long time ago.........

    It still works great on win/unix


    What it does..............


    uploads files............


    dis-allow based on............

    (TYPE,SIZE)


    sends a email, like this to the admin.............


    From Sunny@mail.com Sun Jan 06 20:09:20 2002
    X-UID32: 1010376562
    Return-path: Sunny@mail.com
    Received: from 127.0.0.1 by ssl.ya-right.com (SSL SMTPD);
    id s20020106200920.150; Sun, 06 Jan 2002 20:09:20
    Date: Sun Jan 6 23:09:20 2002 -0500
    From: "Sunny" <Sunny@mail.com>
    Subject: New Music File Upload
    To "Sunny" <Sunny@mail.com>
    X-Mailer: <Music Mail Server>
    MIME-Version: 1.0
    Content-Type: text/plain; charset="ISO-8859-1"
    Content-Transfer-Encoding: 8bit

    Hi You

    New Music File Upload

    File Name: bye bye bidie.mp3
    Time Uploaded: Sun Jan 6 23:09:20 2002
    Remote Host: 127.0.0.1


    Write to a database the upload info...........

    1,127.0.0.1,Sun Jan 6 23:13:56 2002,img.zip

    ^^ count,ip,time,file name.....



    mail using basic sockets

    Code:
    #!/usr/local/bin/perl
    
    use CGI qw/:standard/; 
    use CGI::Carp qw/fatalsToBrowser/; ## Carp debugging
    $| = 1;  ## Flush the open filehandle.
    
    # CHANGE TO WHATEVER.
    $title='UPLOAD MUSIC FILES!';
    
    #This is the relative path to the upload directory.
    # ./ If you leave it like this, the uploads would be 
    # placed where this script is (NOT GOOD CHANGE IT).....
    $dir='./'; 
    
    # max KB/b posts. What ever number you place here is the max file size in KB to upload.
    $max = 60;
    
    # only upload files with the file.@good in the brackets. 
    # ie @good = qw(txt html htm asp this that and whatever);
    @good = qw(mp3 wav);
    
    # where to log all the upload info.......
    $data_file = 'data.log';
    
    # the counter file, to keep an upload count...
    $counter = 'count';
    
    # email results info........
    $fromuser = 'you@domain.com';
    $fromname = 'You';
    $touser = 'you@domain.com';
    $toname = 'You';
    $subject = 'New Music File Upload';
    
    # mail server info....
    $server = "localhost";
    $LOCALHOST = 'smtp.domain.com';
    $SMTP_PORT = '25';
    $xmailer = '<Music Mail Server>';
    
    # does the server require AUTH, if yes fill these in
    # this is not called unless $use_AUTH = '1';
    $use_AUTH = '';  # leave empty no-auth, enter 1 if using auth
    # some server allow for plain sent user/pass
    # others want it sent as base64
    $mail_sender = "smtp_login_username";
    $mail_passwd = "smtp_login_pass";
    
    ## THAT IT............
    
    $encoding='multipart/form-data';
    $match=0; 
    $CGI::POST_MAX=1024 * $max; 
    $q = new CGI; 
    print $q->header();
    
    print $q->start_html(-title=>"$title\n", 
    		-meta=>{'description'=>'Music Upload File System',
    			  'keywords'=>'Music Upload'},
    		-dtd=>1, 
    		-BGCOLOR=>'white',
    		-TEXT=>'navy',
    		-link=>'green',
    		-vlink=>'red',
    		-alink=>'blue');
    
    print $q->h1("$title"), "Enter your music file to upload (@good ${max}Kb Max.)\n";
    print $q->startform($method,$action,$encoding);
    print $q->filefield(-name=>'uploaded_file', -default=>'', -size=>40, -maxlength=>120); 
    print $q->submit(-name=>'button_name', -value=>'UPLOAD'); 
    print $q->endform;
    $filename = $q->param('uploaded_file');
    $filename2 = $filename;
    $filename2 =~ /\w:[\\[\w- ]*\\]*([\w- ]*.\w{1,3})$/g;
    $file=$1;
    if ($filename){
    foreach $good (@good){
    if (grep /$good$/i,$filename){$match=1;print "$file UPLOADED!<BR>\n";
    }
    }
    if ($match){
    &upload;
    }
    else {
    &error("File Format is not supported! $file, can not be uploaded!");
    }	
    }	
    
    sub upload{
    open(OUTFILE, ">$dir$file")||&error("Can't open $dir$file. $!");
    binmode OUTFILE;
    # binmode for windows. Ignored by unix
    while ($bytesread=read($filename,$buffer,1024)) 
    {print OUTFILE $buffer; } 
    close (OUTFILE); 
    }
    if ($match){
    &get_number;
    $ip = "$ENV{'REMOTE_ADDR'}";
    $timer = localtime();
    $data_line = "$num,$ip,$timer,$file";
    open (FILE, ">>$data_file") or die "Cannot open $data_file: $!";
    flock(FILE,2) or die "cannot lock file: $!";
    print FILE "$data_line\n";
    close(FILE);
    &add_header;
    print "Thanks for the new music";
    }
    
    sub error{
    @error=@_;
    print "<H2>@error</H2>";
    exit;
    }
    
    sub get_number {
     open (COUNTER_FILE, "<$counter");
      while (<COUNTER_FILE>)
       {
       $current_counter = $_;
       }
     close (COUNTER_FILE);
    
     $current_counter++;
      $num = $current_counter;
     open (FILE, ">$counter");                      
      print FILE "$num";
      close (FILE);
     return $num;
    }
    
    sub add_header {
    $header = "Date: $timer -0500\r\n";
    $header .= "From: \"$fromname\" <$fromuser>\r\n";
    $header .= "Subject: $subject\r\n";
    $header .= "To \"$toname\" <$touser>\r\n";
    $header .= "X-Mailer: $xmailer\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: text/plain; charset=\"ISO-8859-1\"\r\n";
    $header .= "Content-Transfer-Encoding: 8bit\r\n\r\n";
    $header .= "Hi $toname\n\n";
    $header .= "New Music File Upload\n\n";
    $header .= "File Name: $file\n";
    $header .= "Time Uploaded: $timer\n";
    $header .= "Remote Host: $ip\n";
    &send_smtp_mail($fromuser, $touser, $subject, $header);
    }
    sub send_smtp_mail {
    use Socket;
    my ($iaddr,$paddr,$proto);
    my ($from, $to, $subject, $header) = @_;
    no strict 'subs';
        $iaddr = inet_aton($server);
        $paddr = sockaddr_in($SMTP_PORT, $iaddr);
        $proto = getprotobyname( 'tcp' );
        socket(SOCK, PF_INET, SOCK_STREAM, $proto)      or return 0;
        connect(SOCK, $paddr)                           or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "HELO $LOCALHOST")       or return 0;
        receive_from_server(\*SOCK)                     or return 0;
    if ($use_AUTH) { 
        send_to_server(\*SOCK, "AUTH LOGIN")            or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "$mail_sender")          or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "$mail_passwd")          or return 0;
        receive_from_server(\*SOCK)                     or return 0;
    }
        send_to_server(\*SOCK, "MAIL From: <$from>")    or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "RCPT To: <$to>")        or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "DATA")                  or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "$header\r\n.")          or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        send_to_server(\*SOCK, "QUIT")                  or return 0;
        receive_from_server(\*SOCK)                     or return 0;
        close(SOCK)                                     or return 0;
                                                           return 1;
       }
    
    sub send_to_server {
        my($socket)  = shift;
        my($message) = shift;
        send($socket, "$message\r\n", 0) or return 0;
        return 1;
    }
    sub receive_from_server {
        my($socket) = shift;
        my($reply);
        while($reply = <$socket>) {
    	return 0 if $reply =~ /^5/;
    	last     if $reply =~ /^\d+ /;
        }
        return 1;
    }
    
    print "<br><br>\n";
    print $q->
    	hr({-width=>'90%',-size=>3,-style=>'raised'}),
    	p({-align=>CENTER},'Upload music services by ',
    	a({-href=>'http://music-world.com/'},'Music World')
    	);
    print "</body></html>\n";
    
    exit;

    F!
  16. #9
  17. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    83
    Ugh. There's no file locking so you'd have a real problem with concurrent users, most likely wiping data from your DB under any sort of load.
  18. #10
  19. No Profile Picture
    Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Location
    Boston Ma.
    Posts
    1,529
    Rep Power
    0
    Hi

    what do you mean?, there is a file lock when writing to the database....


    F!
  20. #11
  21. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    83
    Not when you get the number. Everything that accesses a file has to respect the lock, otherwise you're going to run into a potential race condition or garbage data.

    Locking shouldn't only be done for writes, it has to be done for all file accesses.

    What if your "get number" sub opens the file, without respecting the lock, while the write sub is trying to write to it? It might work most of the time, but sometimes, and inexplicably, you'd get garbage. This is a major problem down the road especially if you're doing computations on data from an unlocked data file. You could end up with garbage computations as well.

    File locking is trickier than it seems. What if you write another reporting script to access the data that doesn't respect the lock? You could run into the garbage data issue again.

    File locking and data integrity has to be approached holistically, that's why I advise most folks to use MySQL for "collect and report" type applications- it's easier, once you learn a little about DBI. It's also more powerful.
  22. #12
  23. phpkid ~~~~~~ :o)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Nov 2000
    Location
    NJ, USA
    Posts
    2,534
    Rep Power
    17
    I agree completely, Hero.

    You got to take care of this issue, specially in web based application , cause there will be always simultaneous requests.

    JD

    P.S. : I guess you can reply to my last PM.
    _____________________________
    d.k.jariwala (JD)
    ~ simple thought, simple act ~
    I blog @ http://jdk.phpkid.org
  24. #13
  25. No Profile Picture
    Senior Member
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Nov 2001
    Location
    Boston Ma.
    Posts
    1,529
    Rep Power
    0
    Hi

    First off I wrote it a long time ago, and it was used just for personal use.......


    Secondly, I put it here so the person who made a request for a script like this, may/might find it useful as a starting point. Is not what this BB all about.


    True I did not put a lock on the $num return file, and that is because I added it quickly to my old upload routine, so that I could give a simple example on how to do what he/she wanted done....


    So to you =>H<=, it may have be a mistake, but to me, I just plain forgot to add it.....


    Also to you =>H<=, unlike you, shown by your past actions, where you would rather be rude than say, hey (person) you forgot something, or you can do it like this also. I would never be like you, in fact the only time I would be rude, is when someone is rude to me, without letting me explain (why!)




    F!
  26. #14
  27. 11
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Jul 2001
    Location
    Lynn, MA
    Posts
    4,635
    Rep Power
    83
    I'm sorry that you interpreted my directness as rudeness, I didn't mean to ruffle your feathers. Re-reading this thread I don't particularly see where I was rude, beyond the fact that I pointed out an oversight.

    I just like that when someone is aware of the limitations of themselves and their applications that they are direct with them. I'd just hate for someone to use the code above in a production application.
  28. #15
  29. No Profile Picture
    Dev
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2001
    Posts
    1,436
    Rep Power
    41
    Ugh that is a nasty looking script just to do a file upload. Should have used PHP for that simple of a web app.
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo