Re: [PHP] Re: System specific information gathering
On 7/23/05, Vidyut Luther [EMAIL PROTECTED] wrote: Ok, If I use the file_get_contents.. how do I actually parse the contents on /proc/uptime cat /proc/uptime 1400293.13 1317047.64 The first number is the total uptime in seconds, the second number is the total idle time. -- ramil http://ramil.sagum.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] inserting html within a mail body
On Tue, 7 Dec 2004 02:31:10 -, Ross Hulford [EMAIL PROTECTED] wrote: Hi, I am using the mail() function in php andI am looking for a quick and easy way to make the mail_body of an auto response email with HTML tags in it so I can add some style to it. Hi! The PHPs manual page on the mail function shows an example of sending HTML mail. http://www.php.net/manual/en/function.mail.php I've also attached it below: snip ?php /* recipients */ $to = [EMAIL PROTECTED] . , ; // note the comma $to .= [EMAIL PROTECTED]; /* subject */ $subject = Birthday Reminders for August; /* message */ $message = ' html head titleBirthday Reminders for August/title /head body pHere are the birthdays upcoming in August!/p table tr thPerson/ththDay/ththMonth/ththYear/th /tr tr tdJoe/tdtd3rd/tdtdAugust/tdtd1970/td /tr tr tdSally/tdtd17th/tdtdAugust/tdtd1973/td /tr /table /body /html '; /* To send HTML mail, you can set the Content-type header. */ $headers = MIME-Version: 1.0\r\n; $headers .= Content-type: text/html; charset=iso-8859-1\r\n; /* additional headers */ $headers .= To: Mary [EMAIL PROTECTED], Kelly [EMAIL PROTECTED]\r\n; $headers .= From: Birthday Reminder [EMAIL PROTECTED]\r\n; $headers .= Cc: [EMAIL PROTECTED]; $headers .= Bcc: [EMAIL PROTECTED]; /* and now mail it */ mail($to, $subject, $message, $headers); ? /snip HTH -- ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sequrity without HTTPS?
On Thu, 18 Nov 2004 12:41:01 +0100, Peter Lauri [EMAIL PROTECTED] wrote: Best groupmember, My webhost (crappy but nonexpensive) does not support HTTPS and I still want to be able to create some sort of secure login. Someone with some tips and tricks to get a secure system without using HTTPS? Not really that secure, but you could do this 1. When the login page is requested, the generate a random string from the server. Let's call this string STR. 2. On the browser, after the user enters his login name and password, DONT send this per se. Instead, do some operation on the password and STR and return this instead. (like concatenate STR and password, then do SHA1 hash it.) 3. Server performs the same operation with STR and the password in the database, and compares this with the value submitted from the client. So, in no time is the password itself sent. I'm sure there are SHA1 or at least MD5 functions already written in javascript. I know there is a term to this method, but it escapes me. HTH! ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sorting...
On Wed, 17 Nov 2004 09:03:12 -0500 (EST), Russell P Jones [EMAIL PROTECTED] wrote: I have an array filled with CSV data... array ( 20040310, Title, Author 20041115, Title, Author 20040513, Title, Author ) where each array element is 1 line from the csv. When I go to print it out, Im going to explode each by , and then print it out the way I like. BUT, I want to sort them all by those first 8 digits, which happen to be the date. Any way to sort an array by the first x characters in its string? How about a non php solution? Maybe sort the lines in the CSV file first using a sort command line utility (like sort in *nix), sample to a temp file, then open that file in PHP ramil http://ramil.sagum.net -- ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Why cookie is created?
On Tue, 9 Nov 2004 11:43:19 +, Jerry Swanson [EMAIL PROTECTED] wrote: So As I understand. Session also store ID on the harddrive. I don't see the big difference between session and cookies from privacy point of view. Instead of Session also store ID on the harddrive a more correct wat to put is is Sessions store ONLY an ID on the [user's] harddrive. All other information you store in the session is placed in the webserver. The user has no direct access to it. This is how it differs from using just cookies (where all of the info is stored in the user's harddisk) -- ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] enterprise php application automated testing
On Sat, 23 Oct 2004 20:00:48 -0400, blackwater dev [EMAIL PROTECTED] wrote: Hello all, I know I can use simpletest to test my application at the class level but I need a tool to test it at a much higher level. I need something to enter data in forms, click links, etc. I have played some with simpletest's web tester without much luck. I am just curious how others are effectively testing their large php enterprise applications? Years ago I wrote Visual test scripts and it had a feature where I could record all my keystrokes as I entered, clicked, etc...I guess I am curious if there is anything like that..open source? Does exactly what you want + load testing http://jakarta.apache.org/jmeter/index.html - ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thanks but problem Again! (MySQL PHP database script PLEASE)
On Fri, 22 Oct 2004 16:13:07 +0900, Sugimoto [EMAIL PROTECTED] wrote: Thank you for two of you. dou itashimashite. This is your problem: Bad query: You have an error in your SQL syntax near 'and Tit like and Aut like and Auty like ' at line 4 The SQL query you formed may have an invalid syntax. Dakara, $result does not contain a valid MySQL resource. Mochiron, next operations with $result will produce errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result What you can do is to debug first your SQL statement: $sql = select * from gen_table where GO like . $_GET[go]. and ym like . $_GET[dt] . and Tit like .$_GET[ti]. . and Aut like .$_GET[au]. and Auty like .$_GET[ay]; print_r($sql); //show the SQL statement, (remove this when everything is working) $result = mysql_query($sql); print_r to var_dump ha php de debug no ni yaku ni tachimasu! ramil http://ramil.sagum.net -- ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Thanks but problem Again! (MySQL PHP database script PLEASE)
sorry, M. Sokolewicz, everyone, reposting in english :) (previous post had some japanese text.) Arigato thank you. It was my pleasure. This is your problem: Bad query: You have an error in your SQL syntax near 'and Tit like and Aut like and Auty like ' at line 4 The SQL query you formed may have an invalid syntax. Because of this, $result does not contain a valid resource. Of course, subsequent operations using $result will produce errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result... Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result What you can do is to debug first your SQL statement: $sql = select * from gen_table where GO like . $_GET[go]. and ym like . $_GET[dt] . and Tit like .$_GET[ti]. . and Aut like .$_GET[au]. and Auty like .$_GET[ay]; //print_r() and var_dump() functions are very helpful in debugging in PHP! print_r($sql); //show the SQL statement, (remove this when everything is working) $result = mysql_query($sql); //add this code to check for $result's validity if($result) { // do some error handling here } As the manual says, mysql_query returns a false when the statement is invalid. Take a loot at http://www.php.net/mysql_query , http://www.php.net/mysql_error , and http://www.php.net/mysql_errno for more details on error handling. --- ramil http://ramil.sagum.net/blog -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] MySQL PHP database script PLEASE
td? echo $row[end]; ?/td tdA HREF=/momatlib/gendai/pdf/? echo $row[GO]; ?.pdfpdf/A/td /tr replace the above block with td? echo $row[end]; ?/td td ?php if($row[GO] = 1000) { ? A HREF=/momatlib/gendai/pdf/? echo $row[GO]; ?.pdfpdf/A ?php }? /td /tr ganbatte! ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] New Line Character while downloading a file!
On Fri, 24 Sep 2004 16:15:19 +0530, Divick Kishore [EMAIL PROTECTED] wrote: Another problem is that when the file is downloaded a new line character is added to the top of it unncessarily due to which it can't be opened with any image viewer. Once I reomove that newline character, it works fine. Maybe that's the key to the problem. You may have a blank line somewhere. Something like: !--- start of PHP file -- ?php code... ? The blank line before the ?php tag gets sent out before your headers are sent. Does the code have this? HTH ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] supplied argument is not a valid
On Sat, 25 Sep 2004 01:01:13 -0400, John Taylor-Johnston [EMAIL PROTECTED] wrote: Hi, Hi, the error on the line line 101 while ($mydata2 = mysql_fetch_object($news2)) says that $news2 is null. The line $news2 = mysql_query($sql2); //desc = z-a probably didn't work. How about trying; $news2 = mysql_query($sql2); //desc = z-a print_r($news2); first and see it $news2 is indeed a valid resource. ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How does work shorten url services?
On Sat, 18 Sep 2004 10:49:34 +0200 (CEST), Henri Marc [EMAIL PROTECTED] wrote: Hello, The principle is that you enter your long url in their form and it gives you a shorten url like tinyurl.com/h4599 I was wondering how it works. I think it must use PHP. It would use a feature of an HTTP server such as Apache -- URL rewriting Basically, you can make rules such that urls like http://tinyurl.com/h4599 become http://tinyurl.com/index.php?id=h4599 you would then handle it from there. But this is off topic :) ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
On Fri, 27 Aug 2004 23:17:29 -0700, Sam Hobbs [EMAIL PROTECTED] wrote: Is it possible to use the DOM to add (HTML) elements to a page at the time the page is being shown? The HTML and VBScript shown below is a simplified version of what I need to do but of course I need to do it in PHP. Since PHP is server-side (right?) perhaps it is not possible. --- Yes, it is possible. And you are right, PHP is a server side language. In addition to PHP, use a client-side scripting language (like JavaScript). JavaScript also has functions for accessing the DOM (createElement and getElementByID). HTH ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic HTML Creation
On Sat, 28 Aug 2004 12:30:48 -0700, Sam Hobbs [EMAIL PROTECTED] wrote: This is for osCommerce, which is a shopping cart system written in PHP. Many of it's pages (the HTML) are not modifiable directly using a WYSIWYG editor, which make the content difficult to modify, especially for non-technical people. So what I can do is to make a page that is stored as a HTML page and then in a separate PHP script add stuff (in this situation, it is left and/or right menu columns) using the DOM. Since the system is written using PHP, this improvement should also use PHP. I think PHP will do quite well using it in this manner yet the system (osCommerce) can be easier to use. Ah. You should have said this in your first mail (which was confusing). It now becomes clear. I think what you are looking for is a template engine, like smarty http://smarty.php.net/ given a template : - body User Information:p Name: {$name}br Address: {$address}br /body - and the php code: $smarty = new Smarty; $smarty-assign('name', 'george smith'); $smarty-assign('address', '45th Harris'); $smarty-display('index.tpl'); I think you can already see what this does. The non-technical people can edit the pages (as long as they leave the placemarkers for the output). The PHP-people can edit the code without worrying about the page layout (as long as the markers are there). I hope this helps. (code was taken from http://smarty.php.net/crashcourse.php) ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] changed number_format function
On Fri, 27 Aug 2004 14:06:56 +0530, Ma SivaKumar [EMAIL PROTECTED] wrote: The latest on-line version is changed as below ?php $number = 1234.56; // english notation (default) $english_format_number = number_format($number); // 1,234 What is the best way to format numbers to put only the thousand separator without removing or adding decimal places to the number. For example, 1000 should return 1,000 1000.5 should return 1,000.5 1000.25 should return 1,000.25 so on. Ma SivaKumar Thus says http://www.php.net/number_format string number_format ( float number [, int decimals]) string number_format ( float number, int decimals, string dec_point, string thousands_sep) . . . If two parameters are given, number will be formatted with decimals decimals with a dot (.) in front, and a comma (,) between every group of thousands. ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse_ini_file problem
On Fri, 27 Aug 2004 12:54:14 +0300, Vladimir [EMAIL PROTECTED] wrote: Hello folks! I have an ini file that looks like this: index.rent=Rent index.faq=FAQ index.contact=Contact index.links=Links then I want to read this file: $english_messages = parse_ini_file('conf/english.ini'); print_r($english_messages); What I see is: Array ( [index.rent] = Rent ) And that's all. Shouldn't parse_ini_file return all the messages I have in ini file but not only the first one? I'm using 4.3.8 on windows XP. TIA. Vladimir I can't seem to replicate your problem (and I copied the code from your email). No warnings? DId you check the log for messages? ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expression help
On Tue, 24 Aug 2004 23:53:53 -0700, Daniel Lahey [EMAIL PROTECTED] wrote: I'm trying to figure out how to formulate a regular expression that will get me everything following a pound sign (#) up to the first space or { character. (I'm trying to parse the ids out of a style sheet.) Can anyone point me in the right direction? I've been searching on the web for hours and reading everything I can find on regular expressions, but I just can't wrap my brain around it. Thanks. Try this snippet pre ?php $css = fopen(http://www.csszengarden.com//001/001.css;, r); $data = fread($css, 3); preg_match_all(/#.+({ )/, $data, $out); print_r($out); ? /pre It gets the default css from the zengarden site. (30k is a large buffer, but this is not a howto on buffered reads) The regular expression /#.+({ )/ means, piece by piece # the # character . dot is a special character in regular expressions. it can match any character + is also a special character, it means match 1 or more times so .+ means match any character 1 or more times ( ) are special characters, they match any single character inside them. in the case of ({ ) , it matches either a space or a left bracket So, the whole expression means: match a strings where they start with #, followed by 1 or more characters, followed by a space or a left-bracket Note that these are very simplified explanations for regular expressions. Now, try the expression /#(.+)({ )/ and instead of print_r($out), try print_r($out[1]); Now you get the classnames :) Check out the following sites for more info (they appear first when you google regular expressions). http://sitescooper.org/tao_regexps.html http://etext.lib.virginia.edu/helpsheets/regex.html Also, check out the PHP manual for the preg_* functions --- Note that the script i gave you has problems with classnames on one line, like #footer a:link, #footer a:visited But I won't spoon feed you :) ramil http://ramil.sagum.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] downloading files
Aaron Todd wrote: I have been using the following code to try to make it work: ?php $file = /home/site/member/filename.xxx; header(Content-Description: File Transfer); header(Content-Type: application/force-download); header(Content-Disposition: attachment; filename=.basename($file)); readfile($file); ? The webroot of my site is at: /var/www/html So far this will create a new file on my computer where ever I want, but it does not download the contents of the file. Any suggestions? Thanks, Aaron It seems that PHP can't read the file '/home/site/member/filename.xxx', what are the permissions for this file? PHP's rights are the same as the user Apache runs on. This is usually httpd or apache in most linux distributions. In your previous post, you were asking where to best place the file so it is protected somehow. You could actually place it in a simpler directory like /var/www/downloads then set x bit for the _other_ users of the downloads directory, so PHP can access files under it chmod o+x downloads and set all files under this directory to be readable by others (esp PHP) chmod o+r downloads/* THis way, PHP can't modify files in this directory. And no one can just download a file by entering a URL (since the files are outside the webserver path). goodluck! HTH. --- ramil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP with CVS...
Paul Danko wrote: I'm a newbie using CVS with PHP development. I created a CVS repository, which contains two directories. /CVSROOT/ /project/ where project has my code. My problem is that CVS modifies the files in the /project/ folder. the extension becomes *.php,v. I want to be able to checkout the code, check it back in, and then essentially refresh my browser and see the changes. In this case, the repository itself cannot be used by apache (because the files are modified as mentioned previously), a checked out version is required. this seems like extra steps. 1.) Check out my copy of the code 2.) Make changes to code 3.) Check the code back into cvs 4.) Checkout a copy of the current code to the web directory 5.) View the changes via the web. Is this how it is typically done? Thanks for any help! -Paul I don't know how it is typically done, but I implemented a similar system months ago. You need to edit one of the commit support files in CVSROOT, the loginfo file. (Note : when editing the loginfo file, check it out, edit it and commit it as you would a normal file in the repository. Don't edit it in place.) (for more info on the commit support files, see https://www.cvshome.org/docs/manual/cvs-1.11.17/cvs_18.htm ) The loginfo file speficies a set of actions to be done when the commit is complete. If you add the line: ^project(date; cat; (sleep 2; cd /var/some/dir; cvs -q update -d) ) $CVSROOT/CVSROOT/updatelog 21 This will cause commits to the projects directory to update the checked out version in /var/some/dir (the above line was shamelessky taken from the manual in the link above, section C.3.5.2 :D) Of course you need to take of permissions issues. Ensure that the user cvs is running in CAN write to /var/some/dir. HTH! --- ramil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php