Re: [PHP]Zip and text files generated are corrupted

2010-03-27 Thread Kim Madsen

Mike Roberts wrote on 25/03/2010 14:56:

remove


No :-) Use the proper unsubscribe method rather than spamming the list.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] $_FILE array being truncated

2010-03-16 Thread Kim Madsen

Ashley Sheridan wrote on 16/03/2010 18:28:


I really wouldn't rely on a form that contains more than 20 file upload
boxes though. If someone uploads some large files, they're stuck with an
extremely long wait which will slow down your server a bit as well if a
lot of people are using the same form at the same time.


True. Instead make the upload with AJAX, so the file starts uploading 
when the field is changed (onChange()) or out of focus (is there such a 
function? onUnFocus()? :-)). See gmail attachment for an example.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Change displayed file name to download

2010-03-14 Thread Kim Madsen

Hi

Make a $new_filename and put that in the header:

$neW_filename = downloadfile. . $filetype;
header(Content-Disposition: attachment; filename=$new_filename);
(the content of the file is now in $content, so if you like you could 
also change the value of $filename if you preferrer that)


You'll need to detect $filetype from $filename to always have the same 
filename as the original file.


/kim

Php Developer wrote on 14/03/2010 21:29:

Hi,

I'm using the following code:

$fp  = fopen($filename, 'r+');
$content = fread($fp, 
filesize($filename));

fclose($fp);
header(Content-type: 
application/msword);
header(Content-Disposition: attachment; 
filename=$filename);

echo $content;
exit;
___

Now when downloading a file the default name that appears for the user is 
the realname of the file i the server with the real path the only 
difference is that the slashes are modified by underscore.


My 
question is: is there any way how to control the name that will be 
displayed for the customer? Or at least skip the path and display just 
the file's name?


Thank you


  __
Be smarter than spam. See how smart SpamGuard is at giving junk email the boot 
with the All-new Yahoo! Mail.  Click on Options in Mail and switch to New Mail 
today or register for free at http://mail.yahoo.ca



--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Anyone good with multiple SSL on Apache?

2010-03-08 Thread Kim Madsen

Skip Evans wrote on 08/03/2010 23:21:

D'oh!

...and I suppose there is just no way around that, eh?


two public IPs pointing to the same server? ;o)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Header function

2010-03-01 Thread Kim Madsen

Ashley Sheridan wrote on 01/03/2010 07:13:


The HTTP header doesn't treat quoteation marks in the same way that PHP
does. It needs double quote marks to function correctly.


How do you mean? And do you have a link to this information?

Even if this is true, then the first Nick did should still be correct?

header('Content-Disposition: attachment; filename=PurchaseReq.doc');

I'm using the same headers for downloads, allthough I use double qoutes 
for the header function aswell:


header(Content-Disposition: attachment; filename=\artist - title.mp3\);

--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] Magento SOAP2

2010-02-25 Thread Kim Madsen

Hi

Does anyone on the list have experience with the above?

The documentation is only on SOAP1.x, but not on SOAP2 and the calls are 
completely different:


SOAP1.x:
http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product_attribute#example_1._getting_product_attribute_s_sets_list_and_get_attributes

$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy-login('apiUser', 'apiKey');

// make a call in SOAP1.x
$attributeSets = $proxy-call($sessionId, 'product_attribute_set.list');
var_dump($attributeSets);

// make a call in SOAP2:
$attributeSets = $proxy-catalogProductAttributeSetList($sessionId2);
var_dump($attributeSets);

This I figured out, but when I wanna create a product (for import from a 
different webshop) I get lost, have no idea now, how to solve this since 
the documentation still is for 1.x only :-/


Documentation
http://www.magentocommerce.com/wiki/doc/webservices-api/api/catalog_product#catalog_product.create

Any ideas will be welcome :-)

--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] obj in array?

2010-02-24 Thread Kim Madsen

Hi folks

I'm hacking on a SOAP2 solution towards Magento and have retrieved the 
catalog in an array, but i'm having trouble accessing the values of the 
array cause there's an object in it. This is a var_dump of $my_array:


array(14) {
  [0]=
  object(stdClass)#2 (2) {
[set_id]=
int(44)
[name]=
string(7) Cameras
  }
  [1]=
  object(stdClass)#3 (2) {
[set_id]=
int(38)
[name]=
string(11) Cell Phones
  }

how do I access for instance set_id in $my_array[0]? I tried declaring 
an instance of $my_array[0] but that fails too: Fatal error: Cannot use 
object of type stdClass as array 


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] obj in array?

2010-02-24 Thread Kim Madsen

Kim Madsen wrote on 24/02/2010 14:02:

how do I access for instance set_id in $my_array[0]? I tried declaring 
an instance of $my_array[0] but that fails too: Fatal error: Cannot use 
object of type stdClass as array 


$my_array[0]-set_id; did the trick


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] $_POST vs $_REQUEST

2010-02-22 Thread Kim Madsen

Hi Slack-Moehrle

Slack-Moehrle wrote on 22/02/2010 21:39:

Hi All,

I have Forms that I submit for processing. I have seen examples of people using 
either $_POST or $_REQUEST.

When would I choose one over the other?


$_REQUEST['test'] is true on both $_GET['test'] and $_POST['test']

I use it from time to time if I have a edit link followed by a form 
posting (where I use method=post), if I decide to have all editing in 
one statement, IE:


if($_REQUEST['test']) {
  if($_GET['test']) {
// make the form here
  }
  elseif($_POST['test']) {
  // get posting from the form
  }
}


Also, I see examples of these being used with and without the single quotes

Like:

$_POST[j_orderValue]
or
$_POST['j_orderValue']

Single quotes is best, correct to prevent sql injection?


Best practice is with '', if you have E_NOTICE on you'll get notices if 
you use $_POST[test] instead of $_POST['test']


It has nothing to do with SQL injection here. But when dealing with SQL 
statements it's best practice to use '', for instance if you are about 
to insert and a number at some point could be inserted as part of the 
statement: price = 250 will do fine, but if price ain't entered price 
=  will cause an error, while price = '' will not make the sql insert 
fail.


Regarding SQL injection, run all inputs through the function 
mysql_real_escape_string()


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Advice on maintaining public and private files

2010-02-21 Thread Kim Madsen

Al wrote on 20/02/2010 19:30:
I use Kim's solution and take it one step forward. Htacces files can get 
lost or corrupted, so


No solution to that problem as I see it.


In my  config file I have the text string.


I like the idea, but what if this file is never accessed?

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Advice on maintaining public and private files

2010-02-20 Thread Kim Madsen

Michael Stroh wrote on 19/02/2010 19:19:

I have a site I'm working on with some data that I want to be
readable by anyone, but some files that I want to keep hidden from
outside users. Here is an example of my file structure.

/products/data1/item_1/data.txt 

 /products/data2/item_2/data.txt

since no one has suggested it then... if you're on an Apache webserver 
use a .htaccess file in data2 which contains:


Deny from all
Allow from none

That will do the trick and PHP can still fetch the files in data2 and 
serve it to the user.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Mysql statement works in phpmyadmin but not in php page

2010-02-11 Thread Kim Madsen

james stojan wrote on 11/02/2010 22:21:


$query=INSERT INTO upload_history (v_id,hour,visits,date) VALUES
(.$v_id.,.$hour.,.$visits.,'$date1'.);;


The ,'$date1'. is not correct syntax, change it to ,'.$date.'


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Magento shopping cart

2010-02-01 Thread Kim Madsen

Skip Evans wrote on 01/02/2010 22:02:

Hey all,

Anyone ever use the Magento shopping cart? Pluses, minuses, opinions? I 
have a client that is pretty adamant about using it, but I've found over 
just about any I've used I can do a better service to the client by 
writing them from scratch. It's easy and they always get exactly what 
they want.


I just installed it a couple of days ago, took me an hour and 5 minutes 
incl. installing danish and make different kind of troubleshooting 
during the installation. Make sure your database user has at least 
(haven't had the time to investigave yet) ALTER privileges  otherwise 
the install fails and it's rather wierd to continue the installation 
after giving the DB user the righs privileges.


I see they seem to have a lot of plug ins, but I think someone just told 
him it is the best cart to use so he's sort of fixated on it.


It sure looks cool, that I must say.

Like I said, I typically find I can custom write one with better 
results. I found xCart, for example, to contain some of the worst code I 
had ever seen and it turned me off to third party carts.


I sort of have the same opinion, but this was a fast install and there's 
lots of admin features.


However as you write elsewhere in this thread, knowing your own code 
makes it easy to make changes. This is definetly going to take longer 
with Magento since you don't know the code. Make sure you customer 
understands this.


A good example: the search button is an image, so this is not 
translated into danish, that could be a potential design problem, if in 
thai search it translated to rapapupapikiwikital :-)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] File Upload

2010-01-30 Thread Kim Madsen

Ali Reza Sajedi wrote on 30/01/2010 12:27:


UPLOAD_ERR_NO_TMP_DIR
Value: 6; Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 
5.0.3.


Has anyone encountered such a problem or has a clue as to what the cause 
could be?


What does print phpinfo(); tell you about the upload_tmp_dir?

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] preg_replace help

2010-01-26 Thread Kim Madsen

Michael A. Peters wrote on 26/01/2010 14:18:

$fixSrch[] = '/\n/';
$fixRplc[] = '[br]';

is what I need except I want it to leave anything between [code] and 
[/code] alone.


I figured it out before but with element /element but I don't even 
remember what I was working on when I did that and I can't for the life 
of me find it now.


Just use the function nl2br()

If you wanna match \n, you need to add a backslash before the 
backslash: \\n


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] SQL question

2010-01-26 Thread Kim Madsen

Michael A. Peters wrote on 26/01/2010 06:04:

I use seconds from epoch in the database simply because it works so well 
with the php date() function.


If you need something where Julian day really is better, I assume it 
isn't that hard to convert between posix and julian day, though it seems 
odd to me that it isn't part of the date() function. It probably should be.


When I do date comparisons in MySQL I use the to_days() function.

 What I need to do is come up with a query that will determine if the 
start_date + no_donations falls within $start and $end.


In the given example one could determine that a month is always 30 days 
and then say to_days(start_date)+(no_donations*30)  to_days(end). This 
would however be a very loose method. You could go for finding the 
number of days in the current month and substract that (10th. = 30-10), 
play with MySQLs left() function


But Skip, as the others say, use a date class, since you're passing a 
php var on to the SQL anyway, then you could determine the exact days 
from start to end of donation. Combine this with to_days and you have 
your solution


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] DirectoryIterator

2010-01-26 Thread Kim Madsen

Christoph Boget wrote on 26/01/2010 21:17:

I've looked through the docs but was unable to find out if this is possible;
I hope it is.  Is there a way that you get the size/length of the collection
to be iterated (e.g. the total number of files) without having to iterate
through at least once?


On Linux with safe mode off you can call system(du -hcs THE_DIR) to 
get the size of all files, no iterations needed.


