[PHP] Event Handling

2010-03-15 Thread Alex Major
Greetings all,

I'm currently looking at building a web application, however I've run into
an area of development I've not come across before. The web site in its
basic form allows users to send cars from a point and then the car will
arrive at another point. When the car is set on its way, the start time,
travel duration and end time are all known and stored in a MySQL database,
what I would like to happen is that an event is triggered on the server at
the end time and then an e-mail is sent to the user. This should happen
regardless of whether someone is browsing the website or not.

I don't believe that I'll be able to solely use PHP, I have spent the
afternoon trying to look at potential solutions but I have to admit I've
drawn a blank. Google hasn't been helpful (64 pages so far), as any searches
related to "event handling" bring up a load of JavaScript tutorials/help for
'onclick' events etc. I have searched through the PHP documentation and
found "libevent" (http://www.php.net/manual/en/book.libevent.php ), I don't
believe that is what I require (although in all honesty the lack of
documentation on it means I'm quite in the dark as to its purpose). Another
potential candidate I came across was a PHP/Java bridge
(http://php-java-bridge.sourceforge.net/pjb/ ), whereby I could use the java
virtual machine, register events with it and then callback PHP scripts,
although this seems extremely long winded.

I was hoping that someone might have some experience with this kind of issue
and could point me in the right direction. I'm sure I've missed something
right in front of me. 

Alex.



RE: [PHP] Event Handling

2010-03-15 Thread Alex Major
Thanks to all for your help on this, it's been very interesting for me to
read.

The system needs to check arrivals in real time (give or take a second or
two), using a cron job every minute doesn't provide the real time checking I
would like.

However, when I then got to thinking about it, wouldn't this be an ideal
solution? I create a PHP script that loops for 60 seconds, checking the
database each second for new entries and processing them (meaning I get near
real time monitoring), and then have that PHP script called by a cron job
every minute.

The reason I think that could be a good solution for me, is that if the PHP
script crashed (for any reason), then at most it's 59 seconds before the
system kicks in again and begins processing all the queued arrivals. If I
coded a PHP script to loop infinitely processing things every second, it's
possible I wouldn't notice a crash for a considerable amount of time. The
proposed solution provides a good fail-safe, I think.

Does that solution seem sensible? Or overkill?

Thanks again for your help in this, it's quite novel for me.

-Original Message-
From: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Sent: 15 March 2010 12:56
To: Midhun Girish
Cc: Jochem Maas; David Hutto; php-general@lists.php.net; Alex Major
Subject: Re: [PHP] Event Handling

On Mon, 2010-03-15 at 18:28 +0530, Midhun Girish wrote:

> rene "a page with an ajax script that kicks off the
check-for-recent-events
> script on the server".. but that method is highly non reliable i dont
> think anyone will take that risk especially for an important web app
> cron or any equivalent which runs on the server must be used instead of
> that..
> 
> 
> Midhun Girish
> Development Lead
> MobAlive Technologies
> 
> 
> 
> On Mon, Mar 15, 2010 at 6:08 PM, Jochem Maas  wrote:
> 
> > Op 3/15/10 12:00 PM, David Hutto schreef:
> > > On Mon, Mar 15, 2010 at 7:31 AM, Jochem Maas 
> > wrote:
> > >
> > >> Op 3/15/10 8:24 AM, Midhun Girish schreef:
> > >>> Hi ,
> > >>> Just as David Hutto has said,What you need is the cronjob... Make a
> > >> script
> > >>> say "check.php" which checks the db to see if any new entries are
> > made...
> > >>> and if yes send the mail ...
> > >>>
> > >>> now using the cronjob feature in linux os(which will be provided as
a
> > >>> service in your linux hosting cpanel), set a cronjob which calls the
"
> > >>> http://www.yoursite.com/check.php"; URL every minute now a
trigger
> > >> will
> > >>> be there every minute to the script and the emails will be send
> > >> irrespective
> > >>> of whether anyone is browsing the site or not hope it is
clear...
> > >>>
> > >>
> > >> use cron - yes
> > >> have cron call a web URL - no, instead just call the script via the
php
> > CLI
> > >> sapi,
> > >> e.g. a cmdline as follows in cron:
> > >>
> > >> /usr/env php /path/to/your/check.php &> /dev/null
> > >>
> > >
> > >
> > > I do believe removing the /dev/null will send error messages during
the
> > > building of the script, correct?
> > >
> >
> > the '&> /dev/null' redirects all output - I kind of make the assumption
> > that the
> > script would be logging stuff to a file or something when in production.
> >
> > so, yes, remove the redirection when your developing/testing the script.
> >
> >
> >


I agree. Even setting a cron on a local computer to call home to a
server script would be preferable to Ajax calls.

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




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



RE: [PHP] Still searching for a bugtracking system

2010-03-30 Thread Alex Major
Surely if it's not suitable for your situation, it's not the best? :)

Mantis is what I'd recommend and believe has already been recommend to you.
Runs using PHP and MySQL, it's flexible for public or private projects,
multiple projects etc.

I do agree with you that Bugzilla seems heavy, I know it has its supporters
but I've always found it to be overkill for the projects I've worked on.

Alex.

-Original Message-
From: Andre Polykanine [mailto:an...@oire.org] 
Sent: 30 March 2010 14:14
To: php-general@lists.php.net
Subject: [PHP] Still searching for a bugtracking system

Hello everyone,
The best of all suggested bugtrackers is JotBug, on my opinion. But it
works only with SQLite databases, and I have no access to such one
(only MySql).
Any solutions?
P.S. I'd use Trac, but since I have no own server yet, we have no
access to Python, either... Only Php, MySql, Perl.
I have looked at Bugzilla... seems to heavy for our service).

-- 
With best regards from Ukraine,
Andre
Http://oire.org/ - The Fantasy blogs of Oire
Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @
jabber.org
Yahoo! messenger: andre.polykanine; ICQ: 191749952
Twitter: http://twitter.com/m_elensule


-- 
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] PHP Application Structre

