Re: [PHP] utf8_decode() not working, conflicts with urlencode()

2011-08-31 Thread Merlin Morgenstern

Am 30.08.2011 12:11, schrieb Per Jessen:

Merlin Morgenstern wrote:


Hi there,

I am having some trouble with utf8_decode(). Somehow the function
returns output=input

e.g.:
$input = '%20%C3%9Cbersetzung%20franz';
$output = utf8_decode($input);
echo $input.'br'.$output;

My goal is to decode the utf8, trim the input and encode with
urlencode();

This is the string which I would like to get: %C3%9Cbersetzung+franz

Trim does not work and if I place urlencode() directly on the input it
will encode the % sign to %25 and produce therfore a mixture of
encodings.


It seems to me that you're probably missing a urldecode() on $input
before you attempt to decode the utf8 chars ?





that is true, thank you.

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



[PHP] Hide php action pages from google

2011-08-31 Thread Merlin Morgenstern

Hi there,

I do have a search form on my site which posts search queries to 
follogin URL:


/subapp_search/search.php

Depending on the search parameters it will then redirect to the 
appropriate URL. e.g.: /suche/labrador


I now discovered in google webmastertools that this very page 
(search.php)  is listed there as a reference for the speed of the whole 
page with 2.7s.


This page should be irrelevant to google. Does somebody know how to hide 
it from google? All redirects coming from there are 301s and the page 
without parameters redirects to /


Thank you for any help on that,

Merlin

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



[PHP] utf8_decode() not working, conflicts with urlencode()

2011-08-30 Thread Merlin Morgenstern

Hi there,

I am having some trouble with utf8_decode(). Somehow the function 
returns output=input


e.g.:
$input = '%20%C3%9Cbersetzung%20franz';
$output = utf8_decode($input);
echo $input.'br'.$output;

My goal is to decode the utf8, trim the input and encode with urlencode();

This is the string which I would like to get: %C3%9Cbersetzung+franz

Trim does not work and if I place urlencode() directly on the input it 
will encode the % sign to %25 and produce therfore a mixture of encodings.


Thank you for any help on that!

Merlin

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



[PHP] correct character decoding

2011-08-30 Thread Merlin Morgenstern

Hi there,

I am trying to find a solution for decoding the same string from 2 
different character sets (UTF-8, Latin-1)


Looks like in the case of latin-1 I need to add utf8_encode before to 
get the same results. Here is an example


// utf-8
$input = urldecode('%20%C3%9Cbersetzung%20franz');
$output = trim(($input));
$output2 = urlencode($output);
echo $input.'br'.$output.'br'.$output2;
echo 'a href='.$output2.'output 2/a';

echo 'hr';
// latin 1
$input = urldecode('%DCbersetzung+franz');
$out = trim(utf8_encode($input));
$out2 = urlencode($out);
echo $input.'br'.$out.'br'.$out2;
echo 'a href='.$out2.'output 2/a';


The latin-1 seems to need the utf8-encode to get the same result. Has 
anybody an idea on how to solve this? I need a function that works for 
latin-1 and UTF-8.


Thank you in advance for any help,

Merlin

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



Re: [PHP] utf8_decode() not working, conflicts with urlencode()

2011-08-30 Thread Merlin Morgenstern

Am 30.08.2011 12:11, schrieb Per Jessen:

Merlin Morgenstern wrote:


Hi there,

I am having some trouble with utf8_decode(). Somehow the function
returns output=input

e.g.:
$input = '%20%C3%9Cbersetzung%20franz';
$output = utf8_decode($input);
echo $input.'br'.$output;

My goal is to decode the utf8, trim the input and encode with
urlencode();

This is the string which I would like to get: %C3%9Cbersetzung+franz

Trim does not work and if I place urlencode() directly on the input it
will encode the % sign to %25 and produce therfore a mixture of
encodings.


It seems to me that you're probably missing a urldecode() on $input
before you attempt to decode the utf8 chars ?



That's right, this was missing. Thank you. However, this leeds to 
another problem which I described in a another posting.


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



Re: [PHP] correct character decoding

2011-08-30 Thread Merlin Morgenstern

Am 30.08.2011 14:12, schrieb Louis Huppenbauer:
Why don't you just check if the string is utf8 or not, and change 
convert it accordingly?


$out = trim((mb_detect_encoding($input, 'UTF-8', 'ISO-8859-1') == 
'UTF-8' ? $input : utf8_encode($input)));


It may not be the most elegant version, but I can't think of anything 
simpler right now.


sincerely
louis



Hello Louis, thank you that solved the problem. Looks like I did not use 
the mb_detect_encoding properly in my tests.


Regards, Merlin




2011/8/30 Merlin Morgenstern merlin.morgenst...@googlemail.com 
mailto:merlin.morgenst...@googlemail.com


Hi there,

I am trying to find a solution for decoding the same string from 2
different character sets (UTF-8, Latin-1)

Looks like in the case of latin-1 I need to add utf8_encode before
to get the same results. Here is an example

// utf-8
$input = urldecode('%20%C3%9Cbersetzung%20franz');
$output = trim(($input));
$output2 = urlencode($output);
echo $input.'br'.$output.'br'.$output2;
echo 'a href='.$output2.'output 2/a';

echo 'hr';
// latin 1
$input = urldecode('%DCbersetzung+franz');
$out = trim(utf8_encode($input));
$out2 = urlencode($out);
echo $input.'br'.$out.'br'.$out2;
echo 'a href='.$out2.'output 2/a';


The latin-1 seems to need the utf8-encode to get the same result.
Has anybody an idea on how to solve this? I need a function that
works for latin-1 and UTF-8.

Thank you in advance for any help,

Merlin

-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






[PHP] notices nightmare - looking for a regex solution

2011-06-01 Thread Merlin Morgenstern

Hi there,

I am working on a pretty huge site with thousands of files with php 
code. Unfortunatelly the app throws a ton of notices du to missing '' in 
arrays. Of course I could simply disable the output on the dev server to 
surpress notices, but I would rather like to get it fixed.


Has somebody a good idea on how to fix this automated somehow with regex?

The vars are right now: $var[element] and should be $var['element']

I was looking into sed, but I was hoping that there is also a way in 
php. Has anybody a hint on how to get the regex done?


I appreciate any help on that.

Best regards,

Merlin

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



Re: [PHP] preg_replace question

2011-01-25 Thread Merlin Morgenstern

Am 24.01.2011 18:08, schrieb Alex Nikitin:

If you declare your arrays, and set k to 0 first, put quotes around array
values and use the correct limit (you can default to -1), you will get
results, here is code and example (hopefully this helps you)


?php
function internal_links($str, $links, $limit=-1) {
$pattern=array();
$replace=array();
$k=0;
foreach($links AS $link){
$pattern[$k] = ~\b({$link['phrase']})\b~i;
$replace[$k] = 'a href='.$link['link'].'\\1/a';
$k++;
}
return preg_replace($pattern,$replace,$str, $limit);
}

