Re: [PHP] Testing people

2006-10-07 Thread Ryan A
Thats why I love this list... people share and help so unselfishly.
Thanks Rich, sure didnt think of the way you wrote the solution till i read 
your code!

Have a fab one!



Richard Lynch <[EMAIL PROTECTED]> wrote:
> I thought of having a hidden text box everytime for each question...
> but that can be quite easily found out... any other suggestions?

Don't send the correct answer to the browser at all.

And don't tie the "ABCD" to the correct answer.

  $question[47] = "Which animal flies around at night and sleeps in
the day?"
  $answer[13] = 'cat';
  $answer[14] = 'dog';
  $answer[15] = 'trout';
  $answer[16] = 'bat';
  $correct[47] = 'bat';
?>

Your HTML could look like this:
A  [input]  cat
B  [input]  dog
C  [input]  trout
D  [input]  bat

To test if the answer is correct:

$q = $_REQUEST['q'];
foreach($q as $index => $a){
  if ($correct[$index] == $a) echo "CORRECT";
  else echo "INCORRECT:  Correct is $correct[$index]";
  echo "
\n";
}

You could also use the index to $answer as the value with:
$correct[47] = 16;
 [input]  bat
if ($correct[$index] == $a){

and all the other code the same.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?




--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

-
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ 
countries) for 2¢/min or less.

Re: [PHP] Testing people

2006-10-07 Thread Ryan A
Thanks!
 Will give it a look-see!

Cheers!

Dotan Cohen <[EMAIL PROTECTED]> wrote: It's not exactly what you describe, but 
you should take a look at:
http://www.bigredspark.com/survey.html

Dotan Cohen
http://what-is-what.com
7



--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)

-
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1¢/min.

RE: [PHP] Unicode Problem

2006-10-07 Thread tedd

At 4:15 PM -0500 10/6/06, Richard Lynch wrote:

Perhaps you would care to extend your browsercam test to some
regression testing of more ancient browsers -- on Mac OS.



The following goes back to IE 5.2 for the Mac -- that's as far back 
as BrowserCam goes.


http://www.browsercam.com/public.aspx?proj_id=289683


I think you meant x2022 a.k.a. (dec)8226 :-)


Ahh, a typo thanks.

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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Set Variable = Long HTML String?

2006-10-07 Thread sit1way
Hey all.

I'm overhauling my PHP based CMS and want to know how to set a variable 
equal to an HTML string, but without having to escape all the quotes!

Example:

$var = "

   News Options
   doc_path 
?>admin/news/add/1/>Add
   doc_path 
?>admin/news/update/1/>Update
   doc_path 
?>admin/news/delete/1/>Delete
  
 ";

This will die due to all the unescaped strings, not to mention the doc_path ?> statements.

How to pull this off?  I don't want to include the HTML snippets as they are 
"sprinkled" throughout my classes.

TIA,

--Noah


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Set Variable = Long HTML String?

2006-10-07 Thread John Wells

On 10/7/06, sit1way <[EMAIL PROTECTED]> wrote:

I'm overhauling my PHP based CMS and want to know how to set a variable
equal to an HTML string, but without having to escape all the quotes!


Noah, meet HEREDOC.  HEREDOC, meet Noah:

http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

Now you cozy two, let's make it a party with the Complex (Curly {}) syntax:

http://uk.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex

All together now!

[code]
$var =<<
   
   News Options
   Add
   Update
   Delete
   

HEREDOC;
[/code]

HTH,
John W


TIA,

--Noah




--
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] Re: Set Variable = Long HTML String?

2006-10-07 Thread David Tulloh
You can mingle double and singal quotes.  So choose one for the PHP
quotes and one for the HTML quotes, HTML will use both interchangably.

For example your string could become:
$var = " Hey all.
> 
> I'm overhauling my PHP based CMS and want to know how to set a variable 
> equal to an HTML string, but without having to escape all the quotes!

You can mingle double and singal quotes.  So choose one for the PHP
quotes and one for the HTML quotes, HTML will use both interchangably.

For example your string could become:
$var = " Example:
> 
> $var = "
>  onChange="MM_jumpMenu('parent',this,0);">
>News Options
>doc_path 
> ?>admin/news/add/1/>Add
>doc_path 
> ?>admin/news/update/1/>Update
>doc_path 
> ?>admin/news/delete/1/>Delete
>   
>  ";
> 
> This will die due to all the unescaped strings, not to mention the  $this->doc_path ?> statements.
> 
> How to pull this off?  I don't want to include the HTML snippets as they are 
> "sprinkled" throughout my classes.
> 
> TIA,
> 
> --Noah
> 
> 
>  
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Set Variable = Long HTML String?

