php-general Digest 20 Jun 2008 11:02:15 -0000 Issue 5524

Topics (messages 275657 through 275678):

Re: Case sensitive password
        275657 by: Kyle Browning
        275666 by: tedd

Associative Arrays
        275658 by: VamVan
        275659 by: Shiplu
        275660 by: Paul Novitski
        275661 by: Chris
        275662 by: Robert Cummings
        275663 by: Paul Novitski
        275665 by: Robert Cummings

Re: Discussion of method -- config files
        275664 by: tedd

Re: Military Service WAS  [PHP] Capitalization of variable
        275667 by: Sancar Saran
        275670 by: Per Jessen
        275671 by: Iv Ray
        275672 by: Dotan Cohen
        275673 by: Dotan Cohen
        275674 by: Dotan Cohen

Re: climb up the path
        275668 by: Iv Ray
        275669 by: Iv Ray

http response 200
        275675 by: joaquinbordado
        275677 by: Iv Ray
        275678 by: Iv Ray

PDF inline viewer
        275676 by: Mário Gamito

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Why not md5 the password, and store the md5 encryption.
Then when they type something in, md5 it and compare the md5 strings.
That will ensure that it is Case Sensitive

On Thu, Jun 19, 2008 at 2:04 PM, R.C. <[EMAIL PROTECTED]> wrote:

> Thank you Daniel,  I think that did the trick.  Am checking this out now...
>
> Best
> R.C.
>
> ""Daniel Brown"" <[EMAIL PROTECTED]> wrote in message > >
> session_start();
> > >
> > >  $_SESSION ['userpass'] = $_POST ['pass'];
> > >  $_SESSION ['authuser'] = 0;
> > >
> > > $login = "VIDEO";
> > > $login2 = "video";
> > >
> > > if (($_SESSION['userpass'] == $login) or ($_SESSION['userpass'] ==
> $login2))
> > > {
> > > $_SESSION['authuser'] = 1;
> > > ?>
> >
> >     Try this:
> >
> > <?php
> >
> > if(preg_match('/^'.$_SESSION['userpass'].'$/i',$login)) {
> >         echo "Good.\n";
> > } else {
> >         echo "Bad.\n";
> > }
> >
> > ?>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
At 4:06 PM -0400 6/19/08, Andrew Ballard wrote:
I could be wrong, but I didn't see anything about a username. It
sounds to me more like it is a single password shared with all the
people who should have access to a specific, non-personalized area of
the site. It certainly wouldn't be my preferred way to set up
security, but depending on the level of risk involved it may be
sufficient.

Andrew

Andrew:

I had the exact same case with a client. My client teaches classes and wanted to provide the attendees with a url where they could download PDF files for the class.

In this case, they only needed a password AND the password was identical for everyone.

Sure attendees could distribute the url and password, but requiring a password makes it just a bit harder than just giving out the url and allowing everyone/thing to download the files. The file were delivered to the user by a password protected script, so no one could bookmark the files.

And doing it this way required no effort by my client to keep track of user names. He just taught the class, gave out the url/password, and the software did the rest.

So, in this case it made sense.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
Hi,

How to create an associative array of this kind in PHP?

 return array(
    12345 => array(
      'mail' => '[EMAIL PROTECTED]',
      'companyName' => 'Asdf Inc.',
    ),
    54321 => array(
      'mail' => '[EMAIL PROTECTED]',
      'companyName' => 'Asdfu Corp.',
    ),
  );

Thanks

--- End Message ---
--- Begin Message ---
On Thu, Jun 19, 2008 at 8:55 PM, VamVan <[EMAIL PROTECTED]> wrote:

> Hi,
>
> How to create an associative array of this kind in PHP?
>
>  return array(
>    12345 => array(
>      'mail' => '[EMAIL PROTECTED]',
>      'companyName' => 'Asdf Inc.',
>    ),
>    54321 => array(
>      'mail' => '[EMAIL PROTECTED]',
>      'companyName' => 'Asdfu Corp.',
>    ),
>  );
>
Well  you have already created one. :)

  return array(
          12345 => array(
                    'mail' => '[EMAIL PROTECTED]',
                    'companyName' => 'Asdf Inc.'
           ),
           54321 => array(
                   'mail' => '[EMAIL PROTECTED]',
                   'companyName' => 'Asdfu Corp.'
           )
 );
Just removed the trailing commas and reformatted a bit. ;)

