php-general Digest 22 Jun 2009 19:52:12 -0000 Issue 6189

Topics (messages 294403 through 294416):

Re: Passing Values between C App and PHP
        294403 by: Per Jessen

Re: PEAR Spreadsheet_Excel_Writer setLocked method
        294404 by: Thodoris

Re: isset question
        294405 by: Ford, Mike

Re: resubmit form after validation error
        294406 by: PJ
        294407 by: Caner Bulut

Pointers for NuSOAP
        294408 by: Anton Heuschen
        294409 by: Jonathan Tapicer
        294411 by: Anton Heuschen

PHP SOAP Using SAML
        294410 by: Carlos Medina
        294412 by: Karel Kozlik

sharing PHP sessions between web servers using NFS
        294413 by: Randy Paries
        294414 by: Per Jessen
        294415 by: [moderação] Erick Couto

XSS Preventing.
        294416 by: Caner Bulut

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 ---
Tobias Krieger wrote:

> This would be a nice and fast solution, but unfortunatelly, it's like
> that the C programm needs to surveilance the hardware all the time
> (controlling values,...) hence, it would run more as a "daemon".
> 

Depending your skill-levels with C, there is not much to it.  Here is
some fairly simple code I use for a daemon that controls an IOM142
(google it) board via the serial port.  

http://jessen.ch/files/fridged.tar.gz

It's very much "send two-byte command", then "receive multi-byte
response", but it also responds to simple http-style requests and I
call it from php to produce this page:  http://jessen.ch/refrigeration/
(in dire need up an update).


/Per

-- 
Per Jessen, Zürich (14.4°C)


--- End Message ---
--- Begin Message ---

Thodoris wrote:
I've used it for some time but never needed to lock a cell. Here is a piece of code that shows how to apply a format to a cell:
 > Hope it helps. I think that by doing something like this:

$format_bold->setLocked();

while creating the format could do the trick but it is not tested.


No, this didn't do it. I already have some formats I've created for dollar amounts, right align, etc, and applying the setLocked() method to them had no affect.

Skip


I have noticed that when you use setLocked to the cell formatting the cell has the protected flag set. My openoffice tells me that the cell protection is meaningful only if the data sheet is protected. I think that the following code does what you need as long as you save the xls before opening it.

<?php
// Include the PEAR script
require 'Spreadsheet/Excel/Writer.php';

// Stop displaying the errors so that the warnings don't get in your spreadsheet
// ini_set('display_errors',0);

// Instantiate a workbook
$workbook = new Spreadsheet_Excel_Writer();

// Send it directly to the browser
$workbook->send("test.xls");

// Set the version (very useful for compatibility)
$workbook->setVersion(8);

// Create a worksheet in the workbook
$worksheet =& $workbook->addWorksheet('Test');

// Set input encoding
$worksheet->setInputEncoding('UTF-8');

// Set protection for the worksheet
$worksheet->protect("");

// Create the formats format
$format_locked =& $workbook->addFormat();
$format_locked->setBold();
$format_locked->setHAlign('center');
$format_locked->setFgColor('yellow');
$format_locked->setLocked();

// Create a format
$format_unlocked =& $workbook->addFormat();
$format_unlocked->setBold();
$format_unlocked->setHAlign('center');
$format_unlocked->setFgColor('yellow');

// Apply the format to a cell
$worksheet->writeString(0, 0, "Locked", $format_locked);
$worksheet->writeString(0, 1, "Unocked", $format_unlocked);

// Close the workbook
$workbook->close();
?>

This protects the file with a blank password. I don't know if this is the proper way to do this but it has been tested and works.

--
Thodoris


--- End Message ---
--- Begin Message ---
On 19 June 2009 19:53, Ashley Sheridan advised:

> On Fri, 2009-06-19 at 12:36 +0100, Ford, Mike wrote:
>> On 18 June 2009 20:25, LAMP advised:
>> 
>>> using !empty() instead isset() will work if you don't care for PHP
>>> Notice: Undefined variable... If you want to avoid PHP Notice
>>> you have
>>> to use both:
>>> 
>>> $msg.=  (isset($_POST['mort']) and !empty($_POST['mort'])) ? "The
>>> mortgage amount is  $mort\n" : " ";
>> 
>> Absolute rubbish -- as it says at http://php.net/empty, "empty($var)
is
>> the opposite of (boolean)$var, except that no warning is generated
when
>> the variable is not set." -- so "protecting" empty() with an isset()
is
>> a total waste of time, space and cpu cycles.
>> 
>> Cheers!
>> 
>> Mike
>> 
>>  --
>> Mike Ford,  Electronic Information Developer,
>> C507, Leeds Metropolitan University, Civic Quarter Campus,
>> Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
>> Email: [email protected]
>> Tel: +44 113 812 4730
>> 
>> 
>> 
>> 
>> 
>> To view the terms under which this email is distributed,
> please go to http://disclaimer.leedsmet.ac.uk/email.htm
>> 
> To be honest, you're still opening yourself up to attack that
> way. What
> I'd do is first assign the variable to a forced int, and then use that
> result if it is >0: 
> 
> $mortgage = (isset($_REQUEST['mort'])?intval($_REQUEST['mort']):0;
> 
> $msg .= ($mortgage > 0)?"The mortgage amount is $mortgage":"";

Too true -- I have a parameter-checking system that does this
automatically for me, so I tend not to think of it when writing actual
processing code. My bad, probably, but good catch.

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: [email protected]
Tel: +44 113 812 4730



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---
--- Begin Message ---
Hi Caner,
Thanks for the input. I'm not sure that would do it as the first
instruction on the page is :
$bid = $_GET['id'] ;

thus, the page cannot even be loaded if there is no id in the uri - it
generates a number of errors.
In order to use the feature of editing, I use a search page and then set
up an href to the edit page with the id of the item to be edited.
I finally figured out to do the action="another_page.php" and with
slight modifications to the form, things finally work.
And, to delete the item (all records related to the item), I set up 2
submits - 1 to "update.php" and one to "delete.php"
Maybe it's all cumbersome and maybe it is possible to streamline the
whole process, but then it does work and I am just learning... :-)
Thanks again.
PJ