2006-10-07 Thread John Wells

On 10/7/06, Noah Cutler <[EMAIL PROTECTED]> wrote:

Yah, John.

Just found it via Google.

I remembered seeing this somewhere a couple years back but never used it.

Very cool -- performance hit using this, or just a really useful function?



From what I understand it suffers the same "hit" as double quotes,

since PHP has to parse it looking for variables.  But it's not really
"special", it's just not as well known.

- John W



Thanks,

--Noah




- Original Message -
From: "John Wells" <[EMAIL PROTECTED]>
To: "sit1way" <[EMAIL PROTECTED]>
Cc: 
Sent: Saturday, October 07, 2006 12:03 PM
Subject: Re: [PHP] Re: Set Variable = Long HTML String?


> On 10/7/06, sit1way <[EMAIL PROTECTED]> wrote:
>> I'm overhauling my PHP based CMS and want to know how to set a variable
>> equal to an HTML string, but without having to escape all the quotes!
>
> Noah, meet HEREDOC.  HEREDOC, meet Noah:
>
> 
http://uk.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
>
> Now you cozy two, let's make it a party with the Complex (Curly {})
> syntax:
>
> 
http://uk.php.net/manual/en/language.types.string.php#language.types.string.parsing.complex
>
> All together now!
>
> [code]
> $var =<< 
> onChange="MM_jumpMenu('parent',this,0);">
>News Options
>Add
> value="{$this->doc_path}admin/news/update/1/">Update
> value="{$this->doc_path}admin/news/delete/1/">Delete
>
> 
> HEREDOC;
> [/code]
>
> HTH,
> John W
>
>> TIA,
>>
>> --Noah
>>
>>
>>
>>
>> --
>> 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] set cookie with non-english

2006-10-07 Thread Ahmad Al-Twaijiry

BTW I want to access the (cookie or session) variable from php &
javascript, so I don't think session is a solution

so again, does anyone know how to resolve the problem so I can write
the cookie output to UTF-8 html page ?

On 10/5/06, Richard Lynch <[EMAIL PROTECTED]> wrote:

On Tue, October 3, 2006 11:18 pm, Ahmad Al-Twaijiry wrote:
> I already made the application with cookies, it's will be very
> defaucalt to go and replace cookies with session,
>
> is it possible to use cookies & session in the same time ? (
> session_start() & setcookie in the same page ?)

Sure...

Though if it's hard to convert your Cookies code to session_start()
you've done something very wrong already... ;-)

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?





--

Ahmad Fahad AlTwaijiry

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Separate PHP Code From HTML || Pros & Cons?

2006-10-07 Thread sit1way
Hey all.

I've built a simple, yet effective PHP based CMS, one that I use in all 
sites I develop.

Unfortunately, from site-to-site, functionality may be different; i.e. I 
often have to extend the original CMS to account for custom client needs, 
which means grabbing the most recent version of my CMS, and hacking it to 
address whatever customization is required.

This presents problems in that any updates I make to the CMS only affect the 
site I'm working on.  So, while working on one site I may make changes to 
the CMS, changes that improve the app., but other older sites do not get 
updated -- it's OK now, but things are getting sloppy ;--)

I would dearly love to have a base CMS repository that all sites would draw 
on, extending the base CMS in the event that a particular client has need of 
customization.  Some combo of Linux and Apache would do the trick; e.g. PHP 
requests for any of my sites would point to say, "/home/cms/includes/"

That would help (not solve) the version control problems I'm running into 
now (still have to figure out how to extend the CMS for customization).

Now, the other issue I'd like to address is separating PHP code logic from 
site HTML.

I've restructured my CMS classes to do all MySQL queries, code logic, etc. 
prior to calling target HTML template.  This is great in that now when an 
error occurs, I can catch { throw new Exception($e) } and gracefully display 
the error along with a means to repopulating the offending form page.

I've often heard the mantra, "separate code from HTML", but it seems 
ridiculous at times to include tiny HTML snippets that can easily be echoed 
out, or stored in a variable.  Smarty goes to the extreme in separating code 
from HTML, but looking at their templating system, I wonder what's the 
point?  Is it the end of the world if you've got a few choice if, then, else 
statements in your HTML templates?

I'm thinking of creating a bunch of include files based on request type in 
my CMS Admin Center; e.g. include "classes/admin/news/add.php", where add, 
update, or delete is the request type.  This cleans up my PHP processing 
pages quite a bit (don't have all the if add, do X, elseif update, do Y, 
etc. logic to comb through).