--- End Message ---
--- Begin Message ---
At 6/19/2008 05:55 PM, VamVan wrote:
How to create an associative array of this kind in PHP?

 return array(
    12345 => array(
      'mail' => '[EMAIL PROTECTED]',
      'companyName' => 'Asdf Inc.',
    ),
    54321 => array(
      'mail' => '[EMAIL PROTECTED]',
      'companyName' => 'Asdfu Corp.',
    ),
  );


This is the right PHP syntax, except that you've got an extraneous comma before the closing parenthesis of each array that's going to throw a parse error.

Regards,

Paul
__________________________

Paul Novitski
Juniper Webcraft Ltd.
http://juniperwebcraft.com
--- End Message ---
--- Begin Message ---
Paul Novitski wrote:
> At 6/19/2008 05:55 PM, VamVan wrote:
>> How to create an associative array of this kind in PHP?
>>
>>  return array(
>>     12345 => array(
>>       'mail' => '[EMAIL PROTECTED]',
>>       'companyName' => 'Asdf Inc.',
>>     ),
>>     54321 => array(
>>       'mail' => '[EMAIL PROTECTED]',
>>       'companyName' => 'Asdfu Corp.',
>>     ),
>>   );
> 
> 
> This is the right PHP syntax, except that you've got an extraneous comma
> before the closing parenthesis of each array that's going to throw a
> parse error.

Actually that's allowed (and by design too) :)

-- 
Postgresql & php tutorials
http://www.designmagick.com/

--- End Message ---
--- Begin Message ---
On Fri, 2008-06-20 at 11:19 +1000, Chris wrote:
> Paul Novitski wrote:
> > At 6/19/2008 05:55 PM, VamVan wrote:
> >> How to create an associative array of this kind in PHP?
> >>
> >>  return array(
> >>     12345 => array(
> >>       'mail' => '[EMAIL PROTECTED]',
> >>       'companyName' => 'Asdf Inc.',
> >>     ),
> >>     54321 => array(
> >>       'mail' => '[EMAIL PROTECTED]',
> >>       'companyName' => 'Asdfu Corp.',
> >>     ),
> >>   );
> > 
> > 
> > This is the right PHP syntax, except that you've got an extraneous comma
> > before the closing parenthesis of each array that's going to throw a
> > parse error.
> 
> Actually that's allowed (and by design too) :)

Yep, it's there to primarily simplify generated PHP code. Additionally,
it sure makes commenting out chunks simple since you don't need to
comment out the preceding comma if commenting out the last entry.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
At 6/19/2008 07:36 PM, Robert Cummings wrote:
> >>     54321 => array(
> >>       'mail' => '[EMAIL PROTECTED]',
> >>       'companyName' => 'Asdfu Corp.',
> >>     ),
> >>   );
> >
> >
> > This is the right PHP syntax, except that you've got an extraneous comma
> > before the closing parenthesis of each array that's going to throw a
> > parse error.
>
> Actually that's allowed (and by design too) :)

Yep, it's there to primarily simplify generated PHP code. Additionally,
it sure makes commenting out chunks simple since you don't need to
comment out the preceding comma if commenting out the last entry.


Thanks. I could have sworn I'd gotten parse errors on that. Damned cross-language memory leakage...

I've gotten into the habit of writing comma-delimited lists like so:

        (item
        ,item
        ,item
        ,item
        );

which works for functions with long parameter lists and SQL field lists as well as arrays.

Paul
--- End Message ---
--- Begin Message ---
On Thu, 2008-06-19 at 19:59 -0700, Paul Novitski wrote:
> At 6/19/2008 07:36 PM, Robert Cummings wrote:
> > > >>     54321 => array(
> > > >>       'mail' => '[EMAIL PROTECTED]',
> > > >>       'companyName' => 'Asdfu Corp.',
> > > >>     ),
> > > >>   );
> > > >
> > > >
> > > > This is the right PHP syntax, except that you've got an extraneous comma
> > > > before the closing parenthesis of each array that's going to throw a
> > > > parse error.
> > >
> > > Actually that's allowed (and by design too) :)
> >
> >Yep, it's there to primarily simplify generated PHP code. Additionally,
> >it sure makes commenting out chunks simple since you don't need to
> >comment out the preceding comma if commenting out the last entry.
> 
> 
> Thanks.  I could have sworn I'd gotten parse errors on that.  Damned 
> cross-language memory leakage...
> 
> I've gotten into the habit of writing comma-delimited lists like so:
> 
>          (item
>          ,item
>          ,item
>          ,item
>          );
> 
> which works for functions with long parameter lists and SQL field 
> lists as well as arrays.

