Jump to content

enveetee

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by enveetee

  1. I have several scripts which contain the exact same function name and accept the same number of arguments example script1.php <?php function DoThis($arg1){ . . } ?> script2.php <?php function DoThis($arg1){ . . } ?> script3.php <?php function DoThis($arg1){ . . } ?> What syntax should I use (if indeed i can) to call each one. Is it something to do with NAMESPACE? Thanks
  2. Now, you say that you know where the files went and that you store that location to retrieve it later. What's stopping you from retrieving it now? ...because the url is different for each server Sometimes the app is in the root, sometimes in a sub folder
  3. I know where I created / copied the files to, and I store that location so I can retrieve it later; for example /thismonth /lastmonth /soontobedeleted I need to get a url to a known file in either of those folders
  4. Hi My app sends out emails. Included in the email is a link to a PDF document which can be downloaded and views. The document(s) reside in different folders on the server, only known at creation time. My app can run from the root as well as a folder How can I get the url to the file for inclusion in the email. examples are http://www.myserver.com/docs/document1.pdf http://www.myserver.com/document2.pdf http://www.myserver.com/docs/anotherfolder/document1.pdf Thanks
  5. Mac_gyver - thanks, very enlightening. The solution seems to be to keep sensitive files (MySQL credentials and raw uploaded files) in a folder which the server cannot access so now the question becomes: How do I access files outside of the server web root? public_html/ /phpfiles /includes /docs /script /other /sensitivefiles <<<<< (my php scripts need access to the contents of this folder but a browser cannot gain access) Cheers
  6. OK, so my application is now in the Beta phase and I am rolling it out to some tame customers. I am using justhost.com for hosting using a standard Business Pro package Each one of my PHP scripts has an required_once to a PHP include which contains the MySQL login name and password details. Obviously if anyone gains access to this the game is over. Where is the best place to keep this file (I have it in ../includes) How do I stop anyone from seeing the contents Thanks
  7. Apologies everyone, brain fade here. I had echo statements inside include files which was wrecking the php output Sorry to waste everyone's time
  8. I have a client application which runs a script on my server using HTTP POST How can I get a clean result of that script Currently, the script returns all sorts of headers, fonts and so on All I need is the name of the currently executing script (__file__?) and a result 1 or 0 plus any error message Suggestions please..
  9. Looking for some guidance on this... I have two applications, A windows desktop application written in VB6/VB.NET and my new (and learning) PHP/MYSQL app. I am mirroring records between them. Records can be added to both systems and I synchronise them. I am currently dealing with downloading the PHP/MYSQL records to my desktop and was wondering if I was going about it in the right way. This is how I have designed it... I have a common form which deals with three actions (POLL, DOWNLOAD and CONFIRM) using POST. I can return the number of records to be downloaded (using the POLL) paramater, the actual record (using a DOWNLOAD parameter along with a record ID) and finally a CONFIRM parameter to mark the MYSQL record as having been downloaded and is in the desktop database. I am ECHO'ing out values from the PHP form which is being received by the desktop component. This does work, but was wondering if the way I was doing it is ok - it seems too simple which scares me! Comments/advice/bullet-between-the-eyes - please here's the code if you are interested... <?php require_once('../includes/cs_functions.php'); require_once('../includes/cs_password.php'); require_once('../includes/meekrodb.2.3.class.php'); require_once('../classes/cUser.php'); FN_MeekroDBSetup(); //Call as POLL first to return id's of records needed to be downloaded TAB separated //Whitelist the POST values into WhiteListParameter array $WLP = allowed_post_params(['cs_name', 'cs_password', 'cs_mode', 'cs_id', 'cs_serialno', 'cs_downloadtime']); //Declare the user class for user name and password validation later $cUser = new clsUser; //These are debug settings so form can be executed in Netbeans $WLP['cs_name'] = 'Admin'; $WLP['cs_password'] = 'a'; $WLP['cs_mode'] = 'POLL'; $WLP['cs_mode'] = 'DOWNLOAD'; $WLP['cs_mode'] = 'CONFIRM'; //Validate user, returns NULL if user not valid $cUser = FN_Validate_User($WLP['cs_name'], $WLP['cs_password'], TRUE); if ($cUser == NULL) { } else { //Detect mode POLL, CONFIRM, DOWNLOAD switch ($WLP['cs_mode']) { case "POLL": //Check if any records to be downloaded and return a TAB delimited list of record ID's $resultsArray = db::query("SELECT * FROM bk WHERE bkwebbooking=%s AND bkwebbooking_downloadedtime=%s", '1', NULL); $tmp = ''; foreach ($resultsArray as $row) { $tmp = $tmp . $row['id'] . chr(9); } //Loose trailing TAB $tmp = FN_Shorten($tmp, 1); break; case "DOWNLOAD": //Return the record for import into desktop system $resultsArray = db::query("SELECT * FROM bk WHERE id=%s", $WLP['cs_id'], NULL); $tmp = ''; foreach ($resultsArray as $row) { $tmp = $tmp . $row['id'] . chr(9) . $row['bkaccount'] . $row['bkservice']; } break; case "CONFIRM": //Update MYSQL record with time and serial number from desktop system $cs_serialno, $cs_downloadtime default: $tmp = 'Call with POLL or DOWNLOAD or CONFIRM'; break; } echo $tmp; }
  10. @CroNix not sure I understand your answer... I don't have a 'php user' Its just a website with php scripts. The scripts can be executed by any browser
  11. I am trying to upload a large dataset in CSV format for batch loading into a MYSQL table using LOAD DATA INFILE The CSV file (test.csv) is in /var/services/web/php My table is in /var/services/mysql/TABLENAME When I run the SQL command from a PHP script I get an error ERROR: Can't get stat of '/var/services/mysql/TABLENAME/test.csv' (Errcode: 2) Which I believe is because the file needs to be in /var/services/mysql/TABLENAME. Indeed, if I move it there, it works fine If I try and use the LOCAL switch LOAD DATA LOCAL INFILE I get an error stating that feature is not available. Research shows it can cause a security hole and needs to be enabled separately, something I am not prepared to do I cant copy the file in my PHP script to /var/services/mysql/TABLENAME as it is outside or /var/services/web So short of manually copying the FTP'd file to my table directory, how could I copy it from my PHP script? This also leads to my second question 'how do I access files outside my web root' Thanks
  12. I am trying to upload a large dataset in CSV format for batch loading into a MYSQL table using LOAD DATA INFILE The CSV file (test.csv) is in /var/services/web/php My table is in /var/services/mysql/TABLENAME When I run the SQL command from a PHP script I get an error ERROR: Can't get stat of '/var/services/mysql/TABLENAME/test.csv' (Errcode: 2) Which I believe is because the file needs to be in /var/services/mysql/TABLENAME. Indeed, if I move it there, it works fine If I try and use the LOCAL switch LOAD DATA LOCAL INFILE I get an error stating that feature is not available. Research shows it can cause a security hole and needs to be enabled separately, something I am not prepared to do I cant copy the file in my PHP script to /var/services/mysql/TABLENAME as it is outside or /var/services/web So short of manually copying the FTP'd file to my table directory, how could I copy it from my PHP script? This also leads to 'how do I access files outside my web root' Thanks My scripts is in /var/services/web/php , this directory is not accessable from my PHP script. I can FTP the CSV file to the server but I cannot copy the file to my table's directory and I cannot assess the FTP folder from within the LOAD DATA INFILE
  13. Hi Not sure if anyone can help me here - probably better off asking on a VB forum. I have a desktop database application written in Visual Basic 6. As records are added to the local VB6 database, copies are POSTed to my PHP application. Users can add records to the PHP application on-line, and these record(s) a transferred down to the desktop system for inclusion into the VB6 database - all works fine (100 way to skin a cat I suppose). I was wondering, what the best way of polling the server to see if there are any records waiting to be downloaded? I am currently using an HTTP POST and checking the response Thanks...
  14. Hi I have a desktop system which uses plain text files for its storage and I need to do a one off import of these files (tables) into a SQL table The largest table as just under 2 million records each of 850 bytes in length I have written a PHP script and used set_time_limit to zero. The server ran for about 8 hours but did not import the entire table Maybe I should be uploading a CSV? What is the best way to go about this - best practice/suggestions please
  15. Hi As my application grows, I am becoming more and more concerned about my configuration and .INC files which are contained within sub directories of my web root folder. I am lead to understand that it is good practice to move sensitive files (those containing passwords and mysql logon credentials) outside of the general www folder How do I access those files in PHP with, say an include or required statement I am currently using include'../configuration/config.php' how do I access files above ../ Thanks
  16. Thanks mac_gyver No, nothing specific, just a style question really, wanted to know what other people were doing. In the .NET world, I use a DO/LOOP and broke out of it as soon as a test failed - force of habit really Just curious
  17. Do you want someone to give you the exact code or do you want some sort of overview Are you using a database (MySQL) or something
  18. Hi As I get deeper into PHP I am always coming across a situation where I have multiple condition testing. I end up coding thus: If (condition){ } else { } This can get very messy when you get 4 or 5+ conditions to test for. In other languages, I have used loops and then use break out of the loop if a condition fails: WHILE(TRUE) if (!condition) { break; } break; } Can anyone comment or make a better suggestion pls Thanks
  19. @kicken - thanks Yes, I get this but it is not working. Is there a way of testing flock()
  20. Hi I can't get flock() to work, it seems to be such a simple function but I am stumped. What I think I know... 1. There is a blocking and advisory mode (blocking, waits for a lock whereas advisory lets you know if a lock was succesfully applied) 2. Some UNIX systems do not support blocking 3 Open the file with fopen (+r), apply flock() and if the lock is successful, write to the file. I have my script $bse = fopen($filename, "r+"); //Open for reading and writing; place the file pointer at the beginning of the file. File must exist if (!flock($bse, LOCK_EX)) { echo "Waiting for lock on ".$filename; } I am using this method to open a file, get a serial number, increment the serial number, write it back to the file then add the serial number to a MySQL table with UNIQUE set on the serial number field. I to this to test if the serial number has been added before and thus test the file locking. It does not work, I get duplicate serial numbers trying to be added. Anyone got any pointers as to what I may be doing wrong
  21. Cheers everyone, came across the include after my post. Thanks
  22. Hi I have a self calling script which does the following: Stage 1: First run, it detects that $_POST is empty, and so displays a chunk of html which prompts for a password. Stage 2: When resubmitted, it detects $_POST and displays another chunk of html which prompts the user for some values Stage 3; When resubmitted the second time, $_POST is detected, along with the user values and some php is executed and a menu displayed. So, question is this, what is the best method to output the html at stage 1 and stage 2? I have tried using echo statements and wrapping each chunk in a function = messy. I have tried using HEREDOCS (<<<VARNAME), better but ties my HTML to my script which is a pain I am thinking to use file_get_contents("../html/chunk1.htm") this seems quite elegant and allows me to get someone else on our team to design the HTML keeping it out of my script Thoughts and suggestions? Thanks as ever p.s. who pays for this site, are donation accepted?
  23. I have had a customer want to run my application (PHP/APACHE/MYSQL) on their server rather than a commercial hosting offering (JUSTHOST/GODADDY) I am reluctant, as it means giving them access to my PHP code which could possibly be copied or distributed. Can I protect against this?
  24. Thanks for the replies folks, I can't thank you individually (some sort of limit!)
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.