php-general Digest 15 Jun 2009 01:31:19 -0000 Issue 6175

Topics (messages 294028 through 294036):

Re: preg_replace problem
        294028 by: Mark Kelly

Re: 3d image rotating
        294029 by: דניאל דנון
        294032 by: Nitsan Bin-Nun

include file in a class with global/parent scope?
        294030 by: Daniel Kolbo

Re: Periodic Actions in PHP?
        294031 by: Parham Doustdar
        294033 by: Phpster

Uniquely identifying an array... as a key to another array
        294034 by: Eddie Drapkin

Issues with APC, cache corruption?
        294035 by: James McLean

Re: High ID (unique, auto increment) causes slow responses on PHP (MySQL)
        294036 by: Andrew Ballard

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

On Saturday 13 June 2009, Al wrote:
> I may not have been very clear. Feed it just      "test"   with the
> quotes. You should get back, "test" the same as you gave it.   Instead,
> I get back &quote;test&quote;

Like Shawn, I have tried your code in isolation and only get the expected 
results. I looped it over a few test values:

<?php
$valueList = array('"','"test"','"test&test"','"test&amp;test"');
echo "<pre>\n\n";
foreach ($valueList as $value) {
        echo "Before: $value\n";
        $value=preg_replace("%&(?!amp;)%i", "&amp;", $value);
        echo "After: $value\n\n";
}
echo '</pre>';
?>

outputs (ignoring <pre> as that was just to remove the <br /> for easy 
reading):

Before: "
After: "

Before: "test"
After: "test"

Before: "test&test"
After: "test&amp;test"

Before: "test&amp;test"
After: "test&amp;test"

The only conclusion is that something else in your code is converting the 
quotes. Have a look around.

HTH

Mark