echo internal_links(süße knuffige Beagle Welpen ab sofort,
array(array('phrase'=beagle,
'link'=http://google.com;),array('phrase'=welpen,
'link'=http://wolframalpha.com;)), -1);

Output:
süße knuffigea href=http://google.com;Beagle/a  a href=
http://wolframalpha.com;Welpen/a  ab

~Alex



Hello,

thank you all for your help. It seems that I am building the array 
wrong. Your code works with that array:


$internal_links = array(array('phrase'=beagle, 
'link'=http://google.com;),array('phrase'=welpen, 
'link'=http://wolframalpha.com;));


I am pulling the data out of a DB and am using this code:
while ($row = mysql_fetch_object($result)){ 
$internal_links[$row-ID]['phrase'] = $row-phrase;
$internal_links[$row-ID]['link'] = $row-link;
}   

You build the array different, could you help me to adapt this on my 
code? I tried $internal_links['phrase'][] as well, but that did not help 
either.


Thank you for any help,

Merlin

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



Re: [PHP] preg_replace question

2011-01-25 Thread Merlin Morgenstern

Am 25.01.2011 12:31, schrieb Merlin Morgenstern:

Am 24.01.2011 18:08, schrieb Alex Nikitin:

If you declare your arrays, and set k to 0 first, put quotes around array
values and use the correct limit (you can default to -1), you will get
results, here is code and example (hopefully this helps you)


?php
function internal_links($str, $links, $limit=-1) {
$pattern=array();
$replace=array();
$k=0;
foreach($links AS $link){
$pattern[$k] = ~\b({$link['phrase']})\b~i;
$replace[$k] = 'a href='.$link['link'].'\\1/a';
$k++;
}
return preg_replace($pattern,$replace,$str, $limit);
}

echo internal_links(süße knuffige Beagle Welpen ab sofort,
array(array('phrase'=beagle,
'link'=http://google.com;),array('phrase'=welpen,
'link'=http://wolframalpha.com;)), -1);

Output:
süße knuffigea href=http://google.com;Beagle/a a href=
http://wolframalpha.com;Welpen/a ab

~Alex



Hello,

thank you all for your help. It seems that I am building the array
wrong. Your code works with that array:

$internal_links = array(array('phrase'=beagle,
'link'=http://google.com;),array('phrase'=welpen,
'link'=http://wolframalpha.com;));

I am pulling the data out of a DB and am using this code:
while ($row = mysql_fetch_object($result)){
$internal_links[$row-ID]['phrase'] = $row-phrase;
$internal_links[$row-ID]['link'] = $row-link;
}

You build the array different, could you help me to adapt this on my
code? I tried $internal_links['phrase'][] as well, but that did not help
either.

Thank you for any help,

Merlin



HI Again :-)

the building of my array seems fine. Here is what goes wrong:

If you use this array: 	$internal_links = array(array('phrase'=Beagle 
Welpen, 'link'=http://wolframalpha.com;), array('phrase'=Welpen, 
'link'=http://google.com;));


Then it will fail as well. This is because the function will replace 
Beagle Welpen with the hyperlink and after that replace the word 
welpen inside the hyperlink again with a hyperlink.


Is there a function which will not start looking for the words at the 
beginnning of the text for each replacement, but simply continue where 
it did the last replacement?


Thank you for any help,

Merlin

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



[PHP] preg_replace question

2011-01-24 Thread Merlin Morgenstern

Hi there,

I am trying to replace certain words inside a text with php. 
Unfortunatelly my function is creating invalid html as output.


For example the words beagle and welpen have to be replaced inside 
this text: süße knuffige Beagle Welpen ab sofort


My result looks like this:
zwei süße knuffige a href=/bsp/hunde,beagleBeagle a 
href=/bsp/hundeWelpen/a/a


The problem is, that my function is not closing the href tag before it 
starts to replace the next item.


Here is the code: 


// create internal links
function internal_links($str, $links, $limit) {
foreach($links AS $link){
$pattern[$k] = ~\b($link[phrase])\b~i;
$replace[$k] = 'a href='.$link[link].'\\1/a';
$k++;
}
return preg_replace($pattern,$replace,$str, $limit);
}

I

I could not find a way to fix this and I would be happy for some help. 
Thank you in advance!


Merlin

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



[PHP] Autorename extracted files from zip-archive

2011-01-19 Thread Merlin Morgenstern

Hello,

I am using shell_exec to uncompress zip files which works fine, but has 
one big problem. Whenever the zip-archive containes an already existing 
file name, it will overwrite the current one. I need the file to be 
extracted and autorenamed.


This is the code line:

$output = shell_exec('unzip -jo '.$filename.' -d '.$path);

Does anybody know a way on how to autorename existing files?

I thought about a workaround on extracting to a tmp folder and then 
moving to the proper directory while renaming the files if they already 
exists. Unfortunatelly I could not find a way to do this.


Thank you for any help on this.

Merlin

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



[PHP] Hot to replace words with preg_replace without duplicates

2010-12-18 Thread Merlin Morgenstern

Hi there,

I want to create a function which will replace certain words out of a 
text with internal links. That works so far, but if I have two matches, 
I end up with invalid html code.


Example:
Welpen  /hunde
Chihuahua Welpen/hunde,chihuahua

function seo_internal_links($str, $links, $limit) {
foreach($links AS $link){
$pattern[$k] = ~\b($link[phrase])\b~i;
$replace[$k] = 'a href='.$link[link].'\\1/a';
$k++;
}
return preg_replace($pattern,$replace,$str, $limit);
}

seo_internal_links($ad[text], $seo_internal_links, $limit = 1);

This will result in:
a href=//hunde,chihuahuaChihuahua a href=/hundeWelpen/a/a

Has somebody an idea on how to avoid this? I would also like to limit 
the amount of hits, but the limit in preg_replace accounts only for 
unique words, not the whole array.


Thank you for any hint,

Merlin

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



[PHP] export from one server to another

2010-06-15 Thread Merlin Morgenstern

HI there,

I am thinking about building a partner network where partners can export 
content to my server which will then be imported. It should be as easy 
as possible for the partner and not rely on any special php functions.



The best way to do this I guess is to deliver them a php file which will 
create a xml structure that I can import. The problem I have now is, how 
to transfer this xml-file to my server? Of course I could do this via 
FTP, but then they need to have FTP enabled inside their php 
installation. This might scare some partners away.


Does anybody have a good suggestion on how to do this?

Thank you for any hint,

Merlin

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



Re: [PHP] Finding similar results with php from mysql

2010-05-08 Thread Merlin Morgenstern

Am 08.05.2010 03:04, schrieb David McGlone:

On Friday 07 May 2010 19:37:32 Merlin Morgenstern wrote:

Hi there,

I am searching for a way to show the user similar records from the mysql
database. A functionality like this could also be of interest to you.

Does anybody know if this is there is a standard functionality to do
this, or a good way on retrieving this with the help of PHP?

Kind regards, Merlin


I have some code that makes suggestions on items that one might be interested
in based on what they are buying or did buy in the past using PHP.

Is this what your interested in?



Hi David,

I did manage to create a function that provides datasets that are 
similar based on the title. My page is a site similar to craigslist, so 
I don't know if your code would make sense. It would be interesting 
though to show items that have been visited by other people after the 
viewed a particular classified. Could your code be adapted to serve that?


Kind regards, Merlin

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



[PHP] Finding similar results with php from mysql

2010-05-07 Thread Merlin Morgenstern

Hi there,

I am searching for a way to show the user similar records from the mysql 
database. A functionality like this could also be of interest to you.


Does anybody know if this is there is a standard functionality to do 
this, or a good way on retrieving this with the help of PHP?


Kind regards, Merlin

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



[PHP] classes and variables

2010-05-03 Thread Merlin Morgenstern

Hi there,

I am new to classes in PHP and do want to change a class that has been 
in a package I downloaded. I do simply want to access a variable from 
outside.


This is the code:

class search_helper extends AjaxACApplication
{

   //global $DB;

   var $db_database = 'test';
}

I would like to replace 'test' with $DB. This is the variable from 
outside that holds the name of the Database.


Thank you for any help!

Merlin

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



[PHP] finding out datasets in a certain distance of a zip code

2010-04-27 Thread Merlin Morgenstern

Hi there,

I am trying to find mysql db entries inside a tabel with the help of php 
that are in the distance of a certain amount of kilometers from a given 
zip code.


Unfortunatelly something must be wrong, as I do not get the desired 
results. Has anybody experience with that?


Here is the code I wrote:

$plz = '79279';
$distance = 1000;

###
# find geo data for this zip code
$stmt =
SELECT
lat,
lang
FROM
test.zip
WHERE
zip = '$plz'
;
$row=db_get_row2($stmt);
$breite = deg2rad($row-lat);
$laenge = deg2rad($row-lang);
###

if ($breite){ // only if results
###
# search for the members
$stmt = 
SELECT SQL_CALC_FOUND_ROWS
cl.ID,
g.city,
g.area_1 AS quarter,
g.* ,
IFNULL( (
ACOS( (
SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS( $breite ) * COS( 
RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) ) *6371

), 0
) AS e
FROM
test.zip g,
test.cl cl
WHERE
IFNULL( (
ACOS( (
SIN( $breite ) * SIN( RADIANS( lat ) ) ) + ( COS( $breite ) * COS( 
RADIANS( lat ) ) * COS( RADIANS( lang ) - $laenge ) ) ) *6371

), 0
)  $distance
AND g.id = cl.zip_id
GROUP BY cl.ID  
ORDER BY
e ASC
;
$result = execute_stmt($stmt, $link);
while ($row = mysql_fetch_object($result)){
$entfernung_km  = round(($row-e*1.4),2);
echo 'cl: '.$row-cl_id.' '.$entfernung_km.'br';
}
$num_results = db_numrows($result);
###

} // end if results

Thank you for any help!

Merlin

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



[PHP] Saving form data into session before leaving a page

2010-04-13 Thread Merlin Morgenstern

Hello everybody,

I have form where users enter data to be saved in a db.

How can I make php save the form data into a session before the user 
leaves the page without pressing the submit button? Some members leave 
the page and return afterwards wondering where their already entered 
data is.


Any ideas how to save into php session data before someone leaves the page?

Thank you for any hint,

Merlin

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



[PHP] 404 redirects stolen by provider

2010-04-09 Thread Merlin Morgenstern

Hello,

I am running a website under apache and php where I do redirects on 404 
errors:


apache conf:
ErrorDocument 404 /subapp_members/search_user.php

This is done to allow ULRs with usernames like this:
www.server.com/username

The PHP script search_user.php looks in a db if the user name is 
existent and if yes shows his member page. If the name is not existent 
it displays an internal 404 message.


This worked perfectly for recent years until now. Some users complain 
that they do see advertisement instead of the page. A research showed 
that they are using a provider called unitymedia. As soon as a site 
has a page not found error it redirects them to their own advertisement 
page. This is true for all pages on the net. e.b. ebay.com/testing shows 
their advertisement.


Has somebody an idea on how to fix that from my site?

Thank you for any help,

Merlin

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



Re: [PHP] 404 redirects stolen by provider

2010-04-09 Thread Merlin Morgenstern


Am 09.04.2010 21:53, schrieb Ashley Sheridan:

On Fri, 2010-04-09 at 21:29 +0200, Merlin Morgenstern wrote:

Hello,

I am running a website under apache and php where I do redirects on 404
errors:

apache conf:
ErrorDocument 404 /subapp_members/search_user.php

This is done to allow ULRs with usernames like this:
www.server.com/username  http://www.server.com/username

The PHP script search_user.php looks in a db if the user name is
existent and if yes shows his member page. If the name is not existent
it displays an internal 404 message.

This worked perfectly for recent years until now. Some users complain
that they do see advertisement instead of the page. A research showed
that they are using a provider called unitymedia. As soon as a site
has a page not found error it redirects them to their own advertisement
page. This is true for all pages on the net. e.b. ebay.com/testing shows
their advertisement.

Has somebody an idea on how to fix that from my site?

Thank you for any help,

Merlin

 


It looks like the ISP is looking at the header response codes and 
capturing the 404 ones. I've seen other ISP's do this and return a 
search results page of their own sponsored content.


I think the best way round this is to use the .htaccess redirect rules 
instead to deliver the correct content:

RewriteRule ^(.+) /users.php?username=$1

Of course that's only a simple example, and you might need to tweak it 
a bit.


This way, no extra header codes are sent to the user, and can't be 
captured by anyones ISP.


Thanks,
Ash
http://www.ashleysheridan.co.uk




This sounds like the best solution to me. The only problem is that my 
regex knowledge is pretty limited. The command:

RewriteRule ^(.+) /subapp_members/search_user.php

leads to an internal server error, the syntax seams ok?! Could you help 
with the correct rewrite rule?


The script search_user.php gets the user name and looks it up in the db:
$parameter = explode('/', $_SERVER[REQUEST_URI]);
$user_name = addslashes($parameter[1]);

So I would need to redirect all potential 404s to that script. How could 
that rewriterule look like?


Re: [PHP] 404 redirects stolen by provider

2010-04-09 Thread Merlin Morgenstern


Am 09.04.2010 22:58, schrieb Peter Lind:

On 9 April 2010 22:20, Merlin Morgensternmerli...@fastmail.fm  wrote:
   

This sounds like the best solution to me. The only problem is that my regex
knowledge is pretty limited. The command:
RewriteRule ^(.+) /subapp_members/search_user.php

 

The above rule will try to redirect everything to
/subapp_members/search_user.php. If you're looking to allow
example.com/username, then use something like:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subapp_members/search_user.php?member=$1 [L]

This is likely to not do what you want from it, but it's the closest I
can guess as to what you want.

Have a read of http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

   



This will not work, as I do have a bunch of other redirects inside the 
page.


What might work is a rule, that redirects urls that do not have a full 
stop or slash inside. Is this possible? My regex knowledge is 
unfortunatelly pretty limited.


--
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 Merlin Morgenstern



Devendra Jadhav wrote:

what do you think about this?
if( ! (page == 1  page == 2)){
  //here
}



Well a simple  (and) does not help.

I want to have all results that contain either page = 1 OR page = 3, AND 
in the same time I want to have the results that contain page=2 OR page= 3
, But the result should never contain page = 1 and page = 2 in the same 
time.


Any further idea?





On Mon, Dec 7, 2009 at 4:22 PM, Merlin Morgenstern 
merli...@fastmail.fm mailto:merli...@fastmail.fm wrote:


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?

Thank you in advance for any help!

Merlin

-- 
PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php




--
Devendra Jadhav
देवेंद्र जाधव


[PHP] Re: logic operands problem

2009-12-07 Thread Merlin Morgenstern


Peter Ford wrote:

Merlin Morgenstern wrote:

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?

Thank you in advance for any help!

Merlin



Surely what you need is xor (exclusive-or)
I can't believe a programmer has never heard of that!

(page==1 XOR page==2) AND page==3



HEllo Peter,

thank you for your reply. I know about XOR, but unfortunatelly I might 
not know how to use it properly OR it is not aplicable on SQL. I am 
trying to retrive data:

SELECT * FROM test WHERE ((page = 1 XOR page = 2) OR page = 3)

I know this is not php, but I thought the logic should be the same in 
this case?!


Regards, Merlin

--
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 Merlin Morgenstern



Ashley Sheridan wrote:

On Mon, 2009-12-07 at 11:52 +0100, Merlin Morgenstern wrote:

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?

Thank you in advance for any help!

Merlin




I thought this might work:

(page = 3) OR (page = 1 XOR 2)

But having given it more thought, I'm not so sure. I assume from your 
example that this is MySQL code and not PHP. Having said that, how can 
a field of one row have more than one value? Surely `page` is either 
1, 2 or 3, not two of them at once. How do you want your results 
pulled? Assuming you have rows containing all three values, how do you 
decide which of the pair of results you want?


Thanks,
Ash
http://www.ashleysheridan.co.uk





You have described the problem very well. This is exactly where I can 
not find a solution.


the page number translates to the following: 1= first page 2= following 
pages 3= all pages


This are the options a user has while booking a product on my site. Now 
if ther is a new
client that wants to book all pages, I need to query the table to find 
out if the spot is available.
The spot would be full if page 1 has more results then 3 , OR all 
following pages have more then 3 results. So to find out if all pages 
option would be available I need to query the db to retrieve all 
results, that are (page = 3) OR (page = 1 XOR 2)


Am I wrong?



Re: [PHP] Re: logic operands problem

2009-12-07 Thread Merlin Morgenstern



Ashley Sheridan wrote:

On Mon, 2009-12-07 at 12:37 +0100, Merlin Morgenstern wrote:

Peter Ford wrote:
 Merlin Morgenstern wrote:
 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?

 Thank you in advance for any help!

 Merlin
 
 
 Surely what you need is xor (exclusive-or)

 I can't believe a programmer has never heard of that!
 
 (page==1 XOR page==2) AND page==3
 


HEllo Peter,

thank you for your reply. I know about XOR, but unfortunatelly I might 
not know how to use it properly OR it is not aplicable on SQL. I am 
trying to retrive data:

SELECT * FROM test WHERE ((page = 1 XOR page = 2) OR page = 3)

I know this is not php, but I thought the logic should be the same in 
this case?!


Regards, Merlin




This will likely retrieve all the records in the table. Is that what 
your tests have shown?


Thanks,
Ash
http://www.ashleysheridan.co.uk




Exactly! This is unfortunatelly what happens! Any ideas how to get the 
correct results?


Re: [PHP] Re: logic operands problem

2009-12-07 Thread Merlin Morgenstern



Sándor Tamás (HostWare Kft.) wrote:
I don't really get it. This is a select statement working with the 
datas of one table.
A field of a record (namely page here) can only take one value, so 
it is totally nonsense to give XOR for that field.


I think you want to select two different recordsets: one with page 1 
and 3, and another with 2 and 3, am I right?


SanTa


Yes, you are right. Any ideas on how to do this within one query?



- Original Message - From: Ashley Sheridan 
a...@ashleysheridan.co.uk

To: Merlin Morgenstern merli...@fastmail.fm
Cc: Peter Ford p...@justcroft.com; php-general@lists.php.net
Sent: Monday, December 07, 2009 12:39 PM
Subject: Re: [PHP] Re: logic operands problem



On Mon, 2009-12-07 at 12:37 +0100, Merlin Morgenstern wrote:


Peter Ford wrote:
 Merlin Morgenstern wrote:
 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?

 Thank you in advance for any help!

 Merlin


 Surely what you need is xor (exclusive-or)
 I can't believe a programmer has never heard of that!

 (page==1 XOR page==2) AND page==3


HEllo Peter,

thank you for your reply. I know about XOR, but unfortunatelly I might
not know how to use it properly OR it is not aplicable on SQL. I am
trying to retrive data:
SELECT * FROM test WHERE ((page = 1 XOR page = 2) OR page = 3)

I know this is not php, but I thought the logic should be the same in
this case?!

Regards, Merlin




This will likely retrieve all the records in the table. Is that what
your tests have shown?

Thanks,
Ash
http://www.ashleysheridan.co.uk







Re: [PHP] logic operands problem

2009-12-07 Thread Merlin Morgenstern

Hi everybody,

thank you for all the help and thoughts. I have solved it, but I guess 
it is not an elegant solution. What I do now, is simply check again for 
the second case. There are 2 cases. Either first page OR all pages, 
second case: following pages OR all pages.


My booking checking looks now as following:

  
   


   # on which page will the tl be placed?
   if ($data[page] == 3){ // all pages
   $where_page = 'AND (page = 1 OR page = 3)'; // unfortunatelly we 
have to test later on page = 2 OR page = 3. No solution inside one 
query. We tried also (page=1 XOR page=2) OR page = 3

   $where_page_2 = 'AND (page = 2 OR page = 3)';
   }
   else{ // page one or all following pages
   $where_page = 'AND page = '.$data[page];
   }
   

   


   # find out first possible booking period
   do{
   // get all toplistings that are at least with one day inside the 
desired booking period

   $stmt= 
   SELECT
   *
   FROM
   $DB.$T54
   WHERE
   cat_id = '$data[cat_id]'
   AND cat_type = '$data[cat_type]'
   $where_page
   AND
   (
   (start_date = '$new_start' AND expires = 
'$new_start')

   OR (start_date = '$new_end' AND expires = '$new_end')
   OR (start_date = '$new_start' AND start_date= 
'$new_end')
   )   
   ;

   #echo $stmt.$br;
   $result = execute_stmt($stmt, $link);
   while ($row = db_get_row($result)){   
   $booked[start][] = $row-start_date;

   $booked[end][]= $row-expires;
   }
   $possible_bookings = count($booked[start]);
   // would there be more bookings then possible?
   if ($possible_bookings = $places){ // not enough space. Try 
nest day

   $shift = true; // shift period for one day
   $reservation = 1;
   $new_start =  date(Ymd,strtotime($new_start. + 1 day));
   $new_end = date(Ymd,strtotime($new_end. + 1 day));
   }
   else{ // enough space
   unset($shift);
   }
   unset($booked);   
   } while ($shift); // shift as long as we find free space
   




   

   # if client wants to book all pages, we have to try also the second 
constellation

   # we could not find a way to do this in one sql query
   # find out if booking period has to be shifted even further due to 
all pages booking

   if ($page == 3){
   do{
   // get all toplistings that are at least with one day inside 
the desired booking period

   $stmt= 
   SELECT
   *
   FROM
   $DB.$T54
   WHERE
   cat_id = '$data[cat_id]'
   AND cat_type = '$data[cat_type]'
   $where_page_2
   AND
   (
   (start_date = '$new_start' AND expires = 
'$new_start')
   OR (start_date = '$new_end' AND expires = 
'$new_end')
   OR (start_date = '$new_start' AND start_date= 
'$new_end')
   )   
   ;

   //echo $stmt.$br;
   $result = execute_stmt($stmt, $link);
   while ($row = db_get_row($result)){   
   $booked[start][] = $row-start_date;

   $booked[end][]= $row-expires;
   }
   $possible_bookings = count($booked[start]);
   // would there be more bookings then possible?
   if ($possible_bookings = $places){ // not enough space. Try 
nest day

   $shift = true; // shift period for one day
   $reservation = 1;
   $new_start =  date(Ymd,strtotime($new_start. + 1 
day));

   $new_end = date(Ymd,strtotime($new_end. + 1 day));
   }
   else{ // enough space
   unset($shift);
   }
   unset($booked);   
   } while ($shift); // shift as long as we find free space

   }
   

  

This is rather a dirty solution. Maybe someone has an idea on how to do 
it more elegant? I believe there should be one simple line that is 
different instead of checking it all over again for a second time.



Any ideas?


Kim Madsen wrote:

Hey Merlin

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

Hello everybody,

I am

[PHP] Finding out the first possible booking date with php

2009-12-03 Thread Merlin Morgenstern

Hello everybody,

I am pretty much stuck with a problem and I was hoping to find some help 
here with you guys.


A PHP Script with MySQL as DB has to find out the first possible booking 
period available. I can't figure out the logic behind and if there is a 
trick with PHP to do it.


Following facts:
- There can only be 3 bookings in the same time period
- I want to find out the first period available
- There should be a less as possible periods that are unbooked

Example:
Start   End
1.1214.12
4.1218.12
5.1219.12
In this example the first possible booking would be 14.12 - 28.12 as 
this is a time period where I can offer a place that holds a max of 3 
bookings.


My Problem now is how to pull this info and process it?

Should I get all dates out of the DB and process them via PHP, or do a 
magical MYSQL Query (which by the way seems not to be possible in that 
case in my knowledge) ?


Let's asume we go with PHP. Has somebody an idea how to form that kind 
of logic?


Thank you for ANY help,

merlin

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



[PHP] amount of overlaping dates

2009-12-03 Thread Merlin Morgenstern

Hello again,

I am searching for a way to identify the amount of simultanious date ranges.

Example:

array start=('1.12', '5.12', '9.12');
array end =('8.12', '12.12', '16.12');

Looks like this in a table:
start   end
1.128.12
5.1212.12
9.1216.12

Obviously the first and last daterange do not overlap. So the amount of 
overlaping bookings is 2. But how to identify this with PHP?!


Any ideas?

Thank you for any help on this!!

Merlin

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



Re: [PHP] amount of overlaping dates

2009-12-03 Thread Merlin Morgenstern

David Otton wrote:

2009/12/3 Merlin Morgenstern merli...@fastmail.fm:

  

I am searching for a way to identify the amount of simultanious date ranges.

Example:

array start=('1.12', '5.12', '9.12');
array end =('8.12', '12.12', '16.12');

Looks like this in a table:
start   end
1.128.12
5.1212.12
9.1216.12

Obviously the first and last daterange do not overlap. So the amount of
overlaping bookings is 2. But how to identify this with PHP?!



Store the start and end times of each event in an SQL table.

SELECT COUNT(*) FROM `event` WHERE `start` = NOW() AND `end` = NOW()

gets you the number of events that are happening right now.
  


That is what I thought first, too! But this does not work correct as 
there might be a booking starting for example tomorrow. There needs to 
be free place for the entire booking period.


I am a bit further now, but still stuck.

So far I could pull out all dates from the database that are within the 
range:
SELECT * FROM `datetest` WHERE '2009-12-06' between start and end OR 
'2009-12-13' between start and end


Now the trick would be to find overlaps. Here is an example:

I have a table with following booking info:

start end
2009-12-01 2009-12-08
2009-12-05 2009-12-12
2009-12-09 2009-12-16

I want to find out the first possible booking range for 14 day period 
begining from 2009-12-06 at the earliest where a max of 3 bookings are 
present. The result schould be: 2009-12-06


First I am pulling out all dates between the desired range:

SELECT *
FROM `datetest`
WHERE '2009-12-06'
BETWEEN START AND END OR '2009-12-13'
BETWEEN START AND END
LIMIT 0 , 30

Now the tricky parts starts where I do not know how to find out that the 
first daterange in the table and the last daterange do not overlap.


Any ideas?


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

2009-11-25 Thread Merlin Morgenstern

Hello Raymond,

thank you for your hint. I will go with sessions. Thanx for the note 
regarding XSS.


Kind regards, merlin

Raymond Irving wrote:

There are a couple of ways that you can do this:

1. Store the post values in the $_SESSION variable then echo them back 
to the screen. Be careful with this as it can lead to XSS. Strip html, etc
2. Send the post values back to the form as part of the query sting. 
This solution is limited to the size of the query string (2k). Be 
careful with XSS


Another solution is to use a framework to handle the post back values. 
One such framework is called Raxan. Here's an example of what it can do:


http://raxanpdi.com/form-state-example.html

__
Raymond Irving

*From:* Merlin Morgenstern merli...@fastmail.fm
*To:* php-general@lists.php.net
*Sent:* Tue, November 24, 2009 12:14:01 PM
*Subject:* [PHP] processing html forms and keeping the values

Hi there,

I am trying to redirect a user back to a html form if a validation 
failes. The form shoult then hold all entered values. So far I did 
this over $_GET, but there is a 100 Character limitation. How could I 
do this while keeping all characters?


Thank you for any hint,

Merlin

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



[PHP] processing html forms and keeping the values

2009-11-24 Thread Merlin Morgenstern

Hi there,

I am trying to redirect a user back to a html form if a validation 
failes. The form shoult then hold all entered values. So far I did this 
over $_GET, but there is a 100 Character limitation. How could I do this 
while keeping all characters?


Thank you for any hint,

Merlin

--
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-24 Thread Merlin Morgenstern



Ashley Sheridan wrote:

On Tue, 2009-11-24 at 18:14 +0100, Merlin Morgenstern wrote:

Hi there,

I am trying to redirect a user back to a html form if a validation 
failes. The form shoult then hold all entered values. So far I did this 
over $_GET, but there is a 100 Character limitation. How could I do this 
while keeping all characters?


Thank you for any hint,

Merlin




Change the form to post

Thanks,
Ash
http://www.ashleysheridan.co.uk




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?



[PHP] regex for multiple line breakes

2009-10-14 Thread Merlin Morgenstern

Hi there,

I am trying to remove multiple linebreakes from a textarea input. 
Spammers tend to insert multiple line breakes. The problem is, that I 
want to allow 2 line breaks so basic formating should be allowed.


I am doing this by regex:
$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

I would need a regex that allows \r\n\r\n, but not more than this.

Thank you for any help,

Merlin

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



Re: [PHP] regex for multiple line breakes

2009-10-14 Thread Merlin Morgenstern

That sounds very logical but does not work unfortunatelly.
The result is the same. It removes all linebreakes but one.
I would like to pass this one:

-
first line

second
third
-

But not this one:
-
third




forth




Fernando Castillo Aparicio schrieb:

You are replacing 1 or more matchs of a new line. To match 2 or more you can use 
{2,}. It's a range, first number means min matches, second max matches. 
Omitting last number means no max limit.

$data[txt] = preg_replace('`[\r\n]{2,}`',\n,$data[txt]);




De: Merlin Morgenstern merli...@fastmail.fm
Para: php-general@lists.php.net
Enviado: mié,14 octubre, 2009 12:17
Asunto: [PHP] regex for multiple line breakes

Hi there,

I am trying to remove multiple linebreakes from a textarea input. Spammers tend 
to insert multiple line breakes. The problem is, that I want to allow 2 line 
breaks so basic formating should be allowed.

I am doing this by regex:
$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

I would need a regex that allows \r\n\r\n, but not more than this.

Thank you for any help,

Merlin

-- 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] regex for multiple line breakes

2009-10-14 Thread Merlin Morgenstern



Ashley Sheridan schrieb:

On Wed, 2009-10-14 at 12:42 +0200, Merlin Morgenstern wrote:


That sounds very logical but does not work unfortunatelly.
The result is the same. It removes all linebreakes but one.
I would like to pass this one:

-
first line

second
third
-

But not this one:
-
third




forth




Fernando Castillo Aparicio schrieb:

You are replacing 1 or more matchs of a new line. To match 2 or more you can use 
{2,}. It's a range, first number means min matches, second max matches. 
Omitting last number means no max limit.

$data[txt] = preg_replace('`[\r\n]{2,}`',\n,$data[txt]);




De: Merlin Morgenstern merli...@fastmail.fm
Para: php-general@lists.php.net
Enviado: mié,14 octubre, 2009 12:17
Asunto: [PHP] regex for multiple line breakes

Hi there,

I am trying to remove multiple linebreakes from a textarea input. Spammers tend 
to insert multiple line breakes. The problem is, that I want to allow 2 line 
breaks so basic formating should be allowed.

I am doing this by regex:
$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

I would need a regex that allows \r\n\r\n, but not more than this.

Thank you for any help,

Merlin

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


  



You still have an issue with your regex:

$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

Even if you replace the + with a {2,} you are asking it to match any one
of the characters in the square brackets twice or more and replace it
with a single \n. If your line breaks actually do consist of the \r\n
pattern, then the {2,} will match those two characters, not two sets of
those characters. You might be better off replacing all \r characters
with an empty string, and then matching against the \n character only.

Thanks,
Ash
http://www.ashleysheridan.co.uk




Thank you. That worked!
$data[txt] = preg_replace('`[\n]{3,}`',\n,str_replace(\r, 
,$data[txt]));


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



[PHP] Help on pregreplace

2009-08-18 Thread Merlin Morgenstern

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


   $pattern = /\b($words)\b/is;
   $replace = 'span style=background:#FF;color:#FC;\\1/span';
   return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin

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



Re: [PHP] Help on pregreplace

2009-08-18 Thread Merlin Morgenstern



Ashley Sheridan wrote:

On Tue, 2009-08-18 at 16:00 +0200, Merlin Morgenstern wrote:

Hi there,

I am highlighting keywords with the help of pregreplace. This works 
great with one limitation. If the word that has to be replaced contains 
a slash, preg throws an error. So far I could not find a fix. Can 
someone help?


Here is the code:


$pattern = /\b($words)\b/is;
$replace = 'span style=background:#FF;color:#FC;\\1/span';
return preg_replace($pattern,$replace,$str);

Thank you in advance,

Merlin


Well, a slash has a special meaning inside PHP strings, more so for
double quoted strings. Are you correctly escaping the slash as a double
slash so that it's not interpreted by the string as an escaped
character, as you will need to as the preg_replace will be interpreting
it as an escape sequence to match?

Thanks,
Ash
http://www.ashleysheridan.co.uk




HI, replacing the delimiter slash by ~ solved the problem. Thank you

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



[PHP] regex - filtering out chinese utf8 characters

2009-07-30 Thread Merlin Morgenstern

Hi there,

I am trying to filter out content that is not ascii. Can I do this with 
regex? For example:


$regex = '[AZ][09]';
if (preg_match($regex, $text)) {
return TRUE;
}
else {
return FALSE;
}

The reason I need to do this is that I am doing a mysql query with the 
text and I need to make sure it is not UTF8. Otherwise I do get 
following error:


Error: 		Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and 
(utf8_general_ci,COERCIBLE) for operation '='


I am new to regex and would be happy for a jump start to get this fixed.

Best regards, Merlin

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



[PHP] detecting spam keywords with stripos

2009-05-29 Thread Merlin Morgenstern

Hi there,

I am matching text against an array of keywords to detect spam. 
Unfortunatelly there are some false positives due to the fact that 
stripos also finds the keyword inside a word.

E.G. Bewerbung - Werbung

First thought: use strpos, but this does not help in all cases
Second thought: split text into words and use in_array, but this does 
not find things like zu Hause or flexible/Arbeit


Does somebody have an idea on how to make my function better in terms of 
not detecting the string inside a word? Here is the code:


while ($row = db_get_row($result)){
$keyword[]  = $row-keyword;
$weight[]   = $row-weight;
};  
$num_results = db_numrows($result); 

for ($i=0;$i$num_results;$i++){
$findme  = $keyword[$i];
$pos = stripos($data[txt], $findme);
$pos2 = stripos($data[title], $findme);
if ($pos !== false OR $pos2 !== false){ // spam!
$spam_level += $weight[$i];
$triggered_keywords .= $keyword[$i].', ';
}
}
$spam[score] += $spam_level;

Thank you for any help!

Merlin

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



Re: [PHP] detecting spam keywords with stripos

2009-05-29 Thread Merlin Morgenstern



Per Jessen wrote:

Merlin Morgenstern wrote:


Hi there,

I am matching text against an array of keywords to detect spam.
Unfortunatelly there are some false positives due to the fact that
stripos also finds the keyword inside a word.
E.G. Bewerbung - Werbung

First thought: use strpos, but this does not help in all cases
Second thought: split text into words and use in_array, but this does
not find things like zu Hause or flexible/Arbeit


First thought - use Spamassassin.
Second thought - use regexes.

/Per




sorry this is a different scneario. I do need to to it this way in my 
case. It is about spam inside user postings.


Any ideas?

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



[PHP] unzip a file - destination folder wrong

2009-04-23 Thread Merlin Morgenstern

Hi there,

I am trying to unzip a zip file. Therefore I am using this function:

# unzip a file
function extract_zipfile($filename){
$zip = zip_open($filename);
if ($zip) {
  while ($zip_entry = zip_read($zip)) {
$fp = fopen(zip_entry_name($zip_entry), w);
if (zip_entry_open($zip, $zip_entry, r)) {
  $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
  fwrite($fp,$buf);
  zip_entry_close($zip_entry);
  fclose($fp);
}
  }
  zip_close($zip);
}
}

It works, but unfortunatelly the extracted files are all placed into the 
directory where the php file is located. Not where the original zip file 
was found. I tried to add the directory to fwrite, but without success.


Does somebody know where to specify the target directory?

Thank you for any help,

Merlin

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



[PHP] Re: unzip a file - destination folder wrong

2009-04-23 Thread Merlin Morgenstern



Shawn McKenzie wrote:

Merlin Morgenstern wrote:

Hi there,

I am trying to unzip a zip file. Therefore I am using this function:

# unzip a file
function extract_zipfile($filename){
$zip = zip_open($filename);
if ($zip) {
  while ($zip_entry = zip_read($zip)) {
$fp = fopen(zip_entry_name($zip_entry), w);
if (zip_entry_open($zip, $zip_entry, r)) {
  $buf = zip_entry_read($zip_entry,
zip_entry_filesize($zip_entry));
  fwrite($fp,$buf);
  zip_entry_close($zip_entry);
  fclose($fp);
}
  }
  zip_close($zip);
}
}

It works, but unfortunatelly the extracted files are all placed into the
directory where the php file is located. Not where the original zip file
was found. I tried to add the directory to fwrite, but without success.

Does somebody know where to specify the target directory?

Thank you for any help,

Merlin


Try this:

$fp = fopen(dirname($filename) . '/' . zip_entry_name($zip_entry), w);



thank you this worked. How come the . '/' . zip_entry_name($zip_entry) 
is needed? Looks like a double file name, but the result is ok. Could 
you explain this line? Thank you!


Kind regards

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



[PHP] Regex not working with :

2009-04-22 Thread Merlin Morgenstern

Hi there,

I am trying to remove a text which does contain a : inside. Somehow the 
regex does not match, no matter what I do:


$contents = mb_ereg_replace('^(.*)this is the test: replace(.*)$', '', 
$contents ,'UTF-8');


Looks like this is a result of the :.

Does anybody have an idea how to do this?

Thank you for any help.

Merlin

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



Re: [PHP] Regex not working with :

2009-04-22 Thread Merlin Morgenstern



Richard Quadling wrote:

2009/4/22 kyle.smith kyle.sm...@inforonics.com:

Have you tried escaping the : with a \?

Like:
mb_ereg_replace('^(.*)this is the test\: replace(.*)$', '', $contents
,'UTF-8');

Also, have you tried removing the : and adjusting the input string to
verify your belief that it's the :?

HTH,
Kyle

-Original Message-
From: Merlin Morgenstern [mailto:merli...@fastmail.fm]
Sent: Wednesday, April 22, 2009 4:09 AM
To: php-general@lists.php.net
Subject: [PHP] Regex not working with :

Hi there,

I am trying to remove a text which does contain a : inside. Somehow the
regex does not match, no matter what I do:

$contents = mb_ereg_replace('^(.*)this is the test: replace(.*)$', '',
$contents ,'UTF-8');

Looks like this is a result of the :.

Does anybody have an idea how to do this?

Thank you for any help.

Merlin

--
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




Can you try ..

# Your regular expression could not be converted to the flavor
required by this language:
# A POSIX Extended RE cannot match the start and the end of a line with ^ and $
# A POSIX Extended RE cannot match the start and the end of a line with ^ and $

# Because of this, the code snippet below will not work as you
intended, if at all.

$contents = mb_ereg_replace('^(.*)this is the test: replace(.*)$',
'\1\2', $contents, 'UTF-8');



The warnings above come from RegexBuddy. Considering the PHP examples,
I'm not sure how accurate they are.

Hi there,

thank you for the help. Actually it was due to case sensitivity. Use 
str_ireplace to fix it.


Regards, Merlin

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



[PHP] preg_match and multibyte

2009-04-09 Thread Merlin Morgenstern

Hello,

I am trying to extract a number out of a string that is in utf-8 and 
contains chines characters.


This unfortunatelly does not work:

preg_match('{(\d+)}', $details, $m);
$number = $m[1];

I also tried to utf8decode it, but still, no luck.

Does anybody know how to overcome this problem?

Regards, Merlin

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



Re: [PHP] preg_match and multibyte

2009-04-09 Thread Merlin Morgenstern



tedd wrote:

At 4:18 PM +0200 4/9/09, Merlin Morgenstern wrote:

Hello,

I am trying to extract a number out of a string that is in utf-8 and 
contains chines characters.


This unfortunatelly does not work:

preg_match('{(\d+)}', $details, $m);
$number = $m[1];

I also tried to utf8decode it, but still, no luck.

Does anybody know how to overcome this problem?

Regards, Merlin


That's simple, there's no chines characters in Unicode.

Cheers,  :-)

tedd



:-) sorry about my spelling. Chinese.
e.g.:
月租: 350元其

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



[PHP] extracting text - regex

2009-04-08 Thread Merlin Morgenstern

Hello,

I am trying read text out of a text that is inbetween two divs. Somehow 
this should be possible with regex, I just can't figure out how.


Example:

div id=test
bla blub
/div

I would like to extract the text bla blub out of this example.

Has anybody an idea on how to do that? Is there a special php function 
available for this?


Thank you for any hint,

Merlin

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



Re: [PHP] extracting text - regex

2009-04-08 Thread Merlin Morgenstern



George Larson wrote:

On Wed, Apr 8, 2009 at 9:13 AM, George Larson george.g.lar...@gmail.comwrote:


I'm what you might consider rather green, myself.
I certainly wouldn't use this code for production but if you're just
debugging or something then how about something like this:

?php
$handle = @fopen('page.htm', 'r');
if ($handle) {
while (!feof($handle)) {
$eos = trim(fgets($handle, 4096));
if (strpos($eos,div) !== FALSE) { $echo_output = TRUE; }
if (strpos($eos,\div) !== FALSE) { $echo_output = FALSE; }
if ($echo_output == TRUE) { echo $eos; }
}
fclose($handle);
}
?




On Wed, Apr 8, 2009 at 8:30 AM, Per Jessen p...@computer.org wrote:


Merlin Morgenstern wrote:


Hello,

I am trying read text out of a text that is inbetween two divs.
Somehow this should be possible with regex, I just can't figure out
how.

Example:

div id=test
bla blub
/div

I would like to extract the text bla blub out of this example.


This might do the trick (not tested):

preg_match( /div\s+[^]*([^]*)\/div, $yourtext, $match );
print $match[1];


/Per


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


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



Sorry about the top-post.  I forgot. :)




Thank you everbody. I figured it out without regex. It's not for 
production, just testing:

$pos_1 = strpos($contents, $word1);
$pos_2 = strpos($contents, $word2, $pos_1);
$text = strip_tags(substr($contents, $pos_1, $pos_2 - $pos_1));

That works as well.



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



[PHP] opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern

Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes 
chinese characters and looks ok, when opened in a browser.


Now I want to extract some text from the file. In order to do this I do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks 
or wired characters. To fix it I tried to add:


$contents = utf8_decode($contents);
header(Content-Type: text/html; charset=utf-8);

But still... no luck :-(

Has somebody an idea why??

Regards, Merlin

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



[PHP] Re: opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern



Merlin Morgenstern wrote:

Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes 
chinese characters and looks ok, when opened in a browser.


Now I want to extract some text from the file. In order to do this I do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks 
or wired characters. To fix it I tried to add:


$contents = utf8_decode($contents);
header(Content-Type: text/html; charset=utf-8);

But still... no luck :-(

Has somebody an idea why??

Regards, Merlin


Something really strange: If I open the file directly from the hard 
drive inside the browser, the chinese characters show OK. If I open the 
file through the webserver the characters do not show OK. File encoding 
is set to utf-8.


Isn't this strange?°?!?

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



Re: [PHP] opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern



Per Jessen wrote:

Merlin Morgenstern wrote:


Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes
chinese characters and looks ok, when opened in a browser.

Now I want to extract some text from the file. In order to do this I
do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks
or wired characters. To fix it I tried to add:

$contents = utf8_decode($contents);
header(Content-Type: text/html; charset=utf-8);

But still... no luck :-(

Has somebody an idea why??


Check that the page really is displayed with the right encoding - in FF,
Ctrl-I. 


/Per




yes it is. I checked it. UTF-8.

It looks like it has to do something with wget, the programm I used to 
retrieve the file. Or Linux itself. The language-pack for china is not 
on the suse box, and I can't even find the chinese language through yast 
languages. This might explain, why I can open it from a mounted samba 
share directly, but not through the apache webserver who reads it from 
the linux system.


Did somebody else have such a probl. before?

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



Re: [PHP] opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern



Andrew Ballard wrote:

On Wed, Apr 8, 2009 at 11:38 AM, Per Jessen p...@computer.org wrote:

Merlin Morgenstern wrote:


Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes
chinese characters and looks ok, when opened in a browser.

Now I want to extract some text from the file. In order to do this I
do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks
or wired characters. To fix it I tried to add:

$contents = utf8_decode($contents);
header(Content-Type: text/html; charset=utf-8);

But still... no luck :-(

Has somebody an idea why??

Check that the page really is displayed with the right encoding - in FF,
Ctrl-I.

/Per


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


A bit off topic, but Ctrl+I no longer brings up the Page Info in
Firefox like it used to -- at least on my Windows computers. (It opens
the bookmark list in the sidebar.) Does it do differently under Linux?

Andrew


I use windows right click for this.

Actually I isolated the problem, but still I can't figure out how to 
solve it. The page is not utf-8, but ugb2312.


I am already sending the header through php:
header(Content-Type: text/html; charset=ugb2312);

And with apache http.conf:
AddDefaultCharset ugb2312

However firefox still claims that it is utf-8 which is causing the 
strange characters.


What a night mare! Does anybody have an idea on how to get closer to 
solving this?


Regards, Merlin

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



Re: [PHP] opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern



Paul Gregg wrote:

In mail.php.general, Merlin Morgenstern merli...@fastmail.fm wrote:

Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes 
chinese characters and looks ok, when opened in a browser.


Now I want to extract some text from the file. In order to do this I do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as questinomarks 
or wired characters. To fix it I tried to add:


$contents = utf8_decode($contents);


You don't want this.


header(Content-Type: text/html; charset=utf-8);


You do want this.


But still... no luck :-(

Has somebody an idea why??


Try it with just the Content-Type: header addition.

header('Content-Type: text/html; charset=UTF-8');

Regards,
PG


Looks like this was a caching problem in firefox. The caracters show now 
in GB2312.


Next problem up... How to convert them into unicode :-)

I found the function to convert GB2312  into unicode from a member:
http://de.php.net/utf8_encode (gb2unicode in the lower bottom)

Unfortunatelly the required file is missing with the encoding. The post 
is also pretty old.


The question is how to get this chinese characters saved into a mysql db 
under utf-8 unicode?





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



Re: [PHP] opening utf-8 files - chinese mb characters

2009-04-08 Thread Merlin Morgenstern


Merlin Morgenstern wrote:



Paul Gregg wrote:

In mail.php.general, Merlin Morgenstern merli...@fastmail.fm wrote:

Hello everybody,

I am having some trouble with utf-8 encoding. The html file containes 
chinese characters and looks ok, when opened in a browser.


Now I want to extract some text from the file. In order to do this I do:

$handle = fopen($file, r);
$contents = fread($handle, filesize($file));

echo $contents;

The chinese characters are gone by then. They show up as 
questinomarks or wired characters. To fix it I tried to add:


$contents = utf8_decode($contents);


You don't want this.


header(Content-Type: text/html; charset=utf-8);


You do want this.


But still... no luck :-(

Has somebody an idea why??


Try it with just the Content-Type: header addition.

header('Content-Type: text/html; charset=UTF-8');

Regards,
PG


Looks like this was a caching problem in firefox. The caracters show now 
in GB2312.


Next problem up... How to convert them into unicode :-)

I found the function to convert GB2312  into unicode from a member:
http://de.php.net/utf8_encode (gb2unicode in the lower bottom)

Unfortunatelly the required file is missing with the encoding. The post 
is also pretty old.


The question is how to get this chinese characters saved into a mysql db 
under utf-8 unicode?





got it:
$text = iconv(gb2312, UTF-8, $text);

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



[PHP] php bug from 2003 still alive?!

2009-03-30 Thread Merlin Morgenstern

Hello,

I am experiencing problems with utf-8 and php. There seems to be a 
problem with BOM.


Some postings say that I have to compile php with 
--enable-zend-multibyte. HOwever those postings are very old (2003!).

http://bugs.php.net/bug.php?id=22108

Is this still necessary with the newest php build? If yes, do you 
believe I will run into trouble on sites that are saved in ansi?


Thank you for any hint.

Merlin

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



[PHP] Re: php bug from 2003 still alive?! - UTF8 BOM

2009-03-30 Thread Merlin Morgenstern

Hello everybody,

has anybody an idea on how to fix this? Is it really necessary to 
recomplile for utf-8 BOM support?


Regards, Merlin

Merlin Morgenstern wrote:

Hello,

I am experiencing problems with utf-8 and php. There seems to be a 
problem with BOM.


Some postings say that I have to compile php with 
--enable-zend-multibyte. HOwever those postings are very old (2003!).

http://bugs.php.net/bug.php?id=22108

Is this still necessary with the newest php build? If yes, do you 
believe I will run into trouble on sites that are saved in ansi?


Thank you for any hint.

Merlin


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



Re: [PHP] php bug from 2003 still alive?!

2009-03-30 Thread Merlin Morgenstern

Yes I was reading about this. However, try to do a search on this:
http://www.google.de/search?hl=deq=enable-zend-multibytebtnG=Google-Suchemeta=

Loads of postings that do not look that good. What are all the chinese 
sites do? It is strange that there is no official description on php.net 
regarding this support.


Thiago H. Pojda wrote:

On Mon, Mar 30, 2009 at 12:42 PM, Merlin Morgenstern
merli...@fastmail.fmwrote:


Some postings say that I have to compile php with --enable-zend-multibyte.
HOwever those postings are very old (2003!).
http://bugs.php.net/bug.php?id=22108



Did you see what Derick said abut this in the last comment?
*
[22 Aug 2005 6:35pm UTC] der...@php.net*
This will come with Unicode support in PHP 6.0



Is this still necessary with the newest php build?


Looks like it.



If yes, do you believe I will run into trouble on sites that are saved in
ansi?



I'm not sure, you should probably wait for someone else to reply :)

Regards,
Thiago Henrique Pojda
http://nerdnaweb.blogspot DOT com



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



[PHP] UTF 8 support - enable-zend-multibyte ( was Re: [PHP] php bug from 2003 still alive?! - )

2009-03-30 Thread Merlin Morgenstern

HI there,

I now compiled php with zend multibyte. The trouble with the extra 
characters is now gone, but all special characters are now replaced with 
a questionmark! The document type shows utf-8, but somehow php seems not 
to pars the content OK.


Does nobody have the same problem?

Regards, Merlin

Merlin Morgenstern wrote:

Yes I was reading about this. However, try to do a search on this:
http://www.google.de/search?hl=deq=enable-zend-multibytebtnG=Google-Suchemeta= 



Loads of postings that do not look that good. What are all the chinese 
sites do? It is strange that there is no official description on php.net 
regarding this support.


Thiago H. Pojda wrote:

On Mon, Mar 30, 2009 at 12:42 PM, Merlin Morgenstern
merli...@fastmail.fmwrote:

Some postings say that I have to compile php with 
--enable-zend-multibyte.

HOwever those postings are very old (2003!).
http://bugs.php.net/bug.php?id=22108



Did you see what Derick said abut this in the last comment?
*
[22 Aug 2005 6:35pm UTC] der...@php.net*
This will come with Unicode support in PHP 6.0



Is this still necessary with the newest php build?


Looks like it.


If yes, do you believe I will run into trouble on sites that are 
saved in

ansi?



I'm not sure, you should probably wait for someone else to reply :)

Regards,
Thiago Henrique Pojda
http://nerdnaweb.blogspot DOT com



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



Re: [PHP] UTF 8 support - enable-zend-multibyte ( was Re: [PHP] php bug from 2003 still alive?! - )

2009-03-30 Thread Merlin Morgenstern

haliphax wrote:

On Mon, Mar 30, 2009 at 12:34 PM, Merlin Morgenstern
merli...@fastmail.fm wrote:

HI there,

I now compiled php with zend multibyte. The trouble with the extra
characters is now gone, but all special characters are now replaced with a
questionmark! The document type shows utf-8, but somehow php seems not to
pars the content OK.

Does nobody have the same problem?

Regards, Merlin


Please stop top-posting.

Anyway, are you using a META tag codepage to tell the web browser what
to do with those special characters? I'm not certain a DOCTYPE is
going to handle everything.




HI,

I am using a meta tag:
meta http-equiv=content-type content=text/html; charset=UTF-8

I have also configured apache:
AddDefaultCharset utf-8

Also php:
header('content-type: text/html; charset=utf-8');

Header:
HTTP/1.x 200 OK
Date: Mon, 30 Mar 2009 19:14:22 GMT
Server: Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8h PHP/5.2.9
X-Powered-By: PHP/5.2.9
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8

The chinese characters which come directly out of the database are shown 
corretly. The chinese chars that are saved in a text file show up as a 
question mark.





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



[PHP] Working in UTF-8 - BOM trouble

2009-03-30 Thread Merlin Morgenstern

Hi there,

I am having trouble to switch with an i18n project to utf-8. The problem 
is, that php has trouble with files that are saved in UTF-8 with BOM. It 
is causing strange bahavior like adding extra headers. On the other hand 
most editors only save UTF-8 with BOM.


Has somebody experienced the same problem? How did you overcome it?

Regards, Merlin

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



Re: [PHP] Re: compiling php with libjpg64

2009-03-04 Thread Merlin Morgenstern

Hello JOchem,

thank you for your help. That worked out.

Regards, Merlin

Jochem Maas wrote:

google is your friend (and with friends like that who needs enemies):

try what's mentioned here:
http://www.linuxquestions.org/questions/linux-software-2/compiling-php-on-rhel-5-64-bit-685606/

otherwise:
http://www.google.com/search?q=compile+php+64+bit+libs

Merlin Morgenstern schreef:
  

Hi everybody,

I have to compile from source for several reasons. Any idea on how to
fix this particular problem with the lib64?

Regards, merlin

Shawn McKenzie schrieb:


Ashley Sheridan wrote:
  

On Fri, 2009-02-27 at 12:43 -0600, Shawn McKenzie wrote:


Merlin Morgenstern wrote:
  

Hi there,

I am trying to get a 64 bit suse 10.3 system to run with php 5.
Somehow
it does not recognize the libjpg which is definatelly in place:

server:/home/sw/php-5.2.9 # './configure' '--enable-fastcgi'
'--with-mysql=/usr/local/mysql' '--prefix=/usr/local/php'
'--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-mbstring'
'--with-pdo-mysql=/usr/local/mysql/' '--enable-soap'
'--with-zlib-dir=/usr/lib64' '--with-freetype-dir=/usr/lib64'
'--with-gd' '--with-jpeg-dir=/usr/lib64' '--with-png-dir=/usr/lib64'
'--enable-exif' '--with-pdflib=/usr/local'  configure.txt

configure: warning: bison versions supported for regeneration of the
Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1
(found:
none).
configure: warning: flex versions supported for regeneration of the
Zend/PHP parsers: 2.5.4  (found: 2.5.33)
configure: warning: You will need re2c 0.13.4 or later if you want to
regenerate PHP parsers.
configure: error: libjpeg.(a|so) not found.

but:
# locate libjpeg.so
/usr/lib64/libjpeg.so
/usr/lib64/libjpeg.so.62
/usr/lib64/libjpeg.so.62.0.0

# locate libjpeg.a
/usr/lib64/libjpeg.a

I am kind of lost with this one. I can not find the error. Has
somebody
an idea how to fix this?

Thank you for any help, Merlin


Might try adding:  --with-libdir=lib64

--
Thanks!
-Shawn
http://www.spidean.com

  

I've got Suse10.3 on my laptop, all 64-bit, and running the correct
graphics libraries which I use for GD. I used Yast to install the whole
thing, as it sorts out everything for me. For Suse, I'd recommend it, as
it really is a great admin tool, albeit a little slow when building
repository lists when you install things!


Ash
www.ashleysheridan.co.uk



Yes, I always use a package from whatever distro (ubuntu for my desktop
for several years and fedora on my web host).  I've never needed to
compile apache/php/mysql or most anything else.  Sometimes there's
something that I want that you can only get from source, but normally
that builds easily for me.

  


  


Re: [PHP] Re: compiling php with libjpg64

2009-02-28 Thread Merlin Morgenstern

Hi everybody,

I have to compile from source for several reasons. Any idea on how to 
fix this particular problem with the lib64?


Regards, merlin

Shawn McKenzie schrieb:

Ashley Sheridan wrote:

On Fri, 2009-02-27 at 12:43 -0600, Shawn McKenzie wrote:

Merlin Morgenstern wrote:

Hi there,

I am trying to get a 64 bit suse 10.3 system to run with php 5. Somehow
it does not recognize the libjpg which is definatelly in place:

server:/home/sw/php-5.2.9 # './configure' '--enable-fastcgi'
'--with-mysql=/usr/local/mysql' '--prefix=/usr/local/php'
'--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-mbstring'
'--with-pdo-mysql=/usr/local/mysql/' '--enable-soap'
'--with-zlib-dir=/usr/lib64' '--with-freetype-dir=/usr/lib64'
'--with-gd' '--with-jpeg-dir=/usr/lib64' '--with-png-dir=/usr/lib64'
'--enable-exif' '--with-pdflib=/usr/local'  configure.txt

configure: warning: bison versions supported for regeneration of the
Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found:
none).
configure: warning: flex versions supported for regeneration of the
Zend/PHP parsers: 2.5.4  (found: 2.5.33)
configure: warning: You will need re2c 0.13.4 or later if you want to
regenerate PHP parsers.
configure: error: libjpeg.(a|so) not found.

but:
# locate libjpeg.so
/usr/lib64/libjpeg.so
/usr/lib64/libjpeg.so.62
/usr/lib64/libjpeg.so.62.0.0

# locate libjpeg.a
/usr/lib64/libjpeg.a

I am kind of lost with this one. I can not find the error. Has somebody
an idea how to fix this?

Thank you for any help, Merlin

Might try adding:  --with-libdir=lib64

--
Thanks!
-Shawn
http://www.spidean.com


I've got Suse10.3 on my laptop, all 64-bit, and running the correct
graphics libraries which I use for GD. I used Yast to install the whole
thing, as it sorts out everything for me. For Suse, I'd recommend it, as
it really is a great admin tool, albeit a little slow when building
repository lists when you install things!


Ash
www.ashleysheridan.co.uk



Yes, I always use a package from whatever distro (ubuntu for my desktop
for several years and fedora on my web host).  I've never needed to
compile apache/php/mysql or most anything else.  Sometimes there's
something that I want that you can only get from source, but normally
that builds easily for me.



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



[PHP] compiling php with libjpg64

2009-02-27 Thread Merlin Morgenstern

Hi there,

I am trying to get a 64 bit suse 10.3 system to run with php 5. Somehow 
it does not recognize the libjpg which is definatelly in place:


server:/home/sw/php-5.2.9 # './configure' '--enable-fastcgi' 
'--with-mysql=/usr/local/mysql' '--prefix=/usr/local/php' 
'--with-apxs2=/usr/local/apache2/bin/apxs' '--enable-mbstring' 
'--with-pdo-mysql=/usr/local/mysql/' '--enable-soap' 
'--with-zlib-dir=/usr/lib64' '--with-freetype-dir=/usr/lib64' 
'--with-gd' '--with-jpeg-dir=/usr/lib64' '--with-png-dir=/usr/lib64' 
'--enable-exif' '--with-pdflib=/usr/local'  configure.txt


configure: warning: bison versions supported for regeneration of the 
Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: 
none).
configure: warning: flex versions supported for regeneration of the 
Zend/PHP parsers: 2.5.4  (found: 2.5.33)
configure: warning: You will need re2c 0.13.4 or later if you want to 
regenerate PHP parsers.

configure: error: libjpeg.(a|so) not found.

but:
# locate libjpeg.so
/usr/lib64/libjpeg.so
/usr/lib64/libjpeg.so.62
/usr/lib64/libjpeg.so.62.0.0

# locate libjpeg.a
/usr/lib64/libjpeg.a

I am kind of lost with this one. I can not find the error. Has somebody 
an idea how to fix this?


Thank you for any help, Merlin

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



[PHP] Converting Euro sign

2009-02-26 Thread Merlin Morgenstern

Hello everybody,

I have an xml-file where a euro sign is in. Now the sign shows up as 
questionmark after importing into a mysql db.


On the utf_8_decode site I found that iconv will help here, but first of 
 all I do not even know if the xml file is utf8encoded (I doubt it), 
and secondly I do not want to install another module just for this.


Any ideas on how to build a workaround?

Thank you for any hint,

Merlin

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



[PHP] XML and :

2009-02-24 Thread Merlin Morgenstern

Hi there,

I am trying to pars an XML file with php. This works if the xml tag 
looks like this: anbieternr88/anbieternr

In that case I retrieve the info: $xml-anbieternr

But now the tag looks different like this: 
imo:anbieternr88/imo:anbieternr


The command $xml-imo:anbieternr does not work in that case.

Has somebody an idea how to adress this?

Thank you for any help!

Merlin

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



[PHP] German characters Ö,Ä etc. show up as ?

2009-02-05 Thread Merlin Morgenstern

Hi there,

I recently upgraded on my prod system from php 4.x to the newest php 
version. Now german characters lik Ö show up as ?. I have the same 
setup running on a test server, where the characters show up OK. After 
searching on Google I found that there is an entry in the php.ini:
default_charset = iso-8859-1 which could help me, however this is not 
set in the test environment! How come? Is there another way to fix this?


Kind regards,Merlin

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



[PHP] unlink file rights problem

2009-01-28 Thread Merlin Morgenstern

Hi there,

I am trying to unlink a file which is inside a folder that is not 
writable to phps user www. Of course this failes, but I need to find a 
solution for it.


Backgroud is following:
I have pure-ftpd installed where user directories get created by 
pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does 
only create the homedirectory folder in 750 mod.
My PHP-Script scans this directories every x minutes and processes those 
files. Upon completinon those files should get deleted, but as the dir 
is not writable by the user www this failes.


The dir looks like this:
drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/

files inside look like this:
-rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*

User www which executes php via cron is inside the group ftpgroup.

Any ideas? I am kind of lost with this one. Thank you for any help!

Best regards, Merlin

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



[PHP] importing from XML-files

2009-01-22 Thread Merlin Morgenstern

Hi everybody,

I am creating an import script which is getting data out of an xml file.
Now I do have a problem with a file where 2 images are included. I need 
to access the second image name, but can not find out how.


I do:
$xml = simplexml_load_file($files[$i]);
$data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt;

This get's me the first image in line. But how could I get the second one?

Thank you for any help,

Merlin

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



[PHP] Re: importing from XML-files

2009-01-22 Thread Merlin Morgenstern



Carlos Medina wrote:

Merlin Morgenstern schrieb:

Hi everybody,

I am creating an import script which is getting data out of an xml file.
Now I do have a problem with a file where 2 images are included. I 
need to access the second image name, but can not find out how.


I do:
$xml = simplexml_load_file($files[$i]);
$data[pic1_base64] = $xml-anbieter-anhang-anhanginhalt;

This get's me the first image in line. But how could I get the second 
one?


Thank you for any help,

Merlin

Hi Merlin,
well please tell us how shows the XML DOC?. I can see that the XML read 
a node like anbieter. Is the Anhang an Object or Array? Is this Empty?



viele Gruesse

Carlos Medina


Hello Carlos,

the xml structure looks like this:

-
anhaenge

anhang location=EXTERN gruppe=TITELBILD
anhangtitelAnsicht_Strassenseite/anhangtitel
formatjpg/format
daten
pfad_1006-kurz_ansicht_strassenseite.jpg/pfad
/daten
/anhang

anhang location=EXTERN gruppe=GRUNDRISS
anhangtitelGrundriss_Modern-kuehl/anhangtitel
formatjpg/format
daten
pfad_1006-lang2_grundriss_modern-kuehl.jpg/pfad
/daten
/anhang

/anhaenge
--

Thank you for your help,

Merlin

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



[PHP] libphp5.so error

2009-01-17 Thread Merlin Morgenstern

Hi there,

I have installed php5.2.8 successfully on my suse test system. Now I 
want to reproduce it on my prod system, but there is an error I can't 
find a solution for.


I compiled php and the I did run configtest on apache 1.x

/etc/init.d/apachectl configtest
Syntax error on line 223 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp5.so into server: 
/usr/local/apache/libexec/libphp5.so: symbol mysql_set_character_set, 
version libmysqlclient_14 not defined in file libmysqlclient.so.14 with 
link time reference


Any ideas? I do not want to upgrade to apache 2.x. I am kind of lost 
right now. Thank you for any help!


Best regards, Merlin

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



[PHP] Re: libphp5.so error

2009-01-17 Thread Merlin Morgenstern

Hi there,

I could solve this error. It was due to not compiling php with mdo which 
is needed for mysql 3.x


Now I am running into a new strange error :-( Will post into a new topic.

Best regards,

Merlin

Merlin Morgenstern schrieb:

Hi there,

I have installed php5.2.8 successfully on my suse test system. Now I 
want to reproduce it on my prod system, but there is an error I can't 
find a solution for.


I compiled php and the I did run configtest on apache 1.x

/etc/init.d/apachectl configtest
Syntax error on line 223 of /usr/local/apache/conf/httpd.conf:
Cannot load /usr/local/apache/libexec/libphp5.so into server: 
/usr/local/apache/libexec/libphp5.so: symbol mysql_set_character_set, 
version libmysqlclient_14 not defined in file libmysqlclient.so.14 with 
link time reference


Any ideas? I do not want to upgrade to apache 2.x. I am kind of lost 
right now. Thank you for any help!


Best regards, Merlin


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



[PHP] php5 with apache 1.x - white page

2009-01-17 Thread Merlin Morgenstern

Hi there,

after strugling a while with the installation of php5 on an older suse 
system with mysql 3.x and apache 1.x I got it compiled and installed.


Apache starts and there are processes running, even the access log shows 
  access to it. Response is 500 (internal error). The page itself does 
not load and it shows only a white page. I can not find any entry inside 
a log that show unnormal hints.


Any idea where I could look for the error? I tried php error log file 
and var/log/messages.


Thank you for any help.

Merlin

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



[PHP] Re: php5 with apache 1.x - white page

2009-01-17 Thread Merlin Morgenstern



got it :-) Both are needed!
--with-mysql=/usr/local/mysql' '--with-pdo-mysql=/usr/local/mysql/'

Merlin Morgenstern schrieb:

Hi there,

after strugling a while with the installation of php5 on an older suse 
system with mysql 3.x and apache 1.x I got it compiled and installed.


Apache starts and there are processes running, even the access log shows 
  access to it. Response is 500 (internal error). The page itself does 
not load and it shows only a white page. I can not find any entry inside 
a log that show unnormal hints.


Any idea where I could look for the error? I tried php error log file 
and var/log/messages.


Thank you for any help.

Merlin


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



Re: [PHP] Re: php5 with apache 1.x - white page

2009-01-17 Thread Merlin Morgenstern



Ashley Sheridan schrieb:

On Sat, 2009-01-17 at 15:31 +, Nathan Rixham wrote:

Merlin Morgenstern wrote:


got it :-) Both are needed!
--with-mysql=/usr/local/mysql' '--with-pdo-mysql=/usr/local/mysql/'

Merlin Morgenstern schrieb:

Hi there,

after strugling a while with the installation of php5 on an older suse 
system with mysql 3.x and apache 1.x I got it compiled and installed.


Apache starts and there are processes running, even the access log 
shows   access to it. Response is 500 (internal error). The page 
itself does not load and it shows only a white page. I can not find 
any entry inside a log that show unnormal hints.


Any idea where I could look for the error? I tried php error log file 
and var/log/messages.


Thank you for any help.

Merlin
nice to see somebody answering there own questions - you should just 
email them to yourself :p



But you'd have to have some sort of if($question == 'really complex')
just to make sure you don't get stuck in an infinite loop of recursive
answering ;)


Ash
www.ashleysheridan.co.uk

yeah...sorry guys :-) I just wanted to answer since I thought it might 
be helpful for somebody else.


Merlin

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



[PHP] PMA_List_Database

2009-01-17 Thread Merlin Morgenstern

Hi guys..

here comes the last question for today :-)

Everything works fine. My Apps run beautiful with php5. The only thing 
now left which does not work ist phpmyadmin. I googled the error msg, 
but could only find servers which had the same problem. No solution to 
find. Config looks fine. Maybe somebody has an idea. This is the msg:


Fatal error: Class 'PMA_List_Database' not found in 
/home/www/tools/mysqladmin/libraries/common.inc.php on line 862


I have not changed the installation of phpmyadmin. Just went from 5.2.6 
to 5.2.8 with a re-compile.


Merlin

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



Re: [PHP] upgrade php 5.2.6 - 5.2.8 mysql problems!

2009-01-13 Thread Merlin Morgenstern

Hi there,

has somebody an idea how to fix this? I do appreciate any help.

Thank you in advance, Merlin

Merlin Morgenstern wrote:
No. The with-pdo-mysql command secures compatibility with oder databases 
. That workes fine. The yes in the error msg. seams to be normal in this 
case. I found loads of such via google. e.g:

http://www.rootforum.de/forum/viewtopic.php?f=158t=35941start=0

All point to the fact that there needs to be mysql-dev installed. But 
why? I am already running 5.2.6. And mysql-dev does not come with suse 
11. I doubt that this is the cause.


Any other ideas?

Thanx, merlin

Chris schrieb:



Here is the configure command that is pretty much the same as in 5.2.6:


So look at the differences ;)

'./configure' '--enable-fastcgi' '--with-mysql' 
'--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' 
'--enable-mbstring' '--with-pdo-mysql=/usr/local/mysql/' 
'--with-mysql-sock=/tmp' '--enable-soap' '--with-zlib' 
'--with-freetype-dir=/usr/local/lib' '--with-gd' 
'--with-jpeg-dir=/usr' '--with-png-dir=/usr/lib' '--enable-exif' 
'--enable-cli'


snip


configure: error: Cannot find MySQL header files under yes.


This gives you the clue - it's not --with-mysql=yes or something (no 
idea where yes is actually coming from).


Try --with-mysql=/usr/local/mysql



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



[PHP] installing php 5 with pdflib

2009-01-13 Thread Merlin Morgenstern

Hi there,

I am still facing trouble with pdflib and php 5. After hours of research 
I found that I do have to install the pecl package. So I decided to 
compile it into php staticly like described here:

http://www.php-resource.de/handbuch/install.pecl.static.htm

The configure command stops with the error:
configure: error: pdflib.h not found! Check the path passed to 
--with-pdflib=PATH. PATH should be the install prefix directory.


actually the file is and always was there. Does it have to be a new 
version? I am using pdflib 4.x which workes fine in the running php 4.x 
installation.


Thank you for any help,

Merlin

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



[PHP] update von php 4.4.6 zu 5.2.8

2009-01-12 Thread Merlin Morgenstern

Hello everybody,

I want to upgrade my system and do face some trouble with pdflib. 
compile says:


Notice: Following unknown configure options were used:
--enable-gd-imgstrttf
--with-pdflib

I guess the gd functionality is enabled now anyway? How about the 
pdflib? Is there another command for this? I know there is a free pdf 
functionality integrated now in php 5, but I would like to stick to the 
old scripts and use my old pdflib. Is this possible?


Thank you for any help,

Merlin

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



[PHP] upgrade php 5.2.6 - 5.2.8 mysql problems!

2009-01-12 Thread Merlin Morgenstern

Hello everybody,

I am trying to update php 5.2.6 to 5.2.8 on a test system. Somehow it 
can not find the working mysql installation. With 5.2.6 I everything is 
fine.


Here is the configure command that is pretty much the same as in 5.2.6:

'./configure' '--enable-fastcgi' '--with-mysql' 
'--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' 
'--enable-mbstring' '--with-pdo-mysql=/usr/local/mysql/' 
'--with-mysql-sock=/tmp' '--enable-soap' '--with-zlib' 
'--with-freetype-dir=/usr/local/lib' '--with-gd' '--with-jpeg-dir=/usr' 
'--with-png-dir=/usr/lib' '--enable-exif' '--enable-cli'



PHP returns:

checking for MySQL UNIX socket location... /tmp
configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

According to a google search mysql-dev is not installed. So I tried to 
get it with yast on the suse 11.0 server. No luck. So I got it via a 
rpm. That returns:


 rpm -i mysql-devel.rpm
error: Failed dependencies:
mysql-client is needed by mysql-devel-5.0.26-21.x86_64
mysql-shared = 5.0.26 is needed by mysql-devel-5.0.26-21.x86_64
libc.so.6()(64bit) is needed by mysql-devel-5.0.26-21.x86_64
libc.so.6(GLIBC_2.2.5)(64bit) is needed by 
mysql-devel-5.0.26-21.x86_64
libc.so.6(GLIBC_2.3.4)(64bit) is needed by 
mysql-devel-5.0.26-21.x86_64

libcrypt.so.1()(64bit) is needed by mysql-devel-5.0.26-21.x86_64
libm.so.6()(64bit) is needed by mysql-devel-5.0.26-21.x86_64
libnsl.so.1()(64bit) is needed by mysql-devel-5.0.26-21.x86_64
libpthread.so.0()(64bit) is needed by mysql-devel-5.0.26-21.x86_64
libpthread.so.0(GLIBC_2.2.5)(64bit) is needed by 
mysql-devel-5.0.26-21.x86_64
libpthread.so.0(GLIBC_2.3.2)(64bit) is needed by 
mysql-devel-5.0.26-21.x86_64


Something must be wrong. I can't believe that there is so much change 
necessary for such a minur upgrade.


Any ideas? Thank you for any help,

Merlin

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



Re: [PHP] upgrade php 5.2.6 - 5.2.8 mysql problems!

2009-01-12 Thread Merlin Morgenstern
No. The with-pdo-mysql command secures compatibility with oder databases 
. That workes fine. The yes in the error msg. seams to be normal in this 
case. I found loads of such via google. e.g:

http://www.rootforum.de/forum/viewtopic.php?f=158t=35941start=0

All point to the fact that there needs to be mysql-dev installed. But 
why? I am already running 5.2.6. And mysql-dev does not come with suse 
11. I doubt that this is the cause.


Any other ideas?

Thanx, merlin

Chris schrieb:



Here is the configure command that is pretty much the same as in 5.2.6:


So look at the differences ;)

'./configure' '--enable-fastcgi' '--with-mysql' 
'--prefix=/usr/local/php' '--with-apxs2=/usr/local/apache2/bin/apxs' 
'--enable-mbstring' '--with-pdo-mysql=/usr/local/mysql/' 
'--with-mysql-sock=/tmp' '--enable-soap' '--with-zlib' 
'--with-freetype-dir=/usr/local/lib' '--with-gd' 
'--with-jpeg-dir=/usr' '--with-png-dir=/usr/lib' '--enable-exif' 
'--enable-cli'


snip


configure: error: Cannot find MySQL header files under yes.


This gives you the clue - it's not --with-mysql=yes or something (no 
idea where yes is actually coming from).


Try --with-mysql=/usr/local/mysql



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



[PHP] is_readable() returns 1 if file is still uploading

2009-01-10 Thread Merlin Morgenstern

Hi there,

I am importing data out of xml files on a linux server. Now I am running 
into problems if the file is currently beeing uploaded and the upload 
has not finished to the server.
Is there a function which returns true if the file is complete and not 
in upload status? I tried is_readable(), but this only returns false if 
the file is missing.


This is the error msg from php:
parser error : Premature end of data

thank you for any help.

regards, merlin

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



Re: [PHP] Adressing XML Objects

2009-01-08 Thread Merlin Morgenstern

Hello nathan,

I am unsing simplexml as it looks really simple :-) However, I could 
still not figure out how to adress data inside tags with attributes. For 
example:


anhang location=INTERN gruppe=TITELBILD
databla blub/data

$xml-anhang[intern][titelbild]-data will not work.

Thank you for any hint.

Best regards,

Merlin



Merlin Morgenstern schrieb:

Hello Nathan,

I upgraded to PHP 5, so I am using nativ support.

Best regards, Merlin

Nathan Nobbe schrieb:
On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern 
merli...@fastmail.fm mailto:merli...@fastmail.fm wrote:


Hi there,

I am justing walking my first steps on XML and PHP. As I learned
from a tutorial adressing is very simple:

echo $xml-anbieter-immobilie-preise-kaufpreis;


this is meaningless unless we know which xml library you are using.  i 
believe you said youre running php4 earlier, right?


so which xml library have you settled on?
 
btw; php4 has DOMXML as a native extension, but the api is a bit 
cumbersome.


-nathan





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



Re: [PHP] Adressing XML Objects

2009-01-08 Thread Merlin Morgenstern
ok... it seems that I am doing something fundamentally wrong. I get no 
output at all with this:


$xmlStr = file_get_contents($filename);
$xmlelement = new SimpleXMLElement($xmlStr);
echo 
'$xmlelement-xpath(//anbieter/immobilie/anhaenge/anha...@location='INTERN' 
and @gruppe='TITELBILD']/daten/anhanginhalt);


