Category Archives: Notepad

htaccess max upload size in wordpress

I had a host today that wouldn’t allow wordpress to upload any files (images/themes/plugins).

It turns out some .htaccess magic saved the day:

SecFilterScanPOST Off
php_value upload_max_filesize 32M
php_value post_max_size 32M
php_value max_execution_time 300
php_value max_input_time 300

Given that it’s in the .htaccess file, it will only work on some hosts that allow you to configure php via the .htaccess, but hey if it works great!

Thanks to this site for help

Building CSS sprites using Python Glue

css-sprite was giving me some issues so I went looking for a different way to tackle the problem.

While a pain in the rear end to install, I found Glue. Given I already had all the python stuff installed it was pretty easy for me to get it working for this project.

  1. Install Glue http://glue.readthedocs.org/en/latest/installation.html
  2. Run Glue, here is the command that I like:
    glue src glue –scss –sprite-namespace= –namespace= –cachebuster

(The above command, looks for all the images in the src folder, and then outputs into the glue folder).

While the scss support is woeful, the retina side of things seems to be working better. (Although I’m not using the retina switch in the command above).

osTicket 1.9.4 –Easy Custom Column in Ticket View

By popular demand, I have update the instructions for the Easy Custom Column for osTicket 1.9.4 for form lists.

What does this allow you to do?
It allows you to show a custom form list in your Agents Ticket Queue. This is rather helpful for when you have a list of items relating to your business and you want to be able to see it.

I have only tested this code with lists.

The full code can be found here:

https://gist.github.com/a-bennett/6febddc9e328151dc99a

For those who are interested in doing it themselves (or maybe have already edited there tickets.inc.php file) you can see the changes between the original file and the updated here:

https://gist.github.com/a-bennett/6febddc9e328151dc99a/revisions

How do I find the form ID?

  1.   By looking at the table _form_field and finding your form object by looking down the list of the labels, then once you have found it taking the ID from that row.
  2. If you know how to inspect an web element, (using web inspector, firebug, etc) then you can try the following:
    In the admin panel go to “Manage” -> “Forms” -> click on your form name.
    Inspect the input field of the name of your item mine came up like this:
    <input type=”text” size=”32″ name=”label-17″ value=”Business”>
    Then take the number after the “label-X” so mine is 17.

For those interested here is a break down:

At the top of the file add the following two lines:
$ab_list[‘field_id’] = “XX”; //ID from from _form_field table
$ab_list[‘heading’] = “XXXXXXX”; //Name displayed to front end users.

~Line 169:
Update the $sortOptions array withe the following:

$sortOptions=array(‘date’=>’effective_date’,’ID’=>’ticket.`number`*1′,
‘pri’=>’pri.priority_urgency’,’name’=>’user.name’,’subj’=>’cdata.subject’,
‘status’=>’status.name’,’assignee’=>’assigned’,’staff’=>’staff’,
‘dept’=>’dept.dept_name’,
‘custom1’=>’Custom1′); //AB Added

~Line 253
Append to the end of the $qselect. variable the following: (remember to move the ;)
.’ ,cdata.’.$CustomList1Name.’ as Custom1′; //AB – Custom 1

~Line 262
Add the following to the $qfrom variable straight after the line:

.’ LEFT JOIN ‘.TABLE_PREFIX.’ticket__cdata cdata ON (cdata.ticket_id = ticket.ticket_id) ‘
.’ LEFT JOIN ‘.TABLE_PREFIX.’form_entry_values fentry_val ON (cdata.field_’.$ab_list[“field_id”].’ = fentry_val.entry_id) AND fentry_val.field_id = ‘.$ab_list[“field_id”] //AB We need to link to the form values as of 1.9.4

~Line 412

Add in the following header row just above the </tr>.

<!– AB – Custom Col 1 –>
<th width=”60″ >
<a <?php echo $custom1_sort; ?> href=”tickets.php?sort=custom1&order=<?php echo $negorder; ?><?php echo $qstr; ?>”
title=”Sort By <?php echo $CustomList1Desc; ?> <?php echo $negorder; ?>”><?php echo $CustomList1Desc; ?></a></th>
<!– AB – Custom Col 1 -–>

 

~Line 498

Add in the data row just about the </tr>
<!– AB – Custom Col 1 –>
<td nowrap>&nbsp;<?php echo $row[‘Custom1’]; ?>&nbsp;</td>
<!– AB – Custom Col 1 –>

