Re: [PHP] Date comparison going wrong, wrong, wrong

2012-11-12 Thread Duken Marga
Try this:

$todaydate = strtotime(date(D, M jS, Y g:i:s a));
$showenddate = strtotime(date(D, M jS, Y g:i:s a,
strtotime($showsRecord['end_date'])));

if ($todaydate  $showenddate):
echo The date of the show has not yet arrived;
else:
echo The show has ended;
endif;

You must convert both $todaydate and $showendate with strtotime() function,
then you can compare them.

On Mon, Nov 12, 2012 at 1:30 AM, Terry Ally (Gmail) terrya...@gmail.comwrote:

 Hi all,

 I am having a problem with comparing time. I am using the following:

 $todaydate = date(D, M jS, Y g:i:s a);
 $showenddate = date(D, M jS, Y g:i:s a,
 strtotime($showsRecord['end_date']));

 if ($todaydate  $showenddate):
 echo The date of the show has not yet arrived;
 else:
 echo The show has ended;
 endif;

 The problem that I am encountering is that PHP is rendering the reverse of
 the equation. For example:

 If today's date is *11 Nov 2012* and the show's end date is *18 Nov 2012*,
 the message that I am getting is *the show has ended* which is wrong. A
 test example is at http://www.lakesidesurrey.co.uk/test.php.

 You can also me what I am doing wrong?

 Thanks
 Terry




-- 
Duken Marga


Re: [PHP] set up mass virtual hosting with apache/nginx and PHP ... best practice 2012?

2012-08-25 Thread Duken Marga
From my experience to maintain many virtual host, I prefer use Apache + PHP
+ suPHP. I think this combination will be able to cover your ideal
situation above. But, I usually use authentication via shell user
(/etc/user). You must find tutorial or something that integrate Apache and
Active Directory (there are many out there).

suPHP is designed to replace suExec (default Apache mod). It will run a PHP
file as a user that own the files. There are no problem if you want to use
it for many user, because suPHP is designed for that. For user who will
uploade file, you can always use FTP to access their own file. Each user
can has their own .htaccess in their own directory and all the websites
will have one global rule in httpd.conf.