The names and structure seems fine. The syntax according to your posting 
and php.net also.


Any ideas?

Thanx Merlin

Nathan Nobbe schrieb:



On Thu, Jan 8, 2009 at 4:38 PM, Nathan Rixham nrix...@gmail.com 
mailto:nrix...@gmail.com wrote:


Nathan Nobbe wrote:

On Thu, Jan 8, 2009 at 4:02 PM, Merlin Morgenstern
merli...@fastmail.fm mailto:merli...@fastmail.fmwrote:

Hello nathan,

I am unsing simplexml as it looks really simple :-)
However, I could still
not figure out how to adress data inside tags with
attributes. For example:

anhang location=INTERN gruppe=TITELBILD
  databla blub/data

$xml-anhang[intern][titelbild]-data will not work.



again, ill need some clarification.  are you trying to get the
data node
directly, OR, are you trying to get the contents of all nodes
which are
descendants of anhang nodes, w/ attributes location and
gruppe, having
values INTERN and TITLEBILD respectively?

these are two different the things, the former being, well simple

$xml-anhang-data

the latter i would do via xpath, which SimpleXML supports as well.

-nathan


I think you hit the nail on the head with XPath nathan;

//anha...@location='INTERN' and @gruppe='TITELBILD']/data

which would be requiring DOMDocument and DOMXPath