Caner BULUT wrote:
> Hi,
>
> You can use a variable to that. Like following. Example if the variable is 1
> you start to processing form input.
>
> Example 
>
> <form method="post" action="file.php?action=1>
>
> And in file.php you check the action variable if it is 1 you can start the
> processing data.
>
> If($_GET['action']==1) {
>  Echo "done";
> }
>
> Thanks.
> Caner.
>
>
> -----Original Message-----
> From: PJ [mailto:[email protected]] 
> Sent: 20 June 2009 22:55
> To: [email protected]
> Subject: [PHP] resubmit form after validation error
>
> I'm having a bit of a time figuring out how to resubmit a form after
> obligatory field missing error.
> The problem is that the page is accessed from a search page href where
> the uri is like = file.php$=123.
> Since the method="post" action="file.php?=<?php echo $number; ?> does
> not work nor does PHP_SELF, I have set the action="otherfile.php". All
> is well, if all fields are properly entered, but if there is an error,
> how to resubmit the form for correction and resubmission without using
> js or functions or redoing it all from scratch?
>
>   


-- 
Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
-------------------------------------------------------------
Phil Jourdan --- [email protected]
   http://www.ptahhotep.com
   http://www.chiccantine.com/andypantry.php


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

You can use the structure following

$bid = htmlentities($_GET['id']);

if(empty($bid) {
 $bid=0;
}


if(is_numeric($bid)) {

if($bid==0) {
do something
} else if($bid==1) {
do something
}

}

After this code there will always a number, If the id variable is 0, bid
will be 0 and you can control it.

Thanks.
Caner.

2009/6/22 PJ <[email protected]>

> Hi Caner,
> Thanks for the input. I'm not sure that would do it as the first
> instruction on the page is :
> $bid = $_GET['id'] ;
>
> thus, the page cannot even be loaded if there is no id in the uri - it
> generates a number of errors.
> In order to use the feature of editing, I use a search page and then set
> up an href to the edit page with the id of the item to be edited.
> I finally figured out to do the action="another_page.php" and with
> slight modifications to the form, things finally work.
> And, to delete the item (all records related to the item), I set up 2
> submits - 1 to "update.php" and one to "delete.php"
> Maybe it's all cumbersome and maybe it is possible to streamline the
> whole process, but then it does work and I am just learning... :-)
> Thanks again.
> PJ
>
>
>
> Caner BULUT wrote:
> > Hi,
> >
> > You can use a variable to that. Like following. Example if the variable
> is 1
> > you start to processing form input.
> >
> > Example
> >
> > <form method="post" action="file.php?action=1>
> >
> > And in file.php you check the action variable if it is 1 you can start
> the
> > processing data.
> >
> > If($_GET['action']==1) {
> >  Echo "done";
> > }
> >
> > Thanks.
> > Caner.
> >
> >
> > -----Original Message-----
> > From: PJ [mailto:[email protected]]
> > Sent: 20 June 2009 22:55
> > To: [email protected]
> > Subject: [PHP] resubmit form after validation error
> >
> > I'm having a bit of a time figuring out how to resubmit a form after
> > obligatory field missing error.
> > The problem is that the page is accessed from a search page href where
> > the uri is like = file.php$=123.
> > Since the method="post" action="file.php?=<?php echo $number; ?> does
> > not work nor does PHP_SELF, I have set the action="otherfile.php". All
> > is well, if all fields are properly entered, but if there is an error,
> > how to resubmit the form for correction and resubmission without using
> > js or functions or redoing it all from scratch?
> >
> >
>
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- [email protected]
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>

--- End Message ---
--- Begin Message ---
Does anyone have any good links to basic and more advanced (and some
examples) of NuSOAP and using this ?

Would be appreciated to see some recommendations that might of helped
others etc.

Thank you in advance.

