Exclamation  Add many Downloads to the Download Module at once?

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Add many Downloads to the Download Module at once?
Mattdylan
CZ Newbie
Mattdylan has been a member for over 15 year's 15 Year Member
usa.gif pennsylvania.gif
Occupation: Web Designer, Computer Programmer
Age: 33
Gender: Male
Fav. Sports Team: Pittsburgh Steelers
Website:
Status: Offline
Joined: Feb 07, 2009
0.00 posts per day
Posts: 23
Points: 0
  MSN Messenger 
I was wondering if there is a script or a SQL statement that would allow me to add MANY(about 463) downloads at once to my download module on my website. If someone (Telli doesn't have to do everything lol) provide me with this and instructions, that would be great. I'm pretty desperate...... icon_rolleyes.gif



Back to top Reply with quote
#2   
trunks
CZ Super Newbie
 Codezwiz Site Donator
trunks has been a member for over 16 year's 16 Year Member
uk.gif
Age: 2024
Gender: Male
Fav. Sports Team: New York Rangers - NHL
Website:
Status: Offline
Joined: Sep 15, 2008
0.01 posts per day
Posts: 36
Points: 685
  MSN Messenger 
Im pretty sure i've seen a script that allows you to upload via FTP and select the download from a drop down in the downloads admin... for the life of me i cant remember where... try a google on it



Back to top Reply with quote
#3   
Mattdylan
CZ Newbie
Mattdylan has been a member for over 15 year's 15 Year Member
usa.gif pennsylvania.gif
Occupation: Web Designer, Computer Programmer
Age: 33
Gender: Male
Fav. Sports Team: Pittsburgh Steelers
Website:
Status: Offline
Joined: Feb 07, 2009
0.00 posts per day
Posts: 23
Points: 0
  MSN Messenger 
You just don't know how many times have googled it. I can't find anything.



Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,440
   
You could write something to read a file's contents and use the file name as the title and description. So you would create a folder on your FTP and upload all the downloads into it. Then your script would read that file and insert the new download.

Example:


$direct = 'files/themes/';
$putdirect = 'downloads/themes/';

if ($handle = opendir($direct)) {
   while (false !== ($file = readdir($handle))) {
      if ($file != '.' and $file != '..' and is_dir($direct.$file)) {
         $filename = $file;
         $desc = $file;
         $category = '12';
         $filesize = @strlen(@file_get_contents($filename));
         $db->sql_query("INSERT INTO ".DB_PREFIX."_downloads_downloads VALUES (NULL, '$category', '0', '$file Theme', '$filename', '$desc', now(), '', 'no@nowhere.com', '', '', '', '', '', '$filesize', '1.0', 'http://www.phpnuke.org', '1')");
      }
   }
}
closedir($handle);


That is just an example and was NOT tested.



_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#5   re: Add many Downloads to the Download Module at once?
Mattdylan
CZ Newbie
Mattdylan has been a member for over 15 year's 15 Year Member
usa.gif pennsylvania.gif
Occupation: Web Designer, Computer Programmer
Age: 33
Gender: Male
Fav. Sports Team: Pittsburgh Steelers
Website:
Status: Offline
Joined: Feb 07, 2009
0.00 posts per day
Posts: 23
Points: 0
  MSN Messenger 
The thing is Telli, I have no idea on where to start on writing a script. icon_redface.gif I would need some help. icon_neutral.gif



Back to top Reply with quote
#6   Re: re: Add many Downloads to the Download Module at once?
Mattdylan
CZ Newbie
Mattdylan has been a member for over 15 year's 15 Year Member
usa.gif pennsylvania.gif
Occupation: Web Designer, Computer Programmer
Age: 33
Gender: Male
Fav. Sports Team: Pittsburgh Steelers
Website:
Status: Offline
Joined: Feb 07, 2009
0.00 posts per day
Posts: 23
Points: 0
  MSN Messenger 


Originally posted by Mattdylan @ Sat Mar 14, 2009 2:13 pm:

The thing is Telli, I have no idea on where to start on writing a script. icon_redface.gif I would need some help. icon_neutral.gif


I cannot get this script to work at all. It keeps coming out in code form when I try and run it.

?php
global $prefix, $dbi;
include_once("mainfile.php");
$url_downloads_folder = "http://guitarherocustoms.com/modules/charts4trunk/"; put the url to the directory with your downloads - you need the trailing slash!
$cat = 1; // the download category id (cid)
$description = "The offset of the chart is at the beginning of the file name of the chart. Visit the forums for guides on how to use this chart.";
$name = "Trunk Charts for you";
$email = "Unknown";
$the_hits = 0; // you can change this if you want
$filesize = 10000;  // you can change this if you want
$version = "1";  // you can put something betwenn the quotes if you want, or leave them empty
$homepage = "http://www.guitarherocustoms.com";

$fp = @fopen("$url_downloads_folder","r");
if($fp) {
   echo "success opening the $url_downloads$downloads_folder folder.<br><br>";
   
   $i=0;
   while (!feof ($fp)) {
      $download_full_name = "";
      $buffer = fgets($fp, 2048);
      if (eregi("(<A HREF=")([^?])(.+)(">)",$buffer)) {
         $download_full_name = eregi_replace("(.+)(<A HREF=")([^?])(.+)(">)(.+)","34",$buffer);
         if(eregi("(.+)(.)(.+)",$download_full_name)) {
            $i++;
            $all_full_names .= "$download_full_name<br>";
            $download_name_no_extension .= eregi_replace("(.+)(.)(.+)","1<br>",$download_full_name);
            $title = eregi_replace("(.+)(.)(.+)","1",$download_full_name);
            $url = $url_downloads_folder.$download_full_name;
            $the_sql_querys .= "insert into ".$prefix."_downloads_downloads values (NULL, '$cat', '0', '$title', '$url', '$description', now(), '$name', '$email', '$the_hits','','0','0','0', '$filesize', '$version', '$homepage');<br><br>";
            //sql_query("insert into ".$prefix."_downloads_downloads values (NULL, '$cat', '0', '$title', '$url', '$description', now(), '$name', '$email', '$the_hits','','0','0','0', '$filesize', '$version', '$homepage')", $dbi);
         }
      }
   }
   fclose ($fp);
   echo "There were $i downloads found in $url_downloads_folder<br><br>";
   echo "<table><tr><td><b>All download names with extension&nbsp;&nbsp;&nbsp;</b><br>$all_full_names</td>";
   echo "<td><b>All download names no extension</b><br>$download_name_no_extension</td></tr></table>";
}else {
   echo "couldn't connect to $url_downloads_folder";
}
echo "$the_sql_querys";
?>



Back to top Reply with quote
#7   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,440
   
At the begining of your code it should start like:


<?php




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#8   re: Add many Downloads to the Download Module at once?
Mattdylan
CZ Newbie
Mattdylan has been a member for over 15 year's 15 Year Member
usa.gif pennsylvania.gif
Occupation: Web Designer, Computer Programmer
Age: 33
Gender: Male
Fav. Sports Team: Pittsburgh Steelers
Website:
Status: Offline
Joined: Feb 07, 2009
0.00 posts per day
Posts: 23
Points: 0
  MSN Messenger 
Wow..... I feel like an idiot now.



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum