[PHP] Mcrypt Function - New to it
Hi there..some what a new programmer when it comes to all this. I'm trying to encrypt some data and then decrypt it. It doesn't have to be high bit encryption just something simple like 3DES. But I keep getting it wrong. Any help would be greatful. Here's the piece of code: $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_3DES, MCRYPT_MODE_ECB), MCRYPT_RAND); $key = md5("Secret Key"); $sample2 = "Hello"; $lockdata = mcrypt_encrypt (MCRYPT_3DES, $key, $sample2, MCRYPT_MODE_ECB, $iv); echo "$lockdata\n"; $text = mcrypt_decrypt (MCRYPT_3DES, $key, $lockdata, MCRPYT_MODE_ECB, $iv); echo "$text\n"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Mcrypt Function - New to it
Well now I have the Encryption problem figured out but when I try to decrypt the information, I'm getting this error: Warning: mcrypt module initialization failed in test.php on line 11 Here's Line 11: $text = mcrypt_decrypt (MCRYPT_TripleDES, $key, $lockdata, MCRPYT_MODE_ECB, $iv); again any help would be appreciated. Tom Rogers wrote: > Hi > Here are a couple of functions that should help to get you started, iv > is set to all 0's so it does not have to be passed around or stored in > sessions. It is base64 encoded so it can be stored or passed to the > browser. > > Function Code_id($id,$password){ > $eid = 0; > $td = mcrypt_module_open (MCRYPT_TripleDES, "", > MCRYPT_MODE_ECB, ""); > $iv = pack("a".mcrypt_enc_get_iv_size($td),$iv); > mcrypt_generic_init ($td, $password, $iv); > $eid = base64_encode(mcrypt_generic ($td, $id)); > mcrypt_generic_end ($td); > return $eid; > } > Function Get_id($eid,$password){ > $id = 0; > $td = mcrypt_module_open (MCRYPT_TripleDES, "", > MCRYPT_MODE_ECB, ""); > $iv = pack("a".mcrypt_enc_get_iv_size($td),$iv); > mcrypt_generic_init ($td, $password, $iv); > $id = mdecrypt_generic ($td, base64_decode($eid)); > mcrypt_generic_end ($td); > return $id; > } > Tom > > > At 11:07 PM 30/05/2002 -0400, Tom Ray wrote: > >> Hi there..some what a new programmer when it comes to all this. I'm >> trying to encrypt some data and then decrypt it. It doesn't have to >> be high bit encryption just something simple like 3DES. But I keep >> getting it wrong. Any help would be greatful. Here's the piece of code: >> >> $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_3DES, >> MCRYPT_MODE_ECB), MCRYPT_RAND); >> >> $key = md5("Secret Key"); >> $sample2 = "Hello"; >> >> $lockdata = mcrypt_encrypt (MCRYPT_3DES, $key, $sample2, >> MCRYPT_MODE_ECB, $iv); >> >> echo "$lockdata\n"; >> >> $text = mcrypt_decrypt (MCRYPT_3DES, $key, $lockdata, >> MCRPYT_MODE_ECB, $iv); >> >> echo "$text\n"; >> >> >> >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > >
[PHP] PHP as HTML
Hey there- I'm trying to use an .htaccess file to parse .php files as .html does anyone know how to do this? It doesn't work with the same structure as parsing the .shtml files. any suggestions would be great. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP as HTML
I tried this, and it just prompts me to download the file from the server. I can't see what the issue is. - Original Message - From: "Kevin Stone" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 04, 2002 5:35 PM Subject: Re: [PHP] PHP as HTML > AddType application/x-httpd-php .html > AddType application/x-httpd-php .htm > > ----- Original Message - > From: "Tom Ray" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, June 04, 2002 2:41 PM > Subject: [PHP] PHP as HTML > > > > Hey there- > > > > I'm trying to use an .htaccess file to parse .php files as .html does > anyone > > know how to do this? It doesn't work with the same structure as parsing > the > > .shtml files. > > > > any suggestions would be great. > > > > > > > > > > -- > > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP as HTML
you know, that's a good question. How would I determine that on the server? Peter wrote: >Tom, this does work fine... doing what Kevin says... >ie the > >AddType application/x-httpd-php .html >AddType application/x-httpd-php .htm > >is PHP installed as a module or cgi ver? > >Cheers > >-----Original Message- >From: Tom Ray [mailto:[EMAIL PROTECTED]] >Sent: Wednesday, 5 June 2002 9:49 AM >To: Kevin Stone; [EMAIL PROTECTED] >Subject: Re: [PHP] PHP as HTML > > >I tried this, and it just prompts me to download the file from the server. I >can't see what the issue is. > > >- Original Message - >From: "Kevin Stone" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Tuesday, June 04, 2002 5:35 PM >Subject: Re: [PHP] PHP as HTML > > > > >>AddType application/x-httpd-php .html >>AddType application/x-httpd-php .htm >> >>- Original Message - >>From: "Tom Ray" <[EMAIL PROTECTED]> >>To: <[EMAIL PROTECTED]> >>Sent: Tuesday, June 04, 2002 2:41 PM >>Subject: [PHP] PHP as HTML >> >> >> >> >>>Hey there- >>> >>>I'm trying to use an .htaccess file to parse .php files as .html does >>> >>> >>anyone >> >> >>>know how to do this? It doesn't work with the same structure as parsing >>> >>> >>the >> >> >>>.shtml files. >>> >>>any suggestions would be great. >>> >>> >>> >>> >>>-- >>>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 General Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php > > > > >
Re: [PHP] PHP as HTML
Thanks. I got the issue figured out. There was an .htaccess file in the root of the website that I had forgotten about, it was affecting everything due to it's bad config. Pushkar Pradhan wrote: >If you do a phpinfo() you get a columen Server API, mine lists CGI as it >is what I installed php as. > > >>you know, that's a good question. How would I determine that on the server? >> >>Peter wrote: >> >> >> >>>Tom, this does work fine... doing what Kevin says... >>>ie the >>> >>>AddType application/x-httpd-php .html >>>AddType application/x-httpd-php .htm >>> >>>is PHP installed as a module or cgi ver? >>> >>>Cheers >>> >>>-Original Message- >>>From: Tom Ray [mailto:[EMAIL PROTECTED]] >>>Sent: Wednesday, 5 June 2002 9:49 AM >>>To: Kevin Stone; [EMAIL PROTECTED] >>>Subject: Re: [PHP] PHP as HTML >>> >>> >>>I tried this, and it just prompts me to download the file from the server. I >>>can't see what the issue is. >>> >>> >>>- Original Message - >>>From: "Kevin Stone" <[EMAIL PROTECTED]> >>>To: <[EMAIL PROTECTED]> >>>Sent: Tuesday, June 04, 2002 5:35 PM >>>Subject: Re: [PHP] PHP as HTML >>> >>> >>> >>> >>> >>> >>>>AddType application/x-httpd-php .html >>>>AddType application/x-httpd-php .htm >>>> >>>>- Original Message - >>>>From: "Tom Ray" <[EMAIL PROTECTED]> >>>>To: <[EMAIL PROTECTED]> >>>>Sent: Tuesday, June 04, 2002 2:41 PM >>>>Subject: [PHP] PHP as HTML >>>> >>>> >>>> >>>> >>>> >>>> >>>>>Hey there- >>>>> >>>>>I'm trying to use an .htaccess file to parse .php files as .html does >>>>> >>>>> >>>>> >>>>> >>>>anyone >>>> >>>> >>>> >>>> >>>>>know how to do this? It doesn't work with the same structure as parsing >>>>> >>>>> >>>>> >>>>> >>>>the >>>> >>>> >>>> >>>> >>>>>.shtml files. >>>>> >>>>>any suggestions would be great. >>>>> >>>>> >>>>> >>>>> >>>>>-- >>>>>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 General Mailing List (http://www.php.net/) >>>To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> >>> >>> >>> >>> >>> >> >> > >-Pushkar S. Pradhan > > > >
[PHP] Retrieving Info from Cookies
I've been playing with cookies, and I've been able to write information to a cookie, but now what I want to do is pull that information from the cookie. Is there something special I need to do to pull that info or should I just be to get that data by delcaring a variable in the php script? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Retrieving Info from Cookies
when I do that it comes up with Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' Justin French wrote: >you should be able to access it via $_COOKIE['name'], or what I do, $cookie >= $_COOKIE['name']. > >Justin French > > >on 05/06/02 2:19 PM, Tom Ray ([EMAIL PROTECTED]) wrote: > > > >>I've been playing with cookies, and I've been able to write information >>to a cookie, but now what I want to do is pull that information from the >>cookie. Is there something special I need to do to pull that info or >>should I just be to get that data by delcaring a variable in the php >>script? >> >> >> > > >. > > >
[PHP] Search a flat file.
I want to be able to search a flat file line by line looking for data such as a username then display all the information in that line. Is there some way to search the following format: record1:username:info:info:info record2:username:info:info:info record3:username:info:info:info So if someone submits the username in record two for the search I want it to stop at record two and then display that information... any suggestions? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Search a flat file.
ok I believe I follow you on that, I will give that a try. But the question I have now is how do I loop that request? Gaylen Fraley wrote: >Use the explode() function based on the colon. Then parse the 2nd array >element for the username that you want. If matched, display all elements in >that array row. Conversely you could use the implode() to reassemble the >array row. > >(Assume $file_row is the row name that you have assigned) > >/* your code to loop through the file goes here */ >$your_array = explode(":",$file_row); >/* remember that arrays start with element 0 */ >if ($your_array[1]) == "some name" { >/* routine to display entire row */ >} >/* continue processing loop */ > >-- >Gaylen >PHP KISGB v4.0.5 Guest Book http://www.gaylenandmargie.com/phpwebsite/ > >"Tom Ray" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > >>I want to be able to search a flat file line by line looking for data >>such as a username then display all the information in that line. Is >>there some way to search the following format: >> >>record1:username:info:info:info >>record2:username:info:info:info >>record3:username:info:info:info >> >> >>So if someone submits the username in record two for the search I want >>it to stop at record two and then display that information... >> >>any suggestions? >> >> >> > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Getting users monitor size
Is there a way to do this with PHP? I couldn't find it in the online docs and the archive search is offline :( thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Another Flat File question.
I know I've asked this before but I don't believe I asked the question correctly. I have a flat file database that is delimited with colons. This file will have new records added to it on a regular basis. What I want to do is be able to search that file based on a keyword that is inputted by a user, then it will search that database comparing each record for that value, if that value returns true, I want it to display the results of that record. How would I do this when I don't know the number of records that will be searched (since it will rise and fall almost daily)? Also, how would I create a dynamic array? I hope this makes sense to someone, I've been pulling my hair out on this. Thanks! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Include question
I'm trying to use the include function in some PHP scripts, but when I do include 'config.inc'; or include 'config.php; It returns all the information in the file when I look at my test php file (which calls the include) Anyone know why this is? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Include question
Yes, but according to http://www.php.net/manual/en/function.include.php I should be able to delcare the include and then pull the information out normally. So by what the manual says I can do this somefile.php callfile.php But when I just do It prints: $apple = 'green'; $pear = 'yellow': Why is that? John Holmes wrote: >Umm...that's what it's supposed to do...it's "including" it... > >---John Holmes... > > > >>-Original Message- >>From: Tom Ray [mailto:[EMAIL PROTECTED]] >>Sent: Tuesday, June 11, 2002 9:29 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP] Include question >> >>I'm trying to use the include function in some PHP scripts, but when I >> >> >do > > >>include 'config.inc'; or include 'config.php; >> >>It returns all the information in the file when I look at my test php >>file (which calls the include) Anyone know why this is? >> >> >>-- >>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] Include question
Well I got it solved. It would help if I formatted my files correctly. Sorry about that, i've been messing with PHP for about a year now, but am now really diving into it so I may have stupid questions here and there :) TIA to all for help. John Holmes wrote: >Umm...that's what it's supposed to do...it's "including" it... > >---John Holmes... > > > >>-Original Message- >>From: Tom Ray [mailto:[EMAIL PROTECTED]] >>Sent: Tuesday, June 11, 2002 9:29 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP] Include question >> >>I'm trying to use the include function in some PHP scripts, but when I >> >> >do > > >>include 'config.inc'; or include 'config.php; >> >>It returns all the information in the file when I look at my test php >>file (which calls the include) Anyone know why this is? >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > > >
[PHP] Unlink question more or less
I want to use unlink() to delete a wildcard, but at the moment I keep getting parse errors. Here's what happening: I'm mucking around with some login stuff, when a user logs in it writes a flat file that collects some information about them, the flat file is created with the name username.dateyeartime Now each time they log in I want to delete that file and replace it with the new file that has the latest dateyeartime ending on it. I've tried unlink (username.*); but that returns an error. Is there a way for unlink() to recongize wildcards? If not how would I do this? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Unlink question more or less
Yeah they are, actaully I switched it to a static name and then added the time stamp as part of the information I'm gathering. Now I just re-write the file on each log in. John Holmes wrote: >You can't use wildcards. Use a system() or exec() call to do it. > >Why use the datetime part at all? The usernames are unique, right? > >---John Holmes... > > > >>-----Original Message- >>From: Tom Ray [mailto:[EMAIL PROTECTED]] >>Sent: Tuesday, June 11, 2002 11:06 PM >>To: [EMAIL PROTECTED] >>Subject: [PHP] Unlink question more or less >> >>I want to use unlink() to delete a wildcard, but at the moment I keep >>getting parse errors. Here's what happening: >> >>I'm mucking around with some login stuff, when a user logs in it >> >> >writes > > >>a flat file that collects some information about them, the flat file >> >> >is > > >>created with the name username.dateyeartime Now each time they log in >> >> >I > > >>want to delete that file and replace it with the new file that has the >>latest dateyeartime ending on it. I've tried unlink (username.*); but >>that returns an error. Is there a way for unlink() to recongize >>wildcards? If not how would I do this? >> >> >>-- >>PHP General Mailing List (http://www.php.net/) >>To unsubscribe, visit: http://www.php.net/unsub.php >> >> > > >. > > >
Re: [PHP] Unlink question more or less
Any word on when glob() will be in the production version? thanks for the help Miquel. - Original Message - From: "Miguel Cruz" <[EMAIL PROTECTED]> To: "Tom Ray" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, June 12, 2002 2:01 AM Subject: Re: [PHP] Unlink question more or less > On Tue, 11 Jun 2002, Tom Ray wrote: > > I want to use unlink() to delete a wildcard, but at the moment I keep > > getting parse errors. Here's what happening: > > > > I'm mucking around with some login stuff, when a user logs in it writes > > a flat file that collects some information about them, the flat file is > > created with the name username.dateyeartime Now each time they log in I > > want to delete that file and replace it with the new file that has the > > latest dateyeartime ending on it. I've tried unlink (username.*); but > > that returns an error. Is there a way for unlink() to recongize > > wildcards? If not how would I do this? > > Once glob() makes it into the production version, > > foreach(glob('*') as $f) unlink($f); > > Until then, use system('rm *'); or a readdir loop. > > unlink() is not the rm command. It's a system call that deletes a specific > named file. > > miguel > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Dynamic Arrays
I have an array question. I want to use a dynamic array but I don't know how to do this. What I want to do is this, I want to write a form script that takes the elements of the form and submits them in the array then I want to do a loop and check to see if each element in the array has a value and then if it does bullocks for them, but if it doesn't then I want it to come to a screeching halt and tell them what dolts they are for missing a field. So basically I want to have a Required field option for the form. I'm still learning arrays and dynamic arrays are just throwing me and I can't find a good code example to work from. TIA. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] beginner in PHP
Try this: echo "$catalog[unitprice]"; in my experience I've only been able to use the echo() without the quotation marks if I'm calling a function, for variables you need the quotation marks. Hope this helps. Phillip Perry wrote: >Can someone tell me why this doesn't work? >The $mycart array is fine and the $catalog array is also fine but nothing >inside the if statement prints. I've tried other echo statements but nothing >prints at all. > >while (list($key,$value) = each($mycart)) > { >if ($value == $catalog[itemcd]) > { > > echo $catalog[unitprice]; > > } > } > > >Thanks > >Phil > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] server problems
And what are the directory/file permissions where you are writing the archive files? - Original Message - From: "1LT John W. Holmes" <[EMAIL PROTECTED]> To: "Kris Vose" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, June 18, 2002 11:54 AM Subject: Re: [PHP] server problems > Are you sure display_errors is turned ON in php.ini on the new server? Do > the two servers have different settings for register_globals in php.ini? > > ---John Holmes... > > - Original Message - > From: "Kris Vose" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, June 18, 2002 11:12 AM > Subject: [PHP] server problems > > > I just uploaded a php driven web site that use text files to archive data to > a unix server. When I went to try and add another archive the script fails > without a warning. It does not store the data in the text file and it does > not add another archive. I wrote this application about 4 months ago when I > was just learning php and I have found since then that mysql is the best way > to store data! duh... Anyway I was wondering if my permissions are screwed > up on the unix server, or if there is something that I am overlooking here! > I do not really want to rewrite the code! I spoke with the administrator of > the server and he has no idea. They are using PHP 4.0.2B and we are using > PHP 4.1.2 Anyway...thanks in advance. > > Kris > > -- > 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 General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Searching for a new provider
Hey Andy- I work with a hosting company that I believe has everything you're looking for in your wish list. They're a small company that's been around for about 10 years (started as an ISP). If you can get me more information on the type of hosting you're looking to do and what other specifics you might need for your sites, I can get you a ball park figure on what it will cost. Andy wrote: >Hi there, I am searching for a provider who fullfills those criterias and >does not cost a fortune: > >>- PHP >= 4.06 bzw. PHP 4.x mit GDLibrary ab 2.0 >> > >>- GDLibrary >= 2.0 >> > > > - PHP installed as module > >>- mind 5 Subdomains >> > >>- mind 100 MB Speicherplatz >> > >>- evtl. Java VM >> > >>- MySQL >> > > > >Thanx andy > > > >
[PHP] Simple Question
I have a quick question that I haven't been able to find the answer to yet. I've made a couple of guest books via PHP but the biggest problem I'm having is if any one inputs a ' or " or anything like that, the output in the book shows the stupid \ for the escape. So the word "Tom's" looks like "Tom\'s" Is there anyway for me to handle those characters so the backslash doesn't appear in the output? Thanks, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: Simple Question
oh no, Iv'e gotten two answers... stripslashes() and strip_slashes() which one? which one?! Gaylen Fraley wrote: >strip_slashes() > >-- >Gaylen >[EMAIL PROTECTED] >Home http://www.gaylenandmargie.com >PHP KISGB v2.6 Guest Book http://www.gaylenandmargie.com/phpwebsite > >"Tom Ray" <[EMAIL PROTECTED]> wrote in message >[EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >>I have a quick question that I haven't been able to find the answer to >>yet. I've made a couple of guest books via PHP but the biggest problem >>I'm having is if any one inputs a ' or " or anything like that, the >>output in the book shows the stupid \ for the escape. So the word >>"Tom's" looks like "Tom\'s" Is there anyway for me to handle those >>characters so the backslash doesn't appear in the output? >> >>Thanks, >>Tom >> > > >