Unfortunately, commenting out the first entry brings you back to the
same problem of commenting out the last entry in the event trailing
commas weren't supported. You've merely reversed the problem...
unnecessarily so ;)

Personally, I use two styles of long parameters in my code (I still try
to write code to 78 characters wide). If a single line drop will suffice
I do the following:

    functionWithLotsOfParams(
        $param1, $param2, $param3, $param4, $param5, $param6 );

If I would still get wrapping, then I use a block style:

    functionWithFarToManyParamsOrLongVariableNames
    (
        $param1, $param2, $param3, $param4, $param5, $param6,
        $param7, $param8, $param9, $paramA, $paramB, $paramC
    );

Unlike array declarations, it's unlikely the parameter count will change
often :)

Cheers,
Rob.

Ps. Please Tedd... don't show an example using your weird ass
indentation style -- it makes me shudder that I might ever have to
maintain someone's code that follows your style ;)

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
At 5:31 PM +0300 6/19/08, Sancar Saran wrote:
Hi tedd

My final solution was.

class conf {

        public static $vals  = array(); // config array
...
}

conf::$vals['mysql_host'] = 'localhost';
conf::$vals['mysql_user'] = "[EMAIL PROTECTED]";

you can access anywhere of your script and you won't need to pollute $GLOBALS.

Regards

Sancar

Yeah, but now your code is OOP polluted.  :-)

Cheers,

tedd
--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--- End Message ---
--- Begin Message ---
On Thursday 19 June 2008 18:25:10 Jay Blanchard wrote:
> [snip]
>     I wonder how many of us on the list served.  It's got to be more
> than just you and I, Tedd, wouldn't you think?
> [/snip]
>
> U.S. Air Force

The Turkish Gendarmerie (Jandarma Genel Komutanligi)


--- End Message ---
--- Begin Message ---
Daniel Brown wrote:

>     I do agree, and I think it's worth another mention to the Website
> Team to discuss a specific OT list for those of us who would like to
> stray once in a while.  After all, you can't spend every day speaking
> with the same people on here without developing some common interests
> and bonds.

Very true - you'll also find me on one or two OT lists :-)

I don't know the story with the PHP lists, but if it's of any use, I'd
be happy to host a PHP-OT mailing list. 


/Per Jessen, Zürich


--- End Message ---
--- Begin Message ---
Per Jessen wrote:
Call me .. uh no, I'm getting sick ... you guys are so completely and
utterly off-topic - please take it off-line.

It was obviously off-topic from the beginning,... however it felt somehow OK... - I mean, it gave the list a personal touch and every successful organization dreams of its people having a more personal touch.

I'd also hate it if the list goes greatly off-topic inflated, but, I think, I'd hate it exactly as much if it was a dry on-topic thing where nobody says anything personal. If we were not so divided in time and space, we would occasionally meet for a "beer" - for me the off-topic explosions are the digital equivalent of this.

Iv

--

--- End Message ---
--- Begin Message ---
2008/6/19 Jay Blanchard <[EMAIL PROTECTED]>:
> [snip]
>    I wonder how many of us on the list served.  It's got to be more
> than just you and I, Tedd, wouldn't you think?
> [/snip]
>
> U.S. Air Force
>

Golani, IDF

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
2008/6/19 Nitsan Bin-Nun <[EMAIL PROTECTED]>:
> Dan i'm 16 years old, currently my monthly salary (working as php
> freelancer) almost catching my dad's and he is living good.
> In 2 years from now I have to serv, probably at the battle field (I'm
> healthy qualified) and usualy the place where guys like me being send to
> includes additional 2 years - at the bottom line I'm getting in at age of 18
> and becoming a citizen when i'm 23-24, I believe that if I won't take this
> service (there are zillions of oppertunities to step back from the
> service) I can start work at some web developing company (not freelancing)
> and start learn at university or something, but in Israel the feelings of
> apperciation to the motherland is higher than anywhere else in the world,
> since you are young the people around you (the nuclear family and everyone
> you know) injecting you the poison of this apperciation, so when you are 18
> years-old you know what is the meaning of service and you are aspiring to
> serv as much & as good as you can.
>
> Regards,
> Nitsan
>