Number of files could be a find command piped into wc -l, called from 
system(), like find . -name * | wc -l (but that would count dirs aswell)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Object Oriented Programming question

2010-01-20 Thread Kim Madsen

tedd wrote on 20/01/2010 16:11:

At 10:26 AM -0500 1/19/10, Bob McConnell wrote:

Some problems will fit into it, some don't.


I teach OOP thinking at the local college and haven't run into a problem 
that doesn't fit. For example, in my last class I had a woman who wanted 
to pick out a blue dress for her upcoming wedding anniversary. The class 
worked out the problem with a OOP solution.


Don't forget to throw an exception if another woman shows up in the same 
dress and color at the wedding! That would make you OOPD crash totally! ;-)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] SMTP Local development to Send email in PHP; Windows Platform/ XP with no IIS

2010-01-15 Thread Kim Madsen

Hi Gaurav

Gaurav Kumar wrote on 15/01/2010 09:54:


NO SMTP

Any trusted SMTP software to install on local development machine and how to
set it up with php to send an email?

Also just providing the SMTP server details in php.ini will not work for me
as this requires authentication/credentials etc..


Get PHPmailer and make a gmail account that you connect to and mail through.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] strtotime

2010-01-14 Thread Kim Madsen

Hi guys

I have a question:

snip
Ashley Sheridan wrote on 14/01/2010 19:20:
MySQL uses a default -00-00 value for date fields generally, but
when converted into a timestamp, the string equates to a false value. In
PHP, timestamps are numerical values indicating the seconds since
Midnight of the 1st January 1969. As PHP uses loose data typing, false
/snip

Adam Richardson wrote on 14/01/2010 19:25:
snip
2. date returns 1969, because it's not passed a valid timestamp and it 
works from December 31, 1969 for any invalid date.

/snip

Why is this? Unixtime starts at January 1st 1970 GMT (see for instance 
http://php.net/microtime), I've never heard of the other dates you 
mentioned.


My guess is the time, date or GMT is wrong for Johns setup and that's 
why he get 1969 and not 1970, cause something is seting time in the past


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-14 Thread Kim Madsen

Hey

Haven't had the time to read up on the maillist, but here's my input.

Mattias Thorslund wrote on 09/01/2010 02:26:

To my eyes, ? means look there is more content coming, which seems 
kind of silly when there isn't.


To mine it means, no more PHP code for now. I don't wanna make it 
diffenrent from a file containing pure PHP code or one that contains 
both PHP and HTML, where I jump in and out of the PHP tag.


Remember the ? stops the parser

And I find it bad coding standard to start a tag and not end it, even if 
it's possible. Remember Perl is a smart, but also terrible language, 
where one can leave out the ; in the end of a oneline script and make a 
bunch of stuff on $_ without showing what variable you're working on.


And finally, mysql_close() was always called after a script was closed, 
so I've never learned to practice that and for the last ten years I've 
seen only _one_ developer added that function call to the end of his 
files. In PHP6 that call is required, so making the cleanest code is in 
my opinion more readable and also more correct, since you'll never know 
what the PHP core team will come up with next ;-)


A neat thing with pairing every ?php with a ? when mixed in HTML is 
that these are valid XML processing instructions. If your HTML satisfies 
XML well-formedness, your PHP document will also be valid XML. Not that 
I've ever had any need to process my layout templates as XML but anyway.


I don't see your argument. PHP generates HTML or XML files. When you're 
aware of the XML tag of course you make sure the XML file generated is 
valid. Why would you ever add PHP code to a HTML file (other than for 
documentation, examples etc.)?


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-14 Thread Kim Madsen

John Corry wrote on 12/01/2010 17:04:

I leave ? out.

I'm pretty careful about my code formatting and whitespace.

It's my opinion that if I can eliminate a potential problem by not including
an optional closing tag...there's really no reason why I shouldn't.


What is the difference between:

?
print hello PHPeople;
?WHITESPACE

and

?
print hello PHPeople;
WHITESPACE

Same shit when I look at it, a sloppy developer is what it is :-)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-14 Thread Kim Madsen

Ashley Sheridan wrote on 14/01/2010 23:30:


What is the difference between:

?
print hello PHPeople;
?WHITESPACE

and

?
print hello PHPeople;
WHITESPACE

Same shit when I look at it, a sloppy developer is what it is :-)

--
Kind regards
Kim Emax - masterminds.dk



Plenty of differences, if you include the first one as a file, the 
whitespace gets sent to the browser because it is not part of the PHP, 
and so is assumed to be HTML. Once this happens, the headers have been 
sent, so you can't use different headers in your script.


Hmm... you could be right. I guess I just never made that mistake :-)
--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] POLL: To add the final ? or not...

2010-01-14 Thread Kim Madsen

Ashley Sheridan wrote on 14/01/2010 23:36:

What has been said on this thread a few times is it is not always a 
developer error, but a bug with the editor, which is not something that 
will be picked up until it occurs.


Once again I love my VIm :-) (with whitespace highlight if needed)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Display just 1 record in a query

2010-01-12 Thread Kim Madsen

deal...@gmail.com wrote on 12/01/2010 22:52:

I did a query... then I display records like:

table
  ?php do { ?
tr
  td?php echo $row_cur['tid']; ?/td
  tdnbsp;/td
/tr
?php } while ($row_cur = mysql_fetch_assoc($cur)); ?
/table


Q: but how I i just display a particular record with out the do / while 
loop?


Just use extract($row_cur); before the table starts. That would give you 
first row only


Another approach could be to add  LIMIT 1 to the end of your SQL statement


like just the 2nd record only:

i tried
?php echo $row_cur['tid',2]; ?
but this makes an error

or $row_cur('tid',2) --- hmmm what's the syntax?


Getting only second row, but not the first? That would be using a count 
var and show only data if count == 2



table
?php
$count=0;
do {
$count++;
if($count == 2) {
  echo '
tr
  td'. $row_cur['tid'] .'/td
  tdnbsp;/td
/tr';
  }
} while ($row_cur = mysql_fetch_assoc($cur));
?
/table


Another thing: drop the do and use this syntax instead, it's more readable:

table
?php
$count=0;
while ($row_cur = mysql_fetch_assoc($cur)) {
  $count++;
  if($count == 2) {
echo '
tr
  td'. $row_cur['tid'] .'/td
  tdnbsp;/td
/tr';
  }
}
?
/table


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Display just 1 record in a query

2010-01-12 Thread Kim Madsen

Daevid Vincent wrote on 13/01/2010 00:00:


Holy, Jesus, Marry and Joseph! You can't be serious with that?!
So you're going to loop over potentially hundreds or thousands of records
and only display one?
Wow. Speechless.


Either you're talking to dealtek or you didn't read my post very well:

Another approach could be to add  LIMIT 1 to the end of your SQL 
statement


I just pointed out different approaches and answered his questions. Of 
course I would use last or break on the count == 2 approach, not running 
through _any_ records after getting what I wanted. I don't really get 
the like just the 2nd record only, but again, from the material we've 
seen it's hard to give the right advice


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] PHP uploaded files logs

2010-01-01 Thread Kim Madsen

Hi

Manoj Singh wrote on 01/01/2010 08:07:

Hi,

Is PHP maintaining the logs regarding files uploaded? Actually I needed it
because recently in my developed web site upload functionality seems to stop
working even for the correct file and i want to check that which type of
files are uploaded. Actually I cannot debug through PHP on the server as my
site is on production.


Not to my knowledge, but that should be pretty easy to create, just save 
all $_FILES['uploaded_file'] (or just 
$_FILES['uploaded_file']['tmp_name'], $_FILES['uploaded_file']['name'] 
and $_FILES['uploaded_file']['size']) into a logfile, note there's an 
error variable too.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] PHP uploaded files logs

2010-01-01 Thread Kim Madsen

Daniel Egeberg wrote on 01/01/2010 17:10:


No, Apache doesn't log POST data only the request.


And even if it did, not all hosting companies give you access to your 
access and error log files...


Making your own logfile is a good way to debug, for instance I had a 
problem with creating a zip header, in that case you can't print to the 
screen, so putting debug info in a php generated logfile is a easy way 
to move on...


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Merry Christmas!

2009-12-25 Thread Kim Madsen

Rene Veerman wrote on 25/12/2009 17:04:

+1 from Amsterdam :)

 a happy, productive  profitable new year to all a ya.


Copenhagen sents kind regards too, may you all have some swell days.

And C U at Queensday? :o)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Checking for internet connection.

2009-12-23 Thread Kim Madsen

Hi Bob

Bob McConnell wrote on 23/12/2009 14:35:

From: Andy Shellam


And I was pointing out that this would not be a valid
test when there is a caching DNS on the LAN.



I also pointed out how to avoid caching issues - the
comment was aimed at the author of the message before mine.


Too much of the conversation and most of the attribution
was stripped too early for this to be coherent.

Why the negativity?  A question was asked and several
possible solutions were provided based on that original
question.  All the conversation was relevant IMO.


But long before it was done it was impossible to tell who had asked
which questions, who had provided which answers and who had countered
those answers. In several instances, replies appeared to be directed to
the wrong individuals.


Leaving the above for a reason. I find your answer to Andy rude and 
offensive! Remind me not to try to help you next time.



Some people here tend to go way too far when trimming context from
replies. Yes, I know it gets difficult to read when there are more than
ten or twelve levels of attribution, but stripping all but the last
layer is even worse.


No, that's called netetiquette, have a look at: 
http://www.the-eggman.com/writings/etiquitte_1.html


Quote: When responding to E-Mail, don't quote the entire original 
message in your reply. Only quote the relevant parts, and only to the 
extent that they will help orient the recipient on your reply.


(and this mail is not to start a flame war)


Removing the participants names from the top should
be a hanging offense. I don't keep copies of every message in any of the
dozens of mailing lists and news groups I follow, so there is no simple
way to go back through the conversation to figure out where it all came
from.


Well, because _you_ don't wanna follow proper netetiquette doesn't mean 
everyone else should violate those rules, does it? :-)


And a merry christmas to you.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Checking for internet connection.

2009-12-23 Thread Kim Madsen

Kim Madsen wrote on 23/12/2009 17:01:

Okay, explanation excepted, E-mails can easily be misunderstood :-) May 
you have a merry Christmas (grab another cup of choco, just in case ;-))


correction: accepted

Now _I'M_ gonna get a cup of chocolate :-)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Checking for internet connection.

2009-12-22 Thread Kim Madsen

Bob McConnell wrote on 21/12/2009 15:05:


Both at home and at work there are caching DNS on the LAN. So a DNS
request may come back with a valid IP address when the WAN connection is
down. I still won't be able to connect to the remote site.


Then use fopen() to read a page you know exists?

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Highlighting image map on load

2009-12-16 Thread Kim Madsen

leledumbo wrote on 2009-12-14 13:37:

