WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Fetching product details from the commission junction website using php
Categories : PHP, FTP, Filesystem, Compression Click here to Update Your Picture
Robin Varghese
Date : Jun 23rd 2009
Grade : 1 of 5 (graded 1 times)
Viewed : 7606
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Robin Varghese
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

Fetching product details from commission junction using php and uploads csv files to uploads folder.This code fetches only the files created yesterday.

<?php
//FETCH FILES FROM CJ USING PHP AND UNZIP THAT GZIP FILE USING PHP FUNCTION AND CREATE CSV FILE FROM IT.
//WE FETCH ONLY FILES CREATED ON YESTERDAY,NOT ALL FILES
//SET MEMORY LIMIT AND ALSO EXECUTION TIME IF NEEDED
ini_set("memory_limit","200M");
//Set here Memory size to 200MB becuase we have to download file size of large MB
//IF NOT SET IT CAUSES MEMORY ALLOCATION PROBLEM
ini_set("max_execution_time","3600");//SET TO 1 HOUR
$ftp_server     =     "datatransfer.cj.com";
$ftp_user_name    =    "username";//Give FTP username for cj
$ftp_user_pass    =    "password";//Give FTP password for cj

$local_path ='/opt/lampp/htdocs/cj/';//LOCAL FILE PATH

$server_path = 'outgoing/productcatalog/26997/';//CJ FILE PATH


function parse_rawlist( $array )
{
   
$i=0;

    foreach(
$array as $curraw)
    {
       
$struc = array();
       
$current = preg_split("/[\s]+/",$curraw,9);

       
$struc['perms']      =     $current[0];
       
$struc['number']    =     $current[1];
       
$struc['owner']      =     $current[2];
       
$struc['group']     =     $current[3];
       
$struc['size']      =     $current[4];
       
$struc['month']      =     $current[5];
       
$struc['day']        =     $current[6];
       
$struc['time']         =     $current[7];
       
$struc['zfile_name']    =     $current[8];
     
$structure[$i]      =     $struc;
   
$i++;
    }
   return
$structure;

}
$conn_id = ftp_connect($ftp_server,21);
if(
$conn_id)
{
    echo
"Successfully connected";
}
 
$login_result     =     ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
ftp_chdir($conn_id, $server_path);//Change Current Working Directory
$file_list     =    ftp_rawlist($conn_id,".");



$zip_details    =    parse_rawlist($file_list);
$yest_date1    =    strtotime("-1 day");
$yest_date = strtotime(date('M/d/Y',$yest_date1));
 
for(
$i=0;$i<count($zip_details);$i++)
{
   
$fname        =    $zip_details[$i]['zfile_name'];   
     
$mod_date1    =    $zip_details[$i]['month']."/".($zip_details[$i]['day'])."/".date("Y");//Changes here   
     
       
$mod_date    =    strtotime($mod_date1);//File Modified Date
     
     
     
   
   
if($mod_date == $yest_date)//If modified date equals yesterdays date
   
{
   
       
$local_file    =    $fname;
       
$server_file    =    $fname;
        if (
ftp_get($conn_id, $local_file, $server_file, FTP_BINARY))
        {
       
            echo
"\n<br/>Successfully written to $local_file\n";
        }
        else
        {
            echo
"\n<br/>There was a problem\n";
        }
       
$contents    =    '';
       
$size    =    52428800;//=50MB
       
if(file_exists($local_file))
        {
           
           
//To Get the size of the uncompressed file
           
$FileRead = $local_file;
           
$FileOpen = fopen($FileRead, "rb");
           
fseek($FileOpen, -4, SEEK_END);
           
$buf = fread($FileOpen, 4);
           
$GZFileSize = end(unpack("V", $buf));
           
fclose($FileOpen);
           
//To Get the size of the zip file

           
$fzip_size    =    $GZFileSize;
             
           
$filename    =    $local_file;
           
$ext        =    pathinfo($filename,PATHINFO_EXTENSION);   
           
$file_name    =    pathinfo($filename,PATHINFO_FILENAME);       
           
$file_name    =    $file_name.".csv";

           
$zd         =     gzopen($filename, "rb");
           
//If file size is greated than 50MB Cut that file otherwise causes memory allocation problem
           
if($fzip_size > $size )
            {
               
$fzip_size    =    $size;   
            }
           
$contents     =     gzread($zd, $fzip_size);
           
gzclose($zd);
           
$file_name    =    "uploads/".$file_name;
           
$fp    =    fopen($file_name, "wb");
            if(
strlen($contents) == 52428800)
            {
               
$cval    =    explode("\n",$contents);
               
$i    =    count($cval) - 1;
                unset(
$cval[$i]);
               
$contents    =    implode("\n",$cval);
               
fwrite($fp, $contents);
            }
            else
            {
               
fwrite($fp, $contents); //write contents of feed to cache file
           
}
           
fclose($fp);
            if(
file_exists($file_name))
            {
               
chmod($file_name,0755);
               
unlink($local_file);
            }
        }
    }
}
ftp_close($conn_id);
?>



Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
A PHP Script that shows how to use FTP to run a shell script, read two local files and update data in a database.
Categories : PHP, Filesystem, FTP, Date Time, Databases
3 lines of Code to extract Tar, Zip, Gzip etc..
Categories : PHP, Filesystem, PHP Classes, Compression
PHP ZIP file creation on a linux box using exec. Create ZIP files containing images
Categories : PHP, Compression, Filesystem
Using PHP to Delete a directory with all sub directories and files using FTP
Categories : PHP, FTP, Directories, Filesystem
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
Upload function using PHP's FTP abilities.
Categories : PHP, Filesystem, FTP
Moving folder hierarchy b/w server
Categories : PHP, FTP, Filesystem
Link Submition - Allow your visitors to submit links to the site.
Categories : PHP, Arrays, Filesystem, Beginner Guides
Unix Disk Information with graphs
Categories : PHP, Shell Scripting, Filesystem
Upload Via FTP - an alternative to move_uploaded_file
Categories : PHP, FTP, Beginner Guides
Finds files on your site, uses UNIX find command.
Categories : Complete Programs, Filesystem, PHP
Show Source with Line Numbers
Categories : PHP, Regexps, Filesystem
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Image Browser
Categories : Filesystem, GD image library, Content Management, PHP