2010-05-10 Thread Alex Major
Greetings all,

 

This question basically surrounds how you structure your PHP applications,
whether it changes depending on what you're doing and which you'd favour. I
have a feeling it'll come down to a question of personal taste, but on the
off-chance there's a best practice I'll ask anyways.

 

>From what I've seen and used, there seem to be three distinct ways of going
about it.

 

1)  Using a 'core' class which has a request handler in it. All pages in
the site are accessed through that one page, e.g.

 

http://www.somesite.com/index.php?page=ViewUser
http://www.somesite.com/index.php?page=ViewProduct

 

This is one that I've personally used most after becoming familiar with a
bulletin board system several years ago. It means that pages are easily
created as all the template/session/database handling is done by the central
class.

 

2)  Using SE friendly URL's like:

 

http://www.somesite.com/products/22012/cool-game/
http://www.somesite.com/products/22013/other-game/

 

This approach seems to be becoming more common on the sites I frequent,
however by accounts I've read it seems to be more intensive on apache as it
requires a mod-rewrite function. 

 

3)  Using different PHP files for each page:

 

http://www.somesite.com/viewproduct.php?product=
http://www.somesite.com/viewuser.php?user=...

 

This would appear to be the least developer friendly option?

 

Hopefully someone can shed some insight into which is the recommended
approach and why. I've been building bigger and bigger sites so having a
solid foundation is becoming more and more important.

 

Thanks for any help/feedback, I hope I've been clear.

 

Alex.



RE: [PHP] multi thread work?

2010-08-04 Thread Alex Major
> -Original Message-
> From: Tontonq Tontonq [mailto:root...@gmail.com]
> Sent: 04 August 2010 18:21
> To: PHP General Mailing List
> Subject: [PHP] multi thread work?
> 
> Hi
> how to make a script multi task  based like this
> 
>  
> 
> for($i=1;$i<=100;$i++)
> {
> 
> 
> $ch = curl_init();
> curl_setopt($ch, CURLOPT_URL,
> 'http://www.facebook.com/ajax/reqs.php?__a=1'
> );
> curl_setopt($ch, CURLOPT_POST, 1);
> curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; tr)
> Presto/2.6.22 Version/10.50");
> curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
> curl_setopt($ch, CURLOPT_REFERER, "http://www.facebook.com/reqs.php";);
> curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
> //curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
> curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
> curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
> curl_setopt($ch, CURLOPT_PROXY, "127.0.0.1:");
> curl_exec($ch);
> 
> 
> }
> ?>
> 
> 
> lets say this takes 1000 seconds and it doesnt focus to another curl
> process
> before it finish the previous one
> 
> is it possible to let the script focus another curl process without
> wait
> answer of the previous one
> 
> i hope if u could understand me ^^