--- End Message ---
--- Begin Message ---
That not what I meant, but I found a solution with (sadly, wanted pure GD,
but it would've required going over the WHOLE image) imagemagick. Anyway, I
even found more then I wanted
http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=10830&start=0

Thanks (especially for nitsan that suggested me imagemagick might have it),
Ashley and PJ.

 Daniel
On Sat, Jun 13, 2009 at 10:15 PM, PJ <af.gour...@videotron.ca> wrote:

> דניאל דנון wrote:
> > Hello.
> >
> > I'm looking for way to rotate normal images, but not x/y, but with Z
> also.
> > I get a source image (png, jpg, gif...) and I want to rotate it. assuming
> > the "depth" of the image is 1 pixel for example...
> >
> > I'm looking for a way to do it without using imagemagick - only GD. I
> know
> > it might be slower, but its need to run on a server without imagemagick.
> >
> > I've searched information about it, also in PEAR, but I couldn't find
> > anything that takes a normal image and rotate it..
> >
> > Thanks, Daniel
> >
> >
> Hi Daniel,
> I had the same question a short while ago and the only answer I could
> find was to redo the image with either gimp or PhotoShop an save it as
> png 8 with transparency. The only downside is that this seems to leave
> the angled frame (if you use one) a bit scuzzy; but you dont need Z. The
> other downside is that you can't dynamically rotate the image. Of
> course, I am assuming that by "rotate" you mean turn it at an angle and
> not "replace by other images".
> HTH
> Phil
>
> --
> Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> -------------------------------------------------------------
> Phil Jourdan --- p...@ptahhotep.com
>   http://www.ptahhotep.com
>   http://www.chiccantine.com/andypantry.php
>
>


-- 
Use ROT26 for best security

--- End Message ---
--- Begin Message ---
As I have already mentioned, you can read the whole derivation of this 3d
perspective engine and write it down using GD. It should not be such a big
issue.

Good luck!

On Sun, Jun 14, 2009 at 3:07 PM, דניאל דנון <danondan...@gmail.com> wrote:

> That not what I meant, but I found a solution with (sadly, wanted pure GD,
> but it would've required going over the WHOLE image) imagemagick. Anyway, I
> even found more then I wanted
>
> http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=10830&start=0
>
> Thanks (especially for nitsan that suggested me imagemagick might have it),
> Ashley and PJ.
>
>  Daniel
> On Sat, Jun 13, 2009 at 10:15 PM, PJ <af.gour...@videotron.ca> wrote:
>
> > דניאל דנון wrote:
> > > Hello.
> > >
> > > I'm looking for way to rotate normal images, but not x/y, but with Z
> > also.
> > > I get a source image (png, jpg, gif...) and I want to rotate it.
> assuming
> > > the "depth" of the image is 1 pixel for example...
> > >
> > > I'm looking for a way to do it without using imagemagick - only GD. I
> > know
> > > it might be slower, but its need to run on a server without
> imagemagick.
> > >
> > > I've searched information about it, also in PEAR, but I couldn't find
> > > anything that takes a normal image and rotate it..
> > >
> > > Thanks, Daniel
> > >
> > >
> > Hi Daniel,
> > I had the same question a short while ago and the only answer I could
> > find was to redo the image with either gimp or PhotoShop an save it as
> > png 8 with transparency. The only downside is that this seems to leave
> > the angled frame (if you use one) a bit scuzzy; but you dont need Z. The
> > other downside is that you can't dynamically rotate the image. Of
> > course, I am assuming that by "rotate" you mean turn it at an angle and
> > not "replace by other images".
> > HTH
> > Phil
> >
> > --
> > Hervé Kempf: "Pour sauver la planète, sortez du capitalisme."
> > -------------------------------------------------------------
> > Phil Jourdan --- p...@ptahhotep.com
> >   http://www.ptahhotep.com
> >   http://www.chiccantine.com/andypantry.php
> >
> >
>
>
> --
> Use ROT26 for best security
>

--- End Message ---
--- Begin Message ---
Hello,

I understand the why $vars is not in the global scope, but i was
wondering if there was a way from within the class file to include a
file in the parent's scope?

i tried ::include('vars.php'), parent::include('vars.php'), but this
breaks syntax...

Please consider the following three files:

'scope.class.inc'
<?php
class CScope {
        
        public $var = 'class scope\n';
        
        function cinclude($filename) {
                include('vars.php');
                echo "In class $vars\n";
        }
}
?>

'vars.php'
<?php
//global $vars;//if this line is uncommented then the desired result is
achieved however, i don't want to change all the variables to global
scope (this file is includeded in other files where global scoped
variables is not desireable).
$vars = 'vars.php scope\n';
?>

'scope.php'
<?php
include('scope.class.inc');
$object = new CScope;
$object->cinclude('vars.php');
echo "In original $vars\n";//$vars is not defined***
?>

Thanks,
dK

--- End Message ---
--- Begin Message ---
Actually, your message sparked an idea in my [slow] mind. :)
I can put the PHP code in a java script, and tell javascript to call it 
every fifteen seconds. Best option, I think. :)
Any ideas?
Thanks!
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com
""bruce"" <bedoug...@earthlink.net> wrote in message 
news:1528701c9ec4d$322e6cb0$0301a...@tmesa.com...
> hi...
>
> is this a php/web based app...
> are the users using the chat function via the browser..
> if this is a browser/web app, are you looking for a way for the
> php web app to refetch the textfile... i would assume so...
>
> have you figured out a rough architecture/design for your app..
> in your design, you're going to need to figure out how to
> accomplish updates to the text file, and when you do, you'll
> also have figured out how to do the reads...
>
> i'm assuming that you don't want a continuously running thread
> for your php/web app.. ie one continuously, never ending loop...
> -so you'll have the user add some text, the app will write this to
>  a file..
> the user will either select a refresh kind of btn, or your
> app will have to implement a refresh process, which will then
> fetch new/updated data from your files..
> etc...
>
>
>
>
>
>
> -----Original Message-----
> From: richard.he...@gmail.com [mailto:richard.he...@gmail.com]on Behalf
> Of Richard Heyes
> Sent: Saturday, June 13, 2009 2:17 AM
> To: Parham Doustdar
> Cc: php-gene...@lists.php.net
> Subject: Re: [PHP] Periodic Actions in PHP?
>
>
> Hi,
>
>> I'm going to create a small chat script with PHP. The messages you want
> others to see
>> will be added to a flat file (I.E. TXT file), and read and displayed by
> PHP. However, I want
>> this reading and displaying to be periodic. This means that I want PHP to
> check the file for
>> new lines every,say, fifteen seconds. How may I do that? I have been
> unable to find any
>> function that acts like a timer.
>
> If you're on Unix then look into using cron. Type the following at the
> command prompt to get info on cron:
>
> man 5 crontab
>
> Cron tasks can be scheduled at most once per minute. And if you're
> using Windows then I believe the equivalent would be task scheduler,
> but I've no idea how you would go about using it.
>
> --
> Richard Heyes
> HTML5 graphing: RGraph (www.rgraph.net - updated 6th June)
> PHP mail: RMail (www.phpguru.org/rmail)
> PHP datagrid: RGrid (www.phpguru.org/rgrid)
> PHP Template: RTemplate (www.phpguru.org/rtemplate)
> PHP SMTP: http://www.phpguru.org/smtp
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