On Wed, Aug 22, 2012 at 6:26 AM, D. Dante Lorenso da...@lorenso.com wrote:

 All,

 I need to set up a server to enable 5,000 students to have web hosting
 provided by the school with PHP and MySQL support.  I'm trying to figure
 out what is the best way to do this.

 We have Active Directory and are using Centrify to authenticate usernames
 and passwords on our Linux servers.  I am imagining it would be great if we
 use something like ExecCGI to ensure that PHP runs as the user that owns
 the files.  We would then provide FTP access to the files and FTP would
 authenticate against Active Directory making sure to set the proper
 user/group on files when uploaded.

 I see that PHP-FPM exists: http://php-fpm.org  and it claims Ability to
 start workers with different uid/gid/chroot/environment and different
 php.ini (replaces safe_mode) which is exactly what I'm looking for.  It
 also claims PHP-FPM is now included in PHP core as of PHP 5.3.3. so
 that's good.

 I also read about the greatness that is NGinX: http://nginx.org though I
 don't know if I can use it because I think I also need to use .htaccess
 files.  I need a way for students to be able to password protect their
 directories and files.  If there's another way using NGinX or Apache,
 that's good too.  I know of no other way.

 Here is an interesting article from 2009:
 http://www.howtoforge.com/how-**to-set-up-mass-virtualhosting-**
 with-apache2-mod_rewrite-mod_**userdir-mod_suexec-on-centos-**5.3http://www.howtoforge.com/how-to-set-up-mass-virtualhosting-with-apache2-mod_rewrite-mod_userdir-mod_suexec-on-centos-5.3

 That uses mod_rewrite to attempt something like what I'm trying to do ...
 and then, Apache has mod_vhost_alias:
 http://httpd.apache.org/docs/**2.2/mod/mod_vhost_alias.htmlhttp://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html

 So, I see a lot of information out there.  Apache, NginX, ExecCGI,
 FastCGI, mod_vhost_alias, mod_rewrite, SuExec, mod_userdir.  I suspect some
 of these methods are old and out of date.

 In my ideal situation:

  - users would be created in AD and would exist on the OS

  - student domain names would look like:
 http://username.student.**school.edu/http://student.school.edu/- 
 OR -
 http://student.school.edu/**username/

  - file directories would look like:
 /mnt/somedir/username/**docroot

  - students would be able to create PHP applications executed with
 their own permissions

  - I would be able to configure all 5,000 accounts with a single
 configuration (1 virtual host rule?)

 Do you know what the best practices are for now ... here in 2012?

 -- Dante


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




-- 
Duken Marga


Re: [PHP] set up mass virtual hosting with apache/nginx and PHP ... best practice 2012?

2012-08-25 Thread Duken Marga
On Sun, Aug 26, 2012 at 2:30 AM, D. Dante Lorenso da...@lorenso.com wrote:


 Using VirtualDocumentRoot, I was able to create a virtual host defined
 like this:


VirtualHost *:80
 ServerName student.sampledomain.edu
 ServerAlias *.student.sampledomain.edu

 DocumentRoot 
 /mnt/web/student.sampledomain.**edu/docroothttp://student.sampledomain.edu/docroot
 UseCanonicalName Off
 VirtualDocumentRoot /mnt/userwww/%-4+

 ErrorLog |/usr/bin/logger -p local6.notice -t 'error-student'
 CustomLog |/usr/bin/logger -p local6.notice -t 'access-student' full
 /VirtualHost

 That maps domain names like 
 username.student.**sampledomain.eduhttp://student.sampledomain.eduto 
 directories in the /mnt/userwww/username directory.  That gets me
 close, but isn't handling PHP yet.  I think Apache also runs as 'apache'
 user when reading all the files, so users must chmod their files world
 readable still for this to work.

 I don't know what you means isn't handling PHP yet. If you want Apache
handling a PHP program, you must integrate PHP and Apache, in FreeBSD and
Apache, these lines must be written in httpd.conf:

# Apache 2.x
LoadModule php5_modulelibexec/apache/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

The above lines will tell apache to execute php file as a PHP program.
For your latest statement, Yes, default Apache will handling program as
'apache' user. But, if you use suPHP, suExec, or other similiar program,
the file will be execute as a user that own the files. So, in other words,
you must use 'chown' program to assure the php files is own by the right
user. The files still readable with that program if you use secure and
right mode with 'chmod' program. For security reason, you must always use
755 for directory and mode 644 for files.


 You reference suPHP as the way to go.  The problem I have with that is
 this website:
 http://www.suphp.org/Home.html

 Looks like the last update was back in 2009.  That's more than 3 years
 ago.  I think that project has stalled.  There must be something newer that
 has replaced it since then.

 I think the suPHP project is not dead yet. It's because the program is
small and just doing a simple task and if the suPHP program still work for
the latest Apache today, why do we must question it? Even small notepad
from 10 years ago can still be used today, right? If you want advanced and
simple task to manage files for each user, you must buy commercial program
like cPanel or Plesk.


-- 
Duken Marga


Re: [PHP] syntax error breaking in and out of php into html code

2012-08-25 Thread Duken Marga
Can you tell us what is the error shown in browser or CLI?

On Sun, Aug 26, 2012 at 5:54 AM, Ashley Sheridan
a...@ashleysheridan.co.ukwrote:

 I've just inherited some (pretty awful code) that I have to make some
 edits to, and came across a bit of a problem. A lot of the code breaks
 in and out of PHP and into HTML code:

  ?php
 while(condition)
 {
 ?
 lisome html here/li
 ?php
 }
 ?

 But when I check this my PHP parser is saying that this is a syntax
 error (checked in the browser and CLI). I know this is code from a
 working site, so it must be a setting within my PHP configuration.

 Now, I'm intending to re-write this anyway, as the logic is all over the
 place (SQL queries within the HTML, no separation of code and content,
 dozens of warnings all over the place) but I was wondering what setting
 causes this. It's mostly a curiosity thing really, as this thing is
 going to be re-written faster than an school project the eve before
 hand-in.

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





-- 
Duken Marga


Re: [PHP] PHP Database Problems

2012-05-02 Thread Duken Marga
But I don't see any attachments in this message.

On Thu, May 3, 2012 at 2:28 AM, Jim Lucas li...@cmsws.com wrote:

 I do believe attachments are allowed.  Looking back, I see that there have
 been messages sent to the list that had odt, php, and ini attachments


 On 05/02/2012 12:12 PM, Gavin Chalkley wrote:

 Ethan,

 Some coding you are using would be helpful (as far as i am aware
 attachments
 are not support on the mailing list's)

 Gav

 -Original Message-
 From: Ethan Rosenberg [mailto:eth...@earthlink.net]
 Sent: 02 May 2012 19:54
 To: php-db-lists.php.net; php-general@lists.php.net
 Subject: [PHP-DB] PHP  Database Problems

   have a database

 mysql  describe Intake3;
 ++-+--**+-+-+---+
 | Field  | Type| Null | Key | Default | Extra |
 ++-+--**+-+-+---+
 | Site   | varchar(6)  | NO   | PRI | |   |
 | MedRec | int(6)  | NO   | PRI | NULL|   |
 | Fname  | varchar(15) | YES  | | NULL|   |
 | Lname  | varchar(30) | YES  | | NULL|   |
 | Phone  | varchar(30) | YES  | | NULL|   |
 | Height | int(4)  | YES  | | NULL|   |
 | Sex| char(7) | YES  | | NULL|   |
 | Hx | text| YES  | | NULL|   |
 ++-+--**+-+-+---+
 8 rows in set (0.00 sec)

 mysql  describe Visit3;
 ++--+-**-+-+-+**+
 | Field  | Type | Null | Key | Default | Extra  |
 ++--+-**-+-+-+**+
 | Indx   | int(4)   | NO   | PRI | NULL| auto_increment |
 | Site   | varchar(6)   | YES  | | NULL||
 | MedRec | int(6)   | YES  | | NULL||
 | Notes  | text | YES  | | NULL||
 | Weight | int(4)   | YES  | | NULL||
 | BMI| decimal(3,1) | YES  | | NULL||
 | Date   | date | YES  | | NULL||
 ++--+-**-+-+-+**+

 and a program to enter and extract data.

 I can easily extract data from the database. However, if I try to enter
 data, it goes into the incorrect record.  Following are some screenshots.
 The program is attached.  [pardon the comical names.  This is a test, and
 any resemblance to true names is not intentional]

 Let us say that I wish to deal with Medical Record 1:


 This it data from Intake3:
 Site Medical Record First Name Last Name Phone Height Sex History AA 1
 David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o
 success

 This is data from Visit3:
 Index Site Medical Record Notes Weight BMI Date
 2322 AA 1 Second Visit. 170 27.4 2010-01-20
 2326 AA 1 Third visit. Small progress, but pt is very happy. 165
 26.6 2010-02-01


 I then request to enter additional data:

 Site Medical Record First Name Last Name Phone Height Sex History
 AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his
 friends that he is obese. Normal BMI = 23.
 Index Site Medical Record Notes Weight BMI Date

 Notice that it is entered into record 10003

 The data is First Try

 Index Site Medical Record Notes Weight BMI Date
 2590 AA 10003 First Try 189 31.4 02 May 2012

 Help and advice, please.

 Thanks.

 Ethan





 --
 Jim Lucas

 http://www.cmsws.com/
 http://www.cmsws.com/examples/
 http://www.bendsource.com/


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




-- 
Duken Marga


Re: [PHP] PHP Database Problems -- Code Snippets

2012-05-02 Thread Duken Marga
 352-3908
 F: 845 352-7566
 mailto:erosenberg@**hygeiabiomedical.comerosenb...@hygeiabiomedical.com
 erosenber**g...@hygeiabiomedical.com erosenb...@hygeiabiomedical.com



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




-- 
Duken Marga


Re: [PHP] whats wrong

2012-03-31 Thread Duken Marga
Please check this line:
 $result=mysql_query(select(SELECT*FROM COLLEAGUE);

I think it should be:
  $result=mysql_query(SELECT * FROM COLLEAGUE);

On Sat, Mar 31, 2012 at 1:45 PM, saeed ahmed mycomputerbo...@gmail.comwrote:

 i have made a php script with a tutorial helpi dont know where is a
 error.please have a look


 ?php
 //connect and select a database
 mysql_connect(localhost,root,  );
 mysql_select_db(addressbook);
 //Run a query
 $result=mysql_query(select(SELECT*FROM COLLEAGUE);
 ?
 !DOCTYPE html PUBLIC-//w3c//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 head
 titleAddress Book/title
 meta http-equiv=content-type content=text/html;charset=utf-8
 /head
 body
 h1Address Bookh1
 table Border=1 cellpadding=2cellspacing=3
 summary=table holda colleague contacts information
 tr
 th ID/th
 thFirst Name/th
 thLast Name/th
 thTelephone/th
 thEmail Address/th
 /tr
 ?php
 //LOOP through all table rows
 while ($row=mysql_fetch_array($result)) {
 echotr;
 echotd.$row['id'] . /td;
 echo td . $row['firstName'] . /td;
 echo td . $row['lastName'] . /td;
 echo td . $row['telephone'] . /td;
 echo td . Srow['email'] . /td;
 echo/tr;
 }
 //free result memory and close database connection
 mysql_free_result($result);
 mysql_close();
 ?
 /table
 /body
 /html
 thanks




-- 
Duken Marga


Re: [PHP] how to execute Exe file in system

2012-02-17 Thread Duken Marga
Try to write full path to executable file and don't forget to bring
double quote to that path. It must because Program files contain
space and php think your program is Program that contain parameter
files.

if(system(' C:\Program Files\GAMS23.7\gams.exe trnsport_php.gms')


On Fri, Feb 17, 2012 at 6:26 PM, Negin Nickparsa nickpa...@gmail.com wrote:
 I have a Gams 
 applicationhttp://interfaces.gams-software.com/doku.php?id=env%3aspawning_gams_from_php
  which I want to run it through php code after trying many things finally I
 found that for running in commmand line I should go to C:\Program
 Files\GAMS23.7 run a command in commandline for running the application as
 follows:

 gams.exe trnsport_php.gms

 the Gams wil be run successfully in commandline now I wanted to run it in
 php I added an alias with this path

 C:\Program Files\GAMS23.7

 and then I created my php file in there when I want to exacute it with this
 code in php:

 if(system('gams.exe trnsport_php.gms'))
 echo 'Not Error';
 else echo'Error';

 it shows me Error

 and again using this one:

 if(system('./gams.exe trnsport_php.gms'))
 echo 'Not Error';
 else echo'Error';

 has printed again Error

 I tried exec too but no result I don't know what is wrong here.

 I read the manual but I coudn't find what's wrong here

 echo system('dir')

 will show the files of   C:\Program Files\GAMS23.7



-- 
Duken Marga

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



Re: [PHP] how to execute Exe file in system

2012-02-17 Thread Duken Marga
I think it's wrong:
system(' C:/Program Files/GAMS23.7/gams.exe C:/Program
Files/GAMS23.7/trnsport_php.gms'))

Instead, try this:
system(' C:/Program Files/GAMS23.7/gams.exe C:/Program
Files/GAMS23.7/trnsport_php.gms '))

It is a good practice to write full path because we don't know
behaviour any operating system we use when we just use simple name.


On Fri, Feb 17, 2012 at 7:12 PM, Negin Nickparsa nickpa...@gmail.com wrote:
 if (($out = system(' C:/Program Files/GAMS23.7/gams.exe C:/Program
 Files/GAMS23.7/trnsport_php.gms')) !== FALSE)
 {
  print('Not error!');

  printf('Output is %s', $out);
 }
 else
 {
  print('Error');
 }
 Fatih it shows again nothing why I should set the full path even when I run
 my file on the path I don't think so that it is needed I don't know how to
 work with these quotations was it right Duken?



-- 
Duken Marga

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



Re: [PHP] php sendmail_from

2012-01-10 Thread Duken Marga
Actually, you can send an email from explicit email addres without
modifying htaccess or php ini.
In simple words, PHP uses MTA (like postfix or sendmail) to send email to
another email address. An email consist of header, body, and mime (for
example an attachment). Sender, receiver, Subject, and other parts of
message are laid in header. Body is used to store the message.

We can use PHP to write the header of message so we can change sender email
address. For example:

?php
$to  = 'nob...@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmas...@example.com' . \r\n .
'Reply-To: webmas...@example.com' . \r\n .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?

You can see the example above from PHP manual.

On Tue, Jan 10, 2012 at 1:53 AM, alexus ale...@gmail.com wrote:

 I need to change sendmail from field, I added following to my .htaccess:

 php_value sendmail_from 'x...@xxx.xxx'

 and tried to send out an email, but it still comes from apache@FQDN

 through phpinfo(); I see as local value my email address x...@xxx.xxx

 --
 http://alexus.org/

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




-- 
Duken Marga
http://duken.info


Re: [PHP] PHP 5.3.2 max_execution_time

2012-01-01 Thread Duken Marga
If you want to upload large file, maybe you should consider maximum
uploaded size. You can change setting in php.ini on line that contain *
upload_max_filesize*.

On Mon, Jan 2, 2012 at 5:13 AM, Chris Tapp opensou...@keylevel.com wrote:

 I've got a Dokuwiki installation that is producing Apache errors saying
 that the maximum execution time of 30 seconds has been exceeded.

 So, I went and changed max_execution_time in php.ini expecting that this
 would solve the problem (which is due to large files taking a while to
 upload over an ADSL connection). However, the error log still reports that
 the old 30 second value is in use, even though Apache has been restarted.

 phpinfo() for the same site reports max_execution_time as 120 seconds, so
 it seems as if the change to php.ini has been detected as expected. Is
 there another setting that I need to consider? max_input_time is already
 set to 60 seconds and there are no local 'php_value' Apache configuration
 items fighting the ones in php.ini.

 PHP version is 5.3.2 and is running under a CentOS 6.0 system.

 Chris Tapp

 opensou...@keylevel.com
 www.keylevel.com




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




-- 
Duken Marga


Re: [PHP] mysql_fetch_object() equivalent for mongoDB

2011-09-07 Thread Duken Marga
Actually, there is no statement in PHP that can return data from
MongoDB as object (CMIIW). Data are returned as array.
You can convert this array to object using (object).
Look an example at
http://www.richardcastera.com/blog/php-convert-array-to-object-with-stdclass

$posts = (object) $mongo-find();
echo 'Id: ' . $posts-Id;

-- 
Duken Marga

On Wed, Sep 7, 2011 at 1:28 PM, chamila gayan cgcham...@gmail.com wrote:
 hi all,

 Is anybody aware of mysql_fetch_object() equivalent/similar implementation
 for mongoDB?
 thanks..

 ~Chamila Gayan


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