php-general Digest 22 Aug 2009 15:32:27 -0000 Issue 6299
Topics (messages 297068 through 297081):
Re: Tidy on a shared host
297068 by: Manuel Lemos
Re: How to download and configure php mvc website locally
297069 by: Paul M Foster
Re: How do I extract link text from anchor tag as well as the URL from the
"href" attribute
297070 by: Manuel Lemos
Re: Invoking functions stored in a separate directory?
297071 by: Clancy
297075 by: David Robley
Re: daemon without pcntl_fork
297072 by: Lars Torben Wilson
Rounding down?
297073 by: Ron Piggott
297074 by: David Robley
297076 by: Richard Heyes
297077 by: Ashley Sheridan
297078 by: Ron Piggott
297079 by: ×× ××× ×× ××
297080 by: Richard Heyes
preg_replace anything that isn't WORD
297081 by: ×× ××× ×× ××
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
Hello,
on 08/20/2009 09:47 PM Al said the following:
> Or, does anyone know of a stand-alone php class that emulates the tidy
> extension. I've looked; but, not found any.
Yes, you may want to try this Secure HTML parser filter package. It
comes with parser and a filter class that validates HTML against an
eventually auto-detected DTD. It returns an array of tag and data
elements that you can use to rebuild a valid HTML document using the
RewriteElement function.
http://www.phpclasses.org/secure-html-filter
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
On Wed, Aug 19, 2009 at 11:00:46PM -1000, Sumit Sharma wrote:
> Hi all,
> The site I have download was developed using cake php. Now when trying to
> access the website it is showing a blank page. As Sudheer suggested I went
> to error log and noted down the errors there, which are as follows:
>
> [Thu Aug 20 14:10:16 2009] [error] [client 127.0.0.1] File does not exist:
> F:/Rabin/xampp/htdocs/favicon.ico
>
> I think there is no file called favicon.ico but how to create this file. Is
> this something related to cakephp configuration.
>
> Regards,
> Sumit
Lack of favicon.ico will show up in your logs if the file isn't there,
but it will do nothing to prevent your site from showing up.
Frameworks like CakePHP require additional files and database tables to
be created by the programmer, before anything will show up on the
screen. There are either omitted files or missing tables (or missing
table rows).
Paul
--
Paul M. Foster
--- End Message ---
--- Begin Message ---
Hello,
on 08/16/2009 04:33 AM chrysanhy said the following:
> I have the following code to extract the URLs from the anchor tags of an
> HTML page:
>
> $html = new DOMDocument();
> $htmlpage->loadHtmlFile($location);
> $xpath = new DOMXPath($htmlpage);
> $links = $xpath->query( '//a' );
> foreach ($links as $link)
> { $int_url_list[$i++] = $link->getAttribute( 'href' ) . "\n"; }
>
> If I have a link <a href="http://X.com">YYYY</a>, how do I extract the
> corresponding YYYY which is displayed to the user as the text of the link
> (if it's an image tag, I would like a DOMElement for that).
> Thanks
You may want to try this HTML parser class that comes with filter class
and an example script named test_get_html_links.php that does exactly
what you ask.
http://www.phpclasses.org/secure-html-filter
--
Regards,
Manuel Lemos
Find and post PHP jobs
http://www.phpclasses.org/jobs/
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
--- End Message ---
--- Begin Message ---
On Fri, 21 Aug 2009 15:16:11 +0200, ak...@telkomsa.net ("Arno Kuhl") wrote:
>-----Original Message-----
>From: Clancy [mailto:clanc...@cybec.com.au]
>Sent: 21 August 2009 01:26 PM
>To: php-gene...@lists.php.net
>Subject: [PHP] Invoking functions stored in a separate directory?
>
>I am developing an idea for a website engine which can be shared between
>several different websites. Each website would have its own directory under
>a common root directory, and the engine would be in a separate directory
>Engine:
>
>Root
>Website_1.com, Website_2.com, Engine
>
>The website directories would each contain the design data for that website,
>consisting basically of a mixture of text files and images. The various
>pages would be loaded by loading index.php from the website root directory,
>and specifying a number of parameters e.g.
>
>http://www.corybas.com/index.php?path=Holidays&level=0&item=0
>
>I have the minimum amount of code in index.php -- just enough to set some
>parameters to identify the website, and then include
>../Engine/Main_prog.php. This in turn can include any of a large number of
>other include files to carry out particular functions.
.....................................
>
>Using include ../Engine/Main_prog.php won't work for you in a production
>environment. You need to create a path.php file that defines the absolute
>path to the engine for each website, and include it at the top of your
>website script. Then you can do something like:
>
> include ENGINEPATH."Main_prog.php";
Thank you very much for this. It has at last provided the clue I was looking
for, and
after far too long I have got a trivially simple demonstration working. One
complication I
hadn't anticipated is that apparently I can only access functions in the
include file, but
cannot execute any code in it.
Thus when Halla.php read:
<?php echo '<p>Eng_test_'.__LINE__.' Hallejuha!! : </p>'; ?>
and I included it:
$ok = define ('HOST_PATH','../Engine');
$ok = include (HOST_PATH.'/Halla.php');
nothing happened.
When Halla.php read:
<?php function halla ($i) {
echo '<p>Eng_test_'.__LINE__.' Hallejuha!! : '.$i.'</p>';
return $i; } ?>
and I included it:
$ok = define ('HOST_PATH','../Engine');
$ok = include (HOST_PATH.'/Halla.php');
$ok = halla (7);
echo '<p> Returned '.$ok'</p>';
it did work. I presume that this explains your next comment, in that I am
neither reading
nor executing the code in the Include, so permissions don't come into it.
>You shouldn't really have permission problems as long as your website and
>engine are on the same server. ...
>One other advantage it will give you for your particualr design is that you
>can have multiple engines per server (e.g. Engine1, Engine2, etc) so that
>you can bring one engine down for upgrade while still keeping sites running
>on the other engines.
Yes; I have got already got all that working. Now I JUST have to convert my
main program
into one big function!
Will I still be able to access $_GET & $_POST variables, and set up session
variables from
inside this function? I guess I can declare them all GLOBAL?
Thanks, again,
--- End Message ---
--- Begin Message ---
Clancy wrote:
> $ok = include (HOST_PATH.'/Halla.php');
Because you are assigning the result of the include to a variable. Try
include (HOST_PATH.'/Halla.php');
and it will work as you expect. And similarly for
define ('HOST_PATH','../Engine');
Cheers
--
David Robley
Dynamic linking error: Your mistake is now everywhere.
Today is Prickle-Prickle, the 15th day of Bureaucracy in the YOLD 3175.
--- End Message ---
--- Begin Message ---
2009/8/20 Jim Lucas <li...@cmsws.com>:
> Lars Torben Wilson wrote:
>> 2009/8/19 Per Jessen <p...@computer.org>:
>>> Jim Lucas wrote:
>>
>> [snip]
>>
>>> I probably wouldn't have chosen PHP for the first one, but there's no
>>> reason it shouldn't work. For the second one, did you mean to
>>> write "serial port"? That's a bit of a different animal, I'm not sure
>>> how far you'll get with php.
>>>
>>>> Here is what I have come up with so far. Looks to satisfying my
>>>> needs:
>>>>
>>>> tms_daemon
>>> [snip]
>>>> # END OF SCRIPT
>>> Looks good to me. It'll certainly do the job.
>>>
>>>
>>> /Per
>>
>> I agree with Per on all points--I probably wouldn't choose PHP as a
>> first choice for the first task, but the startup script you have shown
>> looks like a bog-standard startup script and should serve you well. I
>> haven't really gone over it with a fine-toothed comb though. Typos
>> etc. are still up to to you. :) Of course, the whole thing depends on
>> how tms_daemon behaves, but the startup script looks OK.
>>
>> Can you explain in a bit more detail exactly what the second part (the
>> serial-network data logger) needs to do? I've written similar daemons
>> in C but not PHP--when I've needed to get something like that going
>> with a PHP script, I've used ser2net (which I linked to in an earlier
>> post) and been quite happy. Maybe you don't even have to do the hard
>> work yourself (or buy extra hardware to do it for you).
>>
>>
>> Cheers,
>>
>> Torben
>>
>
> As for the second project, I asked about it in the previous thread about
> the SMDR/CDR processor.
>
> http://www.nabble.com/SMDR-CDR-daemon-processor-td25014822.html
Sorry, missed that thread.
> Basically, I need to have a process that collects data via serial
> (USB|RS323), connects to a remote port, or listens and receives data
> from the PBX pushing it.
>
> The most common is the RS232 serial connection. Thats why I need to be
> able to listen on the local RS232 port for data coming from the PBX system.
>
> What I have built so far can connect to a remote machine, via a TCP/IP
> connection, and wait for data to be push out the specified TCP port.
>
> I haven't done it yet, but I know that I can easily build, using a
> different project as a base, the version that would connect to a local
> TCP/IP IP:PORT and wait for a PBX to send the data to that IP:PORT.
>
> After the data has been received, the process flow will be the same with
> all three methods. Parse it, sanitize it, store it.
>
> Hopefully that explains a little more.
>
> Jim
In short, are you looking for a program which listens on a serial port
and a network port at the same time, and places any data received from
either into a database?
Regards,
Torben
--- End Message ---
--- Begin Message ---
Is there a way to round down to the nearest 50?
Example: Any number between 400 and 449 I would 400 to be displayed; 450 to 499
would be 450; 500 to 549 would be 500, etc?
The original number of subscribers is from a mySQL query and changes each day.
I am trying to present a factual statement: "There have been over ###
subscribers in 2009" type of scenereo.
Ron
--- End Message ---
--- Begin Message ---
Ron Piggott wrote:
> Is there a way to round down to the nearest 50?
>
> Example: Any number between 400 and 449 I would 400 to be displayed; 450
> to 499 would be 450; 500 to 549 would be 500, etc?
>
> The original number of subscribers is from a mySQL query and changes each
> day. I am trying to present a factual statement: "There have been over
> ### subscribers in 2009" type of scenereo.
>
> Ron
Modulus - http://php.net/manual/en/language.operators.arithmetic.php
Cheers
--
David Robley
Oxymoron: Split level.
Today is Prickle-Prickle, the 15th day of Bureaucracy in the YOLD 3175.
--- End Message ---
--- Begin Message ---
Hi,
> Is there a way to round down to the nearest 50?
>
> Example: Any number between 400 and 449 I would 400 to be displayed; 450 to
> 499 would be 450; 500 to 549 would be 500, etc?
Off the top of my head: divide the number by 50, run floor() on the
result, then times it by 50.
1. 449 / 50 = 9.whatever
2. floor(9.whatever) = 9
3. 9 * 50 = 450
--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
--- End Message ---
--- Begin Message ---
On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote:
> Hi,
>
> > Is there a way to round down to the nearest 50?
> >
> > Example: Any number between 400 and 449 I would 400 to be displayed; 450 to
> > 499 would be 450; 500 to 549 would be 500, etc?
>
> Off the top of my head: divide the number by 50, run floor() on the
> result, then times it by 50.
>
> 1. 449 / 50 = 9.whatever
> 2. floor(9.whatever) = 9
> 3. 9 * 50 = 450
>
> --
> Richard Heyes
> HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
> Lots of PHP and Javascript code - http://www.phpguru.org
>
It should be round() and not floor().
449 / 50 = 8.98
floor(8.98) = 8
8 * 50 = 400
round(8.98) = 9
9 * 50 = 450
Thanks,
Ash
http://www.ashleysheridan.co.uk
--- End Message ---
--- Begin Message ---
Thanks; Amazing. Ron
----- Original Message -----
From: "Ashley Sheridan" <a...@ashleysheridan.co.uk>
To: "Richard Heyes" <rich...@php.net>
Cc: "Ron Piggott" <ron....@actsministries.org>; <php-gene...@lists.php.net>
Sent: Saturday, August 22, 2009 9:02 AM
Subject: Re: [PHP] Rounding down?
On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote:
Hi,
> Is there a way to round down to the nearest 50?
>
> Example: Any number between 400 and 449 I would 400 to be displayed;
> 450 to 499 would be 450; 500 to 549 would be 500, etc?
Off the top of my head: divide the number by 50, run floor() on the
result, then times it by 50.
1. 449 / 50 = 9.whatever
2. floor(9.whatever) = 9
3. 9 * 50 = 450
--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
It should be round() and not floor().
449 / 50 = 8.98
floor(8.98) = 8
8 * 50 = 400
round(8.98) = 9
9 * 50 = 450
Thanks,
Ash
http://www.ashleysheridan.co.uk
--------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.409 / Virus Database: 270.13.64/2319 - Release Date: 08/22/09
06:06:00
--- End Message ---
--- Begin Message ---
I also wrote a function for that,
function round_to($number, $increments) {
$increments = 1 / $increments;
return (round($number * $increments) / $increments);
}
(Also published on php manual - round() )
On Sat, Aug 22, 2009 at 4:11 PM, Ron Piggott <ron....@actsministries.org>wrote:
> Thanks; Amazing. Ron
>
> ----- Original Message ----- From: "Ashley Sheridan" <
> a...@ashleysheridan.co.uk>
> To: "Richard Heyes" <rich...@php.net>
> Cc: "Ron Piggott" <ron....@actsministries.org>; <php-gene...@lists.php.net
> >
> Sent: Saturday, August 22, 2009 9:02 AM
> Subject: Re: [PHP] Rounding down?
>
>
> On Sat, 2009-08-22 at 13:00 +0100, Richard Heyes wrote:
>>
>>> Hi,
>>>
>>> > Is there a way to round down to the nearest 50?
>>> >
>>> > Example: Any number between 400 and 449 I would 400 to be displayed; >
>>> 450 to 499 would be 450; 500 to 549 would be 500, etc?
>>>
>>> Off the top of my head: divide the number by 50, run floor() on the
>>> result, then times it by 50.
>>>
>>> 1. 449 / 50 = 9.whatever
>>> 2. floor(9.whatever) = 9
>>> 3. 9 * 50 = 450
>>>
>>> --
>>> Richard Heyes
>>> HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
>>> Lots of PHP and Javascript code - http://www.phpguru.org
>>>
>>>
>> It should be round() and not floor().
>>
>> 449 / 50 = 8.98
>> floor(8.98) = 8
>> 8 * 50 = 400
>>
>> round(8.98) = 9
>> 9 * 50 = 450
>>
>>
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>>
>>
>>
>>
>
>
> --------------------------------------------------------------------------------
>
>
>
> No virus found in this incoming message.
> Checked by AVG - www.avg.com
> Version: 8.5.409 / Virus Database: 270.13.64/2319 - Release Date: 08/22/09
> 06:06:00
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Use ROT26 for best security
--- End Message ---
--- Begin Message ---
Hi,
> It should be round() and not floor().
>
> 449 / 50 = 8.98
> floor(8.98) = 8
> 8 * 50 = 400
>
> round(8.98) = 9
> 9 * 50 = 450
Not based on the examples given:
> Example: Any number between 400 and 449 I would 400 to be displayed
--
Richard Heyes
HTML5 graphing: RGraph - www.rgraph.net (updated 8th August)
Lots of PHP and Javascript code - http://www.phpguru.org
--- End Message ---
--- Begin Message ---
Lets assume I have the string "cats i saw a cat and a dog"
i want to strip everything except "cat" and "dog" so the result will be
"catcatdog",
using preg_replace.
I've tried something like /[^(dog|cat)]+/ but no success
What should I do?
--
Use ROT26 for best security
--- End Message ---