--- End Message ---
--- Begin Message ---
Sleep(). ?

Bastien

Sent from my iPod

On Jun 14, 2009, at 13:52, "Parham Doustdar" <parha...@gmail.com> wrote:

Actually, your message sparked an idea in my [slow] mind. :)
I can put the PHP code in a java script, and tell javascript to call it
every fifteen seconds. Best option, I think. :)
Any ideas?
Thanks!
--
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
email: parham90 at GMail dot com
""bruce"" <bedoug...@earthlink.net> wrote in message
news:1528701c9ec4d$322e6cb0$0301a...@tmesa.com...
hi...

is this a php/web based app...
are the users using the chat function via the browser..
if this is a browser/web app, are you looking for a way for the
php web app to refetch the textfile... i would assume so...

have you figured out a rough architecture/design for your app..
in your design, you're going to need to figure out how to
accomplish updates to the text file, and when you do, you'll
also have figured out how to do the reads...

i'm assuming that you don't want a continuously running thread
for your php/web app.. ie one continuously, never ending loop...
-so you'll have the user add some text, the app will write this to
a file..
the user will either select a refresh kind of btn, or your
app will have to implement a refresh process, which will then
fetch new/updated data from your files..
etc...






-----Original Message-----
From: richard.he...@gmail.com [mailto:richard.he...@gmail.com]on Behalf
Of Richard Heyes
Sent: Saturday, June 13, 2009 2:17 AM
To: Parham Doustdar
Cc: php-gene...@lists.php.net
Subject: Re: [PHP] Periodic Actions in PHP?


Hi,

I'm going to create a small chat script with PHP. The messages you want
others to see
will be added to a flat file (I.E. TXT file), and read and displayed by
PHP. However, I want
this reading and displaying to be periodic. This means that I want PHP to
check the file for
new lines every,say, fifteen seconds. How may I do that? I have been
unable to find any
function that acts like a timer.

If you're on Unix then look into using cron. Type the following at the
command prompt to get info on cron:

man 5 crontab

Cron tasks can be scheduled at most once per minute. And if you're
using Windows then I believe the equivalent would be task scheduler,
but I've no idea how you would go about using it.

--
Richard Heyes
HTML5 graphing: RGraph (www.rgraph.net - updated 6th June)
PHP mail: RMail (www.phpguru.org/rmail)
PHP datagrid: RGrid (www.phpguru.org/rgrid)
PHP Template: RTemplate (www.phpguru.org/rtemplate)
PHP SMTP: http://www.phpguru.org/smtp

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


--- End Message ---
--- Begin Message ---
Alright, here's the situation.  I'm wrapping memcached, which takes a list
of several servers, into a quasi-singleton.  In other words, I want only one
instance per set of servers, not per server.

Assuming I had three memcached servers at localhost, 192.168.1.1 and
192.168.1.2, I wouldn't want one instance per server, but given that there
are seven possible permutations of combinations / only one server
configuration, MemcacheConnector::$instances could be an array with seven
objects.  I'm expecting MemcacheConnector::getInstance($array) to take an
array formatted like 'server' => 'port'.

Thusly, the question then becomes, what's the lightest possible way to store
a unique-ish array as the key for MemcacheConnector::$instances?  Having
MemcacheConnector::getInstance() check for
self::$instances[serialize($serverArray)] seems a huge waste of both ram and
CPU time.  Is there a better way?


Thanks,
Eddie

--- End Message ---
--- Begin Message ---
Hi All,