I have image map with dynamic circle areas whose coordinates stored in
database. I'd like to colorize these areas so that it's obvious to see them.
Most solutions I found on the net highlights the area on mouse hover, while
my needs is to do it once when the window is loaded. Any idea?


I would say that you should do the following:

1. make a css class, that gives you the highlights you want.
2. put a div with position:absolute over the image where you want the 
class to take effect
3. use a javascript to draw the circle in the div. If you look at for 
instance the nifty and niftycube solutiona, they're working with an 
inner and an outer color, so the outer should be transparent and the 
inner you css class. And my guess is that this has already been made 
before, so google for a javascript solution that fits your needs.


Happy hacking.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] mysterious include problem

2009-12-10 Thread Kim Madsen

LinuxManMikeC wrote on 2009-12-07 22:48:
 Instead of hard coding cases you can validate and constrain the input
 with a regex.  Much more flexible when adding content.  I would also
 add code to make sure the file exists, otherwise fall through to the
 default.

In huge sites with a lot of include files I agree, in small sites this 
solution gives me an overview of the setup.


In this case I have an idea that the RegEx solution could be another 
problem for Allen, but it's just an idea :-)


--
Take Care
Kim Emax - master|minds - Vi tænker IT for dig...
Konsulentbistand, programmering, design  hosting af websites.
http://www.masterminds.dk - http://www.emax.dk
Køb din vin online på http://www.gmvin.dk


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



Re: [PHP] logic operands problem

2009-12-07 Thread Kim Madsen

Hey Merlin

Merlin Morgenstern wrote on 2009-12-07 11:52:

Hello everybody,

I am having trouble finding a logic for following problem:

Should be true if:
page = 1 OR page = 3, but it should also be true if page = 2 OR page = 3

The result should never contain 1 AND 2 in the same time.

This obviously does not work:
(page = 1 OR page = 3) OR (page = 2 OR page = 3)

This also does not work:
(page = 1 OR page = 3 AND page != 2) OR (page = 2 OR page = 3 AND page 
!= 1)


Has somebody an idea how to solve this?


I've read the entire thread and can see that this is a MySQL query you 
want to make (I was about to tell you about the == comparison and the $ 
in a variable in PHP).


What you want is all results containing 1,2 or 3, so make a WHERE page 
IN(1,2,3) and use PHP logic to figure out if a free slot is available 
or not. Or rewrite your booking routine (use data and time fields 
instead, maybe by creating a bunch of free slots and then a booked field 
with a default of 0, changed to 1 when booked)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] mysterious include problem

2009-12-07 Thread Kim Madsen

Hi Allen

Allen McCabe wrote on 2009-12-07 21:03:

I have been using includes for my content for a while now with no problems.
Suddenly it has stopped working, and it may or may not be from some changes
I made in my code structure.

I use default.php for most or all of my pages within a given directory,
changing the content via page numbers in the query string.


So on default.php, I have the following code:


?php
if(isset($_GET['page']))
{
  $thispage = $_GET['page'];
  $content = 'content/'.$_GET['page'].'.inc';
}

 else
 {
   $thispage = default;
   $content = 'content/default.inc';
 }

WOUW! this is a potential security issue!

I can add _any_ parameter to page, incl. an external one, so skip this 
and use a switch instead


switch($_GET['page']) {
  case admin: $content = content/admin.inc; break;
  case member: $content = content/member.inc; break;
  default: $content = content/default.inc;
}

What use is $thispage by the way?


?
html, body, div etc.
?php include($content); ?


I have a content subdirectory where I store all the pages with files such as
default.inc, 101.inc, 102.inc, etc.

As I said, this has been working fine up until now, if I use the url
user/default.php or just user/ I get this error:


*Warning*: include(content/.inc)


$_GET['page'] is not set, try and print it to the screen aswell...


[function.includehttp://lpacmarketing.hostzi.com/user/function.include]:
failed to open stream: No such file or directory in *
/home/a9066165/public_html/user/default.php* on line *89*

AND

*Warning*: include()
[function.includehttp://lpacmarketing.hostzi.com/user/function.include]:
Failed opening 'content/.inc' for inclusion
(include_path='.:/usr/lib/php:/usr/local/lib/php') in *
/home/a9066165/public_html/user/default.php* on line *89*

But if I use user/default.php?page=default  I get the correct content.

It's acting as if page is set, but set to NULL, and then trying to find an
include at path content/.inc  what's going on??




--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Emergency! Performance downloading big files

2009-12-02 Thread Kim Madsen

Brian Dunning wrote on 2009-12-01 23:48:

This is a holiday-crunch emergency.

I'm dealing with a client from whom we need to download many large PDF docs 
24x7, several thousand per hour, all between a few hundred K and about 50 MB. 
Their security process requires the files to be downloaded via https using a 
big long URL with lots of credential parameters.

Here's how I'm doing it. This is on Windows, a quad Xeon with 16GB RAM:

$ctx = stream_context_create(array('http' = array('timeout' = 1200)));
$contents = file_get_contents($full_url, 0, $ctx);
$fp = fopen('D:\\DocShare\\'.$filename, w);
$bytes_written = fwrite($fp, $contents);
fclose($fp);

It's WAY TOO SLOW. I can paste the URL into a browser and download even the 
largest files quite quickly, but the PHP method bottlenecks and cannot keep up.

Is there a SUBSTANTIALLY faster way to download and save these files? Keep in 
mind the client's requirements cannot be changed. Thanks for any suggestions.


try readfile()

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] processing html forms and keeping the values

2009-11-25 Thread Kim Madsen

Merlin Morgenstern wrote on 2009-11-24 18:38:

This is not so easy. I am doing some checking with php on the values and 
if one failes php returns via GET to the form with the help of header 
location:


   $parameter =  demo=this;
   HEADER(Location:/test.html?error=1.$parameter);
   exit;

I would need to change way to many things in order to simply change to 
post.


Isn't there another way?


This is what I normally do with larger forms:

1. create the form as a function: form()
2. submit the form to the same page
3. test relevant input and if the fail print form()

Example:

function form() {
print '
form action='.$_SERVER['PHP_SELF'].' method=post
input type=text name=email value='.$_POST['email'].'
input type=submit name=submit value=send form
/form';
}

if($_POST['submit']) {
  // test email is entered
  if(!$_POST['email']) {
print error: you must enter an e-mail address;
form();
  }
  else {
// do stuff from here...
  }
}
else
  form();

With a 50 field form this is a nice approach for me :-)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] exec() problem

2009-11-14 Thread Kim Madsen

Ashley Sheridan wrote on 2009-11-15 00:23:


Looked to all log...nothing! :-(




What other logs did you look at?


Then do this from a command line:

su - the user apache runs as

copy the command from the ph script and run it from commandline and let 
us see the error you recieve...


--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] PHP: creating combobox in excel sheet?

2009-11-13 Thread Kim Madsen

Hey

I'm working on creating excel sheets from these classes:

http://articles.sitepoint.com/article/pear-spreadsheet_excel_writer/3

http://pear.php.net/package/Spreadsheet_Excel_Writer/download/

Does anyone know how to create a combo box from PHP with these (or other 
classes)? By combobox I mean the select / dropdown box in HTML.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] PHP: creating combobox in excel sheet?

2009-11-13 Thread Kim Madsen

Jim Lucas wrote on 2009-11-13 17:06:

Kim Madsen wrote:

Hey

I'm working on creating excel sheets from these classes:

http://articles.sitepoint.com/article/pear-spreadsheet_excel_writer/3

http://pear.php.net/package/Spreadsheet_Excel_Writer/download/

Does anyone know how to create a combo box from PHP with these (or other
classes)? By combobox I mean the select / dropdown box in HTML.



Where will your combobox reside?


In the excel sheet. Let me clarify my last posting:

By combobox I mean _like_ the select / dropdown box _is made_ in HTML.


What will your combobox contain/display?


some data, could be yes, no, maybe, these 3 data should be in the 
dropdown box when the user click the arrow. I simply wanna generate the 
list I can create in OpenOffice calc by selecting 
data-validity-criteria and select list in allow then adding 
yes[enter]no[enter]maybe[enter]


What are you going to generating your combobox with?  


PHP was the thought, with data from a database


Are you wanting to build it with one of the two listed software packages?


Yes, if possible. Otherwise another class/function is also fine.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] It's not behaving. Error reporting, that is

2009-11-03 Thread Kim Madsen

Hi Philip

Try to post a link to a page, that prints phpinfo()

--
Kind regards
Kim Emax

Philip Thompson wrote on 2009-11-03 17:11:

Hi all.

This seems like a trivial issue to fix, but I'm having issues. I'm 
running a script via command line and it's throwing out PHP notices. 
Well, I want to suppress those notices. At the top of my script I have 
the line...


?php
error_reporting (E_ERROR);
?

...thinking that this would get rid of the notices. However, it did not. 
They still appear. I even attempted using ini_set(), but to no avail. I 
then set error_reporting in php.ini - this made no difference. (I 
shouldn't have to restart apache when running via command line, but for 
giggles, I did.) I then changed display_errors to Off. You guessed it - 
no change! This immediately brought up the question... Well, what 
php.ini is this script using? Here's my results...


[pthomp...@s-irv-pthompson scripts]$ php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /etc/php.d
...

Yup, according to PHP I'm using the correct ini. Now I'm at a loss. Can 
anyone shed some light on this big brain fart I'm having? Thanks in 
advance.


~Philip




--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] PHP String convention

2009-10-28 Thread Kim Madsen

Hi Nick

Nick Cooper wrote on 2009-10-28 17:29:


Thank you for the quick replies. I thought method 2 must be faster
because it doesn't have to search for variables in the string.

So what is the advantages then of method 1 over 3, do the curly braces
mean anything?

1) $string = foo{$bar};

2) $string = 'foo'.$bar;

3) $string = foo$bar;

I must admit reading method 1 is easier, but writing method 2 is
quicker, is that the only purpose the curly braces serve?


Yes, you're right about that. 10 years ago I went to a seminar were 
Rasmus Lerforf was speaking and asked him exactly that question. The 
single qoutes are preferred and are way faster because it doesn´t have 
to parse the string, only the glued variables.


Also we discussed that if you´re doing a bunch of HTML code it's 
considerably faster to do:


tr
  td?= $data ?/td
/tr

Than
print 
\n\ttr
  \n\t\ttd$data/td
\n\t/tr;

or
print '
tr
  td'.$data.'/td
/tr';

I remember benchmark testing it afterwards back then and there was 
clearly a difference.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Issues with MySQL connectivity ... on only one machine, and for a while now

2009-10-26 Thread Kim Madsen

Michael Shadle wrote on 2009-10-26 06:48:

Oct 25 22:00:01 sql02 php: PHP Warning:  mysqli_connect():
(HY000/2013): Lost connection to MySQL server at 'sending
authentication information', system error: 32 in
/home/foo/web/foo.com/core.php on line 2394