ive been really lazy about testing stuff first today :), but why not 
just rock it out w/ SimpleXML,


$xml = new SimpleXMLElement($xmlstr);
$searchResult = $xml-xpath('//anha...@location='INTERN' and 
@gruppe='TITELBILD']/data');


at least im just saying you dont NEED DOMDocument  DOMXPath, but def, 
that is an alternative to SimpleXML.
 
-nathan




[PHP] XML package on PHP

2009-01-07 Thread Merlin Morgenstern

Hi there,

I need pars an xml file with php 4. There seems to be a good package out 
there active link xml. However, last development was 2004. Is there 
something new around which you would recommend over active link?


Thank you for any hints.

Best regards,

Merlin

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



Re: [PHP] XML package on PHP

2009-01-07 Thread Merlin Morgenstern

^THANX: Will upgrade to php5.

c...@l-i-e.com wrote:

XML in PHP4? Don't. :-)

It was very painful and with all kinds of quirks, from my limited experience.

PHP5 was a breeze.

Consider hosting a quick/easy service on a PHP5 box to convert XML to PHP 
serialized data or something as well.  Could be less painful.

Or just upgrade, since PHP4 has passed EOL.



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



[PHP] Adressing XML Objects

2009-01-07 Thread Merlin Morgenstern

Hi there,