Over the weekend I setup a test of APC intending to benchmark a Moodle
installation with various APC settings to see how well I could get it
to perform. I successfully installed Moodle 1.9 and 2.0 under Apache
2.2.3 (installed via apt on Ubuntu 9.04), and with PHP 5.2.9 compiled
from source. I should note, that Ubuntu had an older version of PHP
installed from apt with Suhosin hardened PHP built in. Moodle 2.0
required at least PHP 5.2.8, so I uninstalled the original PHP module
before compiling and installing the 5.2.9.

No issues there; PHP worked well and performance was (mostly) acceptable.

Progressed onto installing APC, firstly by downloading the APC 3.1.2
source from PECL and following the usual 'phpize, configure, make,
make install' process which worked as expected, stop and start Apache
and APC was present in my phpinfo();. I started with the reccomended
PHP config exept with error_display turned on and E_ALL | E_STRICT
enabled, and also the reccomended APC config also.

I copied the 'apc.php' from the source tree to my webroot and changed
the password as suggested.

The issue arose when I attempted to benchmark my Moodle install with
'ab' (I realise it only downloads the single page, but it's good
enough for what I need for now though) and the result was no different
to before I had installed APC. View the apc.php page, and the only
page cached is apc.php itself.. Certainly not what I've witnessed in
the past. Then what would happen was if I viewed my seperate info.php
page containing simply the opening PHP tag and a single line with
phpinfo(); in the file - the cache would appear to reset, and it would
firstly not load the info.php into the cache, it would reset the
counter on the apc.php file back to 0.

Through all of this, there was no errors displayed on the screen and
no errors listed in the Apache error log either. Increased the Apache
log level up to Debug, and no related information was displayed.
Moodle itself worked as expected with no errors, and on a seperate
RHEL installation I have Moodle working with APC and it is caching all
it's files as expected.

At this point, I thought it may be an issue with the module I compiled
myself. I backed up the module, and allowed PECL to install the
module, it installed 3.0.19. Restarted Apache and verified the version
was as PECL had built and installed.

This had no effect, and yeilded the same behaviour.

I'm stumped as to what the issue could be, however I did see this
issue of APC not caching files on an installation of Red Hat
Enterprise Linux in the past - however at the time we assumed it was
an issue with the framework we were using and due to time constraints
simply ran without APC and didn't investigate further.

Has anyone seen this issue in the past and perhaps even rectified it?

Any information would be appreciated.

Cheers,

James

--- End Message ---
--- Begin Message ---
On Sat, Jun 13, 2009 at 3:34 PM, Stuart<stut...@gmail.com> wrote:
> 2009/6/13 דניאל דנון <danondan...@gmail.com>:
>>  I've built a certain system where every time new user enters it creates a
>> "guest row" on "guests" table. he also gets an identifying cookie.
>>
>> The table contains several fields, one of them is ID which is auto increment
>> and unique
>>
>> When he does a certain action it gets recorded in the "done_action" table
>> with several fields on it, one of them is "guest_id" and his ID on it.
>>
>>
>> Problem is the guests table has about 30,000 rows (which means ID is high).
>>
>>  I was wondering whether I should somehow change how the system works.
>>
>> I've thought about couple of options
>>
>> A weekly "cleanup" job. opens a table called "guests_tmp", *copies* all data
>> from guests to guests_tmp.
>>
>> every row it copies it also changes the ID on the table done_action.
>>
>> What do you  think?
>
> I think your problem has nothing to do with high IDs. I have tables in
> MySQL with primary key IDs that have recently passed 2 billion and
> they're still as responsive as they were with 1 row!!
>
> What specific operations are slow, and are you sure it's the MySQL
> query that's being slow and not something in the surrounding code? If
> it is the MySQL query what is it and what engine are your tables
> using?
>
> -Stuart
>
> --
> http://stut.net/
>

Right. 30k rows in most databases is nothing. Neither the number of
rows nor the size of the number should cause problems at that size. Is
there a chance that the table is incorrectly indexed? Every index has
to be updated when a new row is added, so a table with a lot of
unnecessary indexes (for example, every column has its own index) can
get dreadfully slow as it fills up.

Andrew

--- End Message ---

Reply via email to