Thomas Hambach - Web engineer

Web development & web design
home   -   portfolio   -   resume -   contact
Vroooooooaaaap, i'm an airplane

php

August 22nd, 2008 by Thomas Hambach

PHP Get monday, sunday, last monday & last sunday

A function I’ve put togheter for a work-related project to get date of monday, sunday, last monday & last sunday.. Might add in next monday and sunday later.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Get Mondays and Sundays
*
* Get monday, sunday, last monday & last sunday
* Example usage:
*
* // to retreive the dates using today as starting point
* $mondaysAndSundays = getMondaysAndSundays();
* // to retreive the dates using a custom date as starting point
* $mondaysAndSundays = getMondaysAndSundays('1987-04-14');
*

*
* @param date $offset Provide a date from where to calculate from in strtotime() translatable format. If none is given, today’s date will be used.
*
* @return array
*
*/
function getMondaysAndSundays($offset=false)
{

if(!$offset) $offset = strtotime(date(’Y-m-d’));
else $offset = strtotime($offset);

// this week
if(date(’w',$offset) == 1)
{
$mas['monday'] = date(’Y-m-d’,$offset);
}
else
{
$mas['monday'] = date(’Y-m-d’,strtotime(”last Monday”,$offset));
}

if(date(’w',$offset) == 6)
{
$mas['sunday'] = date(’Y-m-d’,$offset);
}
else
{
$mas['sunday'] = date(’Y-m-d’,strtotime(”next Sunday”,$offset));
}

// last week
if(date(’w',$offset) == 1)
{
$mas['lastmonday'] = date(’Y-m-d’,strtotime(’-1 week’,$offset));
}
else
{
$mas['lastmonday'] = date(’Y-m-d’,strtotime(’-1 week’, strtotime(date(’Y-m-d’,strtotime(”last Monday”,$offset)))));
}

if(date(’w') == 6)
{
$mas['lastsunday'] = date(’Y-m-d’,strtotime(’-1 week’,$offset));
}
else
{
$mas['lastsunday'] = date(’Y-m-d’,strtotime(”last Sunday”,$offset));
}

return $mas;
}

April 17th, 2008 by Thomas Hambach

vTiger slow account/products popup

After plowing through tons of code from both vTiger and ADOdb and pushing Google search to the max, I finally found a forum topic on vtiger.com covering the problem we were having with vTiger. The problem was that the popup to select an account or a product had load times averaging 60seconds. That’s a huge usability issue (read: waste of time) when you are creating invoices or filling out your calendar.

Anyway, all the more reason to place it on my blog, with the all right keywords!

And now, for the solution:

Quoting onwealdandy
However, I fixed the performance issue with a work around that doesn’t make much sense, but worked. I read this forum post a few days ago, but couldn’t see how commenting out debug print lines would speed things up. But, that did the trick. However, I did narrow it down to the exact variable causing the ruckus ($list_result) , so I only had to comment out just a few lines in ListViewUtils.php. (any debug log lines with $list_result)

Even with logging set to FATAL, the slowness would occur. When you did set logging to DEBUG, one instance would show the correct information in the debug log for the debug log lines .. basically what you would expect when printing $list_result (which is a recordset object) .. the object id … “Object id #40″ … however on the slow machine it would actually print the 2000+ records which were returned by the query.

There must be a bug in php or apache or mysql ( no idea) that returns the entire result set to $list_result when its evaluated for printing. My guess is that the libmysql.dll must have a default _tostring method in there in some versions. BE CAREFUL .. since there its not documented which versions do this … for the record, my troubled instance was running php5.2.5, apache 2.2.6, and mysql 5.0.45

You can find the original vTiger topic here: http://forums.vtiger.com/viewtopic.php?p=64335

February 13th, 2008 by Thomas Hambach

hostgator upgrades all their servers to PHP & MySQL 5

I was very pleased to receive an e-mail from hostgator today, in which they stated that they will be upgrading all servers to have MySQL 5 and PHP 5 installed by default! I hope this will send out a message to the other hosting firms, which would finally allow us to start using PHP5 in all our opensource projects.

Read the rest of this entry »

Posted in php, random | 1 Comment »
February 11th, 2008 by Thomas Hambach

always_populate_raw_post_data disabled? here’s a workaround

Since HostGator does not support changing the value of always_populate_raw_post_data in PHP to “1″, I had to find a work around. After spending an hour Googling my issue and it turning zero-dot-zero results I was forced into being creative.

Appearantly you can use the input wrappers to go around this setting. Perhaps you could find this useful in the future

1
2
3
4
5
6
7
8
9
<php
if(!$HTTP_RAW_POST_DATA){
$HTTP_RAW_POST_DATA = file_get_contents(’php://input’);
if(empty($HTTP_RAW_POST_DATA))
{
// die here
}
}

September 17th, 2007 by Thomas Hambach

why vTiger is a great CRM

In my previous post I listed everything that sucks about vTiger. This time I’ll point what makes it a great CRM.

  1. It’s fully opensource! You’ll be able to modify it as much as you want and there’s a bunch of plugins -made by the vTiger community- ready for download!
  2. Outlook integration. I admit it’s not perfect but the source code of this plugin is available on sourceforge ;)
  3. Adding a field to a form is -almost- easy as 1 2 3! You can easily add custom fields thorugh the administration panel.
  4. You don’t have to start writing a CRM from scratch. Everything you need is in there!
  5. Very user-friendly interface

And that’s all I could find… I just had a quick look at the other Opensource CRM’ options there are and vTiger will be the best option out there if you want to be able to modify your CRM’s functionality and want all the basic functions already incorporated.

Posted in php, vtiger | 4 Comments »

Categories

Archives


Linky stuff

copyright 2008 by http://www.rdlt.com
Entries (RSS) - Register - Log in
Wordpress - RDLT Media - mortgage companies