I am justing walking my first steps on XML and PHP. As I learned from a 
tutorial adressing is very simple:


echo $xml-anbieter-immobilie-preise-kaufpreis;

I simply just can't figure out how to adress this structure:
anhang location=INTERN gruppe=TITELBILD

This does not work:
echo $xml-anbieter-immobilie-anhaenge-daten-anhanginhalt;

Somehow location and gruppe needs to be placed into the command. I 
already tried a couple of version, but no success.


Thank you for any hint.

Best regards, Merlin

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



Re: [PHP] Adressing XML Objects

2009-01-07 Thread Merlin Morgenstern

Hello Nathan,

I upgraded to PHP 5, so I am using nativ support.

Best regards, Merlin

Nathan Nobbe schrieb:
On Wed, Jan 7, 2009 at 1:10 PM, Merlin Morgenstern 
merli...@fastmail.fm mailto:merli...@fastmail.fm wrote:


Hi there,

I am justing walking my first steps on XML and PHP. As I learned
from a tutorial adressing is very simple:

echo $xml-anbieter-immobilie-preise-kaufpreis;


this is meaningless unless we know which xml library you are using.  i 
believe you said youre running php4 earlier, right?


so which xml library have you settled on?
 
btw; php4 has DOMXML as a native extension, but the api is a bit 
cumbersome.


