Files and Directories
|
|
|
|
<?php
/*
XPC: eXtensible Page Creation
____________________________________________________________
Copyright (c) 2001 by Michael Glazer <mglazer@4arrow.com ->
Parent Site: <http://4arrow.com ->
Sales Site: <http://xpc.4arrow.com ->
Developers Site: <http://dev.4arrow.com ->
@File: xpc.funcs.php
@Usage: common functions
@Function(s): openUrl($url); ftp_save_file($Filepath,$Site_path,$save_file,$Put_File);
@Notes: These functions are very simple, useful and powerful.
They allow you to retreive a url as a variable that can be cached, reloaded, transformed and or saved.
No need for CHMOD or file permissions issues when copying, saving, editing, or writing to files.
*/
function openUrl($url) {
/*
$rf = openUrl($url="http://$domain/home.xpc");
//to display as pure text
//$rf = strip_tags($rf);
echo $rf;
*/
$file = @fopen("$url", "r");//open file for reading
$rf = fread($file, 32000); // read 32K
fclose( $file );
return $rf;
}
function ftp_save_file($Filepath,$Site_path,$save_file,$Put_File) { extract($GLOBALS);
/*
$rf = openUrl($url="http://$domain/home.xpc");
ftp_save_file($Filepath="$ftp_path/cache",$Site_path="$site_path/cache",$save_file="cache.php",$Put_File="$rf");
*/
$page="$Filepath/$save_file";
$page2="$Site_path/$save_file";
//connect to the server
$server="$FtpHost";
$username="$FtpUname";
$password="$FtpPass";
// try to login or die with error
$ftp=ftp_connect($server) or die("invalid server");
$conn=ftp_login($ftp,$username,$password);
$chval = "0666";
$cmd="CHMOD $chval $page";
ftp_site($ftp, $cmd);
$fp = @fopen($page2, "w");
fputs($fp,("$Put_File"));
fclose($fp);
$chval2 = "0644";
$cmd2="CHMOD $chval2 $page";
ftp_site($ftp, $cmd2);
//quit the server
ftp_quit($ftp);
return true;
} ?>
|
|
|
Usage Example
|
/*
You can grab the complete XPC code from http://dev.4arrow.com
example usage of function(s)
$rf = openUrl($url="http://$domain/home.xpc");
//to display as pure text
//$rf = strip_tags($rf);
echo $rf;
$rf = openUrl($url="http://$domain/home.xpc");
ftp_save_file($Filepath="$ftp_path/cache",$Site_path="$site_path/cache",$save_file="cache.php",$Put_File="$rf");
*/
|
|
|
Rate This Script
|
|
|
|