Good for you, Nitsan. If you find yourself in Gdud 51 let me know.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
2008/6/19 Daniel Brown <[EMAIL PROTECTED]>:
>    I don't want to start any arguments or flame wars, but it's been
> my opinion for years that the US should require at least one year in
> the armed services as well.  If you want freedom and privileges, you
> should earn them, not feel automatically entitled to them by birth.
>

Have you read Starship Troopers? Their civilization is based upon this.

Dotan Cohen

http://what-is-what.com
http://gibberish.co.il
א-ב-ג-ד-ה-ו-ז-ח-ט-י-ך-כ-ל-ם-מ-ן-נ-ס-ע-ף-פ-ץ-צ-ק-ר-ש-ת

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?

--- End Message ---
--- Begin Message ---
Jim Lucas wrote:
> Iv Ray wrote:
>> Jim Lucas wrote:
> So, saying that it is outside the source does not tell me if it is
> outside the document root.

A, right.

It is outside the document root.

> Use your include_path php_ini setting

A, right...

Didn't think of it.

Actually, I do not like the include_path - it is too esoteric... - kind of a fog - I prefer to know where things I call come from :) - as it is said in Harry Potter - "Never trust an object of magic if you do not know where it keep its brains." ;)

But thanks, anyway!

Iv

--- End Message ---
--- Begin Message ---
Richard Heyes wrote:
i need a way to get the path to the parent folder of the folder i am in. one "dirty" way i found is this -

require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR .
             ".."              . DIRECTORY_SEPARATOR .
             "config.php");

i can also explode() and reassemble all folders except the last, but this looks also dirty...

is there a direct way?

There's nothing dirty about dirname(), and for your issue, just call it twice:

dirname(dirname(__FILE__));

I called "dirty" the ".." in my example.

Yes, dirname(dirname(__FILE__)); is the way to go - I was just too brainwashed and did not think I can apply it to a directory, too.

Thanks,
Iv

--- End Message ---
--- Begin Message ---
'm a total newbie..i just want to know how can i display an http response 200
with this message "message successfully sent" ...here is my code
<?php
if ($status == "RETEMP02")
echo "Mobile number is empty.";
elseif ($status == "RETEMP03")
echo "Message is empty.";
elseif ($status == "RETEMP05")
echo "Message Id is empty.";
elseif ($status == "RETVAL03")
echo "Invalid mobile number.";
elseif ($status == "RETVAL04")
echo "Mobile number not recognized.";
elseif ($status == "RETVAL05")
echo "Message is containing illegal character.";
elseif ($status == "")
echo "Message sending failed";
else
echo "Message has been sent successfully.";
?>
-- 
View this message in context: 
http://www.nabble.com/http-response-200-tp18026193p18026193.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
joaquinbordado wrote:
> 'm a total newbie..i just want to know how can i display an http response 200

Don't have time to customize it for you, but that's how it can be done-

header("HTTP/1.0 404 Not Found");
/*
 *
 * I copied the DOCTYPE from what Apache 1.3.34 returns.
 *
 */
echo "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">";
echo "<html>";
echo "<head>";
echo "<title>404 Not Found</title>";
echo "</head>";
echo "<body>";
echo "<h1>Not Found</h1>";
echo "<p>The requested URL " . $_SERVER['REQUEST_URL'] . "was not found on this server.</p>";
echo "<hr>";

Note, that you must not have any output before sending header(). There is a way to check, write back, if interested how.

Iv

--- End Message ---
--- Begin Message ---
ryan gacusana wrote:
here is my code
when accessing this url
http://localhost/podcast/podcast.php?mobile=0823172&message=2343443=%3Eryan

This runs on your computer, I can't access it.

else
echo "Message has been sent successfully.";
// in this part i want to respond with a status of 200,sorry i just started php last wik

Actually... If you print this text, the web server sends status 200 to the browser on its own accord. Or am I missing something.

The code I sent you sends custom 404 Not Found - in case you need that.

Iv

--- End Message ---
--- Begin Message ---
Hi,

Does someone knows of a PHP software that is an inline PDF reader ?
You can view the idea here:
http://www.scribd.com/doc/2025925/Clinical-chemistry-II-Biomedical-Science-practical-1

Any help would be appreciated.

Warm Regards,
Mário Gamito

--- End Message ---

Reply via email to