-nathan



[PHP] setting up FTP account names via PHP

2009-01-05 Thread Merlin Morgenstern

Hello everybody,

I am running a real estate site where I would like to enable bulk upload 
via real estate software that exports an xml file into an ftp account.


In order to give every user unique access I would need to generate 
individual ftp name and passwords for each member. I can not see how 
this should work. My portal is written in PHP 4.x and there every 
members loges in with a unique ID. The FTP Server runns on the same 
linux machine. How could I generate users for this FTP server with php, 
for example on sign up?


Thank you for any help on this.

Best regards,

Merlin

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



Re: [PHP] setting up FTP account names via PHP

2009-01-05 Thread Merlin Morgenstern
Is there a good FTP Daemon that can be recommended for this purpose? 
pure-ftpd seams out of development since 2006.




Jason Pruim wrote:


On Jan 5, 2009, at 9:55 AM, Merlin Morgenstern wrote:

Yes, it would be great if he could use the already existing username 
and password. It should not be a one time password.


I am just now looking into mysql support for pure ftpd. One solution I 
have in mind is to write the password into the pureftp DB upon signup.
That would be the easiest. The other solution to write to a conf file 
would be OK, too. What do you think?


I would look real seriously at making sure both the FTP software, and 
your website use the same authentication database. Even if it means 
having to go with a different FTP server, or write your own. That way, 
if they change their password on the web site, it will update it for the 
FTP automatically as well.


