Jump to content

sylvest

Members
  • Content Count

    101
  • Joined

  • Last visited

Everything posted by sylvest

  1. sylvest

    Why Can't I Paste Text

    If I'm writing a message like this one, and I want to insert some text that is presently in a Notepad file, or on another web site, I select the text, press CTRL/C, put my cursor in the message box and press CTRL/V. Nothing happens. If I click the Paste button, still nothing happens. What is going on? How do I insert such text into a message? Are you telling me that I have to retype everything? Surely the clipboard was invented to eliminate such tedious tasks. Why won't it work for me? It seems to be the paste function rather than the copy that is refusing to work, because I can perfectly well paste the copied text into another Windows document - just not into this forum... I hope you can tell me what I'm doing wrong. Thanks - Rowan
  2. I have a requirement for my PHP pages sometimes to send files (e.g. images, CSS files, JS files, fonts) to the client. The normal way to do this seems to be to use the readfile() function, but I understand that this reads the whole file into memory and then sends it to the client, which will cause problems if it is a very large file. I understand that there is an Apache module mod_xsendfile which does a better job, but Support tell me that this is not available on my shared server. So my question is, what is the best/most efficient way of sending files to the client in PHP, without mod_xsendfile? Do I have to write a loop that reads the file a few K at a time and sends each chunk to the client before reading the next? If so, has anyone got this code already working that they would be happy to share with me, to save a bit of time? Thanks - Rowan
  3. Hi, I have an HTML form with a large number of inputs on it. Most of them are <select> elements each with 6 options. There are currently 1295 of these selects, plus a few other inputs, but the number is not constant, since the form is generated dynamically, and it depends on the number of rows and the number of columns for the currently selected period. In the $_POST array it seems that I am only receiving 1000 values, which means that some of the ones I need I am not receiving. I have tried changing the value of max_input_vars in /home/myaccount/public_html/php.ini from 1000 to 10000, but this does not seem to have improved anything. Do I have to do anything (e.g. restart the server) for it to read this file? Or is this the wrong way of changing this limit? Or do I need to reduce the number of inputs in some way (it's not easy to see a way to do this without a lot of Javascript, which I have been trying to avoid). Thanks - Rowan
  4. sylvest

    Mysql Syntax Being Rejected

    I have the following SQL being executed by a mysqli_query() statement in my PHP code: DROP TEMPORARY TABLE IF EXISTS tmptable; CREATE TEMPORARY TABLE tmptable SELECT * FROM Members WHERE MemberId = '105' AND Status > '0'; UPDATE tmptable SET RecordId = '', Status = '0', ChangedBy = '4', ChangedOn = '2017-05-21 19:03:39'; UPDATE Members SET Status = '0' WHERE MemberId = '105' AND Status > '0'; INSERT INTO Members SELECT * FROM tmptable; It is being rejected with the following error: Errno: 1064 Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TEMPORARY TABLE tmptable SELECT * FROM Members WHERE MemberId = '105' AND' at line 1 at line 952 in file: /home/sylvest/public_html/swchoir/edit_member.php If I put the same SQL into the SQL tab in phpMyAdmin, it works fine. What do I have to do to make this work in my PHP code? Thanks - Rowan
  5. I have a web page which under certain conditions forwards to another one using the statement: header($next_page); where $next_page == "Location: http://www.sylvesterbradley.org/swchoir/index.php?v=1493894983" This causes a 500 error. I am reasonably sure that I have sent no output at all (other than to a log file) before the header statement. In any case, on other occasions where I have done this I seem to get a warning, which in this case is not happening. I see nothing in any error_log files that I am aware of (that is /home/sylvest/error_log and /home/sylvest/pubic_html/swchoir/error_log) nor do I see anything relevant in the cPanel Errors list. What am I doing wrong? How can I debug what is happening? I have a log statement early in the redirected-to file (index.php) and this does not seem to be being triggered, so I don't think it is ever executing this file. Thanks - Rowan
  6. I am trying to use the PHP password hashing module in my code, but the following line: $hasher = new PasswordHash(8, false); is giving me the error: Fatal error: Class 'PasswordHash' not found in /home/myaccount/public_html/directory/edit_member.php on line 124 I am running PHP version 5.6.30. I thought that all versions from 5.5.0 onwards had this module? What do I have to do to enable me to use this? Thanks - Rowan
  7. Is it possible to run a PHP program from a cron job? I am trying to do this, and have set up a cron job to run /home/myaccount/include/do_email.php once per day at 3am. It attempts to do it, but fails as follows: [06-Apr-2017 20:49:33 America/Detroit] PHP Warning: require_once(basic_init.php): failed to open stream: No such file or directory in /home/xxxx/public_html/swchoir/index.php on line 2 [06-Apr-2017 20:49:33 America/Detroit] PHP Fatal error: require_once(): Failed opening required 'basic_init.php' (include_path='.:/opt/cpanel/ea-php56/root/usr/share/pear') in /home/xxxx/public_html/swchoir/index.php on line 2 My first question is, why is it trying to run index.php, which is my default page, but is not involved in do-email.php at all, as far as I can see. The second question is why is the include path set to '.:/opt/cpanel/ea-php56/root/usr/share/pear'? I have the following in my php.ini file: include_path = ".:/home/myaccount/include:/usr/lib/php:/usr/local/lib/php" Which works fine when running the PHP files as part of web pages, but it seems that this is not working in a cron job. I hope you can help me put my finger on why this is not working. Thank you - Rowan
  8. sylvest

    Running Php File From Cron Job

    Here's an error reported from last night's attempt to run my PHP file in a cron job: Failed loading /opt/cpanel/ea-php54/root/usr/lib64/php/modules/ioncube_loader_lin_5.4.so: /opt/cpanel/ea-php54/root/usr/lib64/php/modules/ioncube_loader_lin_5.4.so: undefined symbol: execute Zend Guard Loader requires Zend Engine API version 220100525. The Zend Engine API version 220131226 which is installed, is newer. Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Guard Loader. Set-Cookie: PHPSESSID=p4nu293cl2kikl2tb7t7ooo4j6; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0 Pragma: no-cache Content-type: text/html; charset=UTF-8 <br /> <b>Fatal error</b>: Class 'PasswordHash' not found in <b>/home/myaccount/include/do_email.php</b> on line <b>153</b><br /> Questions arising: Why am I getting the undefined symbol: execute error? This seems to be something to do with loading PHP, before it has ever tried to access my script. Why is the session cookie that it is sending set to Expires: Thu, 19 Nov 1981? Why has it failed to find PasswordHash? This file runs correctly when called as part of my website, so I think the problems must be to do with diffferences between the environment when run as a web page and when run as a cron job. Thanks - Rowan
  9. sylvest

    Why Can't I Paste Text

    Well, it sort of helps. Thanks for providing this link. But I think my most straightforward answer is to remember to use Firefox or Chrome if I want to access the TCH forum. Of course I will usually forget this until I find that I can't paste :-(. Thanks - Rowan
  10. sylvest

    Getting Mod_Rewrite To Work

    I am trying to come up with a way of redirecting all requests for files in the directory http://mydomain/swchoir/<filename> to the file with the same name (and the same GET parameters if present) in the directory /home/myaccount/build00001/public_html/swchoir/<filename>. My end objective is to allow the server to contain several different builds and for people who have the necesary permissions to be able to choose which one they want to look at, so for example I could have one build that is on public release, another that is in QA, and a third which is in development. Ordinary users would only be able to see the public release one. QA people would be able to see either the public release or the QA build. And developers would be able to see all of them. As a step towards this, I am trying to develop some rewrite rules that will send _all_ users to build00001. The lines I have added to the .htaccess file in /home/sylvest/public_html are: SetEnvIfExpr True build_num=00001 Rewrite Rule ^swchoir/([0-9a-z/\.?&_=-]+)$ /home/myaccount/buildbuild_num/public_html/swchoir/$1 [NC, L] php_value include_path ".:/home/myaccount/buildbuild_num/include" Now when I try to access a page I get an internal server error. Please can you suggest what is wrong with my rule, or how to best get this to do what I want? In particular I'm not sure how to use the Environmental Variable build_num that I have tried to define. I'm not sure whether "SetEnvIfExpr True" is valid, and I'm not sure whether "sylvest/buildbuild_num/public_html" is a valid way of using the variable. Seems unlikely, but I'm not sure whether it needs some kind of quotes to indicate that it is a variable name, and if so, what kind. If you know a better way of doing the whole job, please tell me that too. It seems odd to me that something like this doesn't already exist somewhere, since it surely must be a commmon need. Thanks - Rowan
  11. sylvest

    Getting Mod_Rewrite To Work

    Bruce, Thanks for your reply. Why is it that I can't do an internal rewrite to a location above public_html? Here is an exerpt from http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule The Substitution of a rewrite rule is the string that replaces the original URL-path that was matched by Pattern. The Substitution may be a: file-system path Designates the location on the file-system of the resource to be delivered to the client. Substitutions are only treated as a file-system path when the rule is configured in server (virtualhost) context and the first component of the path in the substitution is exists in the file-system So I guess this is saying that what I'm trying to do won't work in an .htaccess file. But is there a way that I can make it work in my Virtual Host config file? Surely there cabn;t be any fundamental reason why I can;t redirect to a file system diretory above public_html? I can after all include any of these files, which is pretty close to the same thing? Thanks - Rowan
  12. sylvest

    Getting Mod_Rewrite To Work

    I have found many discussions on the web around this topic. Some say that a rewrite rule assumes that the redirect path is a file system path if the first element of the path (/home in this case) exists at the root of the file system (which it obviously does in this case). Otherwise it assumes that it is relative to the Document Root. Other people imply that redirect to a file system path is not permitted for .htaccess files for security reasons, but that you can use an Alias as a work around. Is it in fact possible to write a RewriteRule that will work in an .htaccess file on a TCH server to redirect to a file system path? How exactly do I do this? If not, is it possible to use an Alias (which would presumably point to a file system path from a web URL)? If so, how do I do this? You may ask - why do I want to do this? The answer is that I prefer to keep all the files that I include or redirect to in non web accessible places, to minimise the chance that someone can deduce or guess the names of these files, and then download them, and see the inner workings of my web site, security system etc,. thus compromising my security. I find it difficult to believe given all the things that mod_rewrite can do, that it can't do this... Thanks - Rowan
  13. sylvest

    Running Php File From Cron Job

    Thank you. I think you can close this ticket now. If I can't get the cron job to work properly after sorting out the INI file I will raise another one. Thanks - Rowan
  14. sylvest

    Running Php File From Cron Job

    Balakrishnan, Thanks for your help with this. Just out of interest, where is "the crontab entry"? Where can I see this, just so I understand what you have done? I will look at simplifying the php.ini file as you suggest, although I may need to ask which entries are necessary and which are not. Thanks again for your help. The excellent support that the TCH team provides is one of the main reasons I stick with you. Rowan
  15. Hi, The web pages that I am currently writing (in PHP) report errors including a timestamp to the file /home/xxxxxxx/logs/main.log. The times reported are UTC. I have the following in my PHP: date_default_timezone_set("Europe/London"); which I believe should set it to use the stated timezone throughout my site, which should (I think) recognise DST, so should now report UTC +01:00. It is not doing so. I thave changed the PHP code that writes to the log file to this: $logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " .... and it is now outputting: [06-Apr-2017 16:19:50 UTC 0 +00:00 GMT] on localhost L_TRACE at line 96 .... from which you can see that it thinks it is outputting UTC. I think the problem is that it is just not switching to the timezone I have requested. Please can you suggest why it is not outputting GMT/DST, i.e. UTC +01:00, or what I need to do to find out what is causing this problem? Thank you - Rowan
  16. Bryan, Thanks for your help with this. Now the system error log is reporting the correct time in GMT with DST, but the PHP log is still reporting GMT without DST. I have removed all the calls to date_default_timezone_set() in my PHP files but it is still the same. To generate the PHP log my code is: $logmsg = gmdate("[d-M-Y H:i:s e I P T] ") . "on " . $hostname . " " . $loglevels[$level] . " " . $msg . " at line " . $line . " in file " . $file . PHP_EOL; The text produced in the log file is (example): [10-Apr-2017 11:47:18 UTC 0 +00:00 GMT] on localhost L_TRACE Redirecting to Location: http://www.sylvesterbradley.org/swchoir/welcome.php using header at line 302 in file /home/xxx/include/initialise.php Any idea why it is doing this, or what I can do to correct it? Please can you explain how the date.timezone = in the PHP.ini file interacts with the date_default_timezone_set() in a PHP file. Does one override the other? Which takes precedence? Or if I use one, does using the other cause an error? Which way round? Ideally I would like the PHP file to determine which timezone it uses, if necesary overriding what is written in the PHP.ini file, since one section of the web site may require a different timezone than another. Or I may want to reflect the timezone of the particular user that has logged on. Thanks - Rowan
  17. sylvest

    Running Php File From Cron Job

    It tried to run the job last night. I noticed the following from my log: [10-Apr-2017 02:07:32 UTC 0 +00:00 GMT] on L_TRACE REQUEST_URI = / at line 82 in file /home/xxx/include/basic_init.php [10-Apr-2017 02:07:32 UTC 0 +00:00 GMT] on L_TRACE SERVER_NAME = xxx.yyy.org at line 83 in file /home/sylvest/include/basic_init.php Where are these values coming from when the file is run in a cron job? The subdomain xxx.yyy.org does exist, from some work I did in the past, but I'm not using it currently. So how has it deduced that this is the Server? These values are returned correctly when I am running as a result of an HTTP request. Is there some way I can detect, in the script, that it is running in a Cron job, and in that case ignore these values? Thanks - Rowan
  18. sylvest

    Why Can't I Paste Text

    Bruce, Thanks for your reply, but it doesn't solve the problem. I have just tried again to copy something from the previous message and paste it, and it does nothing. But then I had a thought - maybe this is a browser problem. So I fired up Firefox, and lo and behold, it works, So there is something about IE11 (or the way I've got it configured) that is stopping "paste" working. Thank you Microsoft. Can anyone suggest what the problem might be, or how to get around it? Meanwhile I will try to remember to use Firefox when I am connecting to the TCH forum in future... Thanks - Rowan
  19. Does anyone know how to access the session variables of a different session, in PHP?. The reason I need to do this is that I am accessing most pages on my website via a domain name, such as http://www.****/login.php. However, the form on the login.php page where the username and password are entered uses https://hostname.tchmachines.com/~username/do_loginphp as its Action page because I must use SSL for this to ensure that my usernames and passwords are not sent over the net in open text. This means that do_login.php is running in a different session from login.php, so I can't use the $_SESSION array to pass values from one to the other. If I pass the PHPSESSIONID of the original unencrypted session to the do_login.php page via a GET or POST variable, what I am trying to find out is, how would I then read and write values from/to the original $SESSION array? Thank you - Rowan
  20. Whatr I'm trying is: in the login page http://www.****/login.php. Do session_start(). Write some values into $_SESSION. add to the login form a hidden control with name='sessionid' and value='<?=session(id)?> In the form handler (https://hostname.tch...ame/do_login.php) Do session_start(). Read the value of session_id(), which is 4579fnvb049q7u5h8dmveqdm92 Check the value of $_SESSION which is an empty array. Check the value of $_POST['sessionid'] which is thp24j106dp9ffdif406l37vg3 Now do: // This should restore the old session. $fname = session_save_path() . "/sess_" . $_POST['sessionid']; session_decode(file_get_contents($fname))) // This should set some new session variables $_SESSION['uehdj'] = 'iwenfio'; $_SESSION['oqyhekj'] = 'owhusnxdi'; Check the value of $_SESSION, which is $_SESSION = Array ( [uehdj] => iwenfio [oqyhekj] => owhusnxdi ) I.e. the old session variables have not been recovered. 6. Now do: // Ths is supposed to write the session data back to the old session file. $session_string = session_encode(); $bytes = file_put_contents($session_string); // This is supposed to return to a http://www.****/ page header('Location: http://www.nydomain,.com/welcome.php'); exit(); 7. Use $_SESSION, which is supposed to contain any values that it had at the beginning of this who process, plus the two I added in do_login.php My main question is: Why are there no sess_ files in the directory /home/myaccount/tmp that match either 4579fnvb049q7u5h8dmveqdm92 or thp24j106dp9ffdif406l37vg3. The only file there is sess_ea6d51dbplto9ukucbk9fvkep86kt5f7 which doesn't mathch any session I know about. I hope someone understands how all this stuff works and can explain to me how to get it working. Thanks - Rowan
  21. I'm getting an error where my web page fails to do an fopen() function with the error message "too many open files". I suspect that the problem is that I am not closing some files that I should be, or that my program is getting stuck in a loop, opening files ad infinitum. But to debug this I would like to see a list of all the open files, so I can work out where they are being opened and where they ought to be closed. I understand that the shell command lsof is supposed to do this. I'm trying to call lsof, and am getting a "command not found" error. This is the code I'm using to call lsof: $output = shell_exec("lsof 2>&1"); print_r($output); This is giving me the "command not found" error. I have tried using exec too, but couldn't work out how to capture the output. 1. What is the best way of finding out where files are being opened, and where they are not being closed, or getting a list of all the currently open files? 2. Should lsof exist on Total Choice Hosting servers? 3. If so, how do I call it successfully, and capture the output generated? 4. If not, how do I find out what all the open files are? Thanks - Rowan
  22. sylvest

    Debugging "too Many Open Files" Error

    Dick, Thanks for your reply. I think I have spotted the problem now. As Bruce suggested, I think the function that opens files was trying to call itself (indirectly) open a log file when it detected an error, resulting in an infinite recursive loop with no end condition. I am trying to come up with a design that doesn't suffer from this problem now. Thanks again. As before, I have found TCH support excellent - second to none, in my opinion. Thanks - Rowan
  23. sylvest

    Debugging "too Many Open Files" Error

    In my PHP script I'm tgrying to open a log file. I am getting the error "too many open file handles". I need to know which files are open to detect why I am getting too many. I guess that files are not being closed properly or I'm stuck in a loop. I tried to use $output = shell_exec('lsof 2>&1'); echo "<pre>$output</pre>"; and I'm now getting a very large number of "sh: lsof: command not found" messages. Does the command lsof exist on TCH hosts? Is this the right way to call it? What is the best way to find out what files are being opened, to debug this type of error? Thanks - Rowan
  24. I submitted a ticket, but the help desk said that some of my questions were outside of their scope. The remaining questions are: 1. Can I use a shared secure URL to access a subdomain on my site, i.e. the web pages I'm developing are in swchoir.sylvesterbradley.org, the files that this subdomain refers to are in /home/sylvest/swchoir (i.e. not within public_html). 2. I have a login page on my website called index.php. Presumably I don't need to encrypt this since it contains no confidential information. I need to encrypt the response to this, which is a URL like swchoir.sylvesterbradley.org/do_login.php. Can I get this encrypted by simply setting my form action property to "https://swchoir.sylv.../do_login.php". 3. Do I have to do anything else to enable the encryption, or does the use of the https protocol enable all the necessary encryption on the client and decryption on the server? 4. How do I prevent people from accessing this page by using the URL http://swchoir.sylve...rg/do_login.php? 5. Does it matter whether I use method GET or POST for the login form? Thanks for your help. Rowan Using_Https.rtf
  25. Thomas - thank you Rowan
×