• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Web Dev> Use onFocus to clear a value and onBlur to replace empty values

Oct17
2011
Written by Scott Rowley

The following can be used to clear a value. I regularly use this for website search bars.

<script>
function blank(a) { if(a.value == a.defaultValue) a.value = ""; }
function unblank(a) { if(a.value == "") a.value = a.defaultValue; }
</script>
<input type="text" value="email goes here" onfocus="blank(this)" onblur="unblank(this)" />

This post was updated using code found here, which I think works a little nicer.

Posted in Web Development - Tagged clear, dev, development, html, Javascript, onclick, this, value, web

Recursively set group permissions to match owner permissions

Oct10
2011
Written by Scott Rowley

I have had need of this multiple times in the past, just making a note of it here:

chmod -R g=u directory_name/
Posted in BASH - Tagged chmod, directory, group, owner, permissions, recursive

Web Dev> Build HTML table from MySQL table using PHP

Aug23
2011
Written by Scott Rowley

Last night I was struggling for several hours trying to figure out how to get this working. After many googlings I finally found my answer and modified it to the following:
The $key in the following will be your column title (field) and the $value is the rows value. In the following I will be populating based off one particular row (in this case it has an id of 1).

print "<table border='1'>";
$sql = "SELECT * FROM table_name WHERE id=1";
$result = mysql_query($sql)or die(mysql_error());
while ($row = mysql_fetch_assoc($result)) {
foreach($row as $key => $value) {
print "<tr><th>" .$key. "</th><td><input type='text' value='" .$value. "' /></td></tr>";
}
print "</table>";

MySQL table:
myql table

Resulting PHP/HTML table from code:
html table

Posted in Uncategorized

osTicket> Alert Department on Ticket Transfer

Aug11
2011
Written by Scott Rowley

Ok this isn’t as nice as my normal MODs, its a bit clunky since its all statically written but it should do the trick nonetheless. This has only been tested right now on 1.6RC5, please let me know if you have success on 1.6ST with it and I’ll update this note. Cheers!

Purpose: When transferring a ticket to another department, the new department will receive an email alerting them to the assignment.

include/class.ticket.php
Inside the function transfer, under ‘global $cfg;’ Add the following:

$sql = 'SELECT email,dept_name FROM ost_email LEFT JOIN ost_department on ost_email.email_id=ost_department.email_id WHERE ost_department.dept_id='.$deptId;
print $sql;
$result = mysql_query($sql) or die(mysql_error());
while($row = mysql_fetch_array($result)){
echo "Department email is " .$row['email'];
$ticketNumber=$this->getId();
$to = $row['email'];
$deptName = $row['dept_name'];
$subject = "Ticket [#$ticketNumber] Assigned";
$message = "$deptName,\n\nTicket #$ticketNumber has been assigned to you.\n\nhttp://YOUR_DOMAIN.EXT/scp/tickets.php?id=$ticketNumber";
$headers = "From: FROM_EMAIL@YOUR_DOMAIN\r\n";
$headers .= "Reply-To: no-reply@YOUR_DOMAIN\r\n";
$headers .= "X-Mailer: PHP\" . phpversion() . \"\r\n";
mail($to, $subject, $message, $headers);
}

If there is enough desire for it I may some day add it into the template database for emails and such but right now this set in there statically was enough for me. As always let me know if you have any questions or concerns.

Posted in osTicket - Tagged alert, department, email, osTicket, ticket, transfer

PHP> Export simple MySQL query to .csv file

Aug08
2011
Written by Scott Rowley

The following will allow you to export your mysql queries from mysql to a csv file that can be opened in several spreadsheet softwares. You may need to change the , (comma) to a ; (semi-colon) depending on your software.

A note for those of you using my osTicket Reports MOD: This is not what I’m using for that.

<?php
$host = 'localhost';
$user = 'userName';
$pass = 'password';
$db = 'databaseName';
$table = 'tableName';
$file = 'export';
$link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
mysql_select_db($db) or die("Can not connect.");
$result = mysql_query("SHOW COLUMNS FROM ".$table."");
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
$csv_output .= $row['Field'].", ";
$i++;
}
}
$csv_output .= "\n";
$values = mysql_query("SELECT * FROM ".$table."");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].", ";
}
$csv_output .= "\n";
}
$filename = $file."_".date("Y-m-d_H-i",time());
header("Content-type: application/vnd.ms-excel");
header("Content-disposition: csv" . date("Y-m-d") . ".csv");
header("Content-disposition: filename=".$filename.".csv");
print $csv_output;
exit;
?>
Posted in MySQL, PHP, Web Development - Tagged csv, dev, development, excel, export, file, libre, MySQL, office, open, php, web

