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

Most Popular

  • osTickets > Reports v4.2 (18056)
  • HTPC > Setup Windows 7 as a Media Center with XBMC (10962)
  • osTicket > View headers for original email message (4173)
  • WebDev > Allow PHP in Wordpress Widgets (3615)
  • Web Dev > Password protect webpage(s) with PHP & LDAP (2475)

Web Dev > Validate Password creation with PHP

Dec06
2011
Leave a Comment Written by Scott Rowley

The following can be used to test for different criteria in passwords.

<?php

$min = 6;
$max = 20;
$password = $_POST['password'];
$confirmpw = $_POST['confirmpw'];

if($password != $confirmpw){
    $error .= "Password and Confirm password do not match! <br />";
}

if( strlen($password) < $min ) {
    $error .= "Password too short! <br />";
}

if( strlen($password) > $max ) {
    $error .= "Password too long! <br />";
}

if( !preg_match("#[0-9]+#", $password) ) {
    $error .= "Password must include at least one number! <br />";
}

if( !preg_match("#[a-z]+#", $password) ) {
    $error .= "Password must include at least one letter! <br />";
}

if( !preg_match("#[A-Z]+#", $password) ) {
    $error .= "Password must include at least one CAPITAL! <br />";
}

if( !preg_match("#\W+#", $password) ) {
    $error .= "Password must include at least one symbol! <br />";
}

if($error){
        echo "Password Failure: $error";
} else {
  // Code to execute on success.
}
?>
ajax loader
Posted in PHP, Security, Web Development - Tagged check, confirm, password, php, secure, security, validate, validation, verify
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

vmWare > Boot to fullscreen VM after host boots.

Nov02
2011
Leave a Comment Written by Scott Rowley

Create a shortcut with the following TARGET.

“C:\Program Files\VMware\VMware Workstation\vmware.exe” -X “C:\Users\YOUR_USER\Documents\Virtual Machines\VMNAME\FILENAME.vmx”
New Shortcut

The -X opens in Full screen (before you go looking, I’ll save you the trouble – there is no dual screen option as of the writing of this article.)
Replace “C:\Users\YOUR_USER\Documents\Virtual Machines\VMNAME\FILENAME.vmx” with your vmx file location.
The quotes are required.

Put the shortcut into the Windows Startup folder
Windows Startup Folder

Voila!
Ubuntu

ajax loader
Posted in Ubuntu, vmWare, Windows - Tagged fullscreen, host, vmware, workstation boot
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

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

Oct17
2011
Leave a Comment Written by Scott Rowley

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

<script type="text/javascript">
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.

ajax loader
Posted in Web Development - Tagged clear, dev, development, html, Javascript, onclick, this, value, web
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Recursively set group permissions to match owner permissions

Oct10
2011
Leave a Comment 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/
ajax loader
Posted in BASH - Tagged chmod, directory, group, owner, permissions, recursive
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > Build HTML table from MySQL table using PHP

Aug23
2011
Leave a Comment 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

ajax loader
Posted in Uncategorized
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

osTicket > Alert Department on Ticket Transfer

Aug11
2011
Leave a Comment 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.

ajax loader
Posted in osTicket - Tagged alert, department, email, osTicket, ticket, transfer
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

PHP > Export simple MySQL query to .csv file

Aug08
2011
Leave a Comment 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."");
$i = 0;
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;
?>
ajax loader
Posted in MySQL, PHP, Web Development - Tagged csv, dev, development, excel, export, file, libre, MySQL, office, open, php, web
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Media > Shoutcast ‘No such file or directory’

Jul29
2011
Leave a Comment 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.
*******************************************************************************
ajax loader
Posted in Ubuntu - Tagged apt-get, audio, cast, directory, file, ia32-libs, install, media, no, shout, shoutcast, such, yum
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

Web Dev > PHP created random password

Jul22
2011
2 Comments 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 = 0;
    $pass = '' ;

    while ($i <= 7) {
        $num = rand() % strlen($chars);
        $tmp = substr($chars, $num, 1);
        $pass = $pass . $tmp;
        $i++;
    }

    return $pass;

}

// Usage
$password = RandomPass();
echo "Random password is: $password";

?>

ajax loader
Posted in Web Development - Tagged create, dev, development, microtime, password, php, rand, random, return, srand, substr, web, while
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail

osTickets > Reports v4.2

Jun13
2011
266 Comments Written by Scott Rowley

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

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

osTickets Reports osTickets Reports
osTickets Reports
READ MORE »

ajax loader
Posted in osTicket - Tagged date_add, date_format, date_sub, day, department, interval, mod, modification, month, MySQL, osTicket, php, report, reports, staff, year
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Older Entries Newer Entries »

Be Heard!

Authors needed! Feel like sharing your tech wisdom with the world? We are looking to expand our writer base and would love to hear from you. We need articles on any relevant technology/software/media/howto/etc (Well...lets at least hold to the legal stuff ;)

Just email scott (at) sudobash (dot) net

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

Sudo Bash Member sites

Des Moines, Iowa Karate Classes
Iowa MMA Tournaments
Iowa SAR
Ooo-er
5point Studios Tattoo & Piercing

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

RSS HowToGeek

  • Week in Geek: Aero Glass Feature will be Removed from Windows 8
  • How to Speed Up Web Browsing with Search & Bookmark Keywords
  • Geek Trivia: Pagers Were First Developed To Assist Which Professionals?
  • The Best Tips and Tricks for Using Email Efficiently
  • Desktop Fun: Starry Skies Wallpaper Collection Series 2

RSS TheGeekStuff

  • UNIX / Linux Processes: C fork() Function
  • How to Calculate IP Header Checksum (With an Example)
  • How to Encrypt Your Bash Shell Script on Linux Using SHC
  • Intro to DOCSIS Architecture, CM CMTS Protocol for Cable Modems
  • Ettercap Tutorial: DNS Spoofing & ARP Poisoning Examples

RSS LifeHacker

  • DIY Maple-Flavored Pancake Syrup [Breakfast]
  • This Week's Top Downloads [Download Roundup]
  • Make Mini Dutch Baby Pancakes in a Muffin Tin [Breakfast]
  • Pour Vinegar Down Your Drain Every Three Months to Keep Clogs Away [Video]
  • Use the Jelly Pocket Method for a Better Drip-Free PB&J [Food Hacks]

EvoLve theme by Blogatize  •  Powered by WordPress Sudo Bash
By Geeks - For Geeks

Back to Top