Other then that, No real info to include to help... Sorry for that.

--
Jason Pruim
japr...@raoset.com
616.399.2355






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



Re: [PHP] setting up FTP account names via PHP

2009-01-05 Thread Merlin Morgenstern
Yes, it would be great if he could use the already existing username and 
password. It should not be a one time password.


I am just now looking into mysql support for pure ftpd. One solution I 
have in mind is to write the password into the pureftp DB upon signup.
That would be the easiest. The other solution to write to a conf file 
would be OK, too. What do you think?


bruce wrote:

are you trying to allow a user who logs in, to use his same username when
interfacing with the FTP server?

obviously, the password for the FTP server will be different. Or are you
looking to dynamically create a one time user/passwd for the user so that it
changes each time they access the FTP server?


-Original Message-
From: Merlin Morgenstern [mailto:merli...@fastmail.fm]
Sent: Monday, January 05, 2009 6:44 AM
To: php-general@lists.php.net
Subject: Re: [PHP] setting up FTP account names via PHP


Marc Steinert wrote:

Merlin Morgenstern schrieb:

Hello everybody,

I am running a real estate site where I would like to enable bulk
upload via real estate software that exports an xml file into an ftp
account.

In order to give every user unique access I would need to generate
individual ftp name and passwords for each member. I can not see how
this should work. My portal is written in PHP 4.x and there every
members loges in with a unique ID. The FTP Server runns on the same
linux machine. How could I generate users for this FTP server with
php, for example on sign up?