~ Line 511

Finally update the footer colspan to make everything balanced.

<td colspan=”8″>

RaspberryPI – AdagiosPI – Installing Nagvis

Nagvis has some issues installing with:
apt-get install nagvis

Here are the extra steps to get it running.

1). Fix the permissions outlined in the file /usr/share/doc/nagios3/README.Debian ( cat /usr/share/doc/nagios3/README.Debian will print out the contents in to the terminal).

2). Edit the backend config, in the web GUI go to Options -> Manage Backends. Then under “Edit backend” select live_1 and change the socket to: unix:/var/lib/nagios3/rw/livestatus
set a timeout to 30 (not sure if this is correct, sounded fun at the time).

3). Edit WuiViewEditMainCfg.php with the changes found here: http://sourceforge.net/p/nagvis/nagvis/ci/c7eb03fe37130546adfe298408606213f2d2fd9a/

nano /usr/share/nagvis/share/server/core/classes/WuiViewEditMainCfg.php
(instead of removing lines, I just added // as a comment).

Resources:
http://serverfault.com/questions/517362/php-error-mk-livestatus-in-nagvis
http://www.monitoring-portal.org/wbb/index.php?page=Thread&threadID=25901
https://www.mail-archive.com/[email protected]/msg1086669.html

osTicket 1.9.4 – Show Due Date Column

Andrew (another one) got in contact with me asking if I could help him to how to show an extra column in osTicket 1.9.4, he tired to follow my previous post without much luck (after rereading it, I’m surprised if that’s ever helped anyone!).

He wanted the ability to see and sort by a “Due Date” column. Well it turns out to be a really easy feature to add.

Here is a GitHub Gist of the modified tickets.inc.php

Instructions for use:

  1. Backup /[osticket-install]/include/staff/tickets.inc.php
  2. Download the following file and copy it to /[osticket-install]/include/staff/tickets.inc.php
  3. Test! (If it break badly, I’m sorry, please restore your backup file).

As a side note, it also got me to finally setup a github account!

Here is the step by step instructions:

  1. Update the sort options ~Line 170.Effectively what we are doing here is adding the ‘duedate’=>’duedate’ to the array. So replace $sortOptions with below:
    [gist id = “c66ef9d90bdcbf874685” file = “step-1.php” width = “90%”]
  2. Add the heading to the table ~Line 374
    Just add the following line in after the closing </th> tag for the line <a <?php echo $date_sort; ?>………
    [gist id = “c66ef9d90bdcbf874685” file = “step-2.php” width = “90%”]
  3. Add the data row to the table ~ Line 468
    After the <td align=”center” nowrap><?php echo Format::db_datetime($row[‘effective_date’]); ?></td> add:
    [gist id = “c66ef9d90bdcbf874685” file = “step-3.php” width = “90%”]
  4. Finally fix up the footer ~ Line 506
    Change <td colspan=”7″> to:
    [gist id = “c66ef9d90bdcbf874685” file = “step-4.php” width = “90%]
  5. Thats it!

Don’t break it!

 

Generate CSS sprites from cmd with css-sprite and node.js

Update: I’ve also found a different method, this time instead using a Python script called “Glue“.

I did this about 12 months, but recently had to setup a new development environment.
Here are some notes on setting up css-sprite.

  1. Install node.js
  2. Install css-sprite
    npm install css-sprite -g
  3. Have fun.

Usage:

  1. Create two folders src (add png files here) and images
  2. run the command from cmd:
    css-sprite images/ src/*.png -p scss -s sprite.scss 
  3. (Here I'm using scss, you can choose from LESS, SCSS or CSS, depending on the project).

cforms v14.6 – switching to custom CSS 403 error

Quick Notes:
TL;DR – When activating a custom CSS from the folder:
/plugins/cforms-custom/[your-css-file].css
You get a 403 error while running WordPress 4.

The issue seems to be in: cforms-css.php
~Line: 142:
Change: echo ‘<option style=”background:#fbd0d3″ selected=”selected” value=”../../cforms-custom/’.$f.'”>’.$f.'</option>’.”\n”;
To: (removing one of the ../)
echo ‘<option style=”background:#fbd0d3″ selected=”selected” value=”../cforms-custom/’.$f.'”>’.$f.'</option>’.”\n”;

Then again on ~Line: 144:
echo ‘<option value=”../../cforms-custom/’.$f.'”>’.$f.'</option>’;
To: (removing one of the ../)
echo ‘<option value=”../cforms-custom/’.$f.'”>’.$f.'</option>’;

This then causes an issue on the frontend. To fix this:

edit: cforms.php

Replace the following (~Line 1209):

if( $cformsSettings[‘global’][‘cforms_no_css’]<>’1′ )
echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . $cforms_root . ‘/styling/’ . $cformsSettings[‘global’][‘cforms_css’] . ‘” />’.”\n”;

With:

if( $cformsSettings[‘global’][‘cforms_no_css’]<>’1′ ){
if (strpos($cformsSettings[‘global’][‘cforms_css’],’cforms-custom’) !== false) {
$cformsCSSpath = “/”;
}else{
$cformsCSSpath = ‘/styling/’;
}
echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . $cforms_root . $cformsCSSpath . $cformsSettings[‘global’][‘cforms_css’] . ‘” />’.”\n”;
}

 

 

I hope that helps someone.

 

This doesn’t appear to work on both the front and the back end…

osTicket 1.9.2 – Easy Custom Column in Ticket View

Dec 14 Update:While these rough instructions can be roughly used in osTicket 1.9.4, it doesn’t return the value from a list, just an ID (Which on a technical level is better in the long run, just makes this process a little harder).
I’m working on fixing this and will post the info once I’ve had a chance to work it out.
New instructions for 1.9.4 can be found here: https://www.andrewbennett.com.au/2014/12/osticket-1-9-4-easy-custom-column-in-ticket-view/

TL;DR (I rushed these notes for myself).

File to edit: /include/staff/tickets.inc.php

1) Added To the top to make things easier. (line 2-3)
The Name field (currently “field_17” ) needs to be worked out from the database by looking at the [tbl_prefix]_ticket__cdata
The Desc field (Currently “Sample 1”) is what your users will see as the column heading.

$CustomList1Name = “field_17”;
$CustomList1Desc = “Sample 1”;

2) Add custom1 to allow sorting. (~Line 157)

$sortOptions=array(‘date’=>’effective_date’,’ID’=>’ticket.`number`’,
‘pri’=>’pri.priority_urgency’,’name’=>’user.name’,’subj’=>’cdata.subject’,
‘status’=>’ticket.status’,’assignee’=>’assigned’,’staff’=>’staff’,
‘dept’=>’dept.dept_name’,
‘custom1’=>’Custom1’); //AB Added

3) Edit the last two lines, frst remove the ; after “pri.priority_color'” then add the last line  (~Line 243)
After line:

$qselect.=’ ,IF(ticket.duedate IS NULL,IF(sla.id IS NULL, NULL, DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)), ticket.duedate) as duedate ‘
.’ ,CAST(GREATEST(IFNULL(ticket.lastmessage, 0), IFNULL(ticket.closed, 0), IFNULL(ticket.reopened, 0), ticket.created) as datetime) as effective_date ‘
.’ ,CONCAT_WS(” “, staff.firstname, staff.lastname) as staff, team.name as team ‘
.’ ,IF(staff.staff_id IS NULL,team.name,CONCAT_WS(” “, staff.lastname, staff.firstname)) as assigned ‘
.’ ,IF(ptopic.topic_pid IS NULL, topic.topic, CONCAT_WS(” / “, ptopic.topic, topic.topic)) as helptopic ‘
.’ ,cdata.priority_id, cdata.subject, pri.priority_desc, pri.priority_color’
.’ ,cdata.’.$CustomList1Name.’ as Custom1 ‘ //AB – Custom 1
;

4) Add Column Heading (~ Line 337)

<!– AB – Custom Col 1 –>
<th width=”60″>
<a <?php echo $custom1_sort; ?> href=”tickets.php?sort=custom1&order=<?php echo $negorder; ?><?php echo $qstr; ?>”
title=”Sort By <?php echo $CustomList1Desc; ?> <?php echo $negorder; ?>”><?php echo $CustomList1Desc; ?></a></th>
<!– AB – Custom Col 1 –>

5) Add Column Data (~ Line 435)

<!– AB – Custom Col 1 –>
<td nowrap>&nbsp;<?php echo $row[‘Custom1’]; ?>&nbsp;</td>
<!– AB – Custom Col 1 –>

When I get around to it I will upload the file to github or bitbucket.