This question has been asked several times over the last week, have a look
over the archive ;).

You need to be looking at something like process forking (
http://php.net/manual/en/function.pcntl-fork.php ).

Alex.


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



[PHP] If statement question

2006-06-26 Thread Alex Major
Hi list.
Basically, I'm still learning new things about php and I was wondering if
things inside an if statement get 'looked at' by a script if the condition
is false.
For example, would this mysql query get executed if $number = 0 ?

If ($number == 1) {
mysql_query($blah)
}

I know that's not really valid php, but hope it gets my point across. I was
just wondering from an optimisation perspective, as I don't want sql
commands being executed when they don't need to be (unnecessary server
usage). 

Thanks in advance for your responses.
Alex.

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



[PHP] A variable inside a variable?

2006-06-26 Thread Alex Major
Thanks for your help with my other question, heres a new one for you.

I need to nest a variable, inside another variable. For example:

$($buildingname)level

How (if at all) is this possible?

Thanks.
Alex.

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



[PHP] Calculations

2006-06-27 Thread Alex Major
Hi there list. 
Thanks for your help with my other questions.

I was carrying on working through, and stumbled across a problem when trying
to times something by the 'power' of something. By this I mean..in maths you
can write 3 * (2 ^ 3), the answer to which would be 24. (as 2 ^ 3 = 8).

The reason that I need this, is because I'm trying to double a variable x
amount of times (x is set by another variable).

For example my code is:

$cost = $farm_cost * (2 ^ $farm_level);

Any ideas how I would go about changing my calculation, as php dosn't seem
to recognise ^ meaning 'to the power of'.

Regards, 
Alex.

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



[PHP] Question about Arrays

2006-10-10 Thread Alex Major

Hi List.
I have a table, which contains 'setting' information for my website.
The table has the following columns: setting_id, setting_name and 
setting_value.
Now there are currently 30 settings stored in this table, however i am 
having trouble pulling values out on a 'as needed' basis.


At the moment i have this select query:
$settings_query = "SELECT * FROM `robin_settings`";
$settings_result = mysql_query($settings_query);

And from that, i would like to pull individual results, for example...

I have a setting which has a 'setting_id' of "4", a 'setting_name' 
called "banner_on" and a 'setting_value' of  "1".


How am i able to pull that information from the results i get?

I know i could pull it by putting a WHERE clause on the SQL query, 
however that would mean having 30 select queries per page and i don't 
really fancy that!