Media> Shoutcast ‘No such file or directory’

Jul29
2011
Written by Scott Rowley

You’ve got a 64-bit operating system and you are trying to run the 32-bit variant of Shoutcast.

32-bit Shoutcast on 64-bit OS

# ./sc_serv
-bash: ./sc_serv: No such file or directory

For CentOS, RedHat and Similar:

yum install lib32-glib

For Debian/Ubuntu:

apt-get install ia32-libs
# ./sc_serv
*******************************************************************************
** SHOUTcast Distributed Network Audio Server
** Copyright (C) 1998-2004 Nullsoft, Inc. All Rights Reserved.
** Use "sc_serv filename.ini" to specify an ini file.
*******************************************************************************
Posted in Ubuntu - Tagged apt-get, audio, cast, directory, file, ia32-libs, install, media, no, shout, shoutcast, such, yum

Web Dev> PHP created random password

Jul22
2011
Written by Scott Rowley
<?php
// The letter l (lowercase L) and the number 1
// have been removed, as they can be mistaken
// for each other.
function RandomPass() {
// Comment the first line to exclude special characters
$chars = "!@#$%^&*";
$chars .= "abcdefghijkmnopqrstuvwxyz023456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
srand((double)microtime()*1000000);
$i = 1;
$pass = '' ;
// Number of digits we'd like to have our password be
$n = 8;
while ($i < $n) {
$num = rand() % strlen($chars);
$tmp = substr($chars, $num, 1);
$pass = $pass . $tmp;
$i++;
}
return $pass;
}
// Usage
$password = RandomPass();
echo "Random password is: $password";
?>
Posted in Web Development - Tagged create, dev, development, microtime, password, php, rand, random, return, srand, substr, web, while

osTickets> Reports v5.0

Jun13
2011
Written by Scott Rowley


IT’S HERE! REPORTS 6.0 FOR OSTICKET VERSION 1.7

NOTE: If you are running any versions from 2.3 to 4.1 the “Replies per Staff” report is WRONG. I strongly suggest you upgrade to 4.2+

Ok, so after being on the osTicket forum since July 2009 I’ve noticed that one big MOD that everyone wants and never fully gets is reporting. The following is my stab at it.

This MOD has been implemented and tested on 1.6ST and 1.6RC5, please let me know if you run into any issues.

Note: For version 3.3+ you will need to create a scp/reports folder (and make sure its writable by Apache) and place the image (csv.png) into the scp/images folder.


Requirements: MySQL 5
pChart (for use with emailed reports) requires the GD and FreeType PHP extensions.

Note: Reports v2.4+ is compatible with Internet Explorer.

osTickets Reports osTickets Reports
osTickets Reports osTickets Reports
READ MORE »

Posted in MySQL, osTicket, PHP - Tagged date_add, date_format, date_sub, day, department, interval, mod, modification, month, MySQL, osTicket, php, report, reports, staff, year

Linux> Aliases

Jun08
2011
Written by Scott Rowley

Aliases can be a great way to more easily remember an oddball command or to shorten a long command. Aliases are stored in your .profile (or .bash_profile) or within a include file referenced from .profile.

A couple of quick examples before showing how to set them up:
READ MORE »

Posted in BASH, Ubuntu - Tagged alias, basic, conditional, epoch, ggrep, grep, if, include, linux, Perl, print, profile, reload, solaris, time, ubuntu, unix, whois

Joomla> Repair c99madshell hacked site

Jun07
2011
Written by Scott Rowley

This is information on removing the c99madshell hack that can get into some Joomla 1.5 sites. Most of this content is an original article of News Blog. I was only able to find one portion of this myself before finding their article, kudos and thanks go to them.

If you see the following Joomla error appearing on most Joomla pages including admin section

File Not Found The requested URL was not found on this server
OR
If you have a list of spam links

then your installation has likely been compromised. There is a security bug in Joomla 1.5 allowing a hacker to reset your admin password.

You should take the following steps to get rid of the error message and secure your Joomla:
READ MORE »

Posted in Joomla, Web Development - Tagged button.gif, c99madshell, file, found, hack, Joomla, not, response.php, spam, tw4x
« Older Entries Newer Entries »

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top