Thank you for any help on this.

Best regards,

Merlin


What ftp server are you using?



I just installed pureftpd. One possible sollution as I figured is to
alter the virtual user table of the ftp server with php.

Is this the way to go, or does somebody have a better idea that saves
dev. time?


--
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] setting up FTP account names via PHP

2009-01-05 Thread Merlin Morgenstern

Marc Steinert wrote:

Merlin Morgenstern schrieb:

Hello everybody,

I am running a real estate site where I would like to enable bulk 
upload via real estate software that exports an xml file into an ftp 
account.


In order to give every user unique access I would need to generate 
individual ftp name and passwords for each member. I can not see how 
this should work. My portal is written in PHP 4.x and there every 
members loges in with a unique ID. The FTP Server runns on the same 
linux machine. How could I generate users for this FTP server with 
php, for example on sign up?


Thank you for any help on this.

Best regards,

Merlin


What ftp server are you using?



I just installed pureftpd. One possible sollution as I figured is to 
alter the virtual user table of the ftp server with php.


Is this the way to go, or does somebody have a better idea that saves 
dev. time?



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



Re: [PHP] setting up FTP account names via PHP

2009-01-05 Thread Merlin Morgenstern

Hello everybody,

thank you all for your help. I got a solution running. In pure-ftpd you 
can authenticate via mysql. Via a user table, exactly the thing I was 
searching for.


However, there is a problem araising. Every user get's his own directory 
for uploads. My next step would have been to create a php script which 
will be run by cron every 5 minutes that scans one dir and if there is 
content inside import it into the mysql db.
With the current setup I would need to scan all dirs to see if there are 
changes inside.


Is there some kind of command where I could find out if there are new 
files inside those folders? I don't see any other solution.


Any suggestions?

Thank you for any help,

merlin

bruce schrieb:

merlin..

if you're going to allow a user to use the same user/passwd for the site,
and the FTP server.. i would strongly argue that you should allow the user
only the minimal access on the FTP server. if someone hacks your site, no
need to have them running rampant over your FTP server.

i would actually argue that you can have the same username, but separate
passwds, but i don'w know exactly what you're going to have on the FTP
server, nor do I know your skill at securing servers/services...

it doesn't really make a difference if you have separate dbs for the
user/passwd auth systems. if you secure the overall system, it's secure. if
you don't, well you're going to run into issues..

you might also look into existing web based mgmt apps for FTP servers to see
if any already exist.



-Original Message-
From: Merlin Morgenstern [mailto:merli...@fastmail.fm]
Sent: Monday, January 05, 2009 6:56 AM
To: php-general@lists.php.net
Subject: Re: [PHP] setting up FTP account names via PHP


Yes, it would be great if he could use the already existing username and
password. It should not be a one time password.

I am just now looking into mysql support for pure ftpd. One solution I
have in mind is to write the password into the pureftp DB upon signup.
That would be the easiest. The other solution to write to a conf file
would be OK, too. What do you think?

bruce wrote:

are you trying to allow a user who logs in, to use his same username when
interfacing with the FTP server?

obviously, the password for the FTP server will be different. Or are you
looking to dynamically create a one time user/passwd for the user so that

it

changes each time they access the FTP server?


-Original Message-
From: Merlin Morgenstern [mailto:merli...@fastmail.fm]
Sent: Monday, January 05, 2009 6:44 AM
To: php-general@lists.php.net
Subject: Re: [PHP] setting up FTP account names via PHP


Marc Steinert wrote:

Merlin Morgenstern schrieb:

Hello everybody,

I am running a real estate site where I would like to enable bulk
upload via real estate software that exports an xml file into an ftp
account.

In order to give every user unique access I would need to generate
individual ftp name and passwords for each member. I can not see how
this should work. My portal is written in PHP 4.x and there every
members loges in with a unique ID. The FTP Server runns on the same
linux machine. How could I generate users for this FTP server with
php, for example on sign up?

Thank you for any help on this.

Best regards,

Merlin


What ftp server are you using?


I just installed pureftpd. One possible sollution as I figured is to
alter the virtual user table of the ftp server with php.

Is this the way to go, or does somebody have a better idea that saves
dev. time?


--
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



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



[PHP] Import files from directory

2009-01-05 Thread Merlin Morgenstern

Hi everybody,

I am running a real estate portal and would like to allow users to 
upload their listing from their existing software. They do this with a 
XML file which they will upload on a ftp server that places this xml 
file into a seperate directory on the file system.


My basic idea was to run a php scipt triggered by cron every 5 minutes 
that checks if there is a new upload and then reads the file and removes 
it. Now here is where the problem starts. Imagine if there are 1000 
users, I would need to go through 1000 folders to check for new content. 
 There must be a better solution to identify the directory that has a 
new  finished upload.


Has anybody an idea on how to do this? Thank you for any hint.

Best regards,

Merlin

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



[PHP] Pass parameters via url inside a php cron job

2008-09-25 Thread Merlin Morgenstern

Hi there,

I would like to run a php file via cron job and there is a parameter to 
be passed. Unfortunatelly this does not work:


# /usr/local/bin/php /home/www/create_notification_emails.php?tf=2
Could not open input file: /home/www/create_notification_emails.php?tf=2

The problem seems to be the ?tf=2

How do I pass parameters to this script? I need the same script but 
executed in different time frames which is passed by the parameter.


Any ideas?

Thank you for any hint,

Merlin

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



Re: [PHP] Pass parameters via url inside a php cron job

2008-09-25 Thread Merlin Morgenstern

Hello Jochem,

thank you this has solved my problem:
bla.php 2
$tf = $argv[1];

Best regards,

Merlin

Jochem Maas wrote:

Merlin Morgenstern schreef:

Hi there,

I would like to run a php file via cron job and there is a parameter to
be passed. Unfortunatelly this does not work:

# /usr/local/bin/php /home/www/create_notification_emails.php?tf=2
Could not open input file: /home/www/create_notification_emails.php?tf=2

The problem seems to be the ?tf=2


something like:

/usr/local/bin/php /home/www/create_notification_emails.php -tf=2

you can retrieve input args via $argv variable - I suggest finding a
package that parses this input for you so you don't have to manually
do it, search for something like php GetOpt package ... PEAR has one
for sure.


How do I pass parameters to this script? I need the same script but
executed in different time frames which is passed by the parameter.

Any ideas?

Thank you for any hint,

Merlin





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



Re: [PHP] Individual bulk e-mails - performance question (was skinning a cat) :-)

2008-09-01 Thread Merlin Morgenstern

Per Jessen schrieb:

Jochem Maas wrote:


lockfile=/var/lock//file
# clear out a lock older than 60mins
find $lockfile -cmin +60 | xargs rm
test ! -f $lockfile  (
touch $lockfile
run some php
rm -f $lockfile
)

wouldn't creating a dir be better here? (with regard to atomicity)



I haven't thought it through, but I don't think it would change
anything. 



/Per Jessen, Zürich



Hello everybody,

thank you for the huge amount of replies on my question. I believe I 
quite lost a bit track on how to solve the problem hands on. To 
summerize, there are aparently two ways of skinning the cat :-)


1. Run a deamon
I admit I have never wrote one, and that seems therefore to be the 
harder option for me. Well... perhaps not.
I assume it is simply creating a shell script like Jochem wrote, however 
   I guess it would just take longer for me to get it running as I have 
never done that before.


2. Create a PHP file that holds some lock code which is triggered by 
CRON every 5 minutes. Taking the example from Robert.


3. Following idea which I am now actually implementing :-)

 - Add all emails into a mysql db with one insert command.
 - Run a php script by cron every 5 min that does the following:
- update table, set session_id = x on all entries without session id
- get all entries with that session ID
- send email to those with that session ID
- remove all entries with that session ID

Looks like easies sollution on how to skimm the cat. DB might not be the 
most performing sollution, but sufficient considering the hard ware power.


Thanks for your help!

Regards,

Merlin

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



Re: [PHP] Ham marked as Spam with BAYES_99 - PhpMailer to old?

2007-12-20 Thread Merlin Morgenstern

Richard Lynch schrieb:

On Tue, December 18, 2007 8:41 am, Merlin Morgenstern wrote:

I am running a small community page with PHP. Members can select
notification e-mails on comments etc.

Since today those e-mails - or basically all e-mails from the system -
get taged as spam with a score of 3.5 that totally results to
BAYES_99.

How come? I am using PHP-Mailer 1.73. I am wondering if this will go
away if I upgrade to 2.0. However I would rather not like to do that
as a .0 release makes me a bit worried.

Does anybody have an idea on how to eleminate that BAYES_99 score?
Those
mails are absolutly no spam. They contain a link to the commment page
but that should not be the problem. At least it was not a problem for
the last years.

Any ideas?


Bayes usually refers to the Bayseian (sp?) algorithm where the system
learns what is junk based on users' marking things as spam.

So if you add a bunch of people to your list that don't expect to be
on it, and they all mark your email as spam, whammo, all your emails
are marked as spam.

Or so I understand it...

Or possibly mis-understand it. :-v



That sounds logical. However those e-mails are opt-in. So it is very 
unlikely that this has happend. I also checked red lists etc.


I believe that I did not configure the server well and the php sending 
function so that the header is missing important settings or so. After 
all the Bayes_99 is the only spam trigger.


Unfortunatelly I can only find postings on the net where people talk 
about how to tweak their spamassasin filtering. Nobody who sends e-mails 
seams to have a problem. Is that only me? (and of course the spamers :-) ).


I tried to send it directly from unix command: mail -s This is a test 
[EMAIL PROTECTED]


That one gets flaged with bayes_50 (spam score 0). After all most of the 
e-mails I receive in my private account are even bayes_00 (-2.x).


Do you believe it is the IP-Adress? I could not find it anywhere on the 
red lists. All looks clean.


Any ideas?

Thank you for any hints,

Merlin

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



[PHP] Ham marked as Spam with BAYES_99 - PhpMailer to old?

2007-12-18 Thread Merlin Morgenstern

Hi there,

I am running a small community page with PHP. Members can select 
notification e-mails on comments etc.


Since today those e-mails - or basically all e-mails from the system -
get taged as spam with a score of 3.5 that totally results to BAYES_99.

How come? I am using PHP-Mailer 1.73. I am wondering if this will go 
away if I upgrade to 2.0. However I would rather not like to do that

as a .0 release makes me a bit worried.

Does anybody have an idea on how to eleminate that BAYES_99 score? Those 
mails are absolutly no spam. They contain a link to the commment page 
but that should not be the problem. At least it was not a problem for 
the last years.


Any ideas?

Thank you for any help,

Merlin

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



Re: [PHP] Ham marked as Spam with BAYES_99 - PhpMailer to old?

2007-12-18 Thread Merlin Morgenstern

Hello everybody,

thank you for the reply.

Stut schrieb:

Merlin Morgenstern wrote:
I am running a small community page with PHP. Members can select 
notification e-mails on comments etc.


Since today those e-mails - or basically all e-mails from the system -
get taged as spam with a score of 3.5 that totally results to BAYES_99.


This is most likely to be the content of the messages you're sending 
rather than the structure of the emails as created by PHPMailer.


I found that it almost any e-mail sent now from the site has that 3.5 
spam score. Registration e-mails, Nitification e-mails etc.



How come? I am using PHP-Mailer 1.73. I am wondering if this will go 
away if I upgrade to 2.0. However I would rather not like to do that

as a .0 release makes me a bit worried.


I doubt it but stranger things have happened. However this has nothing 
to do with PHP itself, and would get a better response from a 
PHPMailer-specific list (I assume there is one).


You are right. I was just wondering if somebody else here has 
experienced it today in their apps.


Does anybody have an idea on how to eleminate that BAYES_99 score? 
Those mails are absolutly no spam. They contain a link to the commment 
page but that should not be the problem. At least it was not a problem 
for the last years.


AFAIK BAYES_99 means it thinks there is a 99% chance of it being spam, 
that's very high for something you're saying is an operational email. Is 
that link the only thing they contain? If so try adding more text.




99%? How can they be so wrong? There must be a serious reason for that.

The message looks like this:

---
Hello xy,

You are receiving this email because you are watching
the topic, Topicname  at Community

This topic has received a reply since your last visit.
You can use the following link to view the replies made.

http://link

If you no longer wish to watch this topic you can either
click the Stop watching this topic link found at the
bottom of the topic above (after you login!), or by
clicking the following link:

http://www.link
---

STrange, isn't it?

It's also worth noting that this score comes from a system that's 
capable of learning: http://en.wikipedia.org/wiki/Bayesian_spam_filtering


-Stut



`Thanks, will do.

Best regards,

Merlin

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



  1   2   >