Thanks for any help! (i'm new at this :) )

Alex.

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



[PHP] Using PHP/HTML effectivly

2006-06-14 Thread Alex Major
Hi List,
I've been (very slowly) working my way through some basic php, and
putting it into my html site. However recently (after trying things out such
as cookies or redirects where they have to be set before any page output)
I've found that the combination or certainly the way that I'm using php and
html together dosn't seem to go too well.

I have a question to you experienced PHP developers, how do you mix the
html/php together. When I've looked at things like the PHPBB forums, and
gone through files they will have absolutly no HTML, just php code. I'm not
sure how they manage their page styling, if anyone could explain this too
me. 

At the moment I have things such as







I'm sure that I'm not doing it the best possible way, so if anyone has any
tips for me.

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



Re: [PHP] Using PHP/HTML effectivly

2006-06-14 Thread Alex Major
Thankyou everyone who responded to my original message. All of your ideas
have showed me the various ways of doing it, however I believe that the idea
from Jons message is best suited to my needs. I realise the logic behind it,
its put together some knowledge I have already so I think I'll use it for
the time being. 

Thankyou for taking the time to respond to my message.

Regards, 
Alex


On 14/6/06 19:48, "Jon Anderson" <[EMAIL PROTECTED]> wrote:

> This is my opinion on the matter...
> 
>  From experience, I would say that mixing PHP and HTML together in a
> complicated page can often get very ugly. I prefer to separate out
> presentation and code into separate layers as much as possible.
> 
> I have most often used template systems such as Smarty (smarty.php.net)
> for that. I use Smarty for work - I find it quite nice. It allows you to
> separate your code from your presentation very effectively. It's easy to
> use, and provides things like caching for performance.
> 
> However, I came to the realization recently that PHP itself is
> essentially a very feature rich template system (nevermind the fact that
> it's a well defined language. ;-)
> 
> By splitting up my most recent project into includes, templates, and
> pages, I get a solution to the problem in pure PHP. In the end, code
> looks like code, and HTML looks (almost) like HTML and both are
> readable. (Same result as what Smarty gives you, without needing Smarty.)
> 
> Most pages look something like:
> 
>  include('include/data_functions.php');
> if ($condition) {
>$title = 'Here is Some Data!';
> $data = getSomeData($var1,$var2);
> } else {
>$title = 'Here is the Other Data!';
>$data = getOtherData($var1,$var2);
> }
> include('template/page.php');
> ?>
> 
> And most templates look something like:
> 
> 
> 
> ...
> 
> 
> 
>   
>   
> 
> 
> 
> ...
> Thanks for your interest in my data!
> 
> 
> jon

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



[PHP] An annoying session problem

2006-06-19 Thread Alex Major
Hi there.
I'm working my way through a new script, but I've stumbled into a problem.
Some data that I've set into a session, won't be processed by part of my php
code, but then later on in the page I can get the session value to output.

Also, just so that its clear, the mysql code is correct (I can put it into
phpmyadmin and get results from it.

Heres the code (this code is 'included' in another page, where the session
originates and session_start(); is set.)



  
 
  
  
Food: 
Wood: 
Stone: 
Gold: 
Session id is: 
  


The error may not necessarily be to do with the session, but non of the
$current_resources are showing.

Thanks for any help guys/gals.

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



Re: [PHP] An annoying session problem

2006-06-19 Thread Alex Major
Thanks for pointing that out, however I've changed the code to:



  

  
  
Food: 
Wood: 
Stone: 
Gold: 
Session user_id is: 
  


And I'm still not getting the output correctly.
I don't think that the SELECT query is working properly, is there  problem
with how I've put:
WHERE user_id = '".$_SESSION['user_id']."'

Regards, 
Alex.


On 19/6/06 16:51, "phpninja" <[EMAIL PROTECTED]> wrote:

>   
> 
> that should be  or  $_SESSION['username']; ?>
> 
> its all in how you call the variables..   isint telling the
> variable to do anything.
> 
> -phpninja

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



Re: [PHP] An annoying session problem

2006-06-19 Thread Alex Major
Hmpf, well I feel like a real tit now.
I tried all the posted suggestions, and still couldn't figure out why it
wasn't working. 
I went back to re-code the whole page from scratch, started off with include
'connection.php', then it hit me...i hadn't included the connection file in
the parent file to the include, so it wasn't (and couldn't) connect to the
database. I put the connection file into the parent file, and now its
working!

Sorry to have taken so much time up with such a silly little thing.

Regards, 
Alex.


On 19/6/06 18:52, "tedd" <[EMAIL PROTECTED]> wrote:

> At 12:27 AM +0700 6/20/06, Gmail nya Suprie wrote:
>> tedd wrote:
>>> Alex Major wrote:
>>> 
>>>> And I'm still not getting the output correctly.
>>>> I don't think that the SELECT query is working properly, is there  problem
>>>> with how I've put:
>>>>   WHERE user_id = '".$_SESSION['user_id']."'
>>>>   
>>> 
>>> Maybe I'm all wet here, but what's the the periods?
>>> 
>>> Why isn't it:
>>> 
>>> WHERE user_id = '"$_SESSION['user_id']"'
>>> 
>> 
>> I don't think the script will work... the period is used to combine two
>> variables or string
>> example :
>> $foo = "hai ";
>> $bar = "there ";
>> so $foo.$bar will produce "hai there"
> 
> Yes, I understand concatenation operators -- but I don't think they will work
> in this setting.
> 
> Just try my suggestion and see if it will work.
> 
> tedd

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