Re: [PHP] 0.0.0.0 & iplong()
On 06/05/2012 05:40 AM, Matijn Woudt wrote: On Tue, Jun 5, 2012 at 1:07 PM, jas wrote: On 06/04/2012 12:48 PM, Matijn Woudt wrote: On Mon, Jun 4, 2012 at 8:38 PM, jaswrote: On 06/04/2012 11:33 AM, Matijn Woudt wrote: On Mon, Jun 4, 2012 at 6:54 PM, jas wrote: Not sure if this is a bug or not... I have run into an error when performing a conditional using iplong() and the ~ bitwise operator $ip = '0.0.0.0'; $mask = '24'; $end = (ip2long($ip) || (~ip2long($mask))) + 1; PHP Fatal error: Unsupported operand types I even tried to typecast the mask to (int) The error is probably not where you suspect it to be. ip2long will return false for ip2long($mask), because $mask is not a valid IP address. The ~ operator is not supported for false. - Matijn Strange... this works $ip = '10.0.2.0'; $mask = '24'; Anything using 0.0.0.0 fails using the bitmask to calculate valid CIDR ranges. Yes, because with $ip being 0.0.0.0, the result of ip2long($ip) will be zero. Zero evaluates to false when PHP is going to parse the || operator, and because of that, it continues to parse the rest. When the result of ip2long($ip) is greater that zero, in case of some other valid IP, it will evaluate to true and PHP will not even execute the rest after the || because the result will be true anyway. Did you mean to use a single | operator, as a bitwise OR? - Matijn With any ACL rule using iptables, hosts.allow/hosts.deny, routers where 0.0.0.0/24 is specified (all of the internet ipv4 addresses) this is a valid range using CIDR notation. It seems like a bug to me Nope, there's no bug here. Can you explain what you're trying to do with ip2long($mask)? - Matijn As stated previously using CIDR notation such as 192.168.0.0/24, 10.0.0.0/24 perform validation on an IP existing within said subnet range. visiting ip: 192.168.0.22 acl allow range: 192.168.0.0/24 acl deny range: 0.0.0.0/24 CIDR notation allows me to utilize shorthand notation for specifying a range of IP's In those two cases any ip within 192.168.0.0 - 192.168.0.255 is allowed while anything else residing between 0.0.0.0 - 255.255.255.255 is denied The problem is I can perform operations on CIDR ranges such as the following: 192.168.0.0/24 192.168.1.0/16 10.0.0.0/24 But cannot use the traditional 0.0.0.0/24 because iplong() evaluates 0.0.0.0 as false thereby invalidating a valid CIDR notation when evaluated as (ip2long($ip) || (~ip2long($mask))) + 1; From my own tests only 0.0.0.0/24 fails or as shown in the example code above (ip2long(0.0.0.0) || (~ip2long(24))) + 1; The class I am using to test with can be found at http://www.php.net/manual/en/function.ip2long.php#108812 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 0.0.0.0 & iplong()
On 06/04/2012 12:48 PM, Matijn Woudt wrote: On Mon, Jun 4, 2012 at 8:38 PM, jas wrote: On 06/04/2012 11:33 AM, Matijn Woudt wrote: On Mon, Jun 4, 2012 at 6:54 PM, jaswrote: Not sure if this is a bug or not... I have run into an error when performing a conditional using iplong() and the ~ bitwise operator $ip = '0.0.0.0'; $mask = '24'; $end = (ip2long($ip) || (~ip2long($mask))) + 1; PHP Fatal error: Unsupported operand types I even tried to typecast the mask to (int) The error is probably not where you suspect it to be. ip2long will return false for ip2long($mask), because $mask is not a valid IP address. The ~ operator is not supported for false. - Matijn Strange... this works $ip = '10.0.2.0'; $mask = '24'; Anything using 0.0.0.0 fails using the bitmask to calculate valid CIDR ranges. Yes, because with $ip being 0.0.0.0, the result of ip2long($ip) will be zero. Zero evaluates to false when PHP is going to parse the || operator, and because of that, it continues to parse the rest. When the result of ip2long($ip) is greater that zero, in case of some other valid IP, it will evaluate to true and PHP will not even execute the rest after the || because the result will be true anyway. Did you mean to use a single | operator, as a bitwise OR? - Matijn With any ACL rule using iptables, hosts.allow/hosts.deny, routers where 0.0.0.0/24 is specified (all of the internet ipv4 addresses) this is a valid range using CIDR notation. It seems like a bug to me -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 0.0.0.0 & iplong()
On 06/04/2012 11:33 AM, Matijn Woudt wrote: On Mon, Jun 4, 2012 at 6:54 PM, jas wrote: Not sure if this is a bug or not... I have run into an error when performing a conditional using iplong() and the ~ bitwise operator $ip = '0.0.0.0'; $mask = '24'; $end = (ip2long($ip) || (~ip2long($mask))) + 1; PHP Fatal error: Unsupported operand types I even tried to typecast the mask to (int) The error is probably not where you suspect it to be. ip2long will return false for ip2long($mask), because $mask is not a valid IP address. The ~ operator is not supported for false. - Matijn Strange... this works $ip = '10.0.2.0'; $mask = '24'; Anything using 0.0.0.0 fails using the bitmask to calculate valid CIDR ranges. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] 0.0.0.0 & iplong()
Not sure if this is a bug or not... I have run into an error when performing a conditional using iplong() and the ~ bitwise operator $ip = '0.0.0.0'; $mask = '24'; $end = (ip2long($ip) || (~ip2long($mask))) + 1; PHP Fatal error: Unsupported operand types I even tried to typecast the mask to (int) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] openssl_sign() & openssl_verify() discrepancy
On 05/23/2012 02:00 PM, Matijn Woudt wrote: On Wed, May 23, 2012 at 9:42 PM, Jason Gerfen wrote: On 05/23/2012 01:26 PM, Matijn Woudt wrote: On Wed, May 23, 2012 at 9:12 PM, Jason Gerfen wrote: On 05/23/2012 01:05 PM, Matijn Woudt wrote: On Wed, May 23, 2012 at 8:29 PM, jas wrote: I have run into a problem that I am altogether unfamiliar with. A scenario. I retrieve a users private key from a database. I then use the openssl_pkey_get_private() function to load it as a resource object and proceed to call the openssl_sign() function to obtain a digital signature of a string. No problem, I get a valid signature which I then base64 encode and store in a database. Now lets say a couple of days from now I load up the public key which corresponds to the private key which was used to originally sign the data to verify it and it does not work. The kicker is if I perform the very same routine without saving the signature and attempting to verify it it works without problems. Have you checked what $signed looks like after running the script? Compare it to $signature. Most likely you corrupted your date elsewhere, maybe when inserting it into the database. - Matijn The example that accompanies the post shows two examples, one works&one does not. Neither however use any type of database, as both simply assign or use the valid signature stored within either the $signature or $signed variables. I wish I could say that is the problem, I took care to properly encode/decode when saving or retrieving the information and as well in the original post I removed this as a possible cause by simply defining the $signature variable and assigning a valid signature to it for testing. First of all, it seems $signature is in base64 format, so I think you should base64_decode that one first. Then it appears to me that $signature is not the same as $signed, on my system. If I base64_encode $signed, save it by copying it from my browser, and then enter it as $signature, and then use base64_decode on $signature it works fine. - Matijn Those are the same steps I just mentioned. The base64_decoding is a typo on the second example. It should read openssl_verify($unsigned, base64_decode($signature), $id); Well, then maybe you should explain the problem further, because with this it works fine, and it appears to me the problem is not here but it comes when you try to store/retrieve the data. - Matijn Well without you saying "should explain the problem further" I wouldn't have conducted the series of tests to verify each component being used within the sign/save & retrieve/verify processes. I was passing the wrong argument in during my retrieve/verify flow. Thanks again! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] openssl_sign() & openssl_verify() discrepancy
I have run into a problem that I am altogether unfamiliar with. A scenario. I retrieve a users private key from a database. I then use the openssl_pkey_get_private() function to load it as a resource object and proceed to call the openssl_sign() function to obtain a digital signature of a string. No problem, I get a valid signature which I then base64 encode and store in a database. Now lets say a couple of days from now I load up the public key which corresponds to the private key which was used to originally sign the data to verify it and it does not work. The kicker is if I perform the very same routine without saving the signature and attempting to verify it it works without problems. Example script: /* this part works */ $id = openssl_pkey_get_private($key, $pass); openssl_sign($unsigned, $signed, $id); $id = openssl_pkey_get_public($pub); openssl_verify($unsigned, $signed, $id); /* this doesn't (here I use the existing signature instead of generating a new one) */ $id = openssl_pkey_get_public($pub); openssl_verify($unsigned, $signature, $id); /* below here is all of the existing variables the above uses */ $unsigned = "w9A5Tt8JA/GVBn89WwpvXnnVsHvyWbEDu5GdX36m+ZQ=:ek4L55qc/VKAmiYdlIQhow==:ek4L55qc/VKAmiYdlIQhow==:6IraS+ArqK+/Yc472tfFqmhk5VdIACUQPCR7+kbLoAEldjejS/P1cSa8EMHxcV2s:50dt57IoKeQZ7eiwoILMR3E91MtbCgt+xVn483+9J1cNzBQGll02Qj40RVhNM/Rh:qEFBUlZzNYZNb7nksj8Fhd8Du52RVDjMBwoT/O0tdzKGfGVOeK2xrpuq1OdoAo2CN63U+Fra4zcfkzwkD3QxDA==:1337713224" $pass = "$2a$07$31a9f929d102f5f0374deuu.cfoTJbmZtGKk92CuAOP63XaRUAVIW"; $signature = "h+SdcyxuQ9kpb2CXZRA/grJjlYj+drlOH2f7Ifsnt5A8dSj9lkMYU11rtjT9sdaEhf3rvoIl9JUMvkzc6dJ4DMypqgGniqbesbK6yf30FmPd0an+bTyIpeQFasmUwxtB1y6wBjIENEzEDTyb6QHPTAZg6ep2m/NjZFfUn/iiDOnDt71KQD1whouwtRZ0+UcDfPvtLQ3bAGw9C5ThDoIHRlg1kzVLrq40QsjA/3zYJE+PKwG9i1srI8zbP6uW/0t6mnUpGQrZmz6sdekkdCjjc7R9bIsFdyZ2Gisr6W1pBH64/X4nGaDkYX99ss8vYfuQMp+fLyZGgEKXuAwHjT02iQ=="; $key = "-BEGIN ENCRYPTED PRIVATE KEY- MIIFDjBABgkqhkiG9w0BBQ0wMzAbBgkqhkiG9w0BBQwwDgQIgeRB2NhoaJgCAggA MBQGCCqGSIb3DQMHBAgk9XLQVrN2UQSCBMgNQWJWdwpXarX8Do5xPGSdEw526jai XlvAR0lX4QzkKGnx1Fe13r0Z7AwGsEyuZWhmiQTeL40sBGtKpqdwr3Eutj+W02Kg 7jlBcgeu5DnYeQHZ6kDUJD4o08LXtDlusTIjsVLOE0YtLA67M7X2GSJrCUOurW/r nPTYGwNt9Z59jtB/EwPqa7kxvhPF0OTZ/6+5NRmWczPnF5KAltLaH0PsR6JI9y9K ben/SZ6QYp4PTVva5HNDBXS2sYAW9AynA7ltEOzXtWTLK2SLcGsVuqWM/WBiTyKw MeRDPA4y6MwJDUuUvZNzNAi9FXy8c10shGSJBHyP4xBrn6DTEXEIrrsGhePRaCB1 GaH26K/q6yxq1HJdRttexHMK7GCyH325ufHT4Fup+FaJqkC0nAK6uuMbCqML4feC K73OVzCF9Sh2o43aaJR3Ktec5ACqW7SDSABirJMU+YQpE9Dyei5d6mo+3E1rulVr 7dfsjeLmJGx5SDf8ip+tEGj4VcVm48w7hWFAmi1KAif8YLbvFEaWwTYhJg0qrCPI eQuFVR8k6EDhGMKs2KnrfkUUhU4riosbryXACB1fi/oHmJmYAEBiYgFhYgwsNX/O QRqedbIPDYcTfCb/j0Z59kkN9Il5YuanzPvaU6zWDMBy6qo1SYdM0lstWH7RJodq eg/WAvKq1zwBPLoedt32UgTgHioQe4r8rVTwmQd0kFAVN+mdsdCtn7xCFliul042 n7bYWtVwiLeXecSOoY0G/0oJ7MhgddAbD9CJlLMoMmM669V+xQldoE0FKQUbrr3W vqOIoBWp1Bd8mQ0FHn5yn/blYYy0sgCEkuSvR+NqgBt620qJ+x7kIpnay9+tdDun v8bXz4gonA8+MGyf3yjwVNR6elZMGH/SxK1dQn65lK1AsPFKTHy+2TC5UgBw1zhe +DjkKkilgsL3TaIKIxr/aDctqja9PfxiZek5GkDRuJN1rk3StW75hpnCyJdIQYXo q4mpdR7MYfknH7l8hsMBGYhDJNQ2iBJ/HZag4FWl2GWRQcqlJ0cZOWST+inMCTs5 UhEKYQoifKpZGLZ9vFUC1U6jiJ5SMmHp8LlEW4XlX1fbpYWU4xiLXjrCgATW9eLE Af3/q0bqBKggjNLqI4ShXjzBhExRKlVOceWxO2PJUzBKYkmENJ3oV1ykuPFp2cwO 2jhmMvCIL9ja3d8xQXc/WbCkmKOIm94PvAT7SmZksf7tvKNlhRrKS53ncGyWxhNp VwRtxQq/VnKJvyXWjImqE4bIeh3Ca1kzVoO0fmSS1la42hRXoXOlFOC59i3P9Tfs qazgCepsMB+PfRoiarnxCRrTHunnExbNw+0aCWR8J0B6X9jTyfbga6dTNNqJvHBI ffp9R9tDd+3trwC7RNbCLSv8E6qRKiNM1kv4UhP4avn0J21wnB0fjz32PASrArNe NCauY0+sSCwrE03nDhdt4NUhylAa6JTJZwQlNM6zwt7ITBOnVTQh0EoZl+fJRN9f QROdqPuvJUHaO1UbL05cm9bqpovs7+vn2UxkpMTkQ/lyS8Vfl5DbqX6dCKz3/3pP KK7LjZegt9Ey2wZB/9OiKGyOPiXPwzXcXR/evC6TFeIA07/8018PRjdjefZV26c4 M4g= -END ENCRYPTED PRIVATE KEY-"; $pub = "-BEGIN PUBLIC KEY- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyEFetjn8mpkqHTgtKATK Gu7dgG6UXHD+Ft8UO6WoWgVGhnjgk+SlNI+4RG9BvCaG4jbPueu4nb15oO4aObQg RXZ7el2gjgEYu90qRILsDSzouoGFc/qPe6tNOUZ/ZXR3kBTm9t3CAW4bNDsnfUnP YFQVdFco03Pbz8vejc0SVSC8l2lw+ZSkMYDzDmhv09Uk1zh1kc/ACOU0AoofEaUM 2eyekwcQiVwzKksGjW70eOuI2QtgpIwuvQSS/BAcymYKkxJZVxUMPCwdBwY+Pyo+ +lD4yGeki0E7x72uQy0bzulxa6iXhQOYFQEcShxyJEF6YN/R/XSIQBLTi9biWvGg 6QIDAQAB -END PUBLIC KEY-"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Typecasting question
I am familiar with typecasting. Booleans, ints, strings, etc. However while using an extension, more specifically the OpenSSL extension I have come across a problem I am not entirely familiar with. I have an array that looks like... array('config' => 'config/openssl.cnf', 'encrypt_key'=> true, 'private_key_type' => 'OPENSSL_KEYTYPE_RSA', 'digest_algorithm' => 'sha256', 'private_key_bits' => 512, 'x509_extensions'=> 'usr_cert', 'encrypt_key_cipher' => 'OPENSSL_CIPHER_3DES'); And according to the current OpenSSL documentation regarding the configuration constants (http://www.php.net/manual/en/openssl.ciphers.php) the array needs to have the 'private_key_type' and 'encrypt_key_cipher' elements as an INT value vs the string they are currently. Like so. array('private_key_type' => OPENSSL_KEYTYPE_RSA, 'encrypt_key_cipher' => OPENSSL_CIPHER_3DES); I have tried to perform typecasting these two elements as an int but because they are specific to the extension I am not certain how I should go about doing this. According to the source for php (the openssl.c) file is an internal attribute that I cannot find an integer value for to set it manually vs. using the pre-defined constant values mentioned in the docs. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Executing shell command?
Ok I am having problems with a command I would like to execute through PHP. I have tried simple backtick operators on the command, passthru, exec, system all with the same results of 0 return code. Here is an example of the command I am attempting to execute if someone could provide me with some insight, examples etc. /usr/bin/dnssec-keygen -a HMAC-MD5 -b 128 -n USER key (which works from a terminal) Here is my php code (I am changing into a writable directory which works fine): chdir( $defined['keys'] ); $cmd = $defined['dnssectool'] . " -a " . $algorithm . " -b " . $key_bit . " -n USER " . $key_name; echo $cmd . ""; system( '$cmd', $ret ); chdir( $defined['virpath'] ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Secure Image Storage
Well if you have the GD libs installed you could do something with imagecreatefromjpeg() and just send a header with the following before the page is displayed. header("Content-Type: image/jpeg"); Kevin Murphy wrote: > Hello all, > > Following up with my success last week with putting downloadable files > in a directory above the web root and then using a combination of fopen > and stuff to download the file, I am now trying to do something similar > with images. > > However, what I am trying to do is to put an image file above the web > root, then use PHP to display that image in the web page, and not > download it. I have the feeling that this isn't possible (all solutions > I've seen involve using header() function, which won't work since this > is midway down the page), but I wanted to make sure. This will return > the binary source of the file: > > print file_get_contents($file_path); > > but doesn't display the image. Is there any way to have this (or > something else) generate the image? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] [SOLVED] Re: [PHP] disappearing array?
Found the problem. I had a typo on my conditional statement. if( $fix->ValArray( $_POST['add_order_items'] === -1 ) ) { $errors['add_order_array'] = $erlink; } Should have been: if( $fix->ValArray( $_POST['add_order_items'] ) === -1 ) { $errors['add_order_array'] = $erlink; } My eyes need to be checked or start exercising my fat fingers. Instruct ICC wrote: > Wow this formatted badly. (new hotmail on Safari -- MS made FF not even > render well) > > Anyway, are you sure you are reaching the code you want to reach? > Perhaps !== is overkill and maybe even wrong when you should use ==. > > Same with the other === usage? > > Try some > echo "HERE1\n"; > echo "HERE2\n"; > to see if you are getting to the line you expect. Like after that "count(~) > !== ". > > _ > Gear up for Halo® 3 with free downloads and an exclusive offer. It’s our way > of saying thanks for using Windows Live™. > http://gethalo3gear.com?ocid=SeptemberWLHalo3_WLHMTxt_2 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] disappearing array?
I am not sure what the heck is going with this but here is my problem. I am trying to validate the contents of an array, then determine if the errors are with the array or another form submitted variable. The problem is after the code validates the array and other form variables using an if statement, I then try to determine if the error is in the array but for some reason the contents of the array disappear. Weird. Any help is appreciated. Here is the code: function ValArray( $array ) { echo ""; print_r( $array ); echo ""; $val = new ValidateStrings(); $data = 0; if( count( $array ) !== 0 ) { for( $x = 0; $x < count( $array ); $x++ ) { echo "DATA: " . $array[$x][0] . ""; if( $val->ValidateInteger( $array[$x][0] ) === -1 ) {// || ( $val->ValidateParagraph( $array[$x][1] ) === -1 ) || ( $val->ValidateMoney( $array[$x][2] ) === -1 ) || ( $val->ValidateAlphaChar( $array[$x][3] ) === -1 ) || ( $val->ValidateAlphaChar( $array[$x][4] ) === -1 ) ) { $data = -1; } } } echo "RESULTS: " . $data . ""; return $data; } if( ValArray( $_POST['add_order_items'] ) === -1 ) { $message = "error"; echo ""; print_r( $_POST['add_order_items'] ); echo ""; // here is where it is empty or something else if( $fix->ValArray( $_POST['add_order_items'] === -1 ) ) { $errors['add_order_array'] = $erlink; } echo ""; print_r( $_POST['add_order_items'] ); echo ""; And the output: Array ( [1] => Array ( [0] => ^&%*&( [1] => ^*&() [2] => ^*&() [3] => ^*&()_ [4] => ^%&*() ) [0] => Array ( [0] => afadsf [1] => adsfasfasdf [2] => asdfasdfasdf [3] => asdfasdfasdf [4] => asdfasdfasdf ) ) DATA: afadsf DATA: ^&%*&( RESULTS: -1 DATA: RESULTS: -1 Array ( [1] => Array ( [0] => ^&%*&( [1] => ^*&() [2] => ^*&() [3] => ^*&()_ [4] => ^%&*() ) [0] => Array ( [0] => afadsf [1] => adsfasfasdf [2] => asdfasdfasdf [3] => asdfasdfasdf [4] => asdfasdfasdf ) ) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php to generate java-script
Anyone have a good method of grabbing the current page and reading data from it? For example: http://php.net"; ); ?> The above code would output the following: Array ( [0] => [1] =>http://"; . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ); ?> Not only does it take a helluva long time to load the page but it also creates a nested array with duplicate values. My best guess is that the order in which the page is being generated has something to do with the lag as well as the nested array with duplicate values. Could anyone help me or point me in a better direction for performing these actions? Thanks in advance, Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] system command?
I didn't sent off list, always to php.general in reply to whatever message thread I am in. In any event, I have tried safe mode = On and safe mode = Off with the 4 commands I listed in my last thread and my actual code is using an echo = "$tailed"; I even tried to remove the -f and replaced it with a -n 600 (for six hundred lines to be output) and it still wont place the $tailed var into the textarea. It will output to the screen but not to the textarea, I am just going to scrap it and try it a different way. Cheers, Jas Jay Blanchard wrote: [snip] It is now... but it still doesn't work. I have tried passthru(), exec(), shell_exec() & system() trying to tail -f a log file into a textarea box and I get nothing or the output is put in the headers and stops the rest of the page from loading. I am at a loss. Jay Blanchard wrote: [snip] Anyone know what this wouldn't work? I have tried using a couple of functions defined at http://us2.php.net/manual/en/ref.exec.php and none seem to have the desired effect. $tailed"; ?> [/snip] Is PHP running in safe mode? [/snip] a. safe mode must be OFF b. you must remove the "=" from the print statement, should be thrwoing a syntax erro c. get rid of the -f as it will not continue to update the text area d. do not reply off-list unless requested -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] system command?
Anyone know what this wouldn't work? I have tried using a couple of functions defined at http://us2.php.net/manual/en/ref.exec.php and none seem to have the desired effect. $tailed"; ?> Thanks in advance, Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: simple, but missing something?
So something like this? function database_connection() { global = $cfg['hostname'],$cfg['username'],$cfg['password']; @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); @mysql_select_database($cfg['database']); } Or could I do an entire array like so... function database_connection() { global = $cfg; @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); @mysql_select_database($cfg['database']); } ??? Stupid question I know... Geir Pedersen - Activio As wrote: $cfg['hostname'] = "www.server.com"; // Server domain or ip address $cfg['username'] = "username";// Database user name $cfg['password'] = "password";// Database password $cfg['bugemail'] = "[EMAIL PROTECTED]"; Then do something like this: function database_connection() { @mysql_connect($cfg[hostname],$cfg[username],$cfg[password]); @mysql_select_database($cfg[database]); } 1) You have to declare $cfg as a global variable in your data_connection() function. PHP differs from C with respect to how you access global variables from within functions. Read about global variables here http://www.php.net/manual/en/language.variables.scope.php 2) Make sure you always quote string constants, even when used as array indexes. --- Geir Pedersen http://www.activio.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] simple, but missing something?
Jay Blanchard wrote: [snip] $cfg['hostname'] = "www.server.com"; // Server domain or ip address $cfg['username'] = "username";// Database user name $cfg['password'] = "password";// Database password $cfg['bugemail'] = "[EMAIL PROTECTED]"; The do something like this: function database_connection() { @mysql_connect($cfg[hostname],$cfg[username],$cfg[password]); @mysql_select_database($cfg[database]); } [/snip] Why are you not using the single quoted array names? i.e. @mysql_connect($cfg['hostname'],$cfg['username'],$cfg['password']); Have you echo'd each out afterwords to see if they are right? Use mysql_error() to return connection errors so that you know what they are. Yeah I have tried single quoted array names, double-quoted variable names, and the output of the print_r($cfg) displays the variables are present and when I do a mysql_error() and mysql_errno() I get could not connect to database, 1046 errors. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] simple, but missing something?
Not sure why I am not able to get this to work, but to make my stuff easier to configure for different environments I am trying to re-code some of my stuff to work with options from an array. $cfg['hostname'] = "www.server.com"; // Server domain or ip address $cfg['username'] = "username";// Database user name $cfg['password'] = "password";// Database password $cfg['bugemail'] = "[EMAIL PROTECTED]"; The do something like this: function database_connection() { @mysql_connect($cfg[hostname],$cfg[username],$cfg[password]); @mysql_select_database($cfg[database]); } Is there something special I have to do to get variables out of an array for use here? I have used $user = "name"; and called stuff like @mysql_connect($name); and it has worked before, I think I am missing something here. TIA Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] eregi for alpha-numeric, punctuation & whitespace?
Not sure how to accomplish this, and not completely familiar with all the options available with regular expressions. I need to sanitize input data by only allowing alpha-numeric characters, whitespace, punctuation (,.;:) and of course carrige returns. here is what I have so far... eregi("^[0-9a-zA-Z]{1,40}$",$_POST['input']) Any help is appreciated, right now anything with a space, period, comma etc gets flagged. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Detecting Binaries
Well you can do a check on the mime type of the file. eg. $mimes = array("1" => "application/octet-stream", "2: => "image/jpeg", etc. For more info... http://us4.php.net/manual/en/ref.filesystem.php Just like the upload file function you can check for the mime types... http://us4.php.net/manual/en/features.file-upload.php Just a thought, might not be a comlete solution however. HTH Jas Axel Is Main wrote: Guys, this isn't THAT stupid of a question is it? From my perspective, the way PHP seems to see it is that I should already know what kind of file I'm looking at. In most cases that's not an unreasonable assumption. Unfortunately, that's only good for most cases. PHP is rich in ways to work with the HTTP protocol, but has no way of detecting whether it's opening a text file or a binary file. To me this is a glaring omission. There has to be a way to do it, even if it's a round-a-bout or backdoor kind of way. Nothing is impossible. Nick Axel IS Main wrote: I'm using file_get_contents() to open URLs. Does anyone know if there is a way to look at the result and determine if the file is binary? I'd like to be able to block binaries from being processed without having to try to think of all the possible binary extensions and omit them with a function that looks for these extensions. Nick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with Sessions
Sheni R. Meledath wrote: Hello: Session is not working in PHP script file when executed through the browser IE 5.0 on Windows 2000 platform. In IE latest versions the script is working fine. Does anybody have any solution or report related to this. PHP version on the server is 4.3. Sheni R Meledath [EMAIL PROTECTED] Well ask yourself a couple of questions... 1. Did you do a 'session_start();' at the top of your script? 2. What Web server are you running? (IIS / Apache etc.) 3. Does my PHP.INI file have the session.save_path directive set? 4. In the folder specified by PHP.INI are there any sess_99898... files? 5. Did you post any examples of your code so we can help pinpoint the exact problem? HTH Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: mycrypt 3des (php vs .net)
Craig, If that doesn't work I am almost certain there might be a discrepency in how the .net & mcrypt libraries actually employ the triple des cipher. On another note, I couldn't get the mcrypt_deinit function to work without error as well. One thing you could do is use the PHP unset() call to unlink your variables once data has been passed through your cipher. I would post your problem to the developers of the mcrypt app at mcrypt.sourceforge.net, I have talked with the guys over there and have always gotten help. I am sure they would want to know about this as well. HTH Jas Craig wrote: > I am not sure if it will help of if you have already tried this but try all of the cipher modes available for the tripledes cipher (eg. cfb, ecb, etc.). There may be a difference in the way .net and mcrypt produces the cipher text but if that were the case then it wouldn't be a true tripledes encryption for either the .net or mcrypt encryption libraries. Are you able to view the source of the .net code which originally produced the cipher text? If so then see what mode it is using with the tripledes cipher. And you are right about the documentation, it took me awhile to get it working and even longer to figure out how it worked. Good luck, Jas I did check out the .net documentation and it uses cbc, but maybe I'll try the other modes for kicks. -Craig Craig wrote: Hi all, I am truly hoping that someone can help with this. I am making the ecommerce site for a product that I had nothing to do with the development of. =) The product is making a licence file using the .net 3des, but I am not able to get the same output using the mcrypt 3des. this is the .net original text and the cipher text: Golf Genie 5.0 ª:b•#–æaŒž"[EMAIL PROTECTED]">#p0, 7 this is what i get ¿^U`ÎdÀ4`oãõwÑî% - from Golf Genie 5.0 ¿^U`ÎdÀ4!é$”GIø - from Golf Genie 5.0\r\n I don't know too much about encyrption, and I have found the documentation of mcrypt to be the worst of any php module I have yet used, so i'm not sure of the consequenses of using cbc versus ecb are, etc. here is the code i am using. $key = "\x6B\x00\x64\x00\x4E\x00\x44\x00\x38\x00\x37\x00\x5E\x00\x21\x00"; $input = "Golf Genie 5.0"; $iv = "\x2B\x00\x5F\x00\x65\x00\x6B\x00"; $td = mcrypt_module_open ('tripledes', '', 'cbc', ''); mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); mcrypt_module_close ($td); echo $encrypted_data; ps. I can't use mcrypt_generic_deinit - i get 'Fatal error: Call to undefined function: mcrypt_generic_deinit()... ' thanks in advance, Craig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: mycrypt 3des (php vs .net)
I am not sure if it will help of if you have already tried this but try all of the cipher modes available for the tripledes cipher (eg. cfb, ecb, etc.). There may be a difference in the way .net and mcrypt produces the cipher text but if that were the case then it wouldn't be a true tripledes encryption for either the .net or mcrypt encryption libraries. Are you able to view the source of the .net code which originally produced the cipher text? If so then see what mode it is using with the tripledes cipher. And you are right about the documentation, it took me awhile to get it working and even longer to figure out how it worked. Good luck, Jas Craig wrote: Hi all, I am truly hoping that someone can help with this. I am making the ecommerce site for a product that I had nothing to do with the development of. =) The product is making a licence file using the .net 3des, but I am not able to get the same output using the mcrypt 3des. this is the .net original text and the cipher text: Golf Genie 5.0 ª:b•#–æaŒž"[EMAIL PROTECTED]">#p0, 7 this is what i get ¿^U`ÎdÀ4`oãõwÑî% - from Golf Genie 5.0 ¿^U`ÎdÀ4!é$”GIø - from Golf Genie 5.0\r\n I don't know too much about encyrption, and I have found the documentation of mcrypt to be the worst of any php module I have yet used, so i'm not sure of the consequenses of using cbc versus ecb are, etc. here is the code i am using. $key = "\x6B\x00\x64\x00\x4E\x00\x44\x00\x38\x00\x37\x00\x5E\x00\x21\x00"; $input = "Golf Genie 5.0"; $iv = "\x2B\x00\x5F\x00\x65\x00\x6B\x00"; $td = mcrypt_module_open ('tripledes', '', 'cbc', ''); mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); mcrypt_module_close ($td); echo $encrypted_data; ps. I can't use mcrypt_generic_deinit - i get 'Fatal error: Call to undefined function: mcrypt_generic_deinit()... ' thanks in advance, Craig -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: apache2 hanging
Well first off you really should be posting to the Apache newsgroup, this is for PHP coding questions etc. However, if you have poorly written code it could cause Apache to hang. I would ask yourself a few questions, does it only happen on one particular website apache is running or on every site that apache is serving up pages for? What kind of code are you running? PHP, Perl etc. Have you looked in the Apache error logs yet? Usually in /path/to/apache/logs/error_log & access_log. If you look at the requests in the error_log it will probably give you a good indication of why it keeps hanging. HTH Jas Bryan Simmons wrote: I'm using php 4.3.4 as a loadable module for Apache2 on a Redhat box. It works for the most part except that for about every 5th page that is requested, the server hangs. It always finishes the process and the page but it hangs for like 5 minutes. Is this a known error? Does anyone know how to fix this? Regards, Bryan Simmons Network Systems Engineer General Physics 410.379.3710 [EMAIL PROTECTED] __ Do you Yahoo!? Yahoo! Finance: Get your refund fast by filing online. http://taxes.yahoo.com/filing.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: authentication using /etc/passwd
Adam Williams wrote: Hi, is there a way to authenticate a username/password someone enters in a form with what is in /etc/passwd? Thanks! Yep, do a search on .htaccess from http://google.com Cheers, jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mcrypt don't work.
Have you tried to check if PHP has been compiled with mcrypt? try this on a page Look for mcrypt directives, if not there you need to download it and compile it like so. http://mcrypt.sourceforge.net Get both the libmcrypt and mcrypt compressed archives from command prompt on linux... cd /path/to/libmcrypt.xx.tar.gz gzip -dfrv libmcrypt.xx.tar.gz tar -xvf libmcrypt.xx.tar cd libmcrypt.xx/ ./config --disable-posix-threads make make install now do the same for mcrypt cd /path/to/mcrypt.xx.tar.gz gzip -dfrv mcrypt.xx.tar.gz tar -xvf mcrypt.xx.tar cd mcrypt.xx/ ./config --disable-posix-threads make make install now you need to compile php for mcrypt support cd /path/to/php-4.xx ./configure --with-mcrypt=/path/to/libmcrypt/ make make install simple, now if your using apache on windows you need to get the windows executables from mcrypt.sourceforge.net Also if mcrypt is already installed simple do a find find / | grep libmcrypt from a command prompt to find the libraries, if you cannot find it them install it, or just re-compile php to include support. Hope this helps, it took me awhile to figure it out too. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Regular expression help?
Adam Bregenzer wrote: On Mon, 2004-02-02 at 14:15, Jas wrote: I have tried this but its not working. !eregi("^[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}$",$_POST['mac']) so it should match 2 characters 0-9a-fA-F each block of 2 characters is followed by a : and repreated in 6 blocks. That's a long expression, try: !preg_match('/^([0-9a-f]{2}($|:)){6}/i', $_POST['mac']); This pattern finds 6 matches of a number or letter (the /i means case-insensitive) followed by either a ':' or the end of the string. Thanks, that worked like a charm. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular expression help?
Not sure if anyone knows of a good way to match strings of this type... 00:02:8b:0c:2f:09 I have tried this but its not working. !eregi("^[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}\:[0-9a-fA-F]{2}$",$_POST['mac']) so it should match 2 characters 0-9a-fA-F each block of 2 characters is followed by a : and repreated in 6 blocks. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How check credit card or magnetic card number.
Pedro wrote: Hi, how i can check credit card or magnetic card number for a site of electronic commerce that i have to design. Sorry for my english. Pedro. //Check credit card & date on HTML form if(empty($_POST['cc']) || (empty($_POST['ccd'])) { echo "Credit card and date fields not submitted."; } else { //Check formats for various card types & date if(eregi("^4[0-9]{16}$",$_POST['cc'])) || eregi("^[0-9]{2}/+[0-9]{2}$",$_POST['ccd'])) { echo "You card is a Visa Card"; if(eregi("^5[0-9]{16}$",$_POST['cc'])) || eregi("^[0-9{2}/+[0-9]{2})) { echo "Your card is a Mastercard"; } ?> You get the idea, you may to need to Google around for the various credit card types and how the need them to be formatted, and my regular expressions may need to be adjusted as I have not tested them out. But that is just an example of how you would accomplish your goal. HTH Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions not working.
John Nichel wrote: Chris W. Parker wrote: C'mon dude. Some of use are on dialup (not me now, but when I get home) and that email REALLY needed to be trimmed. Chris. I remember back in the day We used to do stuff like this. To the people who were using. a 300 baud modem or slower.. when we had 900 or better. Just to mess with them. Sorry, couldn't resist. ;) lmao! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions not working.
TERFACE CGI/1.1 HTTPS off HTTP_ACCEPT */* HTTP_ACCEPT_LANGUAGE en-us HTTP_CONNECTION Keep-Alive HTTP_HOST opsup_dev.telaurus.net HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) HTTP_ACCEPT_ENCODING gzip, deflate INSTANCE_ID 6 LOCAL_ADDR 10.16.1.24 NUMBER_OF_PROCESSORS 1 Os2LibPath C:\WINNT\system32\os2\dll; OS Windows_NT Path C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PATH_INFO /phpinfo.php PATH_TRANSLATED C:\Inetpub\wwwOpSupDev\phpinfo.php PROCESSOR_ARCHITECTURE x86 PROCESSOR_IDENTIFIER x86 Family 6 Model 8 Stepping 10, GenuineIntel PROCESSOR_LEVEL 6 PROCESSOR_REVISION 080a ProgramFiles C:\Program Files REMOTE_ADDR 10.16.2.55 REMOTE_HOST 10.16.2.55 REQUEST_METHOD GET SCRIPT_NAME /phpinfo.php SERVER_NAME opsup_dev.telaurus.net SERVER_PORT 80 SERVER_PORT_SECURE 0 SERVER_PROTOCOL HTTP/1.1 SERVER_SOFTWARE Microsoft-IIS/5.0 SystemDrive C: SystemRoot C:\WINNT TEMP C:\WINNT\TEMP TMP C:\WINNT\TEMP USERPROFILE C:\Documents and Settings\NetShowServices windir C:\WINNT PHP Variables Variable Value _SERVER["ALLUSERSPROFILE"] C:\\Documents and Settings\\All Users _SERVER["CommonProgramFiles"] C:\\Program Files\\Common Files _SERVER["COMPUTERNAME"] WS02TC07927 _SERVER["ComSpec"] C:\\WINNT\\system32\\cmd.exe _SERVER["CONTENT_LENGTH"] 0 _SERVER["GATEWAY_INTERFACE"] CGI/1.1 _SERVER["HTTPS"] off _SERVER["HTTP_ACCEPT"] */* _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us _SERVER["HTTP_CONNECTION"] Keep-Alive _SERVER["HTTP_HOST"] opsup_dev.telaurus.net _SERVER["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) _SERVER["HTTP_ACCEPT_ENCODING"] gzip, deflate _SERVER["INSTANCE_ID"] 6 _SERVER["LOCAL_ADDR"] 10.16.1.24 _SERVER["NUMBER_OF_PROCESSORS"] 1 _SERVER["Os2LibPath"] C:\\WINNT\\system32\\os2\\dll; _SERVER["OS"] Windows_NT _SERVER["Path"] C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem _SERVER["PATHEXT"] .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH _SERVER["PATH_INFO"] /phpinfo.php _SERVER["PATH_TRANSLATED"] C:\\Inetpub\\wwwOpSupDev\\phpinfo.php _SERVER["PROCESSOR_ARCHITECTURE"] x86 _SERVER["PROCESSOR_IDENTIFIER"] x86 Family 6 Model 8 Stepping 10, GenuineIntel _SERVER["PROCESSOR_LEVEL"] 6 _SERVER["PROCESSOR_REVISION"] 080a _SERVER["ProgramFiles"] C:\\Program Files _SERVER["REMOTE_ADDR"] 10.16.2.55 _SERVER["REMOTE_HOST"] 10.16.2.55 _SERVER["REQUEST_METHOD"] GET _SERVER["SCRIPT_NAME"] /phpinfo.php _SERVER["SERVER_NAME"] opsup_dev.telaurus.net _SERVER["SERVER_PORT"] 80 _SERVER["SERVER_PORT_SECURE"] 0 _SERVER["SERVER_PROTOCOL"] HTTP/1.1 _SERVER["SERVER_SOFTWARE"] Microsoft-IIS/5.0 _SERVER["SystemDrive"] C: _SERVER["SystemRoot"] C:\\WINNT _SERVER["TEMP"] C:\\WINNT\\TEMP _SERVER["TMP"] C:\\WINNT\\TEMP _SERVER["USERPROFILE"] C:\\Documents and Settings\\NetShowServices _SERVER["windir"] C:\\WINNT _SERVER["PHP_SELF"] /phpinfo.php _SERVER["argv"] Array ( ) _SERVER["argc"] 0 _ENV["ALLUSERSPROFILE"] C:\\Documents and Settings\\All Users _ENV["CommonProgramFiles"] C:\\Program Files\\Common Files _ENV["COMPUTERNAME"] WS02TC07927 _ENV["ComSpec"] C:\\WINNT\\system32\\cmd.exe _ENV["CONTENT_LENGTH"] 0 _ENV["GATEWAY_INTERFACE"] CGI/1.1 _ENV["HTTPS"] off _ENV["HTTP_ACCEPT"] */* _ENV["HTTP_ACCEPT_LANGUAGE"] en-us _ENV["HTTP_CONNECTION"] Keep-Alive _ENV["HTTP_HOST"] opsup_dev.telaurus.net _ENV["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) _ENV["HTTP_ACCEPT_ENCODING"] gzip, deflate _ENV["INSTANCE_ID"] 6 _ENV["LOCAL_ADDR"] 10.16.1.24 _ENV["NUMBER_OF_PROCESSORS"] 1 _ENV["Os2LibPath"] C:\\WINNT\\system32\\os2\\dll; _ENV["OS"] Windows_NT _ENV["Path"] C:\\WINNT\\system32;C:\\WINNT;C:\\WINNT\\System32\\Wbem _ENV["PATHEXT"] .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH _ENV["PATH_INFO"] /phpinfo.php _ENV["PATH_TRANSLATED"] C:\\Inetpub\\wwwOpSupDev\\phpinfo.php _ENV["PROCESSOR_ARCHITECTURE"] x86 _ENV["PROCESSOR_IDENTIFIER"] x86 Family 6 Model 8 Stepping 10, GenuineIntel _ENV["PROCESSOR_LEVEL"] 6 _ENV["PROCESSOR_REVISION"] 080a _ENV["ProgramFiles"] C:\\Program Files _ENV["REMOTE_ADDR"] 10.16.2.55 _ENV["REMOTE_HOST"] 10.16.2.55 _ENV["REQUEST_METHOD"] GET _ENV["SCRIPT_NAME"] /phpinfo.php _ENV["SERVER_NAME"] opsup_dev.telaurus.net _ENV["SERVER_PORT"] 80 _ENV["SERVER_PORT_SECURE"] 0 _ENV["SERVER_PROTOCOL"] HTTP/1.1 _ENV["SERVER_SOFTWARE"] Microsoft-IIS/5.0 _ENV["SystemDrive"] C: _ENV["SystemRoot"] C:\\WINNT _ENV["TEMP"] C:\\WINNT\\TEMP _ENV["TMP"] C:\\WINNT\\TEMP _ENV["USERPROFILE"] C:\\Documents and Settings\\NetShowServices _ENV["windir"] C:\\WINNT Jeff McKeon IT Manager Telaurus Communications LLC [EMAIL PROTECTED] (973) 889-8990 ex 209 ***The information contained in this communication is confidential. It is intended only for the sole use of the recipient named above and may be legally privileged. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication, or any of its contents or attachments, is expressly prohibited. If you have received this communication in error, please re-send it to the sender and delete the original message, and any copy of it, from your computer system. Thank You.*** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Well in that case do a dump_vars($_session[],$_session[]) for each session variable you register and see if anything is listed. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] php to send emails using exim?
Not sure how to accomplish this, and yes I have read every post on Exim's website and scoured google for examples of sending emails from php using the exim mail server. What I have done this far to try and get it to work... changed php.in sendmail path to a symlink of sendmail which points to the current exim binary, and call the mail() function from php. tried to do a system() to the exim binary as well as exec("/path/to/exim -io -T, $msg") All with no luck, could anyone give me an example of how to accomplish this? Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] HELP <> PLEASE PHP
Man, you really are a card Erik. Fellow manual reader, Jas [EMAIL PROTECTED] wrote: Hello Patrick, I have good news and even better news for you. The good news is that you can make all your form-related woes disappear in less than a day. The even better news is that everything you need to know in order to solve your problem can be found in one convenient location: http://www.php.net/manual/en/index.php You'll probably be able to fix your form just by reading sections I and II. By the way, punctuation was invented for a reason, you know. You might want to consider using it. Good luck, Erik On 29 Jan 2004 at 1:56, Patrick wrote: Hi, I have an situation on my hands I have a form that I am stuck using PHP for thanks to my friends choice of hosting company, I have no idea on how to setup a form in PHP other than HTML or in Flash, I need some one any one to give me some advice on this Posted layout it seems to work but not really, I managed to get it set up but for some reason when you hit Submit and an error message goes off at the top the form is Reset. Other than that I am not sure I wrote all the code correctly. Sorry About the long post Any advice would be great. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Sessions not working.
Have you checked the %temporary% directory permissions to make sure IIS can write session data to the directory? I had a hard time using php on IIS, so I installed linux... =) Depending on the version of PHP installed you may need to call your session variables differently, example: on PHP prior to 4.x echo $HTTP_SESSION_VARS['variablename']; 4.x and later echo $_SESSION['variablename']; Double check the path in PHP.INI then look at the permissions of that folder and make sure the IIS user can write to it, I think it is IUSER_WIN2k or something. HTH Jas Jeff McKeon wrote: Further info. If I echo the session_id() onto the page I do get an id returned. So (correct me if I'm wrong) the session has started correctly with the session_start() at the top of the page. It just doesn't seem to save any of the session variables I set, or if they are set, it can't retrieve them. I get this error when trying to grab the $session['userid'] variable... Notice: Undefined index: userid in C:\Inetpub\wwwOpSupDev\main.php on line 37 -Original Message- From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED] Sent: Thursday, January 29, 2004 9:19 AM To: [EMAIL PROTECTED] Subject: RE: [PHP] Sessions not working. Random thought.. Did you check your PHP.INI on the 'bad' server to make sure that it's configured the same as the 'good' server? Some things to check: Session.use_cookies = 1 Session.auto_start = 0 // This is the first one I'd check. If you have it set to =1 on the good server and aren't doing a session_start(), that could do it I think There are a bunch of other Session related parameters in PHP.INI.. Default timeout value.. If that's set too low, the session might vaporize before you get a chance to see the info, etc. Good luck! -TG -Original Message- From: Jeff McKeon [mailto:[EMAIL PROTECTED] Sent: Wednesday, January 28, 2004 7:44 PM To: [EMAIL PROTECTED] Subject: [PHP] Sessions not working. Pulling my hair out here. I've got an IIS5 webserver running a php website just fine. I created another web for a dev version of the first website. Installed PHP ect... When I load up the old websites files on the new site sessions won't work on the new site. For some reason on the new site's phpinfo.php page, there is no HTTP_COOKIE variable set under the "environmental" section. Also, under the PHP Variables section, there is no _REQUEST["PHPSESSID"] or _COOKIE["PHPSESSID"] variable. What have I missed!??? Here is a section of the phpinfo() for both sites. Good Site: Environment Variable Value ALLUSERSPROFILE C:\Documents and Settings\All Users CommonProgramFiles C:\Program Files\Common Files COMPUTERNAME WS02TC07927 ComSpec C:\WINNT\system32\cmd.exe CONTENT_LENGTH 0 GATEWAY_INTERFACE CGI/1.1 HTTPS off HTTP_ACCEPT */* HTTP_ACCEPT_LANGUAGE en-us HTTP_CONNECTION Keep-Alive HTTP_HOST opsup.telaurus.net HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) HTTP_COOKIE PHPSESSID=ed09aa7b20d4032a3553c16a8f4a782f HTTP_ACCEPT_ENCODING gzip, deflate INSTANCE_ID 3 LOCAL_ADDR 10.16.1.21 NUMBER_OF_PROCESSORS 1 Os2LibPath C:\WINNT\system32\os2\dll; OS Windows_NT Path C:\WINNT\system32;C:\WINNT;C:\WINNT\System32\Wbem PATHEXT .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH PATH_INFO /phpinfo.php PATH_TRANSLATED C:\Inetpub\wwwOpSup\phpinfo.php PROCESSOR_ARCHITECTURE x86 PROCESSOR_IDENTIFIER x86 Family 6 Model 8 Stepping 10, GenuineIntel PROCESSOR_LEVEL 6 PROCESSOR_REVISION 080a ProgramFiles C:\Program Files REMOTE_ADDR 10.16.2.55 REMOTE_HOST 10.16.2.55 REQUEST_METHOD GET SCRIPT_NAME /phpinfo.php SERVER_NAME opsup.telaurus.net SERVER_PORT 80 SERVER_PORT_SECURE 0 SERVER_PROTOCOL HTTP/1.1 SERVER_SOFTWARE Microsoft-IIS/5.0 SystemDrive C: SystemRoot C:\WINNT TEMP C:\WINNT\TEMP TMP C:\WINNT\TEMP USERPROFILE C:\Documents and Settings\NetShowServices windir C:\WINNT PHP Variables Variable Value _REQUEST["PHPSESSID"] ed09aa7b20d4032a3553c16a8f4a782f _COOKIE["PHPSESSID"] ed09aa7b20d4032a3553c16a8f4a782f _SERVER["ALLUSERSPROFILE"] C:\\Documents and Settings\\All Users _SERVER["CommonProgramFiles"] C:\\Program Files\\Common Files _SERVER["COMPUTERNAME"] WS02TC07927 _SERVER["ComSpec"] C:\\WINNT\\system32\\cmd.exe _SERVER["CONTENT_LENGTH"] 0 _SERVER["GATEWAY_INTERFACE"] CGI/1.1 _SERVER["HTTPS"] off _SERVER["HTTP_ACCEPT"] */* _SERVER["HTTP_ACCEPT_LANGUAGE"] en-us _SERVER["HTTP_CONNECTION"] Keep-Alive _SERVER["HTTP_HOST"] opsup.telaurus.net _SERVER["HTTP_USER_AGENT"] Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) _SERVER["HTTP_COOKIE"] PHPSESSID=ed09aa7b20d4032a3553c16a8f4a782f
Re: [PHP] HELP <> PLEASE PHP
John Nichel wrote: Hello Patrick. Where to start, where to start Patrick wrote: Hi, I have an situation on my hands I have a form that I am stuck using PHP for thanks to my friends choice of hosting company, I have no idea on how to setup a form in PHP other than HTML or in Flash, I need some one any one to give me some advice on this Posted layout it seems to work but not really, I managed to get it set up but for some reason when you hit Submit and an error message goes off at the top the form is Reset. Other than that I am not sure I wrote all the code correctly. Sorry About the long post Any advice would be great. www.mdycentrutionmtg.com/formtest.php Formtest.php-- Chances are, all your variables here are going to be empty, since I'm sure the hosting company has register_globals turned off. You can use the global _POST array... $_POST['firstname']...$_POST['lastname']...etc, etc Also, for your 'error' messages, a, well, I would if ( ! isset ( $_POST['firstname'] ) ) { $message .= "Please enter your first name.\n"; } Get rid of the 'else's, and use ".=" when setting your message value so that if multiple items are not filled out, you won't be constantly overwriting the error message. if ($submit) { or you could use this... if(empty($firstname)) { $message .= " } elseif(empty($lastname)) { $message .= " You might have to use it like this though depending on if your using GET or POST if(empty($_POST["$firstname"]) { $message .= " } elseif(empty($_POST["$lastname"]) { $message .= " Or you could just combine them all like so... if((empty($_POST["$firstname"]) || (emtpy($_POST["$lastname"])) || ... { $message = "nothing filled out... HTH Jas if ($firstname <= "") $message = "Please enter your first name."; else if ($lastname <= "") $message = "Please enter your last name."; else if ($homephone <= "") $message = "Please enter your home phone number."; else if ($address <= "") $message = "Please enter your current home address."; else if ($city <= "") $message = "Please enter which city you currently live in."; else if ($state <= "") $message = "Please enter which state you currently live in."; else if ($zip <= "") $message = "Please enter your zip code."; else if ($monthlypayment <= "") $message = "Please enter the amount of your monthly payment."; else if ($presentemployer <= "") $message = "Please enter the name of your present employer."; else if ($rateofpay <= "") $message = "Please enter your rate of pay."; else if ($hoursperweek <= "") $message = "Please enter the average amount of hours worked in a week."; else if ($deposit <= "") $message = "Please enter the amount of your deposit."; else if ($maxpayment <= "") $message = "Please enter an average payment your comfortable with."; if ($message) echo ($yo); Don't know what $yo is here...I'm guessing that you're testing something? However, 'mail()' below here is going to crap out, and give you an error. Look here http://us2.php.net/manual/en/function.mail.php else { mail("[EMAIL PROTECTED]", "Form Results", "First Name $firstname", "Middle Initial $middleinital", "Last Name $lastname", "Social Security Number $ss", "Marital Status $maritalstatus", "Home Phone $homephone", "Address $address", "City $city", "State $state", "Zip $zip", "Apt Number $apt", "Time at address $monthsataddress Months $yearsataddress Years", "Type of residence $typeofres", "Monthly Payment $monthlypayment", "Current Employer $presentemployer", "Time with Employer $monthswithemployer Months $yearswithemployer Years", "Rate of Pay $rateofpay Dollars per $rateofpayper", "Hours per week $hoursperweek", "Work Phone $workphone", "Work History $workhistory", "Other Income $otherincome", "Deposit $deposit", "Maximum Payment $maxpayment", "Type of Loan $typeofloan", "Co First Name $cofirstname", "Co Middle Initial $comiddleinital", "Co Last Name $colastname", "Co Social Security Number $coss", "Co Marital Status $coma
Re: [PHP] PHP to Exim?
Brent Baisley wrote: Look at SquirrelMail. It's an open source PHP web front end to a mail system. You can look at the source code and see how they do things. On Jan 28, 2004, at 4:44 PM, Jas wrote: Not sure if anyone has run into this and I have only found methods of managing users for a exim email service. What I am looking to do is to allow a web form to use exim vs. sendmail using PHP's mail() function. If anyone has accomplished this please let me know.. I have been scouring google, php and exim's websites and have not found an example of how to accomplish this. Thanks, jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Yeah, well I don't see it working with the EXIM mail server specifically Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP to Exim?
Not sure if anyone has run into this and I have only found methods of managing users for a exim email service. What I am looking to do is to allow a web form to use exim vs. sendmail using PHP's mail() function. If anyone has accomplished this please let me know.. I have been scouring google, php and exim's websites and have not found an example of how to accomplish this. Thanks, jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem with mcrypt_encrypt and mcrypt_decrypt.
[EMAIL PROTECTED] wrote: Hi all, i'm trying to crypt and decrypt password with the code below but i get many warnings Warning: mcrypt_get_iv_size(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 36 Warning: mcrypt_create_iv(): Can not create an IV with size 0 or smaller in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 37 Warning: mcrypt_decrypt(): Module initialization failed in /web/htdocs/www.automationsoft.biz/home/invio_mail.php on line 38 and i don't understand why, any help is appreciated. Code is below. This code is in a script //Start crypt $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); should be... $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_ECB); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $key=genera();// genera() function for rand number $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); should be... $emailcifrata=mcrypt_encrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_ECB,$iv); $emailcifrata=$key.$emailcifrata; // End crypt This code is in another script that isn't the same script of previous //Start decrypt $emailcifrata=fgets($fp); $lunghezza_str=strlen($emailcifrata); $emailcifrata=substr($emailcifrata,10); $key=substr($emailcifrata,0,($lunghezza_str-10)); $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_CBC); should be... $iv_size=mcrypt_get_iv_size(MCRYPT_BLOWFISH,MYCRYPT_MODE_ECB); $iv=mcrypt_create_iv($iv_size,MCRYPT_RAND); $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_CBC,$iv); should be... $email=mcrypt_decrypt(MCRYPT_BLOWFISH,$key,$email,MYCRYPT_MODE_ECB,$iv); // End decrypt Thanks in advance. And the reason why is the streaming mode CBC doesn't work with every cipher mcrypt provides, for a list of modes each cipher is compatible with from a shell issue this command... %>/path/to/mcrypt --list Or if you don't have access to a shell on the webserver try these... http://us3.php.net/manual/en/function.mcrypt-list-algorithms.php http://us3.php.net/manual/en/function.mcrypt-list-modes.php From the help file on php.net for mcrypt http://us3.php.net/manual/en/ref.mcrypt.php Predefined Constants The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime. Mcrypt can operate in four block cipher modes (CBC, OFB, CFB, and ECB). If linked against libmcrypt-2.4.x or higher the functions can also operate in the block cipher mode nOFB and in STREAM mode. Below you find a list with all supported encryption modes together with the constants that are defines for the encryption mode. For a more complete reference and discussion see Applied Cryptography by Schneier (ISBN 0-471-11709-9). * MCRYPT_MODE_ECB (electronic codebook) is suitable for random data, such as encrypting other keys. Since data there is short and random, the disadvantages of ECB have a favorable negative effect. * MCRYPT_MODE_CBC (cipher block chaining) is especially suitable for encrypting files where the security is increased over ECB significantly. * MCRYPT_MODE_CFB (cipher feedback) is the best mode for encrypting byte streams where single bytes must be encrypted. * MCRYPT_MODE_OFB (output feedback, in 8bit) is comparable to CFB, but can be used in applications where error propagation cannot be tolerated. It's insecure (because it operates in 8bit mode) so it is not recommended to use it. * MCRYPT_MODE_NOFB (output feedback, in nbit) is comparable to OFB, but more secure because it operates on the block size of the algorithm. * MCRYPT_MODE_STREAM is an extra mode to include some stream algorithms like WAKE or RC4. HTH Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] su idn't working from within php
Marek Kilimajer wrote: You need to edit /etc/sudoers file and allow apache to execute . And you also need to be carefull what you are doing or you will create a security hole. Nitin Mehta wrote: but how would i store keys for apache? - Original Message - From: "Marek Kilimajer" <[EMAIL PROTECTED]> To: "Nitin Mehta" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, January 27, 2004 4:03 PM Subject: Re: [PHP] su idn't working from within php Why do you need su? Set up sudo for apache user. Nitin Mehta wrote: hi all i was trying to execute some commands as an authorized user from within my php script with exec ("su -c \"sudo \" 2>&1;", $output); but it gives me standard in must be a tty how can i make it work? it runs perfectly at command prompt I even tried to ssh, but the problem is where should i copy the rsa-key generated with keygen, as the scripts are run as apache/http user.. Plz help me out of this Thanx in advance Nitin -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Can I recommend you don't try to add the apache webserver user to your sudoers file? Big no-no. If anyone tries to issue a 'su' command on your server from a web based form for example you could compromise your machine. I have a more elegant solution... create a shell script 'command.sh' and then setup a cron job to execute the script every so often. Let me show you an example... [shell.sh] #!/bin/sh if test -f /path/to/file then echo "file found, proceeding to execute command as root" echo "removing temporary file used to signal process" rm -dfr /path/to/file else echo "file was not found, exiting shell gracefully" exit 0 fi [end shell.sh] [script.php] if(!emtpy($yourvariable)) { echo "variable found, creating temporary file to flag shell script to execute"; system("touch /path/to/file"); } else { echo "variable not present, exiting"; } [end script.php] [crontab ] */5 * * * * /path/to/shell.sh >>/tmp/php_log 2>&1 [end crontab ] *** make sure you are root when adding this command to your cron jobs This way your cronjob runs every five minutes and executes your shell script. Your shell script checks to see if a temporary file is present and if it is executes the command on the server as the root user. No privledge escalation holes. Hope this helps, let me know if it doesn't or if you don't have dedicated hosting. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: variable container?
http://us4.php.net/manual/en/function.var-dump.php HTH Jas Jake McHenry wrote: Is there some global variable container that I can print_r out to show me all the variables that are being used on a page? In my efforts of converting from globals over to sessions, I've been getting a little mis organized with my code, and would like to know of all variables that are in use on each page. Thanks, Jake -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem decrypting data stored in MySQL text field using mcrypt?
Jas wrote: Murray @ Planetthoughtful.Org wrote: Hi All, I'm trying to implement encryption on certain data fields in my MySQL database and I'm experiencing ongoing problems. I seem to be able to encrypt the data without issues, but can't figure out how to decrypt the data. My field in my test table, in which I'm storing the encrypted data, is a TEXT type field. The code I'm using, from the PHP help file, is: [ begin code ] $key = "mysecretkey"; $input = "This is some plain text."; $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); $insq = "INSERT into test (entry) VALUES ('$encrypted_data')"; mysql_query($insq); mcrypt_generic_deinit ($td); mcrypt_module_close ($td); $query = "SELECT entry from test"; $res = mysql_query($query); $row = mysql_fetch_array($res); This is your problem... You are assigning a new variable $res to the database contents mysql_free_result($res); $et = $row["entry"]; $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $key, $iv); $plain = mdecrypt_generic ($td, $et); $contents = count($res); for ($z = 0; $z < $contents; $z++) { $decrypted[] = mdecrypt_generic($cipher, $res[$z]); } Now just print it out... $count = count($decrypted); for ($m = 0; $m < $count; $m++) { print "$decrypted[$m]\n"; } mcrypt_generic_deinit ($td); mcrypt_module_close ($td); echo "$input$et$plain"; [ end code ] The output from the echo statement, which I was expecting to be , is: [ begin echo output] This is some plain text. #faÃÅdÅKÃÂÂÅ"âÃÂâÅâÃÃt #faÃÅdÅKÃÂÂÅ"âÃÂâÅâÃÃt [ end echo output ] I assume some of the characters won't display properly in this post, however I can verify that the (line 2) and (line 3) appear to be identical, where I was expecting the (line 1) and (line 3) to be identical. Can anyone give me an insight into what I'm doing wrong? I'm using PHP version 4.3.4 and Apache 1.3.28 on WindowsXP, if these are meaningful. Any help will be immensely appreciated! Much warmth, Murray http://www.planetthoughtful.org Building a thoughtful planet, One quirky comment at a time. Hope this helps... If you want to see my example just let me know. On another note if you were using mcrypt on linux vs. windows you would have to do something like this to get rid of a small bug in the decoding process... /* Define cipher, stream and key */ $key = "Some kinda secret"; $cipher = mcrypt_module_open('rijndael-256', '', 'ecb', ''); $inv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($cipher), MCRYPT_RAND); mcrypt_generic_init($cipher, $key, $inv); /* Count and begin loop for encryption on every element in array */ $cnt = count($data); $encrypted = $data; $anum = count($encrypted); for ($u = 0; $u < $anum; $u++) { array_shift($encrypted); } for ($b = 0; $b < $cnt; $b++) { $encrypted[] = mcrypt_generic($cipher, $data[$b]); } /* Now loop over array and decrypt the cipher text */ $decrypted = $encrypted; for ($w = 0; $w < $anum; $w++) { array_shift($decrypted); } $wu = count($encrypted); // The chop() function removes some extra padding in the decryption process on linux machines, I didn't experience this problem on windows machines for ($z = 0; $z < $wu; $z++) { $decrypted[] = chop(mdecrypt_generic($cipher, $encrypted[$z])); } $inte = count($decrypted); for ($m = 0; $m < $inte; $m++) { print "$decrypted[$m]\n"; } ?> Sorry but I was just wondering if this solved your problem or not? Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Problem decrypting data stored in MySQL text field using mcrypt?
Murray @ Planetthoughtful.Org wrote: Hi All, I'm trying to implement encryption on certain data fields in my MySQL database and I'm experiencing ongoing problems. I seem to be able to encrypt the data without issues, but can't figure out how to decrypt the data. My field in my test table, in which I'm storing the encrypted data, is a TEXT type field. The code I'm using, from the PHP help file, is: [ begin code ] $key = "mysecretkey"; $input = "This is some plain text."; $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $key, $iv); $encrypted_data = mcrypt_generic ($td, $input); $insq = "INSERT into test (entry) VALUES ('$encrypted_data')"; mysql_query($insq); mcrypt_generic_deinit ($td); mcrypt_module_close ($td); $query = "SELECT entry from test"; $res = mysql_query($query); $row = mysql_fetch_array($res); This is your problem... You are assigning a new variable $res to the database contents mysql_free_result($res); $et = $row["entry"]; $td = mcrypt_module_open ('tripledes', '', 'ecb', ''); $iv = mcrypt_create_iv (mcrypt_enc_get_iv_size ($td), MCRYPT_RAND); mcrypt_generic_init ($td, $key, $iv); $plain = mdecrypt_generic ($td, $et); $contents = count($res); for ($z = 0; $z < $contents; $z++) { $decrypted[] = mdecrypt_generic($cipher, $res[$z]); } Now just print it out... $count = count($decrypted); for ($m = 0; $m < $count; $m++) { print "$decrypted[$m]\n"; } mcrypt_generic_deinit ($td); mcrypt_module_close ($td); echo "$input$et$plain"; [ end code ] The output from the echo statement, which I was expecting to be , is: [ begin echo output] This is some plain text. #faÃÅdÅKÃÂÂÅ"âÃÂâÅâÃÃt #faÃÅdÅKÃÂÂÅ"âÃÂâÅâÃÃt [ end echo output ] I assume some of the characters won't display properly in this post, however I can verify that the (line 2) and (line 3) appear to be identical, where I was expecting the (line 1) and (line 3) to be identical. Can anyone give me an insight into what I'm doing wrong? I'm using PHP version 4.3.4 and Apache 1.3.28 on WindowsXP, if these are meaningful. Any help will be immensely appreciated! Much warmth, Murray http://www.planetthoughtful.org Building a thoughtful planet, One quirky comment at a time. Hope this helps... If you want to see my example just let me know. On another note if you were using mcrypt on linux vs. windows you would have to do something like this to get rid of a small bug in the decoding process... /* Define cipher, stream and key */ $key = "Some kinda secret"; $cipher = mcrypt_module_open('rijndael-256', '', 'ecb', ''); $inv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($cipher), MCRYPT_RAND); mcrypt_generic_init($cipher, $key, $inv); /* Count and begin loop for encryption on every element in array */ $cnt = count($data); $encrypted = $data; $anum = count($encrypted); for ($u = 0; $u < $anum; $u++) { array_shift($encrypted); } for ($b = 0; $b < $cnt; $b++) { $encrypted[] = mcrypt_generic($cipher, $data[$b]); } /* Now loop over array and decrypt the cipher text */ $decrypted = $encrypted; for ($w = 0; $w < $anum; $w++) { array_shift($decrypted); } $wu = count($encrypted); // The chop() function removes some extra padding in the decryption process on linux machines, I didn't experience this problem on windows machines for ($z = 0; $z < $wu; $z++) { $decrypted[] = chop(mdecrypt_generic($cipher, $encrypted[$z])); } $inte = count($decrypted); for ($m = 0; $m < $inte; $m++) { print "$decrypted[$m]\n"; } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Suggestion on executing external programs from within php
Using system in this manner may work for small scripts/programs that only need authentication of the webserver. But for something like restarting a service I use a shell script run as a cron job then just call a system("touch /path/to/temp/file") which the cronjob looks at to see if it should restart a service. just 2 cents Jas Ammar Ibrahim wrote: maybe if you put Call1 and Call2 in seprate PHP files, and you call both of them. i guess it would work Ammar "John Clegg" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi I would like to be able to execute 2 system calls simultaneously. I am not interested in the output and I would like to do the equivalent of a fork as these programs take a long time. eg system('/usr/local/bin/process_file file1'); system('/usr/local/bin/process_file file2'); Any suggestions on what to use??? Cheers John Clegg -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Function for crypt and decript.
[EMAIL PROTECTED] wrote: Hi all, are in PHP, functions for crypt and decrypt string? I would to use this function in my script in PHP, how can I use this? I need of an example for use this and a list of this function. Thanks in advance. base64_decode() and base64_encode() http://us2.php.net/manual/en/ref.url.php crypt() http://us2.php.net/manual/en/function.crypt.php mcrypt() - Must have packages installed, but works very well http://us2.php.net/manual/en/ref.mcrypt.php openssl() - Also must have packages installed http://us2.php.net/manual/en/ref.openssl.php Hope this helps... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Ip Tracking Utilities
Rolf Brusletto wrote: Hey all - I've heard mention of Ip database/tracking utilities in the lists before, but I can't seem to find any mention when googling... does anybody know of a good app to track multiple Class C spaces or larger? Thanks, Rolf Brusletto -- http://www.phpExamples.net http://www.emailfeeds.com -- Have you tried using a system to ping a given range of IP's? http://us4.php.net/manual/en/function.system.php Something like... "192.168.0.2", "1" => "192.168.0.3", etc...); for($i = 0; $i > $network; $i++) { $result = system("ping $network[$i]") if($result != "") { echo "host $network[$i] responded"; } } HTH Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Dynamic Forms
Matt Matijevich wrote: [snip] Can anyone suggest a PHP solution to creating a form that gets built after a client enters a variable? [/snip] php runs on your server so to build the forms based on a user entered form field, the form has to be submitted, so you would have to use javascript to automatically submit the form or have the user push a submit button to susbmit the form so php can do its thing. I don't have a solution or tutorial per se'... Google might. Here is a small example of a self processing form, if it helps. "; } elseif((!empty($_POST['var01'])) || (!empty($_POST['var02']))) { $form = " "; } else { $form = "$_POST[var01] $_POST[var02]"; } echo $form; ?> Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] permissions with bash scripts in php?
Jason Wong wrote: > On Tuesday 13 January 2004 06:46, Jas wrote: > > [Please trim your posts!] > > >>Just tried that and I am getting the same error. I guess what I am >>really looking for is a way to have apache restart the service without >>adding the apache user in the 'sudoers' file. > > > If you really must restart system services over insecure interfaces such as a > web browser then consider using something which was 'tailor-made' for the > purpose eg Webmin. Webmin is not ideal, but since you are having to ask the > question I would assume that it would be better than anything you could come > up with at this moment in time. > > If you still want develop your own, then have a look in the archives for > possible solutions using sudo, or cronjobs. > So instead of having a function to run a bash script which would restart the dhcp service after a new dhcpd.conf file has been written (which would run under the same user as the httpd service). You are suggesting to run a cron job which would maybe run every 5 or 10 minutes to run the bash script which restarts the service? Would this be the most secure method of accomplishing such a task? Or is there a way to put a hook in the bash script which php could execute as a privledged user? Thanks for the insight, Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] permissions with bash scripts in php?
Jake McHenry wrote: - Original Message - From: "Jas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, January 12, 2004 4:47 PM Subject: [PHP] permissions with bash scripts in php? Something I have never tried... seems fairly straight-forward but I am running into problems. My problem is that I need to call system to restart a daemon service like so... /tmp/error "); ?> Script contains this command... #!/bin/bash /path/to/dhcpd -cf /path/to/config/dhcpd So far so good right? I mean it works from a command line so why not from php. Lets check some permissions... httpd as Apache:Apache script.sh as Apache:Apache Upon inspection of 'error file' in /tmp I find this... unable to create icmp socket: Operation not permitted Can't create new lease file: Permission denied And... Can't bind to dhcp address: Permission denied Please make sure there is no other dhcp server running and that there's no entry for dhcp or bootp in /etc/inetd.conf. Also make sure you are not running HP JetAdmin software, which includes a bootp server. So lets set a sticky bit on the script.sh and /path/to/config/dhcpd $> chmod 1777 /path/to/config/dhcpd $> chmod 1777 script.sh So far so good but I am still recieving the same error, if anyone has some good tips on what would be the most efficient & SECURE way of starting this service please point me to the tutorial Thanks a ton. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php is the apache user and group able to run the script from the command line? I know under rh9, you have to be root to start / stop / restart just about all the services. Just an idea. Jake Just tried that and I am getting the same error. I guess what I am really looking for is a way to have apache restart the service without adding the apache user in the 'sudoers' file. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] permissions with bash scripts in php?
Something I have never tried... seems fairly straight-forward but I am running into problems. My problem is that I need to call system to restart a daemon service like so... $cmd = "/path/to/shell/script/script.sh"; system($cmd . " &> /tmp/error "); ?> Script contains this command... #!/bin/bash /path/to/dhcpd -cf /path/to/config/dhcpd So far so good right? I mean it works from a command line so why not from php. Lets check some permissions... httpd as Apache:Apache script.sh as Apache:Apache Upon inspection of 'error file' in /tmp I find this... unable to create icmp socket: Operation not permitted Can't create new lease file: Permission denied And... Can't bind to dhcp address: Permission denied Please make sure there is no other dhcp server running and that there's no entry for dhcp or bootp in /etc/inetd.conf. Also make sure you are not running HP JetAdmin software, which includes a bootp server. So lets set a sticky bit on the script.sh and /path/to/config/dhcpd $> chmod 1777 /path/to/config/dhcpd $> chmod 1777 script.sh So far so good but I am still recieving the same error, if anyone has some good tips on what would be the most efficient & SECURE way of starting this service please point me to the tutorial Thanks a ton. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Not working?
I think I must be missing something but this command isn't renaming the file specified... Pointers, tips appreciated! system("rename('/path/to/new.sh', '/path/to/old.$today')"); /to directory has permissions set to current user and is also owned by the current user (test_user)... I can write files into the directory and delete files form the directory using the 'unlink()' command but the rename function I am having problems with. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Looping problem?
require 'database.php'; $t_02 = "subnets"; $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or die(mysql_error()); while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = mysql_fetch_array($sql_subs)) { $num = mysql_num_rows($sql_subs); for($z = 0; $z < $num; $z++) { $vlans[] = "subnet $subnetmask $msk {option domain-name-servers $dns01, $dns02;option routers $rtrs;range $rnge;}"; } } // Write everything out formated... echo $vlans[$z]\n; Right now it only pulling the last record??? Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Checkboxes?
I am having a problem with checkboxes... $_SESSION['logs'] .= "DateTimeIP AddressPortLog MessageDetails?"; require 'database_script.php'; $table = "logs"; $sql = mysql_query("SELECT * FROM $table ORDER BY date",$db)or die(mysql_error()); while($row = mysql_fetch_array($sql)) { list($id,$date,$time,$ip,$host,$referer,$agent,$page,$pagecount,$message,$session) = $row; $_SESSION['logs'] .= "$date$time$ip$host$message"; } // Begin checking if variables are present... if (empty($_POST['id'])) { unset($_SESSION['details']); $_SESSION['details'] = " You must select an access log(s) to view the details of"; } elseif (!empty($_POST['id'])) { unset($_POST['details']); $_SESSION['details'] = "You have selected record number..."; } else { unset($_SESSION['details']); $_SESSION['details'] = " You must select an access log(s) to view the details of."; } ?> I think it has something to do with the naming or values of the checkboxes but if someone could shed some light on it that would be great. jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function problem?
Not sure why the last section won't work... /* Function to search for hosts */ function search_dhcp() { if ((empty($_POST['search'])) && (empty($_POST['hosts01'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) { unset($_SESSION['search']); $_SESSION['search'] = "Search for individual computers to edit**This feature will search all VLAN's for individual machines to make host configuration changes to.ex. 10.10.0.255 or dhcp-client Wildcards are marked as a '%'."; } elseif ((!empty($_POST['search_name'])) && (empty($_POST['hosts01'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) { unset($_SESSION['search']); require 'dbase.inc.php'; $table = "hosts"; $x = @mysql_query("SELECT * FROM $table WHERE hostname LIKE '$_POST[search_name]'")or die(mysql_error()); $num = mysql_num_rows($x); if($num == "0") { $_SESSION['search'] = "Search for individual computers to edit by hostname**This feature will search all VLAN's for individual machines to make host configuration changes to.(ex. dhcp_client_003) Wildcards are marked as a '%'. No hosts matched your search for $_POST[search_name]."; } elseif ($num != 0) { $_SESSION['search'] .= "Here are your search results.**Please select the machine you wish to make changes to."; while($v = mysql_fetch_array($x)) { list($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v']) = $v; $_SESSION['search'] .= "$_SESSION[hn] | $_SESSION[i] | $_SESSION[v]"; } $_SESSION['search'] .= ""; } else { $_SESSION['search'] = "Search for individual computers to edit by hostname(ex. dhcp_client_003)**This feature will search all VLAN's for individual machines to make host configuration changes to. No hosts matched your search for $_POST[search_name]."; } unset($_SESSION['id'],$_SESSION['hn'],$_SESSION['ma'],$_SESSION['i'],$_SESSION['v']); } elseif ((!empty($_POST['hosts01'])) && (empty($_POST['search'])) && (empty($_POST['hn'])) && (empty($_POST['ma'])) && (empty($_POST['i'])) && (empty($_POST['v']))) { unset($_SESSION['search']); require 'dbase.inc.php'; $table = "hosts"; $x = mysql_query("SELECT * FROM $table WHERE hostname = '$_POST[hosts01]' OR ip = '$_POST[hosts01]' OR mac = '$_POST[hosts01]'")or die(mysql_error()); $num = mysql_num_rows($x); if($num == "0") { unset($_SESSION['search']); $_SESSION['search'] = "Search for individual computers to edit by hostname(ex. dhcp_client_003)**This feature will search all VLAN's for individual machines to make host configuration changes to. You did not select a host to edit."; } elseif ($num != 0) { while($a = mysql_fetch_array($x)) { list($_SESSION['id01'],$hn,$ma,$i,$v) = $a; } $_SESSION['search'] = " You are about to make changes to $hn | $i** Please fill out all fields and be carefull when entering the MAC address. The proper format is as such XX:XX:XX:XX:XX Hostname MAC-Address IP-Address VLAN / Subnet: "; } elseif ((empty($_POST['hosts01'])) && (empty($_POST['search'])) && (!empty($_POST['hn'])) && (!empty($_POST['ma'])) && (!empty($_POST['i'])) && (!empty($_POST['v']))) { unset($_SESSION['search']); // Will not get to this point! $_SESSION['search'] = " Your changes to $_POST[hosts01] were successfull** To make your changes active you must use the \"UPDATE DHCP\" link on the left Hostname $_POST[hn] MAC-Address $_POST[ma] IP-Address $_POST[i] VLAN / Subnet: $_POST[v] "; } else { unset($_SESSION['search']); $_SESSION['search'] = " Something broke, please try again."; } } else { unset($_SESSION['search']); header("Location: login.hosts.php"); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] looping problem?
Problem with looping over a CSV file (3 results for each line)? Here is the CSV file contents... MTPC-01,00:02:B3:A2:9D:ED,155.97.15.11 MTPC-02,00:02:B3:A2:B6:F4,155.97.15.12 MTPC-03,00:02:B3:A2:A1:A7,155.97.15.13 MTPC-04,00:02:B3:A2:07:F2,155.97.15.14 MTPC-05,00:02:B3:A2:B8:4D,155.97.15.15 Here is the script... $row = 1; $file = "fa.csv"; $id = fopen("$file","r"); while($data = fgetcsv($id,100,",")) { $num = count($data); $row++; for($c = 0; $c < $num; $c++) { echo "host $data[0] {\nhardware ethernet $data[1];\nfixed-address $data[2];\n}\n"; } } fclose($id); ?> And this is the output... (notice 3 results for the first line in the CSV file) host MTPC-01 { hardware ethernet 00:02:B3:A2:9D:ED; fixed-address 155.97.15.11; } host MTPC-01 { hardware ethernet 00:02:B3:A2:9D:ED; fixed-address 155.97.15.11; } host MTPC-01 { hardware ethernet 00:02:B3:A2:9D:ED; fixed-address 155.97.15.11; } Any help is appreciated... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] post var check failing?
Not sure why it isn't checking my post vars correctly... any help is appreciated. Thanks in advance Jas while($a = mysql_fetch_array($x)) { list($_SESSION['id01'],$hn,$ma,$i,$v) = $a; } $_SESSION['search'] = "...new form with listed vars..."; } elseif ((empty($_POST['hosts01'])) && (empty($_POST['search'])) && (!empty($_POST['hn'])) && (!empty($_POST['ma'])) && (!empty($_POST['i'])) && (!empty($_POST['v']))) { unset($_SESSION['search']); // FiX POST VAR CHECK ! $_SESSION['search'] = "... show posted vars as successful submission ..." -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Script timeout Problem
Ok, I posted an example in the body of this for your time out limits but here it is again... At the end of each of your SQL statements for UPDATE or INSERT simply add ...LIMIT 2000"; That should limit the updating or inserting of database records until the page is refreshed to add more... HTH Jas Haseeb Iqbal wrote: how can i do that? btw the script runs on a local machine but updates the records on a webserver i mean live server. this is also a factor for the timeout. the script was running smoothly for 24000 recods before but now it suddenly timeout after 800records. i dont know what is heppening Haseeb - Original Message - From: "Jas" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 19, 2003 3:16 AM Subject: [PHP] Re: Script timeout Problem Have you tried setting a limit on your MySQL insert and update statements to limit the amount trying to be processed? Haseeb Iqbal wrote: hi, i need to update a mysql table with a dbf file, the dbf file contains more then 16 records. i knew that the script will not be able to update 16 records in 1 go so i am refreshing the page after speacific no of records. but still the same problem. the script timeout.i tried changing the timeout limit to 300 secs but to noavail. i am pasting the code here.plz take a look may by you can tell me what i am doing wrong define("_MySqlEnable",TRUE); set_time_limit(0); require_once(strPath."paths.php"); $strDBName=strPath."uploads/".Date("d-m-Y")."-products.dbf"; $DBPointer=dbase_open($strDBName,0) or die("Cannot open file for reading"); $nNoOfRecs=dbase_numrecords($DBPointer); $nLoopBreak=1500; $nConn=GetCon(); if (empty($nLoopStart)) { $nLoopStart=1; } if ($nNoOfRecs > $nLoopBreak) { $nLoopTill=$nLoopStart + $nLoopBreak; $nFinal=FALSE; } else { $nLoopTill=$nLoopBreak; $nFinal=TRUE; } for ($nCount=$nLoopStart;$nCount<=$nLoopTill;$nCount++) { $arrData=dbase_get_record($DBPointer,$nCount); $GRP=CheckString($arrData[0]); $CAT=CheckString($arrData[1]); $SUB=CheckString($arrData[2]); $VEND_CODE=CheckString($arrData[3]); $MANU_PART=CheckString($arrData[4]); $PART_NUM=CheckString($arrData[5]); $DESCR=CheckString($arrData[6]); $COST=CheckString($arrData[7]); $RETAIL=CheckString($arrData[8]); $QTY=CheckString($arrData[9]); $LIST_PRICE=CheckString($arrData[10]); $EFF_DATE=CheckString($arrData[11]); $TECH_FAX=CheckString($arrData[12]); $STATUS=CheckString($arrData[13]); $UPC=CheckString($arrData[14]); $strQuery="SELECT * FROM products WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $nConn->doQuery($strQuery); if ($nConn->cntResult()==0) $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products. manu_part,products.part_num,products.desc,products.cost,products.retail,prod ucts.qty,products.list_price,products.eff_date,products.tech_fax,products.st atus,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','" $PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRI CE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."')"; $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products. manu_part,products.part_num,products.desc,products.cost,products.retail,prod ucts.qty,products.list_price,products.eff_date,products.tech_fax,products.st atus,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','" $PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRI CE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."' LIMIT 200)"; else $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$R ETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$T ECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$R ETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$T ECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'LIMIT 200"; //echo "nCOunt - > $nCount -".$strQuery; $nConn->doQuery($strQuery); } $nCount++; $nLoopStart=$nCount; if ($nFinal==FALSE) { //1500 records updated so refresh the page ?> Haseeb That might help out with the timeouts too. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Script timeout Problem
Let me know if that solves your problem if you would be so kind... I am sure it will but I just want to make sure. Jas Jas wrote: Have you tried setting a limit on your MySQL insert and update statements to limit the amount trying to be processed? Haseeb Iqbal wrote: hi, i need to update a mysql table with a dbf file, the dbf file contains more then 16 records. i knew that the script will not be able to update 16 records in 1 go so i am refreshing the page after speacific no of records. but still the same problem. the script timeout.i tried changing the timeout limit to 300 secs but to noavail. i am pasting the code here.plz take a look may by you can tell me what i am doing wrong define("_MySqlEnable",TRUE); set_time_limit(0); require_once(strPath."paths.php"); $strDBName=strPath."uploads/".Date("d-m-Y")."-products.dbf"; $DBPointer=dbase_open($strDBName,0) or die("Cannot open file for reading"); $nNoOfRecs=dbase_numrecords($DBPointer); $nLoopBreak=1500; $nConn=GetCon(); if (empty($nLoopStart)) { $nLoopStart=1; } if ($nNoOfRecs > $nLoopBreak) { $nLoopTill=$nLoopStart + $nLoopBreak; $nFinal=FALSE; } else { $nLoopTill=$nLoopBreak; $nFinal=TRUE; } for ($nCount=$nLoopStart;$nCount<=$nLoopTill;$nCount++) { $arrData=dbase_get_record($DBPointer,$nCount); $GRP=CheckString($arrData[0]); $CAT=CheckString($arrData[1]); $SUB=CheckString($arrData[2]); $VEND_CODE=CheckString($arrData[3]); $MANU_PART=CheckString($arrData[4]); $PART_NUM=CheckString($arrData[5]); $DESCR=CheckString($arrData[6]); $COST=CheckString($arrData[7]); $RETAIL=CheckString($arrData[8]); $QTY=CheckString($arrData[9]); $LIST_PRICE=CheckString($arrData[10]); $EFF_DATE=CheckString($arrData[11]); $TECH_FAX=CheckString($arrData[12]); $STATUS=CheckString($arrData[13]); $UPC=CheckString($arrData[14]); $strQuery="SELECT * FROM products WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $nConn->doQuery($strQuery); if ($nConn->cntResult()==0) $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."')"; $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."' LIMIT 200)"; else $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'LIMIT 200"; //echo "nCOunt - > $nCount -".$strQuery; $nConn->doQuery($strQuery); } $nCount++; $nLoopStart=$nCount; if ($nFinal==FALSE) { //1500 records updated so refresh the page ?> } else { // all records updated so redirst to calling page. ?> } ?> Haseeb That might help out with the timeouts too. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: picking up a form name
Do you mean a variable being passed to the next page from within a form ex. or If you are talking about the input name for a text box use this snippit... is(empty($_POST['variable_001']) { // Do negative result code } elseif(!empty($_POST['variable_001']) { // Do positive result code ... Or if it the name of the "actual form" you want try setting a hidden field with the same name as the form. ex. HTH Jas Php wrote: Hi, If I have more than one form on a page, how can I get the name of the form that was sent on the recieving page without using javascript? tia, Craig TOP DRAW INC. p 780.429.9993 f 780.426.1199 [EMAIL PROTECTED] www.topdraw.com 10210 - 111 Street, Edmonton, Alberta T5K 1K9 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Script timeout Problem
Have you tried setting a limit on your MySQL insert and update statements to limit the amount trying to be processed? Haseeb Iqbal wrote: hi, i need to update a mysql table with a dbf file, the dbf file contains more then 16 records. i knew that the script will not be able to update 16 records in 1 go so i am refreshing the page after speacific no of records. but still the same problem. the script timeout.i tried changing the timeout limit to 300 secs but to noavail. i am pasting the code here.plz take a look may by you can tell me what i am doing wrong define("_MySqlEnable",TRUE); set_time_limit(0); require_once(strPath."paths.php"); $strDBName=strPath."uploads/".Date("d-m-Y")."-products.dbf"; $DBPointer=dbase_open($strDBName,0) or die("Cannot open file for reading"); $nNoOfRecs=dbase_numrecords($DBPointer); $nLoopBreak=1500; $nConn=GetCon(); if (empty($nLoopStart)) { $nLoopStart=1; } if ($nNoOfRecs > $nLoopBreak) { $nLoopTill=$nLoopStart + $nLoopBreak; $nFinal=FALSE; } else { $nLoopTill=$nLoopBreak; $nFinal=TRUE; } for ($nCount=$nLoopStart;$nCount<=$nLoopTill;$nCount++) { $arrData=dbase_get_record($DBPointer,$nCount); $GRP=CheckString($arrData[0]); $CAT=CheckString($arrData[1]); $SUB=CheckString($arrData[2]); $VEND_CODE=CheckString($arrData[3]); $MANU_PART=CheckString($arrData[4]); $PART_NUM=CheckString($arrData[5]); $DESCR=CheckString($arrData[6]); $COST=CheckString($arrData[7]); $RETAIL=CheckString($arrData[8]); $QTY=CheckString($arrData[9]); $LIST_PRICE=CheckString($arrData[10]); $EFF_DATE=CheckString($arrData[11]); $TECH_FAX=CheckString($arrData[12]); $STATUS=CheckString($arrData[13]); $UPC=CheckString($arrData[14]); $strQuery="SELECT * FROM products WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $nConn->doQuery($strQuery); if ($nConn->cntResult()==0) $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."')"; $strQuery="INSERT INTO products(products.grp,products.cat,products.sub,products.vend_code,products.manu_part,products.part_num,products.desc,products.cost,products.retail,products.qty,products.list_price,products.eff_date,products.tech_fax,products.status,products.upc) VALUES('".$GRP."','".$CAT."','".$SUB."','".$VEND_CODE."','".$MANU_PART."','".$PART_NUM."','".$DESCR."','".$COST."','".$RETAIL."','".$QTY."','".$LIST_PRICE."','".$EFF_DATE."','".$TECH_FAX."','".$STATUS."','".$UPC."' LIMIT 200)"; else $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'"; $strQuery="UPDATE products SET products.part_num='$PART_NUM',products.desc='$DESCR',COST='$COST',retail='$RETAIL',qty='$QTY',list_price='$LIST_PRICE',eff_date='$EFF_DATE',tech_fax='$TECH_FAX',status='$STATUS',upc='$UPC' WHERE grp='".$GRP."' AND cat='".$CAT."' AND sub='".$SUB."' AND vend_code='".$VEND_CODE."' AND manu_part='".$MANU_PART."' AND part_num='".$PART_NUM."'LIMIT 200"; //echo "nCOunt - > $nCount -".$strQuery; $nConn->doQuery($strQuery); } $nCount++; $nLoopStart=$nCount; if ($nFinal==FALSE) { //1500 records updated so refresh the page ?> } else { // all records updated so redirst to calling page. ?> } ?> Haseeb That might help out with the timeouts too. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Security Question
Does your php.ini have Globals set to off? Was your php installation compiled with session support? If your answer to both of those questions is yes (you can check your server config with a page containing this string ) Then use session to register a variable such as the example below... Then say on your authentication module you do something like this function authentication() { if (!empty($_POST['username'])) && (!empty($_POST['password'])) { // some code to check if username and password variables match database entries or file containing credentials // if a match is found do the rest of the code session_start(); $_SESSION['auth'] = base64_encode(1); //encoded var to deter session hijacking } else { header("location: login.html"); } ?> Hope this helps a bit... more info on stuff like this is available at google.com. =) Jas Thomas Andersen wrote: Hello, I'm trying to develop a secure web based application and my only tools are php, mysql, and a SSL connection. Does anyone know of any good references for this kind of development? What I really need to do is to make sure that given users only gain access to the parts of the application they are given rights to. I'm not sure if I need to pass their user information along from page to page or if I should set a cookie or whatever else would be appropriate. I also want people to be bounced back to the login page if they enter a direct URL to part of the application without logging in first, and I also want people to be able to log out. Thanks, Thomas Andersen -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php compile error with mysql undefined reference to `mysql_real_escape_string'
You really should be subscribing to the php.install list when asking questions of this type. But it sounds like you need to first install mysql, then install apache, then install php. In that order and you should be ok. When in doubt read the manuals for each application for further information on the different options available for your ./configure. HTH Jas Ivone Uribe wrote: Hi all! I'm installing php4.3.3, apache 1.3.28 with mysql3.22.32 I'm using this option --with-mysql=/usr/local/mysql But when I compile the php code, I get this error: ext/mysql/php_mysql.o: In function `zif_mysql_client_encoding': /root/fuente/archivos/php-4.3.3/ext/mysql/php_mysql.c:1118: undefined reference to `mysql_character_set_name' ext/mysql/php_mysql.o: In function `zif_mysql_real_escape_string': /root/fuente/archivos/php-4.3.3/ext/mysql/php_mysql.c:1705: undefined reference to `mysql_real_escape_string' collect2: ld returned 1 exit status To solve it..I try the option --disable-cli on ./configure, and all ok. But now I have the same problem (/php-4.3.3/ext/mysql/php_mysql.c:1118: undefined reference to `mysql_character_set_name') when I try to compile the apache... Please!!! Does anybody know how to solve it? Thanks in advance!! __ Do you Yahoo!? Free Pop-Up Blocker - Get it now http://companion.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: 4 project questions - help appreciated
1. MySQL is free, fairly easy to use and is way better than using a text file. 2. I would use something to effect of a 'id' field in the database and set that to be indexed, auto-incrementing and unique vs. using your 'public key' as the indexed portion of the database 3. Sounds like you already know what kind of function you need. If you need an example here is one. [snippit] function keys() { /* Connect to database */ $db = @mysql_pconnect('localhost','user_name','password') or die(mysql_error()); /* Select databse to use */ @mysql_select_db('keys') or die("Could not connect to remote database."); $tble = "messages"; /* Look for existing key */ $sql = mysql_query("SELECT * FROM $tble WHERE key = '$key'",$db)or die(mysql_error()); /* Create array of variables retrieved */ while ($row = mysql_fetch_array($sql)) { $id = $row["session"]; } /* Check to see if any results were returned */ if (mysql_num_rows($sql) == 0) { $insert = @mysql_query("INSERT INTO $tble VALUES ('','$var1','$var2','$var3','$var4','$var5')",$db)or die(mysql_error()); /* If key exists update data with form data */ } elseif (mysql_num_rows($sql) != 0) { $update = @mysql_query("UPDATE $tble SET var1=\"$var1\", var2=\"$var2\", var3=\"$var3\", var4=\"$var4\", var5=\"$var5\" WHERE key=\"$key\"",$db)or die(mysql_error()); } else { exit(); } } else { exit(); } } ?> [end snippit] 4. You are talking about a one way hash to be used as a public key right? If you are I generate a unique key in this manner (I really don't loop through any array's of numbers or letters) instead I pull an image randomly selected from a specified directory and then through it through a system of functions as illustrated below. You can record the key in the database and use it as a "public key" so to speak so the person your sending the secret message to would need to know that "public key". [snippit] /* Function to create array of images */ $rand_image = array(); $x = 0; $x++; $rand_image[$x] = "shared/image01.jpg"; $x++; $rand_image[$x] = "shared/image02.jpg"; $x++; $rand_image[$x] = "shared/image03.jpg"; $x++; $rand_image[$x] = "shared/image04.jpg"; /* Randomly select image to encrypt and use as session variable */ function random_image() { global $rand_image; srand ((double) microtime() * 100); print $rand_image[rand(1,sizeof($rand_image))]; } /* Encryption function for random image */ $hash = md5(uniqid(microtime($rand_image),1)); } echo $hash; ?> [end snippit] Hope that helps some... Jas Ryan A wrote: Hi, I am making a personal project like so: I enter something in the text box (eg. "PHP REALLY ROCKS!!!") then the program checks if that string already exists in the database, if no, then it should enter it into the database and also generate a "key" This key can be given to pals and they can read the "secret message" Key: Key should first be 1-1000 then a-z then A-Z then axxx (eg: a001, the xxx will always be numbers) once it reaches 999 it should become Axxx then b then B etc after a,A,b,B are done it should go for aaxx,AAxx etc always 4 characters A few questions: 1.Looking at the above (database part) I figured that doing this via a mysql database would be better rather than a text database...do you agree? 2.I was thinking of making the "key" field a primary key and unique and indexedright? 3.The way I see it theres 3 sql statements that need to be run, a) connect and see if string exists b)read the last key c)write to the database...anyway to break the above to 2 statements or am I following this wrong? 4. Logic for the key, I am coming up with crummy logic to make the "key", basically a block of code for 1-1000,another block for a-z another block for A-Z etc.. any ideas,links,URLs or code snippets off the top of your head would be greatly appreciated. Thanks in advance. Cheers, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: var check not working...
Sven wrote: Jas schrieb: For some reason this will not work... my $_POST variables check for no form variables and display a form... if they choose an item from a select box it queries the database for a field matching the $_post var and builds a new form creating 8 separate $_post variables to check for.. so far it works except when selecting an item from the select box it will only display the first form when there are $_post vars present. I think I am missing something, could someone look over my code? Thanks in advance, Jas function vlans_dhcp() { $lvl = base64_decode($_SESSION['lvl']); if ($lvl != "admin") { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } elseif ($lvl == "admin") { $_SESSION['lvl'] = base64_encode($lvl); if (($_POST == "") || (!isset($_POST['dhcp_vlans'])) || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 1st form with dhcp_vlans as $_post var; } elseif (($_POST != "") || (isset($_POST['dhcp_vlans'])) || ($_POST['dhcp_vlans'] != "--") || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 2nd form based on dhcp_vlans $_post var and create 8 different $_post vars...; } elseif (($_POST != "") || (!isset($_POST['dhcp_vlans'])) || (isset($_POST['id'])) || (isset($_POST['sub'])) || (isset($_POST['msk'])) || (isset($_POST['dns01'])) || (isset($_POST['dns02'])) || (isset($_POST['rtrs'])) || (isset($_POST['rnge'])) || (isset($_POST['vlans']))) { now put 8 $_post vars in database...; } else { $_SESSION['lvl'] = base64_encode($lvl); header("Location: help.php"); } } else { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } } hi jas, the problem is, that your second form is only executed if your first condition is false (else if). but because of your or condition (||) only one of them has to be true. right? right! so it doesn't matter if your $_POST['dhcp_vlans'] is not set, when any other isn't set. a solution might be: hth SVEN Yah I figured that out.. those operators always throw me off... Thanks again. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Q on RegExp & extended Char
Well have you thought about maybe an array of illegal or extended characters and simply replacing them? eg. $b = $_POST['whatever_variables_you_have']; $match = array("ö","ç","ä"); $replace = array("o","c","a"); $z = str_replace($match,$replace,$b); Might not be exactly what you want but hope it helps. Jas Jswalter wrote: I've hit my limit on regular expressions. I need to check a string to see if it contains legal characters... A thru Z [a-z], SPACE, PERIOD, DASH/HYPHEN, APOSTROPHE [\' -,\.] OK, this is not a problem. My problem comes in with extended characters, as these examples... González Vänligen före innehålla I'm trying to build a RegExp that will see if the string is a proper name format or not. Names only have A thru Z, extended characters for other languages (than English), SPACE, PERIOD, DASH/HYPHEN, APOSTROPHE Dr. Roger O'Malley Mrs. Sara Harris-Henderson I have a RegExp to do English letters, but not the extended set... Manuel González Försök Bokstäver Contém Espaço-Válido (Ok, these are not really names, but you get the idea) Any ideas on this? All I want to know is if a given string contains only these types of characters. anything else would give me a FALSE. Thanks Walter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] var check not working...
For some reason this will not work... my $_POST variables check for no form variables and display a form... if they choose an item from a select box it queries the database for a field matching the $_post var and builds a new form creating 8 separate $_post variables to check for.. so far it works except when selecting an item from the select box it will only display the first form when there are $_post vars present. I think I am missing something, could someone look over my code? Thanks in advance, Jas function vlans_dhcp() { $lvl = base64_decode($_SESSION['lvl']); if ($lvl != "admin") { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } elseif ($lvl == "admin") { $_SESSION['lvl'] = base64_encode($lvl); if (($_POST == "") || (!isset($_POST['dhcp_vlans'])) || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 1st form with dhcp_vlans as $_post var; } elseif (($_POST != "") || (isset($_POST['dhcp_vlans'])) || ($_POST['dhcp_vlans'] != "--") || (!isset($_POST['sub'])) || (!isset($_POST['msk'])) || (!isset($_POST['dns01'])) || (!isset($_POST['dns02'])) || (!isset($_POST['rtrs'])) || (!isset($_POST['vlans']))) { create 2nd form based on dhcp_vlans $_post var and create 8 different $_post vars...; } elseif (($_POST != "") || (!isset($_POST['dhcp_vlans'])) || (isset($_POST['id'])) || (isset($_POST['sub'])) || (isset($_POST['msk'])) || (isset($_POST['dns01'])) || (isset($_POST['dns02'])) || (isset($_POST['rtrs'])) || (isset($_POST['rnge'])) || (isset($_POST['vlans']))) { now put 8 $_post vars in database...; } else { $_SESSION['lvl'] = base64_encode($lvl); header("Location: help.php"); } } else { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] (0/T) executeing script below public
LMAO, I am in concordance. Jas Ryan A wrote: One wonders how two retards got together to give birth to a bigger retard like you. Hi, I am a bit puzzled here, I have to wipe my a$$ after taking a $hit...but I have to wipe while i'm on the toilet! My usual way is to stand up and do it. I noticed one funny thing about this way, its hard to get all that crap in one swipe...what kind of $hit is this? According to the documentation, the a$$ should be wiped in one of two motions like so Place toilet paper at forward most side of anus and wipe backward (or) Place toilet paper at backward most side of anus and wipe forward How do I do that? Thanks, -Riene fyi- my toilet is a flush-master 3001, if that matters. -Original Message- From: Ryan A [mailto:[EMAIL PROTECTED] Sent: Friday, December 12, 2003 4:08 PM To: [EMAIL PROTECTED] Subject: [PHP] (0/T) executeing script below public Hi, Am a bit puzzled here, we have to run a script to start/stop a serverbut we have to run the script below the public folder! this is our structure /blah/theServer/public_html/ the script is located in /blah/theServer/ I noticed one funny thing about this script, it starts with: #!/bin/sh right on top but does not have a file extention...what kind of a file is this? According to the documentation the script has to be executed like so start (or) stop How do I do that? Thanks, -Ryan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] session var not being passed?
New set of eyes maybe or maybe I am indeed regressing... Page calling functions looks like such... require 'sessions.php'; require 'inc.php'; if (($_SESSION['user'] == "") || ($_SESSION['pass'] == "") || ($_SESSION['lvl'] == "")) { $_SESSION['msg_01'] = "You have not entered the correct authorization information. Please enter your user name, password & department ID."; $_SESSION['msg'] = $dberrors[1]; call_user_func("db_logs"); //call_user_func("exit_app"); } elseif (($_SESSION['user'] != "") || ($_SESSION['pass'] != "") || ($_SESSION['lvl'] != "")) { if ((strlen($_SESSION['user'] >= 255)) || (strlen($_SESSION['pass'] >= 255)) || (strlen($_SESSION['lvl'] >= 255))) { $_SESSION['msg'] = $dberrors[3]; call_user_func("db_logs"); call_user_func("exit_app"); } elseif ((strlen($_SESSION['user'] <= 255)) || (strlen($_SESSION['pass'] <= 255)) || (strlen($_SESSION['lvl'] <= 255))) { $_SESSION['msg'] = $dberrors[10]; call_user_func("db_logs"); call_user_func("menu"); } else { $_SESSION['msg'] = $dberrors[11]; call_user_func("db_logs"); call_user_func("exit_app"); } } else { $_SESSION['msg'] = $dberrors[8]; call_user_func("db_logs"); call_user_func("exit_app"); } ?> Then in body of page I call Now the contents of inc.php is below (at least the "menu" and "dhcp_vlans" functions) function menu() { $lvl = base64_decode($_SESSION['lvl']); if ($lvl == "view") { $_SESSION['menu'] = "custom menu 01"; $_SESSION['lvl'] = base64_encode($lvl); } elseif ($lvl == "user") { $_SESSION['menu'] = "custom menu 02"; $_SESSION['lvl'] = base64_encode($lvl); } elseif ($lvl == "admin") { $_SESSION['menu'] = "custom menu 03"; $_SESSION['lvl'] = base64_encode($lvl); } else { $_SESSION['menu'] = "custom menu 04"; } $_SESSION['lvl'] = base64_encode($lvl); // recreate session variable for more checks } function vlans_dhcp() { $lvl = base64_decode($_SESSION['lvl']); // this session variable is dissapearing from the second nested if / elseif statement? if ($lvl != "admin") { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } elseif ($lvl == "admin") { $_SESSION['lvl'] = base64_encode($lvl); if ($_POST == "") { $_SESSION['lvl'] = base64_encode($lvl); session_unset($_SESSION['list']); ,create automatic form..."; $_SESSION['lvl'] = base64_encode($lvl); //unset($table,$sql,$db_vlans,$vlans,$x); } elseif ($_POST != "") || (isset(var)) { //What happened to my session 'lvl' var? ...creat different form... } elseif ($_POST != "") { session_unset($_SESSION['list']); require 'dbase.php'; $table = "subnets"; $_SESSION['list'] = "...different form again..."; //unset($table,$db_vlans,$vlans,$i,$x); } else { $_SESSION['lvl'] = base64_encode($lvl); header("Location: login.vlans.php"); } } else { $_SESSION['lvl'] = base64_encode($lvl); $_SESSION['msg'] = $dberrors[12]; call_user_func("db_logs"); } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php .htaccess autologin
Combination of session vars and cookie vars... example... [login page] sets cookie with auth=0 (variable) sets session with auth=0 (variable) [logged in page(s)] sets cookie with auth=1 (variable -client side) sets session with auth=1 (variable -server side) hash of users password as client side var then just write a function to look on the users machine for a cookie from your site with auth=1, then if you see that present simply authenticate the user. HTH Jas Evan Nemerson wrote: On Thursday 11 December 2003 04:17 pm, ROBERT MCPEAK wrote: I've dug around quite a bit and can't figure out how I might use PHP to handle an .htaccess login. For example, if I wanted a script to log in the user, rather than the user logging in with the standard .htaccess dialog. Any ideas? I could be wrong, but I think this would be rather client-dependent. I don't think HTTP remembers who you throughout a session- i think the headers get sent every time. My only idea from PHP would be to set the $_SERVER['PHP_AUTH_*'] stuff, but i sincerely doubt that would do anything. I just don't think there's a way to ask the browser to set that info through http. Maybe ask @ javascript forum? If you find a solution, I'd love to hear it... Since the .htaccess vars are stored in the browser, should I be looking at a PHP/JavaScritpt 1-2 punch? Thanks, Bob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to reduce CPU usage in a cycle? [ag]
ex. function rand($attack,$skills,$damage,$armor) { $do = array($attack,$skills,$damage,$armor); finish=false while (!finish) { $do = mt_rand(mktime(microtime(1,100)); } while($do = list($attack,$skills,$damage,$armor)) { calculate total damage for opponent } } ?> I read that the use of mt_rand will produce the same results each time the page is called with a certain number... so I would recommend using microtime in conjunction with your mt_rand calls to ensure true random numbers. By throwing your vars into an array and looping through it applying your random points deduction then listing the contents of the array (with new values) it might improve cpu performance but then again. I am still fairly new to php. Jas Jas wrote: Well have you tried to define one function to include the for all variables that require mt_rand()? Jas Brent Baisley wrote: Personally, I wouldn't worry about it unless it is actually interfering with other processes. The OS will give any process or thread 100% of the CPU if there is nothing else that needs the CPU. What does you context switching numbers look like? If there is a lot of context switching, then your processes or threads are getting kicked off the CPU before they can accomplish much. And that's a problem. The duration of your script is less than a second, so that's not really a long enough time have an affect on other parts of the system. Heck, it may even being completing within just a couple of time slices (the length of time the OS allows a process/thread to use the CPU). You could always adjust the priority level (nice value in Unix) of whatever PHP is running under (i.e. Apache). Although you should understand what you are doing if you are adjusting nice values. On Dec 11, 2003, at 10:03 AM, TauAlex wrote: Hello! I'm having a problem with my php script on my linux web server. In that script there is a cycle with some math calculations (about ~30 steps), the execution time is less 1 second, but the script loads the server CPU up to 90%... I've optimized script already to the minimum math function, anyway, it still overloads the CPU. How can I reduce the CPU load? It seems that usleep() does not help much, especially in Windows (it's not supported). How can I give system a portion of time in the end of each step (I don't mind if it will increase the job time)? Is there a solution for both Windows and Linux? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to reduce CPU usage in a cycle? [ag]
Well have you tried to define one function to include the for all variables that require mt_rand()? Jas Brent Baisley wrote: Personally, I wouldn't worry about it unless it is actually interfering with other processes. The OS will give any process or thread 100% of the CPU if there is nothing else that needs the CPU. What does you context switching numbers look like? If there is a lot of context switching, then your processes or threads are getting kicked off the CPU before they can accomplish much. And that's a problem. The duration of your script is less than a second, so that's not really a long enough time have an affect on other parts of the system. Heck, it may even being completing within just a couple of time slices (the length of time the OS allows a process/thread to use the CPU). You could always adjust the priority level (nice value in Unix) of whatever PHP is running under (i.e. Apache). Although you should understand what you are doing if you are adjusting nice values. On Dec 11, 2003, at 10:03 AM, TauAlex wrote: Hello! I'm having a problem with my php script on my linux web server. In that script there is a cycle with some math calculations (about ~30 steps), the execution time is less 1 second, but the script loads the server CPU up to 90%... I've optimized script already to the minimum math function, anyway, it still overloads the CPU. How can I reduce the CPU load? It seems that usleep() does not help much, especially in Windows (it's not supported). How can I give system a portion of time in the end of each step (I don't mind if it will increase the job time)? Is there a solution for both Windows and Linux? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array problem....
Yeah I understand that and it would be perfect if I only had to call this type of function once on a page... and on any other pages that need something like this I will do it that way but with the counter set to 0 or whatever number I choose which is a sort of view all page so your solutions works better for this page. Thanks again. Jas Chris W. Parker wrote: Jas <mailto:[EMAIL PROTECTED]> on Thursday, December 11, 2003 7:21 AM said: Well just so you understand "why" I needed something like that here is the finished result below [snip] $i = 0; while(list(...) = mysql_fetch_row(...)) { $_SESSION[$i] = "..."; $i++; } I want to change my suggestion and recommend that you go along with what John Holmes suggested a little after my post. Read his post again and see if it is helpful to you. Keep note of the following aspect: You can remove the $i = 0; and the $i++; by changing $_SESSION[$i] = "..."; to $_SESSION[] = "...";. i.e. The following two code blocks perform the same task: Current: $i = 0; while(list(...) = mysql_fetch_row(...)) { $_SESSION[$i] = "..."; $i++; } New: while(list(...) = mysql_fetch_row(...)) { $_SESSION[] = "..."; } Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to reduce CPU usage in a cycle? [ag]
Can we get the code posted so we know what is going on? Sometimes there are a dozen different ways to accomplish the same objective and looking at what your code is doing may assist us in assisting you. Jas Taualex wrote: Hello! I'm having a problem with my php script on my linux web server. In that script there is a cycle with some math calculations (about ~30 steps), the execution time is less 1 second, but the script loads the server CPU up to 90%... I've optimized script already to the minimum math function, anyway, it still overloads the CPU. How can I reduce the CPU load? It seems that usleep() does not help much, especially in Windows (it's not supported). How can I give system a portion of time in the end of each step (I don't mind if it will increase the job time)? Is there a solution for both Windows and Linux? For instance, in C++ under Windows I would do this: do { [... math calculations ...] while(::PeekMessage(&message,NULL,0,0,PM_NOREMOVE)) if (!theApp.PumpMessage()) break; } while(!quit); This gives system to redraw screen, process any other events during long cycles... Is there similar approach in PHP for web server programming? p.s. Would be nice to know other techniques to reduce CPU load ;) Thank you! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array problem....
Well just so you understand "why" I needed something like that here is the finished result below function show() { require 'path/to/dbconnector.inc'; $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or die(mysql_error()); $i = 0; while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = mysql_fetch_row($sql_subs)) { $_SESSION[$i] = "subnet $subnetmask $msk {option domain-name-servers $dns01, $dns02;option routers $rtrs;range $rnge;}"; $i++; } ?> Then ... And you get... subnet 128.110.22.110 netmask 255.255.255.0 { option domain-name-servers 128.110.22.4, 128.110.29.3; option routers 128.110.22.1; range ; } Which allows for easy reading of configuration variables and the ability to modify the individual vars using a form etc. Thanks again for all who gave me some pointers on using numbers instead of names for my session vars. Jas Chris W. Parker wrote: Jas <mailto:[EMAIL PROTECTED]> on Wednesday, December 10, 2003 3:44 PM said: having no idea you could use numbers as session variable names I kinda feel like a retard right now. You solution worked, thank you very much. It's an array just like any other which you probably realize now. ;) Also, unless you're doing some math or something with those variables you might to split them up into their own cells (I don't really know if this is going to be useful for you or not): { $_SESSION[$iCtr]['var1'] = $var1; $_SESSION[$iCtr]['var2'] = $var2; $_SESSION[$iCtr]['var3'] = $var3; $_SESSION[$iCtr]['var4'] = $var4; $_SESSION[$iCtr]['var5'] = $var5; ... } HTH, Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Array problem....
having no idea you could use numbers as session variable names I kinda feel like a retard right now. You solution worked, thank you very much. Jas Chris W. Parker wrote: Jas <mailto:[EMAIL PROTECTED]> on Wednesday, December 10, 2003 3:21 PM said: while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = mysql_fetch_row($sql_subs)) { $_session[''] = "$sub+$msk+$dns01... } No exactly sure what you mean but here goes: $iCtr = 0; while(list(...)) = mysql_fetch_row(...)) { $_SESSION[$iCtr] = "$sub+$msk..."; $iCtr++; } HTH, Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Array problem....
Not very good at arrays so I figured i would look here $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or die(mysql_error()); while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = mysql_fetch_row($sql_subs)) { print $sub; print ""; print $msk; print ""; print $dns01; print ""; print $dns02; print ""; } ?> This pulls each row form a table and assigns a variable to each field, but what I need to do is something like this... $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or die(mysql_error()); while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge) = mysql_fetch_row($sql_subs)) { $_session[''] = "$sub+$msk+$dns01... } I have been scouring the various functions and as of yet have yet to accomplish what I need. Any help would be great. Thanks in advance, jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new set of eyes?
Ok well I think I have it partially solved... $table = "settings"; $db_vlans = array("hosts01","hosts02","hosts03","hosts04","hosts05","hosts06","hosts07","hosts08","hosts09","hosts10"); $vlans = array("VLAN-22","VLAN-27","VLAN-29","VLAN-56","VLAN-57","VLAN-151","VLAN-314","Empty-01","Empty-02","Empty-03"); $i = str_replace($vlans,$db_vlans,$_POST['dhcp_hosts']); $_SESSION['dhcp_table'] = $i; $sql = mysql_query("SELECT $i FROM $table WHERE $i = $i",$db)or die(mysql_error()); $result = array(); while($b = mysql_fetch_array($sql)) { $result[] = explode(" ",$b); print_r($result); $num = count($result); print $num; for ($x = 0; $x < $num; $x++) { print "$result[$x]\n"; } ?> On data in "one" field that looks like: host dhcp-01 { hardware ethernet 00:D0:B7:BD:D2:8D; fixed-address 155.97.1.190; } host dhcp-02 { hardware ethernet 00:02:B3:A2:B6:FD; fixed-address 155.97.1.191; } Is returning this: Array ( [0] => Array ( [0] => Array ) ) 1Array So it sees 1 array and inside are two indexes both containing a new array... now I need to know how to pull the contents out of the second arrays. Sorry, still trying to figure out arrays. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] new set of eyes?
I should probably clarify a bit more on the data in the field and what I am trying accomplish.. First the data: host dhcp-01 { hardware ethernet 00:D0:B7:BD:D2:8D; fixed-address 155.97.1.190; } host dhcp-02 { hardware ethernet 00:02:B3:A2:B6:FD; fixed-address 155.97.1.191; } Second the plan: Trying to break up (only one row in database & always will be only one row to retrieve) contents of field into an array so I can break it down into individual editable fields (eg. etc.) the explode() is so I can separate numerous static dhcp hosts into one big array of each setting. eg. $hosts = array("0" => "host", "1" => "dhcp-02", "2" => "{", "3" => "hardware", "4" => "ethernet", "5" => "00:02:B3:A2:B6:FD", "6" => ";", etc... I hope this clarifies my problem. I have tried a few things such as a eregi statement, explode etc. and so far explode has done what i need it to by separating one db entry into multiple components for editing. Jas David Otton wrote: On Sat, 06 Dec 2003 11:38:18 -0700, you wrote: I think I am loosing my mind this afternoon... could someone review this snippit and tell me why it isn't working? $sql = mysql_query("SELECT $i FROM $table WHERE $i = $i",$db)or die(mysql_error()); while($b = mysql_fetch_array($sql)) { while($ar = current($b) != 0) { $v = array(); list($v) = explode("}",$ar); } print_r($v); } I am hoping to get something like array([0]=>first row of data[1]=>second row of data) Your code doesn't have any context, so I can't be sure whether you're doing something very smart or very dumb with the SQL statement. The explode() is kinda weird, too. Try running this: $rs = mysql_query ($sql, $db) or die (mysql_error ()); $result = array(); while ($row = mysql_fetch_array ($rs)) { $result[] = $row; } print_r ($result); ?> and let us know how close it comes. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] new set of eyes?
I think I am loosing my mind this afternoon... could someone review this snippit and tell me why it isn't working? $sql = mysql_query("SELECT $i FROM $table WHERE $i = $i",$db)or die(mysql_error()); while($b = mysql_fetch_array($sql)) { while($ar = current($b) != 0) { $v = array(); list($v) = explode("}",$ar); } print_r($v); } I am hoping to get something like array([0]=>first row of data[1]=>second row of data) Any help would be great... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: password protection/encryption
Some questions to ask yourself... 1. Am I storing personally identifiable information (eg. Names, addresses, phone numbers, email addresses, credit card data)? 2. Will this data be stored in a text file or database? 3. Is this text file or database directly connected to the internet? 4. What type of data am I trying to protect? Answer these questions and you will know if you need to use public/private key encryption technology in your application. You are currently interested (from your post) in encrypting the data link layer of your website using SSL (Secure Socket Layer). The SSL or lock icon as you pointed out only encrypts data in a streaming manner (eg. when I click the submit button my username / password combination gets passed to the SSL protocol and wrapped in a layer of encryption to be decoded on the server). If you are storing data in a text file / database that would be a "yes" answer to the 4 quesitons listed above I would recommend using some sort of public / private key encrytion. PHP has several encryption functions for your use and links are listed below. When in doubt consult the manual at php.net. http://us4.php.net/manual/en/function.base64-encode.php http://us4.php.net/manual/en/function.base64-decode.php http://us4.php.net/manual/en/function.crypt.php http://us4.php.net/manual/en/ref.mcrypt.php Also a great recommendation... google.com is your friend you can find all sorts of good tips locating information on various encryption techniques and definitions. A great primer on public / private encrytion vs. one-way encryption can be found here... http://www.webopedia.com/TERM/e/encryption.html This site gives you basics of encryption and how it works. http://computer.howstuffworks.com/encryption.htm SSL information can be found here. http://www.webopedia.com/TERM/S/SSL.html Hope this helps Jas Chris Mach wrote: Greetings, I'm working on a project that involves a password protected area of a website. Some one also involved brought up the point that this area should be secure (Whit the lock icon indicating it is encrypted). In this particular project the password protected area will be a quote generating system for a company. Users would log in and choose the products they are interested in purchasing and the site would generate a quote depending on what they selected from the list of products. So my question is.. At what point is encryption necessary? I've always thought encryption was only needed when dealing with stuff like credit card information, am I wrong? How secure is a password protected page done with just PHP? Thanks Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Regular expression assistance...
I am trying to match data from a database that would like like host dhcp-01 { hardware ethernet 00:D0:B7:BD:D2:8D; fixed-address 155.97.1.190; } Using this expression if eregi("^[host]\s+[{]\s+[hardware ethernet]\s+[fixed-address]\s+[}]$",$b) { echo "Put into array"; } Any help would be great, or maybe some insight into the various characters used (besides the basic, ^, $, +, etc). Thanks in advance. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: function problems...
Nevermind, I got it to work... cheers Jas wrote: I call this function it checks a session variable then displays 1 of 3 menus... for some reason it will only display the first menu regardless of the results of my decoded session var. Any help or just a new pair of eyes would help. Thanks in advance. jas function menu() { $lvl = base64_decode($_SESSION['lvl']); echo $lvl; if (($lvl != "admin") || ($lvl != "user") || ($lvl == "view")) { $_SESSION['menu'] = ""; } elseif (($lvl != "admin") || ($lvl == "user") || ($lvl != "view")) { $_SESSION['menu'] = "Manage hosts Update DHCP "; } elseif (($lvl == "admin") || ($lvl != "user") || ($lvl != "view")) { $_SESSION['menu'] = "Global DHCP config. Manage VLANS Manage hosts Update DHCP Users Logs"; } else { $_SESSION['menu'] = ""; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] function problems...
I call this function it checks a session variable then displays 1 of 3 menus... for some reason it will only display the first menu regardless of the results of my decoded session var. Any help or just a new pair of eyes would help. Thanks in advance. jas function menu() { $lvl = base64_decode($_SESSION['lvl']); echo $lvl; if (($lvl != "admin") || ($lvl != "user") || ($lvl == "view")) { $_SESSION['menu'] = ""; } elseif (($lvl != "admin") || ($lvl == "user") || ($lvl != "view")) { $_SESSION['menu'] = "Manage hosts Update DHCP "; } elseif (($lvl == "admin") || ($lvl != "user") || ($lvl != "view")) { $_SESSION['menu'] = "Global DHCP config. Manage VLANS Manage hosts Update DHCP Users Logs"; } else { $_SESSION['menu'] = ""; } } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] eregi function?
Not sure how to do this but I have a call to a database which pulls the contents of a table into an array and I need a eregi string which will sift through the contents and put a line break (i.e. \n or ) after each ";", "}" or "{". here is what I have so far... while($b = mysql_fetch_array($sql)) { list($id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10) = $b; } if(!eregi("^[{]+[}]+[;]$", $id,$date,$user,$level,$global,$vlan01,$hosts01,$vlan02,$hosts02,$vlan03,$hosts03,$vlan04,$hosts04,$vlan05,$hosts05,$vlan06,$hosts06,$vlan07,$hosts07,$vlan08,$hosts08,$vlan09,$hosts09,$vlan10,$hosts10)) // insert line break here } Any help with this would be appreciated Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Remote computer name?
I am at a loss here but doesn't $_SERVER['HTTP_HOST'] return the remote computer name? [Snippit used] $ipaddy = $_SERVER['REMOTE_ADDR']; $host = $_SERVER['HTTP_HOST']; // as of now it is getting the name of the server (i.e. localhost, 168.2.2.1) jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Session vars not echoing?
Yeah I did that, sorry I just didn't note it in the snippit.. and it is now working with the $_SESSION function, i just had to restart the browser to clear the cache after updating the code. jas Pete M wrote: need to issue a session_start() at top of page Pete Jas wrote: Not sure why this is happening but I think it has something to do with an include statement... [Server environment] Apache/2.0.47 (Unix) DAV/2 PHP/4.3.3 register_globalsOnOn report_memleaksOnOn safe_modeOffOff safe_mode_exec_dirno valueno value Session Support enabled [Script registering vars - sessions.php] /* Format Date & Time */ $hour = (date("H:i:s")); $day = (date("d")); $date = (date("F $day, Y")); /* Register vars */ $_SESSION['date'] = $date; [Main script - index.php] session_start() require 'scripts/sessions.php'; echo $_SESSION['date']; //This is not showing up in browser? Any help is appreciated... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Session vars not echoing?
Not sure why this is happening but I think it has something to do with an include statement... [Server environment] Apache/2.0.47 (Unix) DAV/2 PHP/4.3.3 register_globals On On report_memleaks On On safe_mode Off Off safe_mode_exec_dir no value no value Session Support enabled [Script registering vars - sessions.php] /* Format Date & Time */ $hour = (date("H:i:s")); $day = (date("d")); $date = (date("F $day, Y")); /* Register vars */ $_SESSION['date'] = $date; [Main script - index.php] require 'scripts/sessions.php'; echo $_SESSION['date']; //This is not showing up in browser? Any help is appreciated... Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mcrypt libraries?
Evan Nemerson wrote: On Tuesday 18 November 2003 01:13 pm, Jas wrote: Curt Zirzow wrote: * Thus wrote Jas ([EMAIL PROTECTED]): I am not sure if I should post my question here but I will anyways. Ok, I have compiled the mcrypt libraries on a Redhat 9 box running apache 2 with php4. And I need to know the next step(s) in getting php to use the libmcrypt libraries. If anyone has set this up in the past or has some pointers (other than reading the manual) I would appreciate it. Did you read the next step: Installation http://php.net/mcrypt Curt Yes I have and I guess I was looking for a method of using the libmcrypt library without having to recompile php. Sorry for the confusion. Have you tried using phpize? Actually I have not, not sure what phpize is but I will look it up. If you know of a URL where some fairly detailed instructions on compiling PHP with the mcrypt libraries are please post it. Thanks again, Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] mcrypt libraries?
Curt Zirzow wrote: * Thus wrote Jas ([EMAIL PROTECTED]): I am not sure if I should post my question here but I will anyways. Ok, I have compiled the mcrypt libraries on a Redhat 9 box running apache 2 with php4. And I need to know the next step(s) in getting php to use the libmcrypt libraries. If anyone has set this up in the past or has some pointers (other than reading the manual) I would appreciate it. Did you read the next step: Installation http://php.net/mcrypt Curt Yes I have and I guess I was looking for a method of using the libmcrypt library without having to recompile php. Sorry for the confusion. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] mcrypt libraries?
I am not sure if I should post my question here but I will anyways. Ok, I have compiled the mcrypt libraries on a Redhat 9 box running apache 2 with php4. And I need to know the next step(s) in getting php to use the libmcrypt libraries. If anyone has set this up in the past or has some pointers (other than reading the manual) I would appreciate it. Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] form not working...
For some reason my form to edit selected items is not working, I think I need a new set of eyes. Any help is appreciated... Jas // inc.php function db_retrieve() { require 'dbase.inc.php'; $tble = $_SESSION['table']; $show = @mysql_query("SELECT * FROM $tble LIMIT 0, 15",$db)or die(mysql_error()); while ($row = @mysql_fetch_array($show)) { @list($nItemSKU, $bActive, $nUserID, $nItemConfig, $tItemType, $tDepartment, $blSerialNumber, $nPropertyNumber, $blHostName, $nIPID, $tRoomNumber, $tNotes) = $row; $_SESSION['table'] .= "$nItemSKU $bActive $nUserID $nItemConfig $tItemType $tDepartment $blSerialNumber $nPropertyNumber $blHostName $nIPID $tRoomNumber $tNotes "; } $_SESSION['number'] = mysql_num_rows($show); } $bActive $nUserID $nItemConfig $tItemType $tDepartment $blSerialNumber $nPropertyNumber $blHostName $nIPID $tRoomNumber $tNotes "; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] IIS Ports
Well what version of Windows are you running? NT, 2K, XP etc. Have you looked at what ports are open? What services do you need to run? Obviously IIS to serve up web pages, but what else is running? SMTP, FTP etc? Do you need those other services? If not turn them off... NT :: Administrative tools / services / locate service corresponding to port you wish to close and set to 'disabled' 2K :: Control panel / Administrative tools / services / locate service and set to 'disabled' XP :: Control panel / Administrative tools / services / locate service and set to 'disabled' Linux :: edit the file name xinet.d, init.d, ftpd, httpd, etc to disable from starting service A list of port assignments can be found here. http://www.iana.org/assignments/port-numbers Information on securing your box can be found here. http://www.securityfocus.com // recent exploits and tools to help secure your box http://www.nsa.gov/snac/index.html // for windows and linux HTH Jas "Stephen Craton" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] I'm not sure where he tried to find the ports that were open but I'd guess from his apartment in Lafayette. We have a hardware firewall protecting the entire network. We're connected with a cable line and I'm really clueless as to what to do. I run windows update every day to make sure I'm not lagging behind. So far I have no real enemies that want to hack me, but I'm bound to make some eventually. I'll probably end up getting apache sometime or something. Oh, and um, I would beat up my brother but he was in the military (he dropped out because of the 5am 5 mile runs) and he's 5 years older then me... Thanks, Stephen Craton http://www.melchior.us -- http://www.melchior.us/portfolio -Original Message- From: Jeff McKeon [mailto:[EMAIL PROTECTED] Sent: Saturday, September 27, 2003 4:10 PM To: Stephen Craton; [EMAIL PROTECTED] Subject: RE: [PHP] IIS Ports can't you just beat up your brother? It won't fix your pc but it will probably make you feel better. :o) Chances are your bro is no genious and just using scripts (script kiddie) that other people write for known exploits. If this is the case, then you probably haven't been keeping up with your MS updates. What connection did he get to your pc/server though? was he inside the network or coming in from the internet. If he came in from the internet, what kind of connection are you running (cable, DSL etc)? Do you have a hardware firewall between the internet and your network? If not, you should. I make all my friend's/family who have cable/DSL modems spend the money and install them. Very often they've asked me to install them and just for gigles I turn on logging. Usually I see port scans within 10 minutes of the firewall coming up on the cable/DSL modem. Pretty scary. Whether your running MS or Linux, you should check for patches and updates EVERY DAY for all your systems and especially those acting as servers of any kind. There are also plenty of books on hacking that you can read to familarize yourself with the techniques of hacking. This will help you understand what's going on and better equip your network to deal with it. There are also many books on "box hardening" AKA firewalling. If your going to runs servers available on the internet, I suggest you read up on these things. good luck. -Original Message- From: Stephen Craton [mailto:[EMAIL PROTECTED] Sent: Sat 9/27/2003 4:31 PM To: PHP List Cc: Subject: [PHP] IIS Ports This is kind of off topic but kind of not, it's your call. My brother came home this weekend from college this weekend acting all cool since he has been learning to hack. He was telling us (the family) how he did random port penetration on the home network and he said my computer was the most vulnerable with around 25 ports open. I didn't really care until about an hour later he hacked into my computer and then reset it causing me to loose all my important information. I told my dad and my brother promptly lied about anything of the sort. What I want to know.since I know the majority of my ports open are from IIS.is how I can close these. I only need my local server accessible by just my computer but the entire network too.just not the network. I thought the ports would just be open on my computer and not the hardware firewall and everything. I went ahead and turned on the Windows XP firewall but I've heard it really sucks. So is there any way of closing the IIS ports so my brother, and any other hacker, can't get in here and cause havoc? Thanks, Stephen Craton http://www.melchior.us -- http://www.melchior.us/portfolio -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Passing hidden form var?
I think I am just over looking something here, a new pair of eyes would be useful. Thanks in advance. The var $ipaddy is not getting passed to code listed below /* Form for IP checking */ $table = "cm_sessions"; $record = @mysql_query("SELECT * FROM $table",$dbh); while ($row = mysql_fetch_array($record)) { $session = $row['session']; $ipaddy = $row['ipaddy']; $host = $row['host']; $referrer = $row['referrer']; $hck = $row['hck']; $nrml = $row['nrml']; $hour = $row['hour']; $date_stamp = $row['date_stamp']; $stats .= "$session $ipaddy $host $hck $nrml $date_stamp https://localhost/admin/view.whois.php') \" name=\"whois\"> "; } /* Function to check IP vs. Whois db */ $ipaddy = ""; function message($msg){ echo "$msg"; flush(); } function arin($ipaddy){ $server = "whois.arin.net"; if (!$ipaddy = gethostbyname($ipaddy)) $msg .= "Can't check Whois without an IP address."; else{ if (! $sock = fsockopen($server, 43, &$num, &$error, 20)){ unset($sock); $msg .= "Timed-out connecting to $server (port 43)"; } else{ fputs($sock, "$ipaddy\n"); while (!feof($sock)) $buffer .= fgets($sock, 10240); fclose($sock); } if (eregi("RIPE.NET", $buffer)) $nextServer = "whois.ripe.net"; else if (eregi("whois.apnic.net", $buffer)) $nextServer = "whois.apnic.net"; else if (eregi("nic.ad.jp", $buffer)){ $nextServer = "whois.nic.ad.jp"; #/e suppresses Japanese character output from JPNIC $extra = "/e"; } else if (eregi("whois.registro.br", $buffer)) $nextServer = "whois.registro.br"; if($nextServer){ $buffer = ""; message("Deferred to specific whois server: $nextServer..."); if(! $sock = fsockopen($nextServer, 43, &$num, &$error, 10)){ unset($sock); $msg .= "Timed-out connecting to $nextServer (port 43)"; } else{ fputs($sock, "$ipaddy$extra\n"); while (!feof($sock)) $buffer .= fgets($sock, 10240); fclose($sock); } } $buffer = str_replace(" ", " ", $buffer); $msg .= nl2br($buffer); } message($msg); } echo arin($ipaddy); echo $ipaddy; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] dir to array? - SOLVED
I got it fixed, thanks again. Just in case anyone else needs help with this type of item look at readdir() at http://www.php.net Jas "Jason Wong" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > On Thursday 01 August 2002 03:00, Jas wrote: > > Not sure why this isn't working, any help is appreciated. I am trying to > > read the files in a directory and place them into an array. Here is the > > code: > > > > /* Function to create array of directory contents */ > > function dCNTS($files) { > > $dir = opendir("/path/to/directory/"); > > while($imgs = readdir($dir)) { > >if (($imgs != ".") && ($imgs != "..")) { > > $cnt[count($imgs)] = $cnt; > >} else { > > print "Cannot create array of files in directory!"; } > >} > > closedir($dir); > > } > > HOW isn't it working? > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > One person's error is another person's data. > */ > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] dir to array?
Not sure why this isn't working, any help is appreciated. I am trying to read the files in a directory and place them into an array. Here is the code: /* Function to create array of directory contents */ function dCNTS($files) { $dir = opendir("/path/to/directory/"); while($imgs = readdir($dir)) { if (($imgs != ".") && ($imgs != "..")) { $cnt[count($imgs)] = $cnt; } else { print "Cannot create array of files in directory!"; } } closedir($dir); } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Parse error - new set of eyes?
I am getting a parse error on line 14, I am trying to make sure session vars are being set before rendering the page. This is lines 12,13,14 & 15. Any help is appreciated. Jas if ((!$u_name) || (!$p_word)){ header("Location: index.php"); session_destroy(); exit; } /* Check for missing session vars */ elseif ((!isset($HTTP_SESSION_VARS['clk']) || (!isset($HTTP_SESSION_VARS['holy_cow']) || (!isset($HTTP_SESSION_VARS['ipaddy']) || (!isset($HTTP_SESSION_VARS['a'])) { /* Begin logging of client info to database table since session vars are not present */ require '/path/to/connection/class/db.php'; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Credit card checks?
So there is no way to use some sort of string comparison to check the number then? I would have to have a merchant account? Sorry for being nieve, just never tried to work with credit card numbers etc. Jas "Kristopher Yates" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > You should contact Visa International Service Association to determine > what constitues a "valid" credit card number. Just FYI, a valid format > is 16 digits; ---. I believe VISA normally begins with > "41" as the first two digits, however, I am not a Visa Int. agent but I > am a client. Ultimately, you would need a merchant account to verify its > validity, AFTER you have verified its format for accuracy. HTH Kris > > Jas wrote: > > >Yeah, I have looked at that class file and I don't want someone elses > >example to use, I want to build my own but have no way of knowing what makes > >up a valid visa number etc > >Jas > > > >"Richard Baskett" <[EMAIL PROTECTED]> wrote in message > >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > > > >>Try this: > >> > >>http://www.AnalysisAndSolutions.com/code/ccvs-ph.htm > >> > >>Rick > >> > >>A sense of humor can help you over look the unattractive, tolerate the > >>unpleasant, cope with the unexpected, and smile through the unbearable. - > >>Moshe Waldoks > >> > >> > >> > >>>From: "Jas" <[EMAIL PROTECTED]> > >>>Date: Tue, 23 Jul 2002 12:09:48 -0600 > >>>To: [EMAIL PROTECTED] > >>>Subject: [PHP] Credit card checks? > >>> > >>>Just wondering if anyone has come across the need to develop a class to > >>> > >>> > >test > > > > > >>>a string of numbers based on a credit card type. If you have where > >>> > >>> > >would I > > > > > >>>be able to get information on what string of numbers is consistent with > >>> > >>> > >each > > > > > >>>of the different credit cards? Any help would be appreciated! > >>>Jas > >>> > >>> > >>> > >>>-- > >>>PHP General Mailing List (http://www.php.net/) > >>>To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > >>> > > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Credit card checks?
Yeah, I have looked at that class file and I don't want someone elses example to use, I want to build my own but have no way of knowing what makes up a valid visa number etc.... Jas "Richard Baskett" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Try this: > > http://www.AnalysisAndSolutions.com/code/ccvs-ph.htm > > Rick > > A sense of humor can help you over look the unattractive, tolerate the > unpleasant, cope with the unexpected, and smile through the unbearable. - > Moshe Waldoks > > > From: "Jas" <[EMAIL PROTECTED]> > > Date: Tue, 23 Jul 2002 12:09:48 -0600 > > To: [EMAIL PROTECTED] > > Subject: [PHP] Credit card checks? > > > > Just wondering if anyone has come across the need to develop a class to test > > a string of numbers based on a credit card type. If you have where would I > > be able to get information on what string of numbers is consistent with each > > of the different credit cards? Any help would be appreciated! > > Jas > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Credit card checks?
Just wondering if anyone has come across the need to develop a class to test a string of numbers based on a credit card type. If you have where would I be able to get information on what string of numbers is consistent with each of the different credit cards? Any help would be appreciated! Jas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: sessions
You forgot the session_start(); call. You will have to do that before you can tap into registered vars. Hope that helps. Jas "Alexander Ross" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I'm trying to understand sessions so I can set session variables. I set up 2 > very simple pages: > > Page 1: > > session_start(); > $test_var = "froggy"; > session_register('test_var'); > ?> > Click here > > > Page 2: > > print $test_var."!"; > ?> > > > This doesn't seem to work though. $test_var doesn't seem to have a value > when I go the second page. What am I missing. Thanks for helping a newbie. > > Alex > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re[2]: [PHP] timer on sessions?
So under the time() call, comparing it to a simple numerical value such as "300" it knows that you are talking about 300 seconds? Is that because it is a unix timestamp? I previously tried using date("s") to give me the seconds from today's date then tried the compare, so using time() will work better. Thanks a ton. Jas "Asmodean" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > J> I am not able to test from this machine so please tell me if I am right or > J> wrong on this: > J> $tmp = time(); > J> $tme = time() - 5*60; > J> session_register('tmp'); > if ($tmp >>= $tme) { > J> echo 'Time has not reached 5 minutes, session still valid'; > J> } else { > J> echo 'Timer has reached 5 minutes, you will need to log back in to > J> continue.'; } > > J> "Asmodean" <[EMAIL PROTECTED]> wrote in message > J> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >> J> Not sure how to go about setting up a function to parse the date, hour, > >> J> minutes, seconds, take the seconds and register them in a session var, > J> then > >> J> do a check on the session var (seconds) vs. the seconds var + 5*60 (or > J> 5 > >> J> minutes) to time out the session and force the user to log back in. My > >> J> problem is finding the correct way to check the seconds in php. Any > J> help or > >> J> pointers is appreciated. > >> J> Jas > >> > >> time() will give you a UNIX timestamp. Use it to do the math. > >> > >> -- > >> Best regards, > >> Asmodeanmailto:[EMAIL PROTECTED] > >> > > Let's assume you've set your session timestamp (assume it's called > $session_time) to time() at the time of login. Now, in the script... > > if ((time() + 300) > $session_time) { > > } > > This would be a check to see if the session is still valid. Timewise. > > -- > Best regards, > Asmodeanmailto:[EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] timer on sessions?
I am not able to test from this machine so please tell me if I am right or wrong on this: $tmp = time(); $tme = time() - 5*60; session_register('tmp'); if ($tmp >= $tme) { echo 'Time has not reached 5 minutes, session still valid'; } else { echo 'Timer has reached 5 minutes, you will need to log back in to continue.'; } "Asmodean" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > J> Not sure how to go about setting up a function to parse the date, hour, > J> minutes, seconds, take the seconds and register them in a session var, then > J> do a check on the session var (seconds) vs. the seconds var + 5*60 (or 5 > J> minutes) to time out the session and force the user to log back in. My > J> problem is finding the correct way to check the seconds in php. Any help or > J> pointers is appreciated. > J> Jas > > time() will give you a UNIX timestamp. Use it to do the math. > > -- > Best regards, > Asmodeanmailto:[EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php