Last thing to do is write up a generic form builder class to assemble my 
form pages, but that may be more work than necessary -- K-rist, webwork is 
messy business ;--)

Clues, Opinions, etc. are welcome.

TIA,

--Noah


 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] FTP

2006-10-07 Thread Raphael Martins

Hi,

When I send files via FTP, the file size is limited to the php.ini max
upload value?
Thank you!


Re: [PHP] Re: Separate PHP Code From HTML || Pros & Cons

2006-10-07 Thread Thiago Silva

On 10/7/06, sit1way <[EMAIL PROTECTED]> wrote:


Hey all.

This presents problems in that any updates I make to the CMS only affect
the
site I'm working on.  So, while working on one site I may make changes to
the CMS, changes that improve the app., but other older sites do not get
updated -- it's OK now, but things are getting sloppy ;--)

I would dearly love to have a base CMS repository that all sites would
draw
on, extending the base CMS in the event that a particular client has need
of
customization.  Some combo of Linux and Apache would do the trick; e.g.
PHP
requests for any of my sites would point to say, "/home/cms/includes/"



Are you using a version control system? Using one and, maybe, reviewing your
architeture for code re-use might help in this matter, I think

Now, the other issue I'd like to address is separating PHP code logic from

site HTML.

(...)


I've often heard the mantra, "separate code from HTML", but it seems

ridiculous at times to include tiny HTML snippets that can easily be
echoed
out, or stored in a variable.  Smarty goes to the extreme in separating
code
from HTML, but looking at their templating system, I wonder what's the
point?  Is it the end of the world if you've got a few choice if, then,
else
statements in your HTML templates?




Is of my understading that this mantra is about intention in the code.
We have a framework written in PHP that also uses PHP as template language.

I mean, we have source files that define components, where we use PHP to
process the data normally (declaring classes, using DB, etc), but there are
also "snippet" files were we have HTML + PHP.

The special case here is that the snippet files have a couple of arrays with
data (created and offered by the components) available and their only
occupation is to process output: no DB access, no class declaration, no file
inclusion, no socket connectionall they have to do is render HTML (or
whatever) with the data they received. The most complex things we have in
snippet files are small functions where recursions help displaying  some
widgets. Everything else are loops, decision strucutres and lots of
print/echo. Simple source files, in the end.


Thiago Silva


Re: [PHP] FTP

2006-10-07 Thread Brad Chow

Hi Martins,

Of course. You can alter it you want.

I remember that file size limit devided into two type:
1) local access
2) remote access

file size limit only limit remote access because I can upload file from
local more than limit.

Good luck!!

Brad

On 10/8/06, Raphael Martins <[EMAIL PROTECTED]> wrote:


Hi,

When I send files via FTP, the file size is limited to the php.ini max
upload value?
Thank you!




Re: [PHP] Re: Separate PHP Code From HTML || Pros & Cons

2006-10-07 Thread Tony Di Croce

I  dont think its so bad.

What I do is keep the PHP and HTML seperate, but in the same file: php on
top, html in a here document at the bottom. I COULD go one step farther and
have the HTML in a seperate file, but I just dont see the point.

  td

On 10/7/06, Thiago Silva <[EMAIL PROTECTED]> wrote:


On 10/7/06, sit1way <[EMAIL PROTECTED]> wrote:
>
> Hey all.
>
> This presents problems in that any updates I make to the CMS only affect
> the
> site I'm working on.  So, while working on one site I may make changes
to
> the CMS, changes that improve the app., but other older sites do not get
> updated -- it's OK now, but things are getting sloppy ;--)
>
> I would dearly love to have a base CMS repository that all sites would
> draw
> on, extending the base CMS in the event that a particular client has
need
> of
> customization.  Some combo of Linux and Apache would do the trick; e.g.
> PHP
> requests for any of my sites would point to say, "/home/cms/includes/"


Are you using a version control system? Using one and, maybe, reviewing
your
architeture for code re-use might help in this matter, I think

Now, the other issue I'd like to address is separating PHP code logic from
> site HTML.
>
> (...)
>
I've often heard the mantra, "separate code from HTML", but it seems
> ridiculous at times to include tiny HTML snippets that can easily be
> echoed
> out, or stored in a variable.  Smarty goes to the extreme in separating
> code
> from HTML, but looking at their templating system, I wonder what's the
> point?  Is it the end of the world if you've got a few choice if, then,
> else
> statements in your HTML templates?



Is of my understading that this mantra is about intention in the code.
We have a framework written in PHP that also uses PHP as template
language.

I mean, we have source files that define components, where we use PHP to
process the data normally (declaring classes, using DB, etc), but there
are
also "snippet" files were we have HTML + PHP.

