|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 3 Oct 2005 15:51:35 -0000 Issue 3717
php-general-digest-help
lists.php.net
Date: Mon Oct 03 2005 - 10:51:35 CDT
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 3 Oct 2005 15:51:35 -0000 Issue 3717
Topics (messages 223546 through 223565):
Re: session_name("CCLTrolley")
223546 by: John Taylor-Johnston
223547 by: Robert Cummings
223549 by: John Taylor-Johnston
223550 by: John Taylor-Johnston
223551 by: John Taylor-Johnston
223562 by: Robert Cummings
Re: PHP 5 Hosting
223548 by: Oliver Grätz
Re: PDF Thumbnails
223552 by: benc11.gmail.com
How to automate php with crontab?
223553 by: Rasim ÞEN
223555 by: Petar Nedyalkov
Re: convert array to HTML GET request
223554 by: hope
Re: PHP and Active Directory
223556 by: Mark Rees
Re: creating a shopping cart.
223557 by: Jay Blanchard
Re: Array - partical path to the array's path (part 2)
223558 by: Scott Fletcher
Upper case problem
223559 by: Merlin
223560 by: Jay Blanchard
223563 by: Georgi Ivanov
session save path
223561 by: jonathan
Re: decrypting query string back into $_GET['var'] [resend]
223564 by: Graham Anderson
Re: passing a variable with php_self
223565 by: Jeffrey Sambells
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
>Warning: Bad arguments to implode() in /var/.../printtrolley.php on
line 14
>Array ( [TrolleyContents] => 1 3 4 4 5 6 )
I restarted Mozilla and tried again.
It's ok now.
Thanks for your time.
Array
(
[TrolleyContents] => Array
(
[16] => 16
[30] => 30
[47] => 47
[76] => 76
[368] => 368
[1687] => 1687
[1939] => 1939
[1761] => 1761
[1880] => 1880
[1936] => 1936
)
)
attached mail follows:
On Mon, 2005-10-03 at 00:16, John Taylor-Johnston wrote:
> >Warning: Bad arguments to implode() in /var/.../printtrolley.php on
> line 14
> >Array ( [TrolleyContents] => 1 3 4 4 5 6 )
>
> I restarted Mozilla and tried again.
> It's ok now.
> Thanks for your time.
The old session was probably still populated with the string version.
>
> Array
> (
> [TrolleyContents] => Array
> (
> [16] => 16
> [30] => 30
> [47] => 47
> [76] => 76
> [368] => 368
> [1687] => 1687
> [1939] => 1939
> [1761] => 1761
> [1880] => 1880
> [1936] => 1936
> )
>
> )
This is the old version I demonstrated. You should go with the later
version that sets the values to the quantity :)
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
>This is the old version I demonstrated. You should go with the later
>version that sets the values to the quantity :)
I thought I had? Haven't I?
But this is the easiest shopping cart I have ever seen.
However, I still have not understood what you were doing with these
lines I commented out.
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
They did not work, or seem to?
John
---------------snip--------------------
http://testesp.flsh.usherbrooke.ca/db/trolley.php
Array
(
[TrolleyContents] => Array
(
[2378] => 2378
[2504] => 2504
)
)
)
---------------snip--------------------
<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
$_SESSION['TrolleyContents'] = array();
}
echo $_POST['ShopAction']."!!<br>";
if("add" == $_POST['ShopAction'])
{
echo "adding ...";
// Add new entry:
if( isset( $_POST['RNum'] ) )
{
$_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
#echo $_POST['RNum']."!!<br>";
}else{
echo "deleting ...";
//Delete an entry:
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
}
}
print_r( $_SESSION );
?>
--------Delete form: snip -------
<form ACTION="trolley.php" METHOD="POST">
<input type="hidden" name="RNum" value="2378">
<input type="hidden" name="searchenquiry" value="Taylor-Johnston,
John"><input type="hidden" name="ShopAction" value="delete">
<input type="image" name="submit" src="/icon/full3.gif" border="0"
alt="Delete" title="Delete" style="padding-right:
5px;"><br><small>Delete</small></form>
--------Add form: snip -------
<form targt="printwindow" ACTION="trolley.php" METHOD="POST">
<input type="hidden" name="RNum" value="2504">
<input type="hidden" name="searchenquiry" value="John
Taylor-Johnston"><input type="hidden" name="ShopAction" value="add">
<input type="image" name="submit" src="/icon/empty3.gif" border="0"
alt="Add to cart" title="Add to cart" style="padding-right:
5px;"><br><small>Add to cart</small></form>
attached mail follows:
This is what you recommended.
> Is there a reason you're using a comma delimited string? I would
> recommend using an array instead:
> <?php
> session_name( 'CCLTrolley' );
> session_start();
> // Initialize the trolley.
> if( !isset( $_SESSION['TrolleyContents'] ) )
> {
> $_SESSION['TrolleyContents'] = array();
> }
> // Add new entry.
> if( isset( $_POST['AddToTrolley'] ) )
> {
> $_SESSION['TrolleyContents'][$_POST['AddToTrolley']] =
> $_POST['AddToTrolley']
> }
> echo implode( ',', $_SESSION['TrolleyContents'] );
> phpinfo();
> ?>
This is what I implemented? Where did I go wrong?
John
<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
$_SESSION['TrolleyContents'] = array();
}
if("add" == $_POST['ShopAction'])
{
// Add new entry:
if( isset( $_POST['RNum'] ) )
{
$_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
}else{
//Delete an entry:
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
}
}
print_r( $_SESSION );
#phpinfo();
?>
attached mail follows:
This is what you recommended.
> Is there a reason you're using a comma delimited string? I would
> recommend using an array instead:
> <?php
> session_name( 'CCLTrolley' );
> session_start();
> // Initialize the trolley.
> if( !isset( $_SESSION['TrolleyContents'] ) )
> {
> $_SESSION['TrolleyContents'] = array();
> }
> // Add new entry.
> if( isset( $_POST['AddToTrolley'] ) )
> {
> $_SESSION['TrolleyContents'][$_POST['AddToTrolley']] =
> $_POST['AddToTrolley']
> }
> echo implode( ',', $_SESSION['TrolleyContents'] );
> phpinfo();
> ?>
This is what I implemented? Where did I go wrong?
John
<?php
session_name( 'CCLTrolley' );
session_start();
// Initialize the trolley.
if( !isset( $_SESSION['TrolleyContents'] ) )
{
$_SESSION['TrolleyContents'] = array();
}
if("add" == $_POST['ShopAction'])
{
// Add new entry:
if( isset( $_POST['RNum'] ) )
{
$_SESSION['TrolleyContents'][$_POST['RNum']] = $_POST['RNum'];
}
echo implode( ',', $_SESSION['TrolleyContents'] );
}else{
//Delete an entry:
if( isset( $_SESSION['TrolleyContents'][$_POST['RNum']] ) )
{
# $_SESSION['TrolleyContents'][$_POST['RNum']] -= 1;
# if( $_SESSION['TrolleyContents'][$_POST['RNum']] <= 0 )
# {
unset( $_SESSION['TrolleyContents'][$_POST['RNum']] );
# }
}
}
print_r( $_SESSION );
#phpinfo();
?>
attached mail follows:
On Sun, 2005-10-02 at 01:01, Robert Cummings wrote:
>
> If you go with an array system might I suggest the following change to
> what I wrote:
I'm resending a better way to do the simple trolley since you seemed to
have created a Frankensteinian merge of the two examples I sent
previously. This version uses functions which should probably be put
into their own source file and included (let's call it lib.trolley.php).
<?php
session_name( 'CCLTrolley' );
session_start();
//
// Initialize the trolley.
//
if( !isset( $_SESSION['TrolleyContents'] ) )
{
$_SESSION['TrolleyContents'] = array();
}
function trolleyItemQuantity( $itemId )
{
$trolley = &$_SESSION['TrolleyContents'];
//
// Return the $quantity of $item in the $trolley.
//
if( isset( $trolley[$item] ) )
{
return $trolley[$item];
}
return 0;
}
function trolleyItemExists( $itemId, $quantity )
{
$trolley = &$_SESSION['TrolleyContents'];
//
// Return true if $item is in the $trolley; otherwise return false.
//
if( isset( $trolley[$item] ) )
{
return $trolley[$item];
}
return 0;
}
function trolleyItemAdd( $itemId, $quantity )
{
$trolley = &$_SESSION['TrolleyContents'];
//
// Add $quantity of $item to the $trolley.
//
if( isset( $trolley[$item] ) )
{
$trolley[$item] += $quantity;
}
else
{
$trolley[$item] = $quantity;
}
}
function trolleyItemRemove( $itemId, $quantity )
{
$trolley = &$_SESSION['TrolleyContents'];
//
// Remove $quantity of $item from the $trolley.
//
if( isset( $trolley[$item] ) )
{
$trolley[$item] -= $quantity;
if( $trolley[$item] < 1 )
{
unset( $trolley[$item] );
}
}
}
function trolleyPrint()
{
//
// Display the trolley.
//
echo "<pre>\n"
.implode( ',', array_keys( $_SESSION['TrolleyContents'] ) )
."\n</pre>\n";
}
?>
Now the following would facilitate the action you appear to be
performing in your example for adding to the trolley:
<?php
include_once( 'lib.trolley.php' );
if( isset( $_POST['ShopAction'] ) && isset( $_POST['RNum'] ) )
{
echo $_POST['ShopAction'].'!!<br />';
if( 'add' == $_POST['ShopAction'] )
{
echo 'Adding '.$_POST['RNum'].'...<br />';
trolleyItemAdd( $_POST['RNum'], 1 );
}
else
if( 'delete' == $_POST['ShopAction'] )
{
echo 'Deleting '.$_POST['RNum'].'...<br />';
trolleyItemRemove( $_POST['RNum'], 1 );
}
}
else
{
echo 'No action specified!!<br />';
}
trolleyPrint();
?>
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
attached mail follows:
Torgny Bjers schrieb:
> I am assuming they're running PHP through CGI in this case, am I
> correct, or are they hosting on Windows to achieve the multiple PHP
> versions? If CGI, that rather affects performance of larger
> applications, it especially impact render time of more complex templates
> and forms. During my own testing we gained lots of time by just running
> it as a compiled Apache module instead of through CGI and in .htaccess.
Well, I guess you are right. One can compile multiple versions of PHP to
run as Apache module in parallel by changing the sources (one has to
change some symbol names) but I think Strato didn't do that since most
shared hosting services run PHP as CGI anway for security reasons.
Also, I think writing applications with high performance requirements
somewhat contradicts deploying them on shared hosts. If you need
performance: Get a dedicated server and - if you want - even compile yer
own hand-optimized PHP.
And: Clever development circumvents the CGI bottleneck. Developing is
absolutely no problem under CGI since it's done by just a few users and
here the flexibility of multiple version kicks in: You can freely
choose! For the production version you simply use a good userland cache
that minimizes the work done by PHP.
AllOLLi
____________
Bree: "Do you know, I’ve finally convinced Rex to buy his first orchid."
George: "Make sure you study up. I hate people who own precious flowers
and don’t know how to take proper care of them."
Rex: "You know what I hate? Weeds. They just pop up out of nowhere
and you have to work so hard to get rid of them."
George: "I find that with the right chemicals you can get rid of anything."
[DH 120, earns the price for most subtext per sentence.]
attached mail follows:
How do I implement using your script? Do this take all of the files in a
directory and convert them into pdf thumbnails? Where does the directory
path go? Thanks for posting and the help.
On 9/29/05, Matt Darby <matt
matt-darby.com> wrote:
>
> I wrote a script for this; it's designed to run from the command line in
> *nix, but can be triggered via exec():
>
> Usage: ./pdf2thumb.php "source_dir" "out_dir"
>
> [code]
>
> #!/usr/local/bin/php
>
> <?
> function getDirFiles($dirPath){
> $filesArr=array("");
> if ($handle = opendir($dirPath)){
> while (false !== ($file = readdir($handle)))
> if ($file != "." && $file != ".."){$filesArr[] = trim($file);}
> closedir($handle);}
> return $filesArr;
> }
>
> function usage(){
> echo("USAGE: pdf2thumb source_folder_path
> <destination_folder_path>\n\n");
> exit;
> }
>
> if(!isset($argv[1])){usage();}
> substr($argv[1],-1)=="/"?$path=$argv[1]:$path=$argv[1]."/";
>
> isset($argv[2])?$dest_path=$argv[2]:$dest_path=$path;
> substr($dest_path,-1)=="/"?$dest_path=$dest_path:$dest_path.="/";
>
> $total_time=0;
> $total_files=0;
>
> if(!file_exists($dest_path)){`mkdir $dest_path`;}
>
> $files=getDirFiles($path);
>
> for($i=0;$i<count($files);$i++){
> if(substr($files[$i],-3)=="pdf"){
> echo("Converting ".$files[$i]."... ");
> $time_start = microtime(true);
>
> $old_name=$path.$files[$i];
> $new_name=$dest_path.str_replace(".pdf",".jpg",$files[$i]);
>
> `/usr/bin/convert '$old_name' -thumbnail 240x160 '$new_name'`;
>
> $time_end = microtime(true);
> $convert_time=round($time_end-$time_start,2);
> echo("Done. ($convert_time seconds)\n");
> $total_time+=$convert_time;
> $total_files++;
> }
> }
>
> echo("\n---------------------------------------------------\n");
> echo("$total_files files converted in ".round($total_time/60,2)."
> $minutes (AVG: ".round($total_time/$total_files,2)."s)\n\n");
>
> ?>
>
> [/code]
>
> benc11
gmail.com wrote:
>
> >You would haven't happen to have an example? I am new to imagemagick. Any
> >help would be greatly appreciated.
> >
> >On 9/26/05, Jim Moseby <JMoseby
nrbindustries.com> wrote:
> >
> >
> >>>-----Original Message-----
> >>>From: benc11
gmail.com [mailto:benc11
gmail.com]
> >>>Sent: Monday, September 26, 2005 1:43 AM
> >>>To: php-general
lists.php.net
> >>>Subject: [PHP] PDF Thumbnails
> >>>
> >>>
> >>>I give my users an option to upload pdf files to my site and
> >>>would like them
> >>>to see a thumbnail view of the file once uploaded. Has anyone
> >>>heard of a way
> >>>how to do this?
> >>>
> >>>
> >>The 'convert' function of ImageMagick will do it.
> >>
> >>JM
> >>
> >>
> >>
> >
> >
> >
>
>
>
attached mail follows:
hi,
Anybody know how to automate php with crontab. I want to generate in every 5
minute one php file.
thanks alot
rasim
attached mail follows:
On Monday 03 October 2005 11:20, Rasim XEN wrote:
> hi,
>
> Anybody know how to automate php with crontab. I want to generate in every
> 5 minute one php file.
crontab -e :-)
Check:
http://www.phpfreaks.com/tutorials/28/0.php
and
http://www.tech-geeks.org/contrib/mdrone/cron&crontab-howto.htm
>
> thanks alot
>
> rasim
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)
iD8DBQBDQPAjLT98C3rkVDYRAnGyAJ9UeqLa+JH5mk/gCy5qdBQfBocaPQCgntY8
96rPgYMOhnZWR9yDppf2Feo=
=VgYb
-----END PGP SIGNATURE-----
attached mail follows:
on 2nd page you can use
global $HTTP_POST_VARS;
print_r($HTTP_POST_VARS);
/// u can use $HTTP_GET_VARS for GET method
regards
hope
adriano ghezzi wrote:
> if i understand well you need to get an array from html post
> if you use the same name for your html fields you automatically have
> an array in $_POST
> eg
> input type=text name=myfield value="field_1"
> input type=text name=myfield value="field_2"
> you'll get the array ar_myfield = $_POS['myfield']
> you should achieve the same result using myfield[key] in the name of html
> hyh
> by ag.
> 2005/10/2, Martin van den Berg <martinvdberg
gmail.com>:
>> Newbe question:
>>
>> How does one convert an array into a HTML GET request easely? Are
>> there any standard functions?
>>
>> Same for HTML POST requests.
>>
>> Thanks,
>>
>> Martin.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
attached mail follows:
How do I connect a php script running on linux with Active Directory on
a windows machine? I would like to have my php script autmotatically
read email addresses from the AD server. Can this be done? I've found a
bunch of ldap functions for php but they seem to require ldap to be
installed on linux. I'm confused. Thanks in advance for your help.
---------------------------------------------------------------------------
Have you seen this?
http://uk2.php.net/ldap
I've managed to do it from Windows, after a lot of trial and error, but in
the end it wasn't that complicated. Have you got any specific questions,
based on following the steps in the manual?
Mark
attached mail follows:
[snip]
What's the best approach to create a shopping cart.?
[/snip]
I see that you have received some answers already but I wanted to point out
something very obvious....learn how to plan a software application. I know
that I am old school, but I see far too many developers today winging it. A
lot of the reason is that many languages now lend themselves to being
self-taught, and while learning the language is great it is not the only
thing a programmer needs to know about developing software.
A basic flowchart could have helped you to answer your question and broken
down the processes into their componenet parts. Heck, you don't even need
fancy flowcharting software...just write down the steps.
attached mail follows:
Got it figured out by now. I noticed one small bug but I'll fix it monday
morning, so i'm going to post what I did to make this work..
I'm going to donate this code to the guy at
http://www.devdump.com/phpxml.php and hopefully he'll put some of this to a
good use as more and more people are now using xml to exchange data, so this
would be very helpful to people who may need this...
[code]
$array = array
(
'NEWSFEED' => array
(
'0' => array
(
'ATTRIBUTES' => array
(
'ID' => 'test1'
),
'MESSAGE' => array
(
'0' => array
(
'ATTRIBUTES' => array
(
'ID' => 'test2',
'TID' => 'test4'
),
'TITLE' => array
(
'0' => array
(
'VALUE' => 'Title #1'
),
'1' => array
(
'VALUE' => 'Title #2'
)
),
'QUOTE' => array
(
'0' => array ( 'VALUE' => 'Quote #1' )
),
'BODY' => array
(
'0' => array ( 'VALUE' => 'Body #1' )
),
'REFERENCE' => array
(
'0' => array ( 'VALUE' => 'Reference #1' )
)
),
'1' => array
(
'TITLE' => array
(
'0' => array ( 'VALUE' => 'Title #2' )
),
'BODY' => array
(
'0' => array ( 'VALUE' => 'Body #2' )
),
'REFERENCE' => array
(
'0' => array ( 'VALUE' => '' )
)
),
'2' => array
(
'ATTRIBUTES' => array
(
'ID' => 'test3'
),
'TITLE' => array
(
'0' => array ( 'VALUE' => 'Title #3' )
),
'BODY' => array
(
'0' => array ( 'VALUE' => 'Body #3' )
),
'IMAGE' => array
(
'0' => array ( 'VALUE' => 'Image #3' )
),
'REFERENCE' => array
(
'0' => array ( 'VALUE' => 'Reference #3' )
)
)
)
)
),
'BLOG' => array
(
'0' => array
(
'MESSAGE' => array
(
'0' => array ( 'VALUE' => 'Title #1' )
)
)
)
);
function XmlTreeImplode($tree, $branch_level, &$array_key, &$xml_string)
{
$branch_level++;
$tab_spacer = " "; //Options to use white spaces or html spaces,
etc...
foreach($tree as $key => $value)
{
if (strtoupper($key) != "ATTRIBUTES") {
$array_key[count($array_key)] = $key;
}
if ($branch_level % 2 != 0) { //xml tag's name...
if (strtoupper($key) != "ATTRIBUTES") {
if(!(is_array($value))) { //Check for VALUE or CDATA name
tag...
$xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$key.">".$value."</".$key.">"."\r";
} else { //Continue...
//=================================
//Grab the attribute data if any...
//=================================
if (is_array($value['0']['ATTRIBUTES'])) {
foreach($value['0']['ATTRIBUTES'] as $key1 => $value1) {
$attribute .= " ".$key1."=\"".$value1."\"";
}
}
//=================================
//Otherwise
$xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$key.$attribute.">"."\r";
XmlTreeImplode($value, $branch_level, $array_key,
$xml_string);
$xml_string .= str_repeat($tab_spacer,
($branch_level-1))."</".$key.">"."\r";
}
}
} else { //xml name-tag counter...
if ($key != 0) {
//=================================
//Grab the attribute data if any...
//=================================
if (is_array($value['ATTRIBUTES'])) {
foreach($value['ATTRIBUTES'] as $key1 => $value1) {
$attribute .= " ".$key1."=\"".$value1."\"";
}
}
//=================================
$xml_string .= str_repeat($tab_spacer,
($branch_level-1))."</".$array_key[$branch_level-2].">"."\r";
$xml_string .= str_repeat($tab_spacer,
($branch_level-1))."<".$array_key[$branch_level-2].$attribute.">"."\r";
}
XmlTreeImplode($value, $branch_level, $array_key, $xml_string);
}
}
}
$xml_string = GetXmlStr($array);
[/code]
attached mail follows:
Hi there,
I am having problems with users who upload text that only contains upper case
letters. For example "SEARCHING FOR". Is there a way to detect this via PHP?`
I would like to have the script return him to the form and inform him that this
is not allowed.
So basicly I need a sort of regex which does detect upper case letters in a row.
Has anybody ann idea how such an regex could look like?
Thank you for any hint,
Merlin
attached mail follows:
[snip]
I am having problems with users who upload text that only contains upper
case
letters. For example "SEARCHING FOR". Is there a way to detect this via
PHP?`
I would like to have the script return him to the form and inform him that
this
is not allowed.
So basicly I need a sort of regex which does detect upper case letters in a
row.
Has anybody ann idea how such an regex could look like?
[/snip]
/A-Z/
attached mail follows:
<?php
$par=$_GET['string'];
if ($par == strtoupper($par)){
//This is uppercase
}
else{
//it is not uppercase
}
?>
On Monday 03 October 2005 16:28, Merlin wrote:
> Hi there,
>
> I am having problems with users who upload text that only contains upper
> case letters. For example "SEARCHING FOR". Is there a way to detect this
> via PHP?` I would like to have the script return him to the form and inform
> him that this is not allowed.
> So basicly I need a sort of regex which does detect upper case letters in a
> row. Has anybody ann idea how such an regex could look like?
>
> Thank you for any hint,
>
> Merlin
attached mail follows:
I'm looking for where apache / php will be saving the user session
files. when I do a phpinfo(), it tells me that session.save_path will
be temp but when I look at the files in there, there are only a
couple of files and they say nwIN;
Is there any way to directly access the session files in this way to
get at the values?
-jon
attached mail follows:
Is this the safest way to send GET variables ?
Guess I am trying to improve my code :)
//----------------------------------
// 'Sending' PHP script:
require_once("/home/includes/encryption.inc");
$str
=encrypt(urlencode("movie=mymovie.mov&mask=mask.gif&drag=drag.gif"));
$finalURLString = $pathtoReceivingScript.$str ;
//----------------------------------
// 'Receiving' PHP script:
require_once("/home/includes/encryption.inc");
$str =$_SERVER['QUERY_STRING'];
parse_str(urldecode(decrypt($str)),$getVarArray);
$movie = $getVarArray['movie'];
$mask = $getVarArray['mask'];
$drag = $getVarArray['drag'];
//echo "$movie,$mask,$drag";
//----------------------------------
// Encryption.inc
// Encrypt
function encrypt($encrypt) {
$key = "6r9qEJg6";
srand((double) microtime() * 1000000); //for sake of MCRYPT_RAND
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$passcrypt = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $encrypt,
MCRYPT_MODE_ECB, $iv);
$encode = base64_encode($passcrypt);
return $encode;
}
// Decrypt
function decrypt($decrypt) {
global $key;
$key = "6r9qEJg6";
$decoded = base64_decode($decrypt);
$iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256,
MCRYPT_MODE_ECB), MCRYPT_RAND);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $key, $decoded,
MCRYPT_MODE_ECB, $iv);
return $decrypted;
}
On Sep 29, 2005, at 9:33 AM, Jochem Maas wrote:
> Graham Anderson wrote:
>> What is the best way to decrypt a query string back into variables ?
>> $root = "http://www.myserver.com/script.php";
>> $queryString = "?test=mytest&color=red";
>> myEncrypt($queryString); //add mCrypt encryption
>> $finalURL = $root.$encryptedQueryString;
>> what is the proper what to decrypt the GET variables on the other
>> side ?
>
>> Do you need to decrypt the query string first ?
>
> yes - if you have a query string like
>
> 4509134534068953534875104584437043134081743
>
> or whatever then php won't turn it into a $_GET var.
> although your query string could contain &'s and/or ?'s and/or ='s
> in which case you might have cruft in the $_GET array which you would
> want to clean out before extracting your decrypted string into
> $_GET ..
>
>> decrypt($_SERVER['QUERY_STRING']);
>> Once you have decrypted it, can you pass it along to a $_GET as you
>> would with an unencrypted query string ?
>> $test = $_GET['test'];
>> Or, do you need to parse the string to extract variables?
>
> yes you do, but this being php - there is a function that will do it
> for you :-)
>
> http://php.net/parse_str
>
>> many thanks
>> g
>
> --
> 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
attached mail follows:
>>
>> can someone show me the right way to do the following...
>>
>> <a href="<?=$PHP_SELF?action=bigger; ?>">
>>
>>
>> I want to pass a variable to a self submitting link.
>>
>> Thanks,
>>
>>
>
> <a href="<? echo $_SERVER['PHP_SELF'].'?action=bigger';?>">
$PHP_SELF should not be used because it will not work without
register_globals being enabled. Rather, you should use $_SERVER
['PHP_SELF'] for it as above however...
Don't forget to check for XSS! Using PHP_SELF you could simply change
the URL in the browser to:
/path/to/script.php"><script>alert('hello');</script><b "
so always run on htmlspecialchars on PHP_SELF!
<a href="<? echo htmlspecialchars($_SERVER['PHP_SELF']).'?
action=bigger';?>">
-Jeff
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)
We-Create Inc.
jeff
wecreate.com email
519.745.7374 office
519.897.2552 mobile
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get Mozilla Firefox at
http://spreadfirefox.com
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]