function install_web($to_dir) { $to_dir .= DIRECTORY_SEPARATOR . "paypal_php_wps_samples"; copydir_r("." . DIRECTORY_SEPARATOR . "samples" . DIRECTORY_SEPARATOR . "web", $to_dir, 0755); generate_ini_set(dirname(__FILE__), $to_dir . DIRECTORY_SEPARATOR . "ppwps_include_path.inc"); }
/** * Do the install to a remote FTP server. */ function install_remote() { echo "\nProceeding with remote installation.\n\n"; // validate_php_env returns a string on error, empty string on // success, so be careful with logic. if (validate_php_env(array('ftp')) && validate_php_env(array('sockets'))) { error_message('You must have either FTP or Sockets support in PHP to use the remote installer.'); exit(1); } echo "Enter the FTP server to install on: "; $host = trim(fgets(STDIN)); echo "Username for FTP: "; $user = trim(fgets(STDIN)); echo "Password for FTP: "; $pass = trim(fgets(STDIN)); echo "Please enter the path (relative to your FTP root) for the paypal-php-sdk directory: "; $installdir = trim(fgets(STDIN)); echo "Please enter the path (relative to your FTP root) for the paypal-sdk-samples directory: "; $sampledir = trim(fgets(STDIN)); $ftp = ftp_connect($host); if (!is_resource($ftp)) { error_message('Unable to connect to FTP server: ' . $host); exit(1); } if (!ftp_login($ftp, $user, $pass)) { error_message('Unable to authenticate to FTP server as ' . $user); exit(1); } // Install the libraries. echo "\nInstalling SDK libraries...\n"; if (!@ftp_chdir($ftp, $installdir)) { if (!ftp_mkdir($ftp, $installdir)) { error_message('Libraries install directory does not exist and I can\'t create it.'); exit(1); } ftp_chdir($ftp, $installdir); } if (!@ftp_chdir($ftp, 'paypal-php-sdk')) { if (!ftp_mkdir($ftp, 'paypal-php-sdk')) { error_message('Unable to create libraries directory.'); exit(1); } ftp_chdir($ftp, 'paypal-php-sdk'); } ftp_r($ftp, '.'); ftp_cdup($ftp); // Install the samples. echo "Installing SDK samples...\n"; if (!@ftp_chdir($ftp, $sampledir)) { if (!ftp_mkdir($ftp, $sampledir)) { error_message('Samples install directory does not exist and I can\'t create it.'); exit(1); } ftp_chdir($ftp, $sampledir); } if (!@ftp_chdir($ftp, 'paypal-sdk-samples')) { if (!ftp_mkdir($ftp, 'paypal-sdk-samples')) { error_message('Unable to create samples directory.'); exit(1); } ftp_chdir($ftp, 'paypal-sdk-samples'); } ftp_r($ftp, 'samples/php'); // Generate and upload the ppsdk_include_path file. generate_ini_set($installdir, './ppsdk_include_path.inc', "paypal-php-sdk' . DIRECTORY_SEPARATOR . 'lib"); ftp_put($ftp, 'ppsdk_include_path.inc', './ppsdk_include_path.inc', FTP_ASCII); unlink('./ppsdk_include_path.inc'); ftp_close($ftp); }