The special case here is that the snippet files have a couple of arrays
with
data (created and offered by the components) available and their only
occupation is to process output: no DB access, no class declaration, no
file
inclusion, no socket connectionall they have to do is render HTML (or
whatever) with the data they received. The most complex things we have in
snippet files are small functions where recursions help displaying  some
widgets. Everything else are loops, decision strucutres and lots of
print/echo. Simple source files, in the end.


Thiago Silva





--
Publish technical articles @ skilledwords.com and get 100% of the
ad-revenue!
http://www.skilledwords.com


[PHP] Re: set cookie with non-english

2006-10-07 Thread Nisse Engström
On Tue, 3 Oct 2006 01:15:59 +0300, "Ahmad Al-Twaijiry" wrote:

> Hi everyone
> 
> in my PHP code I use the following command to set a cookie with
> non-english word (UTF-8) :
> 
> @setcookie ("UserName",$Check[1]);
> 
> and in my html page I get this cookie using javascript :

[Snipped]

> but the result from writing the cookie using javascript is garbage, I
> don't get the right word !!

   The problem is that JavaScript uses UTF-16, so you
either have to store the cookie as UTF-16 or do your
own UTF-8 decoding in JavaScript.

   For example, consider the string "åäö", containing
the three funny characters in the Swedish language
(åäö). These characters are encoded
as  in UTF-8, and PHP stores these
in the cookie as:

  %C3%A5%C3%A4%C3%B6

Example:

--

http://www.w3.org/TR/html4/strict.dtd";>

UTF-8 flavoured cookies




  document.write(document.cookie);


--

   The unescape() function in JavaScript converts
these characters to the Unicode code points
<00c3 00a5 00c3 00a4 00c3 00b6> which, of course,
is not what you want.

Example:

--

http://www.w3.org/TR/html4/strict.dtd";>

UTF-8 flavoured cookies




  var s = unescape(document.cookie);
  var t = "";
  for (var i = 0; i < s.length; i++) {
var c = s.charCodeAt(i);
t += c < 128 ? String.fromCharCode(c) : c.toString(16) + " ";
  }
  document.write(t);


--

   While there are no doubt better ways to solve this,
you /could/ use the unescape() function to convert the
percent-encoded characters to unicode code point, and
then write your own UTF-8 decoder to do the rest.

Example:

(This is an old C function hammered into JavaScript
 shape. It is likely to be a horrible implementation
 in JavaScript. The error checking adds a bit of bloat.
 Note that the utf_8_decode function supports the full
 Unicode range, while JavaScript doesn't. )
--

http://www.w3.org/TR/html4/strict.dtd";>

UTF-8 flavoured cookies




function utf_8_decode (sin)
{
  function octet_count (c)
  {
var octet_counts = [
/* c0 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
/* d0 */ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
/* e0 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
/* f0 */ 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 0, 0
];

return c < 128 ? 1 :
   c < 192 ? 0 : octet_counts [(c&255)-192];
  }

  var octet0_masks = [ 0x00,0x7f,0x1f,0x0f,0x07,0x03,0x01 ];
  var sout = "";
  var add;
  for (var si = 0; si < sin.length; si += add) {
var c = sin.charCodeAt(si);
add = octet_count(c);
if (si+add <= sin.length) {
  var u = c & octet0_masks[add];
  var ci;
  for (ci = 1; (ci < add) && ((sin.charCodeAt(si+ci)&0xc0) == 0x80);
ci++)
u = (u<<6) | (sin.charCodeAt(si+ci) & 0x3f);
  if (ci == add) {
sout += String.fromCharCode (u);
  } else {
// Invalid UTF-8 sequence. Should probably throw() instead.
sout += "\ufffd"; // Replacement character.
add = 1;
  }
} else {
  // Invalid UTF-8 sequence. Should probably throw() instead.
  sout += "\ufffd"; // Replacement character.
  add = 1;
}
  }

  return sout;
}

document.write (utf_8_decode(unescape(document.cookie)));


--

> BTW:
> * I also tried the php function setrawcookie and I get the same problem
> * I use  in my page

   The  thing might be good for storing pages
on disk, but on the web you should use real HTTP
headers.


  --nfe

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] ECHO $variable

2006-10-07 Thread Ron Piggott (PHP)
In one of my scripts I have



where

$saved_message_title is 1 Peter 5:7 "Cast all your cares on Him for He
cares about you"
--- note the " 

When this is displayed on the screen $saved_message_title reads

1 Peter 5:7 

I am assuming the " closes the value=

How may I echo this to the screen and have the full text be displayed,
not just 1 Peter 5:7 ?

Ron