PHP - Php Ftp Vs. Ftp Client
Dear all,
I'm working on a website that is hosted on a server with 10Mb of file size limit via HTTP file uploading approach (eg. PHP file uploading form using move_uploaded_file()), although there's no file size limit via FTP file uploading approach (eg. Using FTP client). Therefore, I was thinking about using PHP FTP functions to bypass the file size limit. However, when I upload file bigger than 10Mb, I still got this error message telling me that my file can't be over 10Mb... So my question is...what exactly are the differences between PHP FTP and FTP Client, that the web server used to determine whether to block the file bigger than 10Mb or not? Thank you very much! Below is my code: Code: [Select] <?php echo '<form action="" method="post" enctype="multipart/form-data">'; echo 'Click the Browse button to find the file you wish to upload'; echo '<input type="file" name="add_file">'; echo '<INPUT TYPE="submit" name="upload" value="upload">'; echo '</form>'; if($_POST['upload']) { $add_file = $_FILES['add_file']; //change these values to suit your site $ftp_user_name = 'username'; $ftp_user_pass = 'password'; $ftp_server = 'ftp.domainname.com'; $ftp_root = '/'; //File upload $temp_path = $ftp_root . $add_file['tmp_name']; $target_path = basename($add_file['name']); $max_size = 26214400; if($add_file['error'] == 0 && $add_file['size'] < $max_size) { // set up basic connection $conn_id = ftp_connect($ftp_server); // login with username and password $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // upload a file ftp_chdir($conn_id, '/root/second/'); if (ftp_put($conn_id, $target_path, $temp_path, FTP_ASCII)) { echo "successfully uploaded " . $target_path; } else { echo "There was a problem while uploading " . $target_path; } } else { echo "There's been an error, please try again later."; } // close the connection ftp_close($conn_id); } ?> Similar TutorialsI wish to create validation rules once which are used both on the client and on the server.
For instance, I will start off with the following PHP object:
stdClass Object ( [rules] => stdClass Object ( [email] => stdClass Object ( [required] => 1 [email] => 1 [remote] => stdClass Object ( [url] => check-email.php [type] => post [data] => stdClass Object ( [username] => function() {return $( '#username' ).val();} ) ) ) ) [messages] => stdClass Object ( [email] => stdClass Object ( [required] => an email is required ) ) )When the edit page is downloaded to the client, I will include this object in some format suitable to the client. The client will then use the jQuery Validation plugin (http://jqueryvalidation.org/) along with the validation object, and client side validate the page. When the form passes client side validation and is uploaded, PHP will use the same validation object to serverside validate the form (I have this part working as desired). My question is how should I pass this data to the client? Originally, I would just use PHP to write some JavaScript. exit('var myObj='.json_encode($myObj));Note that when I json_encode the object, the value of $myObj->rules->email->remote->data->username is a string with quotes around it, however, I can easily use PHP to strip these tags before sending it to the client. As Jacques1 pointed out in http://forums.phpfre...ascript-client/, I should never ever use PHP to generate JavaScript, and should use AJAX to download the JSON directly. I tried doing the later, but found that a callback function could not be included in the JSON. Please advise on the best way to accomplish this. Thank you Hi everyone, I've been trying to find a decent SOAP client library for PHP. The problem with PHPs own SoapClient is that it's very basic and doesn't really have support for different namespaces and headers with namespaces. It doesn't have the option to make custom attributes on soap headers or params. It can't make nested headers with SoapVars or Params and so on. Same goes to Zends SoapClient which is basicly just a wrapper for PHPs SoapClient. Is there any good client library that could handle all this stuff? I'm trying to access webservices using PHP's soap. Here's my code: <?php // test connection to agwebservice $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $agDN = "myDN"; $agUserName = "myUserName"; $agPass = "myPassword"; $login = new SoapClient($agLogURL); $login->aglogin($agDN, $agUserName, $agPass); // $login.service.agLogin($agDN, $agUserName, $agPass); ?> When I run the script, here's the resulting error: Fatal error: Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object. at AgemniLogin.agLogin(String dn, String username, String password) --- End of inner exception stack trace --- in C:\XAMPP\xampp\htdocs\agsync\syncwork.php:12 Stack trace: #0 [internal function]: SoapClient->__call('aglogin', Array) #1 C:\XAMPP\xampp\htdocs\agsync\syncwork.php(12): SoapClient->aglogin('myDN', 'myUserName', 'myPassword') #2 {main} thrown in \htdocs\agsync\syncwork.php on line 12 Not sure if you'll need more info on the SOAP services, but the info is he http://wiki.agemni.com/Getting_Started/APIs/Agemni_CMS_Sync#Method_details Really could use any help anyone can offer: Hi, guys. I just developed and published first version of 12framework for iOS which can call also PHP web services.
It is web service client which generates dynamic forms from web service results, and enables insert, update and delete of records. You can simply change result field type to text, memo, date, bool.
I also made some simple PHP web service to test functionallity of application, so I will really appreciate your feedback. iOS is locked platform, so 12framework provides possibility, to make some useful data forms that works as native application. Link: https://itunes.apple...88083?ls=1&mt=8
hello, i want to create a client login system so when they use there login it redirects them to a page only for them, is this possible? i am using the following code but it only re-drirects them after login to the "index.php" page not the 2nd user to "Harts.php", what am i doing wrong?, thanks <?php $usernames = array("admin","admin2"); $passwords = array("admin","admin2"); $page = array("index.php","Harts.php"); for($i=0;$i<count($usernames);$i++) { $logindata[$usernames[$i]]=$passwords[$i]; } $found = 0; for($i=0;$i<count($usernames);$i++) { if ($usernames[$i] == $_POST["username"]) { $found = 1; } } if ($found == 0) { header('Location: login.php?value=fail'); exit; } if($logindata[$_POST["username"]]==$_POST["password"]) { session_start(); $_SESSION["username"]=$_POST["username"]; header('Location: '.$page); exit; } else { header('Location: login.php?value=fail'); exit; } ?> I feel like I was 75% there, and now I'm only 25% there. I'm trying to put my links onto my page. http://thingsihateaboutyou.net/michelle is my testing page. So I have register (register.php), login (login.php), logout (logout.php), and the members area. The members area is going to be their username.php, so I assumed this would be $username.php like I have it in the redirect link from the point where you login to the point where you see your client page. This works fine. The part I'm having trouble with is the visibility of the links on my page to these, AND adding a PHP variable ($username) into the "members area" tag. When you click on members area, it should send you to http://thingsihateaboutyou.net/michelle/*whatever you are logged in as*.php As for the visibility, if you are not logged in I obviously don't want you to see a link called "log out" or a link called "members area," and vise versa. It's been like 5 hours now, and I keep getting further and further away. I had to bail on my Wordpress so I don't have a Content Management System in place. All of this DID work and it worked excellent, but after I made the switch earlier today it kind of blew up in my face. I am attaching a ZIP file with everything included... in desperate need of an answer. I have two questions, I was wondering what would be the best method to go about building client side API functions on top of a already built API eg. http://docs.whmcs.com/API:Functions
We would like to provide our clients access to API functions related to their accounts without giving them access to the whole Admin API where they can see a lot of our other client information.
The other question we have an API built using Basic HTTP Auth for API authenication (HTTPS). eg curl username:password http://api.etc.com) If so what would be the best way to secure this method?
Thank you Hello All, I'm working with a SOAP WSDL API for the first time, i need to send off some params to the server so it returns the data i'm after, i've read the SoapClient manual and looked at a few tutorials but I can't seem to work out how to actually send the data. I have been provided a sample XML document of how the request should be formatted which I have attached. All I have worked out so far is how to run the client: Code: [Select] $client = new SoapClient($url); The request XML the server is looking for is as follows: Code: [Select] <?xml version="1.0" encoding="utf-8"?> <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ARN_ReadRQ TransactionIdentifier="f8f766bb-87c0-42c0-83d5-29416b8477b7" TimeStamp="2007-07-31T14:33:52.1051647-07:00" EchoToken="Retrieve" Version="1.0" xmlns="http://www.domain.com/"> <POS> <Source> <RequestorID ID="Username" MessagePassword="Password"/> </Source> </POS> <ReadRequests> <ReadRequest> <UniqueID ID="1020-322162" Type="14"/> </ReadRequest> </ReadRequests> </ARN_ReadRQ> </s:Body> </s:Envelope> I am under the assumption this stuff goes in an array? If so how do I format it and how do I send it across? Any help greatly appreciated, Cheers. I am writing an API for clients to use to integrate with an server API I have written and it will be used in a variety of different environments and used by people with varying coding styles (hopefully), I was just wondering how I should handle errors? I was going to throw an exception, but what if people don't use a try / catch ? Should I return false to allow them to handle an error? private function _request($uri) { if ( ini_get('allow_url_fopen') ) { $this->_response = file_get_contents($uri); return false; } if ( function_exists('curl_init') ) { $ch = curl_init($uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $this->_response = curl_exec($ch); curl_close($ch); return false; } throw new Exception('Allow URL fopen disabled and cURL disabled'); } Also, any scenarios where the above would fail to return a result (apart from the obvious lol) Thanks, Andy Hi, I need to make web site, which will get requests from users that log in and activate those scripts. But, the problem is that the server has to, when the script is activated, send request to another PC with the static IP address. Then, that PC should execute the script, send its results to server, and then the server will notice user who activated it (clicked on the link). So, the main problem is that server - client (static ip) communication, when the server is the first who sends request, not the client. Any instructions would be appreciated, thanks in advance. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=353630.0 I'm in the habit of verifying input client side. For example, there is a field to enter a number, and I ensure that it is within a particular range using Javascript. My backend PHP code does not do such checking... Is this bad? Should I be doing checking using my backend code and send a response back to the client to display a message? Admittedly, I avoid it, since it's a little extra work -- well more extra than just javascripts, IF-THEN-ALERT type statement. Hello guys. I was thinking on posting this under the mysql thread. but i think this can be solved by php.. anyway, i want to dump mysql data on the client side whenever a user logs out. how can i do this? thanks in advance. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=354998.0 I have a general knowledge of PHP. I was wondering if anybody knew of a script that when a user logs in, they have their own unique page setup, but it is the same page. Basically so a client could log in and see the information about their purchase, or website construction etc. Any scripts to build off of? Thanks Hello,
I am trying to connect to the oData service API, I already generated the file which has all the method I need. My problem is when I run in on the web site it shows 401 (Unauthorize user), so i need to input username and password to connect to the OData Service, but I don't know where to put my username or password.
define("DEFAULT_ODATA_SERVICE_URL", "https://sample.service.site/Wcf.OData.svc/"); I want some code to receive email, reformat and then forward to another email address
I'm not sure where to start with this
Does the application need to be constantly running - monitoring incoming emails?
What is involved?
I did a search and saw many discussions saying that Google App Engine was available for usage
I've no experience of this
Just looking for suggestions
Thanks
OM
Well, I'm trying to connect to this webservice but not getting any useful data returned. My code is as follows: <?php // Connect to agwebservice/AgemniLogin $agLogURL = "https://www.agemni.com/_snet/AgemniLogin.asmx?WSDL"; $myLogin->dn = "myDN"; $myLogin->username = "myUserName"; $myLogin->password = "myPassword"; $agLogin = new SoapClient($agLogURL); $agLoginResults = $agLogin->aglogin($myLogin); echo '<h2> AgemniLogin Connection: </h2>'; echo '<p style="color:red"> $agLogin { soap client - agemni session login } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agLogin); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agLogin); echo '<hr>'; // get cookie information from $agLogin session $agCookie = $agLogin->_cookies; echo '<p style="color:red"> $agCookie = $agLogin->_cookies</p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agCookie); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agCookie); echo '<hr>'; $agSession = $agCookie[AGSESSION]; echo '<p style="color:red"> $agSession = $agCookie[AGSESSION]</p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agSession); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agSession); echo '<p style="color:green"> $agSession[0] = '; echo $agSession[0]; echo '</p>'; echo '<p style="color:green"> $agSession[1] = '; echo $agSession[1]; echo '</p>'; echo '<p style="color:green"> $agSession[2] = '; echo $agSession[2]; echo '</p>'; echo '<hr>'; // now connect to agwebservice/ADBAccess echo '<h2> Connect to Agemni Data Access Service ADBAccess</h2>'; $agDataURL = "http://www.agemni.com/_anet/ADBAccess.asmx?WSDL"; $agDataClient = new SoapClient($agDataURL); echo '<p style="color:red"> $agDataClient { soap client - agemni Data Connection } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agDataClient); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agDataClient); echo '<hr>'; // set cookie information for $agDataClient echo '<p style="color:green"> try setting cookies - $agDataClient->_cookies = $agCookie </p>'; $agDataClient->_cookies = $agCookie; echo '<p style="color:green"> then look at contents of $agDataClient again </p>'; echo '<p style="color:red"> $agDataClient { soap client - agemni Data Connection } </p>'; echo '<p style="color:blue"> print_r: </p>'; print_r($agDataClient); echo '<p style="color:blue"> var_dump: </p>'; var_dump($agDataClient); echo '<hr>'; echo '<p style="color:red"> $agDataSet = $agDataClient->getCMSData($agDataParams) </p>' ; $agDataParams->opName = 'appointment'; $agDataParams->startDate = '12/29/2010 12:01:00 AM'; $agDataParams->endDate = '12/29/2010 4:00:00 PM'; $agDataSet = $agDataClient->getCMSData($agDataParams); echo '<p style="color:blue"> print_r($agDataSet) </p>'; print_r($agDataSet); echo '<p style="color:blue"> var_dump($agDataSet) </p>'; var_dump($agDataSet); echo '<hr>'; $agDataResult = $agDataSet->getCMSDataResult; echo '<p style="color:red"> $agDataResult = $agDataSet->getCMSDataReult </p>'; echo '<p style="color:blue"> print_r($agDataResult)</p>'; print_r($agDataResult); echo '<p style="color:blue"> var_dump($agDataResult)</p>'; var_dump($agDataResult); echo '<hr>'; // do var_dump of $agLogin->__getLastResponse echo '<p style="color:green"> var_dump($agLogin->__getLastResponse()) </p>'; var_dump($agLogin->__getLastResponse()); // do var_dump of $agDataClient->__getLastResponse echo '<p style="color:green"> var_dump($agDataClient->__getLastResponse()) </p>'; var_dump($agDataClient->__getLastResponse()); ?> Below you will find the resulting output: AgemniLogin Connection: $agLogin { soap client - agemni session login } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #4 [httpsocket] => Resource id #5 [_use_proxy] => 0 [httpurl] => Resource id #6 [_cookies] => Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) ) var_dump: object(SoapClient)#2 (6) { ["_soap_version"]=> int(1) ["sdl"]=> resource(4) of type (Unknown) ["httpsocket"]=> resource(5) of type (stream) ["_use_proxy"]=> int(0) ["httpurl"]=> resource(6) of type (Unknown) ["_cookies"]=> array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } } $agCookie = $agLogin->_cookies print_r: Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) var_dump: array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } $agSession = $agCookie[AGSESSION] print_r: Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) var_dump: array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } $agSession[0] = AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== $agSession[1] = / $agSession[2] = www.agemni.com Connect to Agemni Data Access Service ADBAccess $agDataClient { soap client - agemni Data Connection } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #9 ) var_dump: object(SoapClient)#5 (2) { ["_soap_version"]=> int(1) ["sdl"]=> resource(9) of type (Unknown) } try setting cookies - $agDataClient->_cookies = $agCookie then look at contents of $agDataClient again $agDataClient { soap client - agemni Data Connection } print_r: SoapClient Object ( [_soap_version] => 1 [sdl] => Resource id #9 [_cookies] => Array ( [AGSESSION] => Array ( => AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A== [1] => / [2] => www.agemni.com ) ) ) var_dump: object(SoapClient)#5 (3) { ["_soap_version"]=> int(1) ["sdl"]=> resource(9) of type (Unknown) ["_cookies"]=> array(1) { ["AGSESSION"]=> array(3) { => string(56) "AW1GerFHiTjs7kCPrE++rZE/ATSCqFLaUqeR6HNzzVIEBV3jF2MO6A==" [1]=> string(1) "/" [2]=> string(14) "www.agemni.com" } } } $agDataSet = $agDataClient->getCMSData($agDataParams) print_r($agDataSet) stdClass Object ( [getCMSDataResult] => stdClass Object ( [any] => 12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM ) ) var_dump($agDataSet) object(stdClass)#7 (1) { ["getCMSDataResult"]=> object(stdClass)#8 (1) { ["any"]=> string(296) "12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM" } } $agDataResult = $agDataSet->getCMSDataReult print_r($agDataResult) stdClass Object ( [any] => 12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM ) var_dump($agDataResult) object(stdClass)#8 (1) { ["any"]=> string(296) "12/29/2010 12:01:00 AM12/29/2010 4:00:00 PM" } var_dump($agLogin->__getLastResponse()) NULL var_dump($agDataClient->__getLastResponse()) NULL it should be returning data somewhere in $agDataSet or $agDataResult, but there is no data except what I submitted. I'm not certain I'm setting the cookies right, or what I might be doing wrong here. Again, the documentation for their webservice is he http://wiki.agemni.com/Getting_Started/APIs/Agemni_CMS_Sync Near the bottom is an example of how to access the service using vb.net and at the bottom is an example given in Python. Not sure if they provide any additional insight, I don't do python or VB.Net so they are little help to me. Any help would be greatly appreciated. I have a client and a server solution setup at the moment. We are currently creating an API that will be run on the clients end that will allow their clients to connect to them. On our end, we want to log the number of attempts are API is being used so that we may charge the clients appropriately. My question is this. How is the most efficient way of doing this? Do I call mysql_connect from the client and just shoot the insert log statements across the web. Should I create a php script on our end that looks for post/get input and takes the data and inserts it? What if the client can't connect to our server; should I cache the data and send it off all at once? Should I create a job that every hour shoots up x records API requests happened? Relatively confused at what angle I should be taking when approaching this. I want this to be scalable to a point where we can have thousands of requests an hour, and not horribly slow down apache/mysql running at either end (Specially if the server is talking with several clients). HI Gurus, I need to export (download) a csv file from the web server to my client. How can this be done in php ? How is the save as dialog invoked ? (I am assuming that file save permissions are allowed) I read that if you invoke the following script (eg form submit), it will work .. <? header("Content-type: text/plain"); header("Content-Disposition: attachment; filename=YOUR_FILE.csv"); ?> Any advice ? Steven M |