It's either this or one or two others. What is odd is I have switched
to making it sockets only - doesn't seem to help. I think it was
anyway, it's all over localhost. It wasn't always like this either.


I think it's related to network flaws, at least that was the 
understanding I had from the same problem, which occured some months ago 
at an ISP i'm using, but you're writing all over localhost?


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Sessions seems to kill db connection

2009-10-24 Thread Kim Madsen

Hi Kranthi

kranthi wrote on 2009-10-24 07:27:

Db error: Access denied for user 'www-data'@'localhost' (using password: NO)



WTF? I´m not using a user called www-data for MySQL connections, but apache 
runs as this user


in the case where $test is true there is an open mysql connection, but
when $test is false there is no open connection is  available. may be
you have opened a connection when $test is true or used a
mysql_close() when $test is false or when $_SESSION['login']['uid'] is
set.


I think you missed my words about resolving the matter, when you were 
cutting the quoted text :-)



regarding www-data, when mysql_query() fails to find a valid MySql
connection, it tries to open a new connection with mysql.default_user
and mysql.default_password (u can see these values trough phpinfo());
http://php.net/manual/en/function.mysql-connect.php


Thanks, that explained the www-data user

--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] using mysql_close() = best practice?

2009-10-24 Thread Kim Madsen

Hi

PHP closes an open db connection when the script is done.

I've read somewhere that in PHP6 this behaviour will dissapear, is this 
true? In that case using mysql_close() would definetly be best practice 
in all current scripts, to make it portable.


A nice solution would probably be adding a end_mysql() or page_end() to 
all pages and put whatever is needed into that function (mysql_close, 
mysql_free_result, etc)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] How to pronounce PHP code over the phone?

2009-10-24 Thread Kim Madsen

Dotan Cohen wrote on 2009-10-23 22:40:

But I think for the OP's purposes, he could simply DEFINE any word he wanted
at the beginning of the conversation: Listen up duder. When I say 'de-ref'
you make hyphen and a greater-than sign. Capiche?. He could just as easily
say, Listen up duder. When I say 'arrow-thingy' you make hyphen and a
greater-than sign. Capiche?  Problem solved. ;-)



That is what was done, but I wanted to know if there was already some
agreed-upon language.


There is... It's called a Fax ;-)

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Sessions seems to kill db connection

2009-10-23 Thread Kim Madsen

Kim Madsen wrote on 2009-10-22 17:51:

Hi PHPeople

I have an odd problem at my new work and wonder if it's some sort of odd 
setup that is causing this problem when using sessions:


Like I said, my new work and odd setup, an include file had a 
mysql_close() in the bottom


Speaking of mysql_close(), I think I've read somewhere that in PHP6 a db 
connection will not be closed, when the script is done. Is this true? 
Cause then it would definetly be best practice to to _always_ have a 
mysql_close() in the end for the main file.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Fedora 11 PHP install problems

2009-10-23 Thread Kim Madsen

Ashley Sheridan wrote on 2009-10-23 19:29:

On Fri, 2009-10-23 at 13:29 -0400, Israel Ekpo wrote:


What about the error

libphp5.so: undefined symbol: OnUpdateLong

Are you still observing that error?


[removed a bunch of old posting]
Ashley, you quotefucker :-)


Well, I'm not compiling from the source now, I went back to trying to
use the Fedora repositories (which was the only reason I ended up trying
to compile from source in the first place)


If I'm not mistaken php had to be compiled with --with-apxs to use 
modules in Apache, did you do that?


Regarding the PHPmyAdmin, did you try to give the root user a password? 
Maybe it's a security feature in PHPmyAdmin. I don't know, havent been 
using that system since 1999 due to the terrrible handling of  and 
null values, which caused severe trouble in an ISP i worked for before 
we figured out what was going on + i LOVE the tab completion in the 
MySQL commandline tool


--
Kind regards
Kim Emax - masterminds.dk

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



[PHP] Sessions seems to kill db connection

2009-10-22 Thread Kim Madsen

Hi PHPeople

I have an odd problem at my new work and wonder if it's some sort of odd 
setup that is causing this problem when using sessions:


if($test) {
  $query = SELECT count(*) FROM articles WHERE group1 = 'fp';# AND 
group2 = 'login';
  $r = mysql_query($query) or die('Db error: ' . mysql_error() . 
'p'.$SQL);

  print There´s  . mysql_num_rows($r) .  rows; // 3 rows
  print session:  . $_SESSION['login']['uid']; // 1234
  exit;
}
else {
  if($_SESSION['login']['uid']) {
$query = SELECT count(*) FROM articles WHERE group1 = 'fp';# AND 
group2 = 'login';
$r = mysql_query($query) or die('Db error: ' . mysql_error() . 
'p'.$SQL);

print There´s  . mysql_num_rows($r) .  rows;
  }
}

if $test is true it´s okay, if it´s false, this error occurs:

Db error: Access denied for user 'www-data'@'localhost' (using password: NO)

WTF? I´m not using a user called www-data for MySQL connections, but 
apache runs as this user.


I've outcommented and login = to exclude a collision in variables (if 
register globals is on, haven't checked that yet)


Anyone seen this wierd behaviour and know a solution or someway to 
test/debug this?


--
Kind regards
Kim Emax



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



Re: [PHP] Create a screenshot of a website

2009-10-22 Thread Kim Madsen

resea soul wrote on 2009-10-22 15:28:

Hi,

I want to be able to get a screenshot of a given website on the fly.
Can you give me any suggestions.


Do you mean I wanna make a screendump of _my_ website? Then this is 
for you: http://dk2.php.net/manual/en/function.imagegrabscreen.php - It 
works with the COM interface on windows and therefore is a windows-only 
function.


If you mean create a screendump of another website you don't have 
control over i think that would require som GD coding, not sure if 
that's possible with PHP only, most likely I would say no.


If you mean you wanna rip a website and use it in your own then there's 
two functions to check:

readfile() which reads the whole site and outputs this again.
fopen() where you can read an URL line by line and easy do some 
alterations to the line if you like.


I hope this will help you on the way.

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] how call a variable in a text

2009-10-21 Thread Kim Madsen

Ashley Sheridan wrote on 2009-10-21 22:43:


The {} only become really useful when you're trying to reference arrays
within a string:

$var = array('great', 'boring');

$text = this is {$var[0]}.;

Without the curly braces, PHP wouldn't be able to figure out whether you
wanted the end string to be 'This is great.' or 'This is [0].' despite
the variable itself clearly being an array.


Ehh what? This has never been a problem for me:

$text = this is $var[0].;

However this does give an error (or notice, don't recall, haven't seen 
the error in quite a while):


$text = this is $var['0'].;

In that case the solution is the curly brackets:

$text = this is {$var['0']}.;

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] how call a variable in a text

2009-10-21 Thread Kim Madsen

Ashley Sheridan wrote on 2009-10-21 22:56:


Try this though:

?php

$var = array(array('great','alright'), 'boring');

print This is $var[0][0].;


Print This is different from your previous example :-);

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Sanitizing potential MySQL strings with no database connection

2009-10-20 Thread Kim Madsen

Dotan Cohen wrote on 2009-10-20 20:06:


if(mysql_real_escape_string($variable) === false)
{
// create a default DB connection
}



Here, the key seems to be to turn the warning level down, which I do
not have privileges to do on this server. But it fact this seems to be
the key that I was missing, and even though I cannot make use of it at
least I know in general what needs to be done.


if(@mysql_real_escape_string($variable) === false)

Well?

--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Spam opinions please

2009-10-20 Thread Kim Madsen

Hey Gary

Gary wrote on 2009-10-20 20:31:
I have several sites that are getting hit with form spam.  I have the script 
set up to capture the IP address so I know from where they come.  


I see that a lot suggested CAPTCHA, I don't like those either.

The IP solution will give you a constant maintaince problem unless you 
save the submissions in database and look for similar postings, then 
blocks the IPs. Or just block them right away if they suggests the usual 
sheiitee like 400 euro casino rewards etc...


What I've done to fix those issues when I had them was to set a session 
var on the frontpage of the site and check on that. If it doesn't exists 
when the user enters the page with the form, then I tell them and just 
don't show the form. Of course the clever programmer can create a script 
that first goes to the frontpage, then the form page, but so far I'm 
pretty happy with the solution, no spam for 3 years :-)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Please don't kick me!

2009-10-20 Thread Kim Madsen

Philip Thompson wrote on 2009-10-20 21:58:

I got it to draw the different background colors successfully. However, 
drawing borders is not as straight forward. I'm sure I could get it 
working as well... but I'd rather it work *out of the box*. Thanks for 
the suggestion. ;)


Well, you're always welcome to contribute to an open source project you 
take advantage of ;o)


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Spam opinions please

2009-10-20 Thread Kim Madsen

Gary wrote on 2009-10-20 22:55:
I like that idea,so in other words they have to get to the form from another 
page on the site, and you set a time limit for a minimum amount of time they 
spend on the page(5-10 seconds)?


I don't set any time, just the session to prevent direct hits from a 
spam script. But if you wanna improve the solution using a time check 
you could save a microtime() value in the session and the test it 
against current time on the form page and the have a min. threshold that 
is accepted.


--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Sanitizing potential MySQL strings with no database connection

2009-10-19 Thread Kim Madsen

Dotan Cohen wrote on 2009-10-18 21:21:


I thought that one could not test if a database connection is
established or not, this is the most relevant thing that I found while
googling that:
http://bugs.php.net/bug.php?id=29645


from http://www.php.net/manual/en/function.mysql-connect.php

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}

So just test if $link is available


All the connections are to MySQL databases, but to _different_ MySQL
databases on the same host.


Would't this solve you problem?

$link1 = mysql_connect('localhost', 'mysql_user1', 'mysql_password');
$link2 = mysql_connect('localhost', 'mysql_user2', 'mysql_password');