--- End Message ---
--- Begin Message ---
I've used this one, split in 4 parts:

Introduction to NuSOAP: http://www.scottnichol.com/nusoapintro.htm
Programming with NuSOAP: http://www.scottnichol.com/nusoapprog.htm
Programming with NuSOAP Part 2: http://www.scottnichol.com/nusoapprog2.htm
Programming with NuSOAP Using WSDL:
http://www.scottnichol.com/nusoapprogwsdl.htm

It's nice, and it has lots of working examples.

Jonathan

On Mon, Jun 22, 2009 at 11:02 AM, Anton Heuschen<[email protected]> wrote:
> Does anyone have any good links to basic and more advanced (and some
> examples) of NuSOAP and using this ?
>
> Would be appreciated to see some recommendations that might of helped
> others etc.
>
> Thank you in advance.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Much appreciated Jonathan, going to look at it later tonight.

2009/6/22 Jonathan Tapicer <[email protected]>:
> I've used this one, split in 4 parts:
>
> Introduction to NuSOAP: http://www.scottnichol.com/nusoapintro.htm
> Programming with NuSOAP: http://www.scottnichol.com/nusoapprog.htm
> Programming with NuSOAP Part 2: http://www.scottnichol.com/nusoapprog2.htm
> Programming with NuSOAP Using WSDL:
> http://www.scottnichol.com/nusoapprogwsdl.htm
>
> It's nice, and it has lots of working examples.
>
> Jonathan
>
> On Mon, Jun 22, 2009 at 11:02 AM, Anton Heuschen<[email protected]> wrote:
>> Does anyone have any good links to basic and more advanced (and some
>> examples) of NuSOAP and using this ?
>>
>> Would be appreciated to see some recommendations that might of helped
>> others etc.
>>
>> Thank you in advance.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>

--- End Message ---
--- Begin Message ---
Hi Anybody,
I am evaluating to use Webservices to solve an knowed Issue. I need to know, if it is Possible to use SAML 1.0 with PHP 4 or PHP 5 and when yes, where can i get information about this Issue or open Source Software,etc.



Regards

Carlos

--- End Message ---
--- Begin Message ---
 Hi,
take a look to Lasso. They claims it support SAML 2.0.
http://lasso.entrouvert.org/

Karel

Carlos Medina napsal(a):
Hi Anybody,
I am evaluating to use Webservices to solve an knowed Issue. I need to know, if it is Possible to use SAML 1.0 with PHP 4 or PHP 5 and when yes, where can i get information about this Issue or open Source Software,etc.



Regards

Carlos


--- End Message ---
--- Begin Message ---
Hello,
I have three web servers (in a lvs cluster)
in the cluster they all think they are www.mydomain.com
With LVS you can not guarantee that each request is going to come in
via the same server

I am trying to share php sessions between servers.

I have seen some examples that use mysql for session, but i think this may work
and would be easier to implement

currently all three servers share the same file system via NFS

so what i was going to do is change the path in the php.ini to
session.save_path = "/mynfsmount/phpsessions". So essentially all
three servers would write the session files in the same location.

my concern is does anyone know how php creates the session ID
the thing that concerns me is that i compared the current session
directories on the 3 servers and there are duplicate file names. Do
you think i can assume that PHP checks for the existence of the
session file before it creates a new PHPSESSIONID??

the one thing that would be ugly is if the servers overwrote the
others files and sessions started getting messed up.

Thanks for your help

--- End Message ---
--- Begin Message ---
Randy Paries wrote:

> Hello,
> I have three web servers (in a lvs cluster)
> in the cluster they all think they are www.mydomain.com
> With LVS you can not guarantee that each request is going to come in
> via the same server

I thought LVS had some session persistence stuff ?


/Per

-- 
Per Jessen, Zürich (11.6°C)


--- End Message ---
--- Begin Message ---
you can use memcached for php sessions.. it´s simple, transparent, and
configurated on php.ini too.
i have used it for a long time.

2009/6/22 Per Jessen <[email protected]>

Randy Paries wrote:
>
> > Hello,
> > I have three web servers (in a lvs cluster)
> > in the cluster they all think they are www.mydomain.com
> > With LVS you can not guarantee that each request is going to come in
> > via the same server
>
> I thought LVS had some session persistence stuff ?
>
>
> /Per
>
> --
> Per Jessen, Zürich (11.6°C)
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

 

I have a question if you have any knowledge about this please let me know.

 

I getting data from a form with POST method like following.

 

$x = htmlentities($_POST['y']);

.

 

After getting all form daha I save them into DB, I used
mysql_real_escape_string. 

 

I have an page which show the information that I have save into DB. But If I
don't use html_entity_decode, there will encodding and charset problems. I
can't set htmlentities charset parameters because this function does not
have Turkish Charset support.

 

The question is that, after saving data into DB with using htmlentities, in
the information page if I use html_entity_decode function still there is an

XSS risk or not? . html_entity_decode function get back all risk again?

 

Please help.

 

Thanks.

Caner.


--- End Message ---

Reply via email to