if($link1) {
etc...

or I would say that your different scripts should require different db 
connection files.


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



Re: [PHP] Blocking video streaming

2009-10-19 Thread Kim Madsen

Hey

Talawa wrote on 2009-10-19 18:29:

Hello everyone,

I post a message here because i didn't find any solution yet.
I just finished video streaming service on my website. I use xmoov script 
(http://xmoov.com/xmoov-php/) to do that. It works like a charm, but I find an 
issue. When the video is buffering into the flash player, all others requests 
are pending until the video is loaded.

I discovered in my search that fopen() function could block php process.

Does someone know this problem ?


I've had a similar problem with zip downloads (which also use fopen), I 
supect either the headers, a caching problem or latin1/utf-8


What does your headers look like? (firefox has a lovely plugin live 
http headers)


Which character encoding do you use?

Show us code bit from fopen to fclose

--
Sincerly
Kim Emax

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



Re: [PHP] Please don't kick me!

2009-10-19 Thread Kim Madsen

Hi Philip

Philip Thompson wrote on 2009-10-19 22:47:
 Hi all.

 I know this question has been asked a thousand times on the list, but 
my searches in the archives are not being nice to me. So... please don't 
kick me.


Why would anyone do that? We're PHPeople and PHfrinds (ho ho)

 Currently, we use DOMPDF to generate PDFs from HTML. However, it's no 
longer maintained and it has a few bugs that we just can no longer live 
with. What PDF generating software do you use? It does not have to be 
free, but it must run on linux and may be command line or run through 
code. Some of the ones I have researched are...


 html2pdf
 html2ps
 html2fpdf
 xhtml2pdf
 fpdf
 tcpdf

 You're thoughts would be appreciated. Oh, my preference would be to 
send HTML/CSS to a script and it just automagically convert to PS/PDF.


I've been using fpdf for 4-5 years for invoices among others and are 
very happy with that.



--
Kind regards
Kim Emax - masterminds.dk

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



Re: [PHP] Header problem - SOLVED

2009-10-19 Thread Kim Madsen
This has been solved today. Talawa had a similar problem and came up 
with a solution to his problem, namely using session_write_close() 
before creating the headers. That stunt also solved my problem :-)


--
Kind regards
Kim Emax

Kim Madsen wrote on 2009-10-03 13:30:

Hi PHP people

I have a really strange and annoying problem. I've got a site, where
members can download music. User clicks index.php (in index.php
there's an iframe, that opens another file), if certain check are okay
then a popup window opens download.php, where a mp3 file is fetched
from the server and renamed in the header, then pushed to the enduser,
this works fine. But now I want to create zipfiles too but when a user
downloads a zipfile it's like the whole site is freezed until download
has completed. My guess is that this is some sort of header problem
(see headers below), due to three headers at the same time, cause the
class works as expected in the test page i've created. Inputs to
correct headers would be appriciated very much :-)

Mp3 headers:
 $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
 header('Content-Description: File Transfer');
 header(Content-Type: application/octet-stream);
 header(Content-Length: $size);
 header(Content-Disposition: $new_filename);
 header(Content-Transfer-Encoding: binary);
 readfile($source_file);

Zip headers:
 $zip = new zipfile();
 $zip-add_dir(.);
 $new_filename= {$artist} - {$title}.mp3;
 if(mysql_num_rows($result)) {
   $zip-add_file($file, $new_filename);
 }
 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);
 header(Content-type: application/zip);
 #header(Content-Type: application/octet-stream);
 header(Content-disposition: attachment; filename=\zipTest.zip\);
 header('Content-Transfer-Encoding: binary');
 ob_end_clean();
 echo $zip-file();

Code example: http://lps.netlinq.dk/test010/test_zip.class.php

Headers (fetched with firefox add-on: live http headers)

This is headers from the site, where the problem occurs:

1. click on the link to a title (Maxwell in this case)
--
http://lps.netlinq.dk/?action=downloadtrack_id=357

GET /?action=downloadtrack_id=357 HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:21 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4250
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

2. I click on download zip (this is a link to index.php)
if conditions are met, then a popup with download.php is activated and
here a zip header is made

--
http://lps.netlinq.dk/index.php

POST /index.php HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
action=ask_questionsdownload_zipfile=1version_id
%5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
%5B1068%5D=1

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:29 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3216
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html
--
http://lps.netlinq.dk/download.php?track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1 



GET /download.php?
track_id=357member_id

Re: [PHP] Sanitizing potential MySQL strings with no database connection

2009-10-18 Thread Kim Madsen

Dotan Cohen wrote on 2009-10-18 10:52:

I assumed the reason you wanted to do escape the string so that you could 
perform DB operations.


Yes, that is my intention. However, the function is found in an
include file of functions used in many different scripts, each of
which connect to a different database or may not connect to a database
at all, so I cannot rely on there existing a database connection. 



test if you have a db connection in the function, if not, skip MRES and 
other mysql_ functions?


In my opinion it's bad code to use a mysql_* function on a Oracle db 
(and vice versa) or on a string for that matter. It lies in the naming 
of the function what it's designed to do and work on. If you want a 
general function to sanitize an input, make your own function 
sanitize_input() based on ereg_* and/or str_replace and the likes.


--
Kind regards
Kim Emax

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



Re: [PHP] Need unrounded precision

2009-10-16 Thread Kim Madsen

Hello

Andre Dubuc wrote on 2010-01-02 02:20:

Hi,

I need to extract the first digit after the decimal point from a number such 
as 28.56018, which should be '5'.


Since no one came up with the simple solution:

$num = 28.56018;
ereg(^[0-9]+\.([0-9]){1}, trim($num), $regs);
if($regs[1])
  $digit = $regs[1];
else
  print no digit found;

--
Kind regards
Kim Emax


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



Re: [PHP] Header problem - solved

2009-10-16 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-05 18:26:


  There's a useful function called headers_sent() which checks to see if
  the headers have already been sent to the browser. This might be a good
  place to throw into your code at various points to check and see if
  something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the 
BOM is automatically added, it can cause lots of problems ... still, 
only if you sent whatever to the output before the download.


I've tried a bunch of things, including link to index.php and as first 
thing check if the request is a zipfile, then throw a zip header, 
readfile the file then exit the code. Nothing helped. So I figured it 
could be a latin-1 / utf-8 problem and tried to post to a fresh new page 
(donwload_zip.php) instead, where I was sure the terminal and Vi was set 
to use latin-1, then it worked.


It's still not the ultimate solution as we wanted the zipfile to be 
created on the fly in memory in order not to have to delete files 
afterwards and to be sure that only allowed users can fetch the files 
(of course you can always put the zipfiles outside webscope, but still...)


--
Kind regards
Kim Emax

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



Re: [Fwd: [PHP] Sessions in databases]

2009-10-06 Thread Kim Madsen

Sam Stelfox wrote on 2009-10-06 18:09:
If you are distributing your application over multiple servers, using a 
database for session tracking allows a user to continue there session 
regardless of which server their request bounces too. It prevents the 
need for 'sticky' network connections which time out anyways. 


I know Alfio don't have access to the php.ini file, but if you do and 
have the above setup, consider using a tmp dir like /phptmp and have one 
root server and mount the other servers /phptmp to the root servers /phptmp


Kind regards
Kim Emax


Il pinguino volante wrote:

(There were some erroros in the previous email, I'm sorry)

Hi to all.

I have to realize an authentication system for a lot of users.

I heard that someone uses to store session states (?) into a database. 
I'd like to know how and, expecially, WHY to do it and what's would be 
better (considering that I CANNOT -d'oh!- edit the php.ini file).


Thanks in advance,
Alfio.








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



Re: [PHP] Header problem

2009-10-05 Thread Kim Madsen

Hi Andrea

Andrea Giammarchi wrote on 2009-10-04 19:36:
Unless I am missing something, your page has too many if and it always 
ends up with print something ... but there is no exit after the 
download, so the zip will have extra output included without a reason 
... which is an error, imho, dunno how else explain if you can't see 
your print links at the end of the page ...


Sorry, the .phps file wasn't updated, but the page still works as 
expected even though I've printed stuff after the header (i tested that 
just for fun).


I'm thinking I'll try and look at the included files, this is what 
happends before the headers are trown:


session_start();
$version_id = $_REQUEST['version_id'];
$track_id = $_REQUEST['track_id'];
$member_id = $_REQUEST['member_id'];
$string = $_REQUEST['string'];
$zipfile = $_REQUEST['zipfile'];

if($DOWNLOAD_OK) {
  include inc/connect.inc;
  include inc/functions.inc;
  include inc/default_functions.inc;

As you said earlier, spaces could do wierd stuff to a header

Also switching between utf-8 and latin-1 character sets can make php 
choke, I've experienced that before with sessions.


Kind regards
Kim


  Date: Sun, 4 Oct 2009 19:09:35 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: Re: [PHP] Header problem
 
  Hello Andrea
 
  Andrea Giammarchi wrote on 2009-10-04 18:49:
  
Header must come first (before you output anything) or you get a 
parse

error
  
   I try to better explain ...
  
   HTTP works like this: you ask something, you receive something, 
html and

   texts are just one option.
 
  Got it so far
 
   Your example page mess up html, zip, everything, because when you
   download a file you still have the rest of the page sent in the output.
 
  Nops, not really.
 
  index.php:
  print stuff
  do stuff
  open download.php in a _new_ window.
  print more stuff
  page end
 
  this should be possible, right? Two different headers for two different
  pages.
 
   A download should have ONLY file related info/headers and nothing else
   in the output ... echo/print in the middle of the code before an 
header

   is an error, everything in output before an header is an error,
   everything after headers that is not related to that header is an 
error,

   got my point?
 
  Jep! And that's actually what I do. What I could, is to add exit; after
  the headers have been sent and the file have been pushed. I do an update
  of the database to tell the system that the files in the zipfile has
  been downloaded.
 
   To decide how a page should behave, you must be able to do not produce
   anything except the expected output with expected headers, that's 
why I

   have said headers are fundamental for a response, we cannot play with
   outputs however we want.
 
  The only output is the headers of the zipfile:
 
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment;
  filename=\.basename($zip_filename).\);
  header(Content-Transfer-Encoding: binary);
  readfile($filename);
 
  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;
 
  // NOTE second param shall be an array, not a variable when
  downloading zip files
  download_completed($member_id, $downloaded_version_ids);
 
  Wouldn't you say this is okay?
 
   As summary, once you have created and tried a dedicated page without a
   single white space or print before, during, or after the dedicated
   download stuff, I'll try to understand where is the error.
   Otherwise it could be everything, and I am against magic 
behaviors ...
   you need to download? Well, create a file which aims id to download 
and

   nothing else, or you gonna constantly find these kind of problems in
   your applications.
 
  I believe the testpage does forfill that request? Or do you mean 
otherwise?

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


Windows Live Hotmail: Your friends can get your Facebook updates, right 
from Hotmail®. 
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009



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



Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-03 13:40:
 Do you want users download the file or the zip?

They can choose between the two.

 do you send other headers before the download?

Header must come first (before you output anything) or you get a parse 
error, so I'm not sure what you mean here? You can see the source of the 
class at the testpage I linked to.


 It's quite a common error to set a default header in PHP at the 
beginning of whatever application, while header should be used as last 
exit point and never in the middle, or at the beginning, of a response.


I'm not sure what you mean by this? My download.php first checks for the 
relevant data is there (track_id/version_id, a session with member_id), 
then if the download is allowed (by access or if it has already been 
downloaded) then it fetches the relevant files, zip these to the disk 
and first then... creates the zip header and afterwards uses a readfile 
on the zipfile just created.


 Moreover, if you use readfile and then zip what do you expect, 
multiple downloads in one? This is not how HTTP work ... so please show 
more php, or explain better what you would like to do.


What do you need to see besides the testpage?

If I have 4 mp3 files of 5mb each, these will be zipped into one 20mb 
file, and that is of course only one download. That's the wish from the 
siteowner: easier download of several mixes of the same artist/track


I hope this makes the problem more clear to you :-)

I've debugged some more into the problem, this is a header of a zip 
download where the site works as expected:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:26:45 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes) (index.php=get_zip).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/zip

I call the file like this: index.php?get_zip=test_output.zip

index.php does this:

  $new_zipfile .= $_SESSION['download_title']..zip;
/*
  header(Cache-Control: no-cache);
  header(Pragma: no-cache);
  header(Expires: now);
*/
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: .filesize($archiveName));
  header(Content-Disposition: attachment; filename=\$new_zipfile\);
  header(Content-Transfer-Encoding: binary);

  readfile($archiveName);
  exit;

The outcommented headers was put in because I discovered that the 
download then was cached after giving the file a strange name, that name 
never occured in the download :-/ I've ended up by making a workaround 
by adding nocache=.microtime(). to the get_zip link but then the site 
freezes againg during the download, arrrghh...


And headers from the original zip solution in download.php, headers are 
set in function.inc, this is the output from Live HTTP headers:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 21:41:49 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 35756585
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: application/zip

difference to the returned zip headers in index.php is pragma, 
cache-control and expires, so I've removed these headers from the 
function, but they still show up:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:25:36 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Content-Type: application/zip

So I think my problem is cache related in some way.

Kind regards
Kim


  Date: Sat, 3 Oct 2009 13:30:38 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: [PHP] Header problem
 
  Hi PHP people
 
  I have a really strange and annoying problem. I've got a site, where
  members can download music. User clicks index.php (in index.php
  there's an iframe, that opens another file), if certain check are okay
  then a popup window opens download.php, where a mp3 file is fetched
  from the server and renamed in the header, then pushed to the 

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hi kranthi

kranthi wrote on 2009-10-03 16:21:
 Thats a lot of headers to read..
 At a first glance I can see that you did not specify a content-length
 header. this is a must and must be equal to the size of the file in
 bytes

I've noticed that too, but it's impossiple to determine the length of 
the zipfile, when creating the file in memory.


Instead I'm now writing the file to disk and uses filesize on the 
zipfile to get the length for Content-Length, then I use 
readfile(zipfile.zip) instead of echo $zip-file(); But the result is 
still the same :-/


Kind regards
Kim

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



Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hello Andrea

Andrea Giammarchi wrote on 2009-10-04 18:49:


  Header must come first (before you output anything) or you get a parse
  error

I try to better explain ...

HTTP works like this: you ask something, you receive something, html and 
texts are just one option.


Got it so far

Your example page mess up html, zip, everything, because when you 
download a file you still have the rest of the page sent in the output.


Nops, not really.

index.php:
print stuff
do stuff
open download.php in a _new_ window.
print more stuff
page end

this should be possible, right? Two different headers for two different 
pages.


A download should have ONLY file related info/headers and nothing else 
in the output ... echo/print in the middle of the code before an header 
is an error, everything in output before an header is an error, 
everything after headers that is not related to that header is an error, 
got my point?


Jep! And that's actually what I do. What I could, is to add exit; after 
the headers have been sent and the file have been pushed. I do an update 
of the database to tell the system that the files in the zipfile has 
been downloaded.


To decide how a page should behave, you must be able to do not produce 
anything except the expected output with expected headers, that's why I 
have said headers are fundamental for a response, we cannot play with 
outputs however we want.


The only output is the headers of the zipfile:

  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment; 
filename=\.basename($zip_filename).\);

  header(Content-Transfer-Encoding: binary);
readfile($filename);

  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;

  // NOTE second param shall be an array, not a variable when 
downloading zip files

  download_completed($member_id, $downloaded_version_ids);

Wouldn't you say this is okay?

As summary, once you have created and tried a dedicated page without a 
single white space or print before, during, or after the dedicated 
download stuff, I'll try to understand where is the error.
Otherwise it could be everything, and I am against magic behaviors ... 
you need to download? Well, create a file which aims id to download and 
nothing else, or you gonna constantly find these kind of problems in 
your applications.


I believe the testpage does forfill that request? Or do you mean otherwise?

Kind regards
Kim

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



[PHP] Header problem

2009-10-03 Thread Kim Madsen

Hi PHP people

I have a really strange and annoying problem. I've got a site, where
members can download music. User clicks index.php (in index.php
there's an iframe, that opens another file), if certain check are okay
then a popup window opens download.php, where a mp3 file is fetched
from the server and renamed in the header, then pushed to the enduser,
this works fine. But now I want to create zipfiles too but when a user
downloads a zipfile it's like the whole site is freezed until download
has completed. My guess is that this is some sort of header problem
(see headers below), due to three headers at the same time, cause the
class works as expected in the test page i've created. Inputs to
correct headers would be appriciated very much :-)

Mp3 headers:
 $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
 header('Content-Description: File Transfer');
 header(Content-Type: application/octet-stream);
 header(Content-Length: $size);
 header(Content-Disposition: $new_filename);
 header(Content-Transfer-Encoding: binary);
 readfile($source_file);

Zip headers:
 $zip = new zipfile();
 $zip-add_dir(.);
 $new_filename= {$artist} - {$title}.mp3;
 if(mysql_num_rows($result)) {
   $zip-add_file($file, $new_filename);
 }
 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);
 header(Content-type: application/zip);
 #header(Content-Type: application/octet-stream);
 header(Content-disposition: attachment; filename=\zipTest.zip\);
 header('Content-Transfer-Encoding: binary');
 ob_end_clean();
 echo $zip-file();

Code example: http://lps.netlinq.dk/test010/test_zip.class.php

Headers (fetched with firefox add-on: live http headers)

This is headers from the site, where the problem occurs:

1. click on the link to a title (Maxwell in this case)
--
http://lps.netlinq.dk/?action=downloadtrack_id=357

GET /?action=downloadtrack_id=357 HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:21 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4250
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

2. I click on download zip (this is a link to index.php)
if conditions are met, then a popup with download.php is activated and
here a zip header is made

--
http://lps.netlinq.dk/index.php

POST /index.php HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
action=ask_questionsdownload_zipfile=1version_id
%5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
%5B1068%5D=1

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:29 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3216
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html
--
http://lps.netlinq.dk/download.php?track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1

GET /download.php?
track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1
HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8

[PHP] PHP4.4 and installing PEAR?

2005-10-20 Thread Kim Madsen
Hi 

I installed PHP 4.4 on a new server and missed the Pear packages after that. I 
looked in the docs, I searched the php maillist and googled without finding an 
answer. I solved it by installing 4.3.9 and after this upgrade to 4.4, but I´m 
just damn curious... How do I install the pear packages next time? And where 
can one read about this?

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Problem w/ Hidden Input Fields

2005-10-11 Thread Kim Madsen
Hello

 -Original Message-
 From: Jason Ferguson [mailto:[EMAIL PROTECTED]
 Sent: Sunday, October 09, 2005 5:55 PM
 To: php-general@lists.php.net
 Subject: [PHP] Problem w/ Hidden Input Fields
 
 I have a input type=hidden field with a value 86 characters long.
 Here is the entire form:
 
   form name=frmWizard id=frmWizard method=post
 action=
   table
   tr
 
   tdinput
 type=radio name=radioKey value=2
 checked=checked /Rootsweb
   input
 type=hidden name=txtKeyValue id=txtKeyValue
 maxlength=90
 value=ABQIh2cCTTmAE6T4OXjecIFe5BQMxb4e6BwgeSB7cBu9SbVQSak6ARTgAPoctbx
 36BXXgbYZONZls0B1LQ
 /
   /td
   /tr
   tr
   tdinput
 type=radio name=radioKey value=2 /Other Site:
 input type=text name=txtKeyValue id=txtKeyOther //td
   /tr
   tr
   td class=center
 
   input
 type=button name=btnGenTemplate id=btnGenTemplate
 value=Generate HTML onclick=setWizardAction('genHTML.php') /
   /td
   tr
   td class=center
   input
 type=button name=btnPrev id=btnPrev value=lt;--
 Prev disabled=true /
   input
 type=button name=btnNext id=btnNext value=Next
 --gt; onclick=setWizardAction('mmwizard1.php')/
   input
 type=button name=btnFinish id=btnFinish value = Finish /
   /td
   /tr
 
   /table
   /form
 
 However, when I submit and do a print_r($_POST), there is no value for
 $_POST['txtKeyValue'].

Because You later in the form set: 

input type=text name=txtKeyValue id=txtKeyOther /

It´s overwritten then.

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper



ComX Networks A/S
Naverland 31, 2 
DK-2600 Glostrup
Denmark
Phone: +45 70 25 74 74
direct: +45 32 87 73 93
Fax: +45 70 25 73 74
Web: www.comx.dk
E-mail: [EMAIL PROTECTED]

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



RE: [PHP] safe mode

2005-07-29 Thread Kim Madsen
 -Original Message-
 From: Bostjan Skufca @ domenca.com [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 28, 2005 1:38 PM

   I would *never* host anything on a server with safe_mode on!
 
 What are your reasons for this decision?

I correted it in a mail 5 minutes after.

With safe_mode off this is possible

System(cat /home/Bostjan/include/db_setup.inc);

From any php script and any user. 

One should be protected by safe_mode_gid and safe_mode_include_dir, but I´ve 
seen several examples of hosting setups that allows complete access to another 
users directory. With safe_mode on I´M more safe and so are my customers ;-)

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] safe mode

2005-07-28 Thread Kim Madsen

 -Original Message-
 From: Ryan A [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, July 26, 2005 6:29 PM

 I presently require hosting with a company that has their servers in
 Sweden,
 and I need a shared hosting account,
 any recommendations are welcome, the server is for a client.
 
 I have found quire a few via google but I noticed most of them are
with
 Safemode ON and Register_globals ON
 which I find to be quite strange because I have always hosted on a
 regular
 server with safe mode off, register_
 globals does not really metter, as if it was off I didnt do anything
but
 if it was on I used a htaccess file to put the b**ch off :-)
 
 I have done a little reading on Safe Mode, but I'm looking for _your_
 experiences with safe mode and the problems
 you have faced or/and any warnings for me. Will continue to read and
 search via google while i wait for your answer/s.

I would *never* host anything on a server with safe_mode on!

System(cat /home/USER/include/db_setup.inc);

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] safe mode

2005-07-28 Thread Kim Madsen
Ahem!

 -Original Message-
 From: Kim Madsen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, July 28, 2005 12:01 PM

 I would *never* host anything on a server with safe_mode on!

s/safe_mode on/safe_mode off/

/Kim

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



RE: [PHP] Re: So many returned mail notices!

2005-06-22 Thread Kim Madsen
 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 21, 2005 8:13 PM


 sarcasm
 you're not your, but it's understandable coming from someone
 named after a car license plate number.

In denmark it costs around 1000€ to get a license plate with Your own name on 
it. On the other hand it´s free to change Your name so, if You wanna have a 
license plate with You name on it... actually he´s quite smart :-)
 
 if there was a 'pointy' scale with spoons at one end and samurai swords at
 the other you're point would weigh in at the spoon end.
 /sarcasm

I sense Monkey Island humor here?

/Kim


RE: [PHP] eml splitting

2005-06-22 Thread Kim Madsen
 -Original Message-
 From: david forums [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 22, 2005 10:48 AM

 Do you are or know where I could find something (already made) to
split
 eml (getting headers, body)

Use fopen() to read the file line by line, then echo/save the info You
need

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Re: editor in WEB PAGE

2005-06-21 Thread Kim Madsen
 -Original Message-
 From: Denyl Meneses Guillén [mailto:[EMAIL PROTECTED]
 Sent: Monday, June 20, 2005 8:26 PM
 To: php-general@lists.php.net; M. Sokolewicz
 Subject: Re: [PHP] Re: editor in WEB PAGE
 
 of course that is Javascript, but I want to know if it is possible and if
 they know some application

Yeps, but still... why ask in a *PHP* group, when You *know* it´s a javascript 
issue? Not respecting the agenda of a maillist wont do You any good in the 
end...

Anyway, there are several of that kind, htmlarea is easy to setup, but works 
*only* in IE5.5 and later, FCKeditor works on several platforms, but is 
difficult to setup with image browsing and upload functionality.

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Re: editor in WEB PAGE

2005-06-21 Thread Kim Madsen

 -Original Message-
 From: Rory Browne [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 21, 2005 9:49 AM
 To: Kim Madsen
 Cc: Denyl Meneses Guillén; php-general@lists.php.net; M. Sokolewicz
 Subject: Re: [PHP] Re: editor in WEB PAGE
 
 On 6/21/05, Kim Madsen [EMAIL PROTECTED] wrote:
   -Original Message-
   From: Denyl Meneses Guillén [mailto:[EMAIL PROTECTED]
   Sent: Monday, June 20, 2005 8:26 PM
   To: php-general@lists.php.net; M. Sokolewicz
   Subject: Re: [PHP] Re: editor in WEB PAGE
  
   of course that is Javascript, but I want to know if it is possible and
 if
   they know some application
 
  Yeps, but still... why ask in a *PHP* group, when You *know* it´s a
  javascript issue? Not respecting the agenda of a maillist wont do You 
  any good in the end...

 The display/rich-editing part is javascript, but the management of it,
 and particularly the content/image upload is managed by PHP.

This quote might give You a hint:

when writing the content of the email him can be put format like Bold,
fonts, etc. 

;-)

  Anyway, there are several of that kind, htmlarea is easy to setup, but
  works *only* in IE5.5 and later, FCKeditor works on several platforms, 
  but is difficult to setup with image browsing and upload functionality.

 where as htmlarea afaik simply doesn't have such functionality, hence
 no requirement to set it up :?

It doesn´t and it suits the needs Denyl asked for. I simply just added that 
the FCKeditor is difficult to set up with image browsing and upload 
functionality, the docs and how-to lacks a lot here... (anyone got it to work 
I´ll appreciate some hints and help ;-))

/Kim

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



RE: [PHP] resetting arrays

2005-06-21 Thread Kim Madsen

 -Original Message-
 From: I. Gray [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, June 21, 2005 2:34 PM
 To: php-general@lists.php.net
 Subject: [PHP] resetting arrays
 
 Hi.
 
 I am sure this is easy, but I can't get this work.  Is there not a php
 function that can do this?

Yes, use sort()
 
 I have an array- for example...
 [1] = Yellow
 [2] = Green
 [3] = Purple
 [4] = Blue
 [5] = Red
 [6] = Orange
 [7] = Cyan

This does however set yellow to 0, not 1 - run through the array with
foreach:

foreach($array AS $key = $val) {
  $count++;
  $new_array[$count] = $val;
}

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] undefined index

2005-06-17 Thread Kim Madsen

 -Original Message-
 From: Ross [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 16, 2005 8:51 PM


 if ($quantity == 0){
 
 }
else {
 
  $pieces = explode( , $quantity);
$formatted_price = sprintf('%0.2f', $pricecode);
   echo table width=\240\ border=\0\ cellpadding=\2\
 cellspacing=\5\trtd valign=\top\ align=\right\
 width=\40\$pieces[0]/tdtd align=\left\ width=\60\/tdtd
 align=\left\ width=\200\$pieces[1] $pieces[2] $pieces[3]
 $pieces[4]/tdtd valign=\top\ align=\left\
 width=\80\$formatted_price/td/tr/table;
 
}
}
 
 The trouble is I get a NOTICE that tells me the indexes 1 to 4 have
not
 been defined. how do I do this.

Probably because $quantity IS 0, then the vars used in the else {} is
never set, but still in the script.

Try setting these before the if statement:

$pieces = array(); 
$formatted_price = 0;
$pricecode = 0; // this one is never set? Or set earlier in the script?


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] htmlArea - a 'client editor'

2005-06-16 Thread Kim Madsen

 -Original Message-
 From: M Saleh EG [mailto:[EMAIL PROTECTED]
 Sent: Saturday, June 04, 2005 2:57 PM
 To: Rory Browne
 Cc: [EMAIL PROTECTED]; php-general@lists.php.net
 Subject: Re: [PHP] htmlArea - a 'client editor'
 
 www.FCKEditor.net http://www.FCKEditor.net
 FCKEditor is the best i've ever seen.
 Check it out.

Yeah, looks cool, but Im having a *lot* of trouble getting the listing of 
current images and upload functionality to work. How and where do You set this 
up? The documentation is very simple and yet confusing.

The filemanager image browser shows that Im looking in /, cant seem to find 
a setting for this anywhere

The upload doesnt return an error, the JS upload in progress just hangs...

/Kim

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



RE: [PHP] autocomplete a field

2005-06-16 Thread Kim Madsen
 -Original Message-
 From: xfedex [mailto:[EMAIL PROTECTED]
 Sent: Saturday, June 04, 2005 4:57 AM
 To: php-general@lists.php.net
 Subject: Re: [PHP] autocomplete a field
 
 Hi,
 
 Anyone know if theres a way to disable this feature for user using old
 browsers or not suporting JS/XML?

It seems there was no replies to this post?

Try autocomplete=off in the input tag:

input type=text name=whatever autocomplete=off

/Kim

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



RE: [PHP] htmlArea - a 'client editor'

2005-06-16 Thread Kim Madsen
 -Original Message-
 From: Kim Madsen [mailto:[EMAIL PROTECTED]
 Sent: Thursday, June 16, 2005 9:14 AM
 To: php-general@lists.php.net
 Subject: RE: [PHP] htmlArea - a 'client editor'


 Yeah, looks cool, but Im having a *lot* of trouble getting the listing of
 current images and upload functionality to work. How and where do You set
 this up? The documentation is very simple and yet confusing.

I should have mentioned that Ive looked at the config file in  
/FCKeditor/editor/filemanager/browser/default/connectors/php/config.php :-)
 
/Kim

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



RE: [PHP] php + cvs

2005-06-01 Thread Kim Madsen

 -Original Message-
 From: Bostjan Skufca @ domenca.si [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 31, 2005 6:57 PM

   is it possible to mount CVS/SVN repository as filesystem?
 
  a. why would you want to? (the whole idea is that you _dont_ edit
files
  directly in the repository) b. this is a php mailinglist not a cvs
  mailinglist. ;-)
 
 
 a. It would create a posibility to run application directly from CVS
if
 http server would have access to it

If You really want that, then set it up in Your virtual host block? No
need for mounting here as I see it.

A typical setup is:

/home/website/cvs // the CVS repository
www.domain.com // /home/website/public_html (the live site)
www.domain.com/~USERS/ // /home/USERS/ (the local checkouts)

Everyone working on the site works on their local checkouts, and commits
changes, then asking a sysadm/CVSadmin to put the changes into the live
environment. Some companies use several levels like dev, pre-production
before production.

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] PHP and USB Devices

2005-06-01 Thread Kim Madsen

 -Original Message-
 From: Joe Harman [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 31, 2005 8:24 PM

 actually what I need to have it do is just fill in the user's name and
 password... security is not high on the priority list... the only
 thing that the fingerprint reader is going to do is make the process
 of login fast and hopefuly error free...
 
 I am using the microsoft fingerprint reader... looks like I need to
 find an activex (that doesn't seem to exist) that will pop the access
 info into the username and password box... the problem with the
 packaged software is that there can only be one fingerprint profile
 per user account... i need like 80 profiles... there should be some
 sort of other hardware/software solution out there that I will run
 across...

microsoft fingerprint reader,  hopefuly error free? Ehh... that doesn´t 
compute... You´re under arrest (Quote from Episode 1)

No really, does the reader by any chance emulate a keyboard like a handscanner 
does? That would definetly be a nice thing for You :-)

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Re: php forum and (almost certainly 0T) client editor

2005-06-01 Thread Kim Madsen

 -Original Message-
 From: Amir Mohammad Saied [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 31, 2005 10:34 PM
 To: php-general@lists.php.net
 Subject: [PHP] Re: php forum and (almost certainly 0T) client editor
 
 For your 2nd question, try kupu
 http://kupu.oscom.org/
 It really rocks!

It made my FireFox crash!

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Stopping users to see uploaded files

2005-05-30 Thread Kim Madsen
 -Original Message-
 From: symbulos [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 27, 2005 6:50 PM
 To: php-general@lists.php.net
 Subject: RE: [PHP] Stopping users to see uploaded files
 
 Thanks everybody for all the useful suggestions.
 
  That way´s just fine. You could upload directly to the dir outside
  webscope if You like?
 
 How do we do that?
 
 Thanks in advance.

Well, I´ve got NO clue how the setup is on the server, where You are running 
the scripts. Let´s say You have Your own server or has a directory, mostly 
called public_html, where You upload files then it should be piece of cake. 
Current Setup:

~user/public_html // containing all your php files

Add a new dir: ~user/tmp (or upload)

And have the uploaded files uploaded into that dir (don´t forget permissions)   

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Re: Free penetration test

2005-05-30 Thread Kim Madsen

 -Original Message-
 From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]
 Sent: Saturday, May 28, 2005 3:48 PM
 To: Ryan A
 Cc: php
 Subject: Re: [PHP] Re: Free penetration test
 
 Ryan A wrote:
  That is extremly generious of you as I didnt really think you would have
 the
  time considering the
  amount of projects,books etc you are involved with (yep, I read your CV
 on
  your site :-D ), but
  I would like to take you up on your offer as I am sure to learn
 something
  from it...only problem is,
  the site I have just made is mostly in Swedish...I can give you a star
  account (Star accounts are the
  paid accounts) for you to login and test the site, but do you think you
  could still test it since its mostly
  in Swedish?
 
 Ja, jeg tror jeg kan klare det.  Sproget er ret ligegyldigt, jeg checker
 bare for XSS problemer med et automatisk tool jeg har skrevet.  Så det
 er heller ikke så meget arbejde.

*LOL* Nice comeback Rasmus

For those who doesn´t know, Rasmus is danish, and the language is in many ways 
and words similar to Swedish (Sweden and denmark are neighbour countries)

Well, Ryan probably didn´t know this, but that made his posting somewhat funny 
:-)

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

ComX Networks A/S
Naverland 31, 2 
DK-2600 Glostrup
Denmark
Phone: +45 70 25 74 74
Fax: +45 70 25 73 74
Web: www.comx.dk
E-mail: [EMAIL PROTECTED]

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



RE: [PHP] Warning: filemtime() (errno=75 - Value too large for defined data type)

2005-05-30 Thread Kim Madsen

 -Original Message-
 From: Andrew Brampton [mailto:[EMAIL PROTECTED]
 Sent: Sunday, May 29, 2005 7:36 PM


 Hi,
 I'm receiving the following warning:
 
 Warning: filemtime(): Stat failed for master.log (errno=75 - Value too
 large
 for defined data type) in test.php on line 5
 
 when I do the following line of code:
 filemtime ('master.log');
 
 The file in question is over 2GB, but I'm not interested in its size, I
 just want to know the time it was last modified.

2 gigs? Ever considered rotating the logfile?

 I presume filemtime is just doing a stat which is failing when it tries to
 read the size field. Whatever the cause filemtime is returning false and
 displaying that warning.
 
 Does anyone know a work around for this warning (which does not involve
 shelling out a command line app)?

Rotate the logfile for instance once a month, Tar it up and move it to a proper 
place

 My code was working fine until the file reached 2GB.

 P.S I'm running PHP 4.3.10-13 on a Debian distro.

On some older systems there´s a 2gb limit: 
http://archives.neohapsis.com/archives/sf/forensics/2002-q2/0031.html

Let me guess. The file is 2GB? If so, this is simply because your
file utilities are not compiled with large file (64 bit) support.
Here are some notes I have on fixing things for Linux:

Updates to Red Hat 7.1 system required to deal with large (2GB)
partition image files with The Coroner's Toolkit and TCTutils/autopsy.

I think that´s the problem. Rotating the logfile is a nice and simple solution.

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Dummy question about gettion select option choosen

2005-05-30 Thread Kim Madsen

 -Original Message-
 From: Jochem Maas [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 30, 2005 10:28 AM
 To: Mário Gamito


  I now have this code in a form:
  ---
  select name=interesse[]
  option1/option
  option2/option
  option3/option
  (etc...)
  /select
 
 if the form containing this element is posted then the following will
 so you what exactly is posted:
 
 var_dump( $_POST['interesse'] );
 
 which should show you an array of one or more items, which either
 come from many form elements named 'interesse[]' OR from a single
 element named 'interesse[]' where that element is multiselect
 (in which case the definition should be something like:
 
   select name=interesse[] multiple
 
 or
 
   select name=interesse[] multiple=multiple

I haven´t tried it but do You think that the multiple would work without a 
value in the option tag? 

option3/option

Should be

option value=33/option


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Stopping users to see uploaded files

2005-05-27 Thread Kim Madsen
 -Original Message-
 From: symbulos [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 27, 2005 1:00 PM

 Unfortunately, that means every person who connects to the directory can
 see
 the files. If some of the files are for sale, how do you stop the user
 from
 seeing them / downloading them without permission?

Move them _outside_ webscope and generate a download with the header() 
function, which is only is executed if the user has access.
 
 Is there any other way to upload files using php?

That way´s just fine. You could upload directly to the dir outside webscope if 
You like?


--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Can I prevent Server variables from being spoofed ?

2005-05-23 Thread Kim Madsen
 -Original Message-
 From: Richard Lynch [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 23, 2005 2:13 PM

 I think they're trying to stop massive bandwidth drain by peeps
 direct-downloading the movie...

That would be faily easy to work around. Have a md5 generated filename, use PHP 
to generate the file in a new window and check that a session var has been set 
earlier... I´m doin that on a site with (legal) mp3s 

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Problem With System Call

2005-05-20 Thread Kim Madsen

 -Original Message-
 From: Michael Stearne [mailto:[EMAIL PROTECTED]
 Sent: Thursday, May 19, 2005 4:17 PM


 No.  It's RedHat Fedora Core 3.

And? (/etc/selinux/ ;-)

It´s a thing that troubles a lot in Feodora3 installations

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

 On 5/19/05, Kim Madsen [EMAIL PROTECTED] wrote:
   -Original Message-
   From: Michael Stearne [mailto:[EMAIL PROTECTED]
   Sent: Thursday, May 19, 2005 9:10 AM
 
   I am having the strangest problem using system() or exec() or any
   variation.  None of them work on the Fedora Core 3 system that was
   just loaded.  The PHP is Version 4.3.9 with Apache 2.0.52, the default
   installation for Fedora Core 3.  Everything in PHP works as expected
   except when trying a system call.  If I run :
  
   ?
   system(/bin/ls /tmp);
   ?
  
   on my OS X (Apache/1.3.33 (Darwin) PHP/4.3.4) this returns the desired
   results, a listing of the tmp directory.  On the Fedora box I get
   nothing, a blank page.  There is content in the /tmp directory on the
   Fedora box.
 
  Are You perhaps running SElinux?
 
  --
  Med venlig hilsen / best regards
  ComX Networks A/S
  Kim Madsen
  Systemudvikler/Systemdeveloper
 
  --
  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: novice: char to varchar

2005-05-19 Thread Kim Madsen
 -Original Message-
 From: tony yau [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, May 18, 2005 9:03 PM

 found the answer sorry about this

But You don´t wanna share the solution with the rest of the class?

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Problem With System Call

2005-05-19 Thread Kim Madsen
 -Original Message-
 From: Michael Stearne [mailto:[EMAIL PROTECTED]
 Sent: Thursday, May 19, 2005 9:10 AM

 I am having the strangest problem using system() or exec() or any
 variation.  None of them work on the Fedora Core 3 system that was
 just loaded.  The PHP is Version 4.3.9 with Apache 2.0.52, the default
 installation for Fedora Core 3.  Everything in PHP works as expected
 except when trying a system call.  If I run :
 
 ?
 system(/bin/ls /tmp);
 ?
 
 on my OS X (Apache/1.3.33 (Darwin) PHP/4.3.4) this returns the desired
 results, a listing of the tmp directory.  On the Fedora box I get
 nothing, a blank page.  There is content in the /tmp directory on the
 Fedora box.

Are You perhaps running SElinux?

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] PHP Phone Number Validation

2005-05-17 Thread Kim Madsen

 -Original Message-
 From: IMEX Research [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, May 17, 2005 2:49 AM
 To: php-general@lists.php.net
 Subject: [PHP] PHP Phone Number Validation
 
 OK, I know this has probably gone aruond the list a few times, but how
do
 I validate a phone number that is in the format ddd-ddd- ??  I
can't
 figure out how.

With regular expressions: 

http://dk.php.net/manual/en/function.ereg.php
http://dk.php.net/manual/en/function.preg-match.php

I expect You wanna match 555-666-0606? (Angelina Jolies number ;-)

This will match the number from start to end:

^[0-9]{3}-[0-9]{3}-[0-9]{5}$

^ means the start of the string
$ means the end of the string
[0-9] means any number from 0 to 9
{3} means _exactly_ 3 occurences, no more no less (can also be {2,4} if
You world allow from 2 to 4 occurences or {2,} if You want at least 2
digits)

So this line says _start_ with 3 digits followed by a - then 3 digits,
then another - and end with 4 digits

Example:

$number = 555-666-0606;

if(ereg(^[0-9]{3}-[0-9]{3}-[0-9]{4}$, $number)) {
  echo valid phonenumber;
}
else {
  echo invalid phonenumber;
}

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] beginner needs help!

2005-05-13 Thread Kim Madsen

 -Original Message-
 From: Jay Blanchard [mailto:[EMAIL PROTECTED]
 Sent: Thursday, May 12, 2005 9:37 PM


  var $exportFile = Export. . date(mdy) . .txt;
 
  I seem to be able to use the date function is I am not starting the
  declaration with var, but then my program is not working correctly.
 [/snip]

 You may have to assemble it beforehand sort of ...
 
 $exportFileName = Export. . date(mdy) . .txt;
 var $exportFile = $exportFileName;

May? You _have_ to. This behavior was introduced in PHP4 as the only non-PHP3 
compatible OOP behavoir as far as I know. Nice spotted for a beginner Rochelle 
:-) I mean the I´m not allowed to use a function call while declaring with 
var. 

Explanation:
PHP3 allowed one to use a function call while declaring a variable:

var $welcome_text = Welcome  . get_username_from_db($loginname) . . Today is 
 . date(l) . , have a nice day;

As of PHP4 one _can´t_ use a function call when declaring a var, but _has_ to 
do as in Your example Jay:

var $welcome_text; 
$welcome_text = Welcome  . get_username_from_db($loginname) . . Today is  . 
date(l) . , have a nice day;


Pay attention to this though: You _not_ suppose to use var to declare a 
variable unless it´s inside a class. I never really tested that before, but 
outside a class this won´t work:

?
var $test = hello;
echo $test; // returns nothing
?

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] Problem with extending classes.

2005-05-13 Thread Kim Madsen

 -Original Message-
 From: Shaw, Chris - Accenture [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 13, 2005 12:10 PM
 To: php-general@lists.php.net
 Subject: [PHP] Problem with extending classes.
 
 Have I missed something or is there bugs with extending classes in
php5?
 Does this happen in php4.3?

$this-$name = $this-ksplit($name);
$this-$contactcontact = $this-ksplit($contact);
$this-$address = $this-ksplit($address);

Regardless of inheriting or not it should be:

$this-name = $this-ksplit($name);
$this-contactcontact = $this-ksplit($contact);
$this-address = $this-ksplit($address);

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



RE: [PHP] MySql injections (related question)

2005-05-12 Thread Kim Madsen
 -Original Message-
 From: Richard Lynch [mailto:[EMAIL PROTECTED]
 Sent: Thursday, May 12, 2005 8:47 AM

 I'd bet a dollar that if the MySQL C Client library changed what needs
 escaping, addslashes would change with it.

Ehhh? I think not. Let´s let a mindgame (can´t spell hypo..whatever :-) and say 
that the MySQL folk figures out they wanna use the same way for escaping as 
PostgreSQL, then addslashes() would add ' ? The whole idea of nameconvention is 
gone then :-)

But I do agree with You, need to hear *WHY* the mysql_real_escape_string() is 
better (and a so fu' long word :)

 What problem do you think addslashes() was written to solve?

For those who has magic qoutes off? I still can figure out why some people hate 
that setting so much? Though one´s not safe with only magic quotes, 
addslashes() are needed too...

--
Med venlig hilsen / best regards
ComX Networks A/S
Kim Madsen
Systemudvikler/Systemdeveloper

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



  1   2   >