Recent Entries
Feb 23, 2009 Linux, Lost+Found, osticket, Software, Windows
As you already know osTicket is a support ticket system which is very easy to use and free. Developers from osTicket are back, they fixed a few bugs and cleaned a little bit most of the code.
Features:
- Multilanguage client interface: You can add as many languages as you want for the client side.
- Error messages can be “catched” and identified by a unique MD5 key which you can translate it in your language file.
- You can configure the Ticket ID field to be a password field or just a text field for “security”.
- It comes with 2 cool, light and fully XHTML valid themes which you can easily modify colors and also the HTML because of it’s clean design.
- It has a built-in CAPTCHA module that will protect you from SPAM.
- Search tickets based only on ticket’s subject.
- Easy to install.
- Last but not least, it’s 100% free, but that doesn’t mean you are allowed to remove credits
It has been tested a while now but it’s still on a beta stage, however, you might find some bugs and I’ll be happy to get some feedback from you. I didn’t include the Spanish language file this time, but I’ll do it someday
If you want to translate it to other language feel free to send me your language file and I’ll include it in the next release
Here are some screenshots:
This specific version is a patched one from Nov/30/2010 which includes all the post-install instructions here, spanish translation included and all the patches needed to work with osTicket 1.6.0 (Stable), get it here: Download osTicket CTheme for 1.6.0 (Stable) (1808)
*** This is still very old news, keeping them there just for the archives ***
Are you still reading? Ok, you deserve it… Download osTicket CTheme (3484) (Compatible with 1.6 RC5)
Necesitas el tema en español? Descarga el archivo osTicket CTheme Spanish Language (2410)
When you uncompress the file it will create a directory called “client”, that directory should be copied to osTicket’s root dir and the rest of the installation instructions are in the README file, have fun!
** Post install notes and bug fix:
- The file thankyou.inc.php from this template has a code error in line 10: $ctlang->docatch($msg?) which should be changed for $ctlang->docatch($msg)?
- Inside osTicket’s root dir, edit the index.php and comment (or delete) all the html code in order to see the template display correctly, then you just need to add this line before the footer in included: require(CLIENTINC_DIR.’main.inc.php’);. This bug and others will be fixed in the next release soon.
Dec 18, 2008 Code, Linux, Software
This is a simple PHP script which will update your dynamic DNS records using EditDNS.
Features:
- You can configure as many records as you want.
- Supports HTTP and HTTPS.
- For PHP 4x and higher compiled with sockets.
- Simple validation.
Here is the code: (editdns.php)
#!/usr/bin/php -q
<?
$port = 443; // use 80 if you dont wanna use SSL
// add as many arrays as you want, first element is the record
// and the second is the password
// $data[] = array('myrecord1.domain.com','mypass1');
// $data[] = array('myrecord2.domain.com','mypass2');
// ... etc etc etc ;)
$data[] = array('somerecord.resolveme.com','blahblah123');
$sleep = 1; // seconds we should sleep before updating another record
// main loop
if (!is_array($data)) die("Nothing to do\n");
foreach ($data as $v) {
echo "Updating $v[0] ... ";
if(_send($port,"p=$v[1]&r=$v[0]")) echo "[OK]\n";
sleep($sleep);
}
function _send($port=443,$args="") {
if ($port == 443) $proto = "ssl";
else $proto = "http";
$fp = fsockopen("$proto://dyndns.editdns.net",$port,$errno,$errstr,10);
if (!$fp) die("\nCouldn't establish connection\n");
$out = "POST /api/dynLinux.php HTTP/1.0\r\n";
$out .= "Host: dyndns.editdns.net\r\n";
$out .= "Content-Type: application/x-www-form-urlencoded\r\n";
$out .= "Content-Length: ".strlen($args)."\r\n";
$out .= "Connection: Close\r\n\r\n";
$out .= $args;
//echo $out;
fwrite($fp, $out);
while (!feof($fp)) {
$res .= fgets($fp,1024);
}
fclose($fp);
$parts = explode("\r\n\r\n",trim($res));
//print_r($parts);
// checking output
if (preg_match("/record has been updated|record already exists/i",$parts[1])) return 1;
// anything else should be an error
echo "[ERROR]\n\t$parts[1]\n";
return 0;
}
?> |
Save it, chmod +x and play with it.
Old sources:
http://forums.nerdie.net/showthread.php?t=616
http://xux.in/blog/post/ip-updater-for-editdnsnet/
ADS!!!
Nov 24, 2008 Code, Ensim, Linux, Lost+Found, Software
Ensim former Parallels Pro Control Panel X for Linux has a command line interface scripts as you SHOULD know
which allows you to do several administrative tasks without login to the appliance. The other day I started to write an API in order to admin N Ensim servers with only 1 interface which is a lot of work/code but hell, I’ll post some screenshots later
… So one of the biggest problems I had was the script ChangePasswdVirtUser (located in /usr/local/bin), which allows you to change a virtual user’s password asking for the new password 2 times and I didn’t want to ruin my weekend and decided to hack that script and make it work like this: ChangePasswdVirtUser domain.com user newpassword
That’s so insecure! I know and I’ll come later with a more secure alternative don’t worry
in the meantime you can play with it:
File: /usr/local/bin/ChangePasswdVirtUser1
#!/usr/bin/ensim-python
#
# Usage:
#
# ChangePasswdVirtUser <domainname> <username> <passwd>
#
# Example:
#
# AddVirtUser myco.com joe doe
import getopt
import getpass
import sys
import traceback
from vh3 import virthost
from vh3 import virtutil
from vh3.modules import users
import string
import be_vherrordisp
if (len(sys.argv) < 4) or (sys.argv[1] == "--help"):
print "usage: ChangePasswdVirtUser1 <domainname> <username> <passwd>"
sys.exit(0)
else:
# checks to see if we are in maintenance mode
virthost.checkMaintenance()
status = be_vherrordisp.CLIError.SUCCESS
status_obj = be_vherrordisp.CLIError()
options, args = getopt.getopt(sys.argv[1:],"")
siteindex = virthost.get_site_from_anything(string.lower(args[0]))
username = string.lower(args[1])
passwd1 = args[2]
if not siteindex:
print "Domain %s does not exist on this server."% string.lower(args[0])
sys.exit(1)
ret = []
try:
virthost.edit_user(ret, siteindex, username, None, passwd1, None, None)
status = virthost.cli_display_status_list(ret)
except:
status = be_vherrordisp.CLIError.ERROR
print traceback.print_exc()
sys.exit(status) |
Nov 24, 2008 Code, Linux, Lost+Found, Software
I ran into a small issue when migrating some sites to a cPanel server, tried a few “tricks” (/scripts/* –force hehe) without luck till I found a great post which pointed me the solution, and it is as simple as that!
Since I’m a very lazy guy, I wrote a tiny script which does what Jerry (from cPanel forums) said/explained. Copy the code, save it and execute it. By default it won’t do anything but show the directories and files current state and how they should be. If you see something is not as it should be then you should change the $debug var to false in order to allow the script to do the job. After that everything should be fixed and if not don’t blame me, you can always do that manually
#!/usr/bin/php -q
<?
// file: fix_auth_perms.php
// turn it off if you want to fix them
// based on http://forums.cpanel.net/showpost.php?p=323248&postcount=3
$debug = true;
$maps = file("/etc/domainusers");
if (!is_array($maps)) die("No users found!\n");
foreach ($maps as $map) {
list($user,$domain) = explode(": ",trim($map));
if (!$user || !$domain) continue;
echo "\nChecking $domain ...\n";
_file_fix("/home/$user/etc",$user,"mail");
_file_fix("/home/$user/etc/$domain",$user,"mail");
_file_fix("/home/$user/etc/$domain/shadow","","mail","0640");
//exit;
}
// $file = full dir/file path
// $nuser = desired user name
// $ngroup = desired group name
// $perms = desired permissions in octal mode (0640)
function _file_fix($file="",$nuser="",$ngroup="",$perms="") {
global $debug;
$uname_array = posix_getpwuid(fileowner($file));
$gname_array = posix_getgrgid(filegroup($file));
$file_perms = substr(sprintf('%o', fileperms($file)), -4);
echo " $file owned by $uname_array[name].$gname_array[name] ($file_perms)\n";
//wrong ownership, fixing it now!
if (!$debug) {
if ($nuser && $nuser != $uname_array[name]) {
if (!chown($file, $uname_array[name])) echo " couldn't change file owner to $nuser\n";
else echo " changed file owner to $nuser\n";
}
if ($ngroup && $ngroup != $gname_array[name]) {
if (!chgrp($file, $gname_array[name])) echo " couldn't change group owner to $ngroup\n";
else echo " changed group owner to $ngroup\n";
}
}
if ($perms && $perms != $file_perms) {
if (!$debug) {
if (!chmod($file,octdec($perms))) echo " couldn't change file mode to $perms\n";
else echo " changed file mode to $perms\n";
}
}
//making a nice output :P
if (!$nuser) $nuser = $uname_array[name];
if (!$ngroup) $ngroup = $gname_array[name];
if (!$perms) $perms = $file_perms;
echo " $file should now be owned by $nuser.$ngroup ($perms)\n";
}
?> |
Nov 8, 2008 Ensim, Linux, Lost+Found, Software, Windows
What is Samba? If you don’t know what it is then you shouldn’t be reading this
Samba can do a lot of things and we are only cover a basic configuration that will allow you to share specific folders on a Linux machine in the same way you share forlder in a Windows machine.
This will cover a very quick installation and setup of Samba on any Linux flavor, however in this particular case I’ll cover CentOS 5.2
First you need to install Samba’s binaries using yum
(you can use apt-get or up2date if you want)
yum install samba samba-common |
Installation stage has been covered, that was fast
Now we need to do a basic configuration in order to start using it and we need to design a structure… let’s say I want to setup a Linux machine to share a specific folder to everyone with read-only access and a specific folder for only local user with read/write access, so here we go:
cd /etc/samba
mv smb.conf smb.conf.backup
nano smb.conf |
And paste the following configuration on the new smb.conf
[global]
netbios name = sambaserver
load printers = no
path = /home
default service = global
security = share
available = no
[share]
path = /var/ftp/pub
guest ok = yes
read only = yes
comment = Public Access
available = yes
[sambademo]
path = /home/demo
guest ok = no
writable = yes
valid users = demo
comment = User demo home
available = yes |
So far we have setup a basic global configuration, a public access area and a restricted area for a local user called “demo”. Before we continue you need to make sure the folder /var/ftp/pub exists. Now, before we start our new Samba server, we need to setup the “demo” account and it can be done in 2 ways:
useradd -s /sbin/nologin demo
smbpaswd -a demo |
If we don’t want to give this user shell access, or…
useradd -s /bin/bash demo
passwd demo
smbpasswd -a demo |
If we want to give this user access to shell and of course we need to set the same password for the system and Samba.
It is time to start our Samba server:
Now let’s try it, on Windows do the following: Start -> Run -> cmd
net use y:\\samba_server_ip\share
net use z:\\samba_server_ip\demo /user:demo thepasswordyouset |
Hopefully you will see you have 2 new units on your Windows File Explorer, Y which is a read-only folder and Z which is a read/write folder
that’s all!
If you want to do more things with Samba and you are lazy you can always get Webmin and use its module to configure Samba and use its advanced options.
NOTE: This article is for educational purposes and should be treated as it is.
Troubleshooting:
- The network name cannot be found: Check your computer’s firewall or if your ADSL/DSL modem, sometimes by default they block all outgoing connections to Netbios port which is 139.
- Anything else check your log files /var/log/samba/smb.log
Literature: (Thanks to them, this tutorial exists)
Sunny Walia
Joel Barrios Dueñas
Samba
Oct 23, 2008 Code, Ensim, Linux
Nothing but an easy to use backup script for Ensim (4.X-10.X) which uses vhexport, so yeah, it’s not fast, but I wrote it because sometimes you just need to backup 1 or a few sites and drop them somewhere
You just need to type this:
./backupsingle.php /path/to/backup domain1.com domain2.com ...domainN.com |
And you’ll see something like this:
Building site's structure... found NN sites
Building backup for N site(s)
Starting backup for domain domain1.com (site1)... [OK]
Starting backup for domain domain2.com (site2)... [OK]
Starting backup for domain domainN.com (siteN)... [OK] |
Can’t be easier
copy the code, save it and chmod +x that’s all
#!/usr/bin/php -q
<?
// dirty code, no comments ;)
$vhexport = '/usr/local/bin/vhexport';
$sitelookup = '/usr/local/bin/sitelookup';
if (count($argv) <= 2) die("Usage: $argv[0] /backup/path domain1 domain2 ...domainN\n");
$path = $argv[1]; $limit = (count($argv)-1);
if (!is_dir($path)) die("$path doesn't exist, creat it first!\n");
if (preg_match("/\/$/",$path)) $path = substr($path,0,-1);
echo "Building site's structure... "; sleep(1);
$ds = explode("\n",trim(`$sitelookup -a site_handle,domain`));
if (!is_array($ds)) die("Server is empty!\n");
foreach ($ds as $dlines) {
$tmpparts = explode(",",trim($dlines));
if (!is_array($tmpparts)) continue;
$domains[$tmpparts[1]] = $tmpparts[0];
}
echo "found ".count($ds)." sites\n"; sleep(1);
echo "Building backup for ".($limit-1)." site(s)\n\n";
for ($i=2;$i<=$limit;$i++) {
$bdomain = $argv[$i];
$bsite = $domains[$bdomain];
if (!$bsite) { echo "Looks like $bdomain has not a valid site_handle, aborting...\n"; continue; }
echo "Starting backup for domain $bdomain ($bsite)... ";
$cmd = $vhexport . ' -s ' . $bsite . ' -U "file://' . $path . '/%(type)-%(name)" -z';
//echo "\n[debug] $cmd\n";
`$cmd`;
echo "[OK]\n";
}
?> |
Sep 28, 2008 Code, Ensim, Linux, Lost+Found
I’ve found some interesting error on some Ensim servers, some users having issues with their quotas and if you remove it and add it again you get the same quota issues. So, after a few minutes I noticed that the users UID’s with issues were duplicated on other sites and that’s a BIG problem.
Ensim uses a postgres database called “appldb” and a table inside “free_uids” (with fields ‘uid’, ‘site_id’) where it stores UID’s and their relation with site’s numbers, so when a user is deleted the field “site_id” is set to nothing and becomes available for the next user.
I did a small/dirty php script in 10 minutes, it’s very simple but effective. It checks if some UID is duplicated. Check the source:
* Create a file somewhere called “check_uids.php”
* Open it and paste the following code:
#!/usr/bin/php -q
<?
echo "Checking your system for duplicated id's...n";
$lines = explode("n",`/bin/cat /home/virtual/site*/fst/etc/passwd`);
if (!is_array($lines)) die("No duplicated UID's found!");
foreach($lines as $k => $v) {
$parts = explode(":",$v);
if ($parts[2] < 22000) continue;
if ($uids[$parts[2]]) { $uids[$parts[2]] .= ",$parts[3]"; $winners[$parts[2]] = true; }
else $uids[$parts[2]] = $parts[3];
}
if (!is_array($winners)) { echo "Your system has no duplicated entries :)n"; exit; }
foreach ($winners as $k => $v) echo "Duplicated UID : $k on GID's: ".$uids[$k]."n";
?> |
* chmod +x check_uids.php
* execute it: ./check_uids.php
If you see a “Duplicated UID…..” then that means you have the same issue I had.
How can I solve that issue?
I’ve found a primitive way to do it, if you have a better one let me know
* Case: UID 220001 is in group 503 (site1) and 504 (site2)
* BACKUP ALL YOUR INFORMATION!
* Go to site2 and remove the user with the UID (normally you can find the username at /home/virtual/site1/fst/etc/passwd)
* Browse your pgsql, appldb -> free_uids and search for the UID at the field “uid” (if you are not a pgsql geek get the latest webmin, install it and have fun)
* Edit the pgsql “site_id” field (which should be empty) and put the value “1″ (which corresponds to the site1)
* Add the user from the site2 again
* Run the script again, if you are lucky you are out of danger
NOTE: In the worse scenario I’ve seen the same UID on 5 different groups… that’d need an extra coffee
Sep 22, 2008 Code, Ensim, Linux
I wrote this small script a few years ago (2005). This script allows you to add/delete 1 or more DNS zones and trust me, when you need to add 300 domains to your Ensim box you’ll come back to thank me
Basicly, the script asks you for 2 options:
What do you want to do?
[1] Add zone(s)
[2] Delete zone(s) |
Then, you’ll need to write the domain(s) separated by spaces and also the IP address and that’s all. By default it uses Ensim’s DNS zone template but you can change it to whatever you want.
File: mdns.php
#!/usr/bin/php -q
<?
// This settings should be OK!
// Add more if you need ;)
define('DEBUG',true); // make it 'false' if you want to see it work
define('DPATH','/usr/lib/opcenter/bind/');
define('ADD',DPATH.'add_zone');
define('REM',DPATH.'remove_zone');
define('AA',DPATH.'add_a');
define('AMX',DPATH.'add_mx');
main_menu();
function main_menu() {
?>
What do you want to do?
[1] Add zone(s)
[2] Delete zone(s)
Option: <?
$option = get_line();
switch ($option) {
case "1":
$__domains = option_domains();
$__ip = option_ip();
option_confirm();
add_domains($__domains,$__ip);
break;
case "2":
$__domains = option_domains();
option_confirm();
rem_domains($__domains);
break;
default:
main_menu();
}
}
function add_domains($domains=array(),$ip="") {
if (!$domains[0] || !$ip) {
print_out("\nThere are no domain(s) or ip, please start again <ENTER>\n");
get_line();
main_menu();
return;
}
foreach ($domains as $k => $v) {
print_out("\nAdding Zone $v ...\n");
ecmd(ADD." -f ".$v);
print_out("\nAdding A (www,ftp,mail) and MX records ...\n");
ecmd(AA." -u $v $ip");
ecmd(AA." -z $v www $ip");
ecmd(AA." -z $v ftp $ip");
ecmd(AA." -z $v mail $ip");
ecmd(AMX." $v mail.".$v." 10");
}
}
function rem_domains($domains=array()) {
if (!$domains[0]) {
print_out("\nThere are no domain(s), please start again <ENTER>\n");
get_line();
main_menu();
return;
}
foreach ($domains as $k => $v) {
print_out("\nRemoving Zone $v ...\n");
ecmd(REM." ".$v);
}
}
function ecmd($cmd="") {
if (!$cmd) {
echo "Nothing to execute!\n";
return;
}
$cmd = escapeshellcmd($cmd);
print_out("\t$cmd\n");
if (!DEBUG) {
$out = `$cmd 2>&1`;
}
}
function option_domains() {
print_out("\nEnter domain or domains separated by spaces or comas:\n");
$line = get_line();
$domains = preg_split('/\s+|,/',$line,-1,PREG_SPLIT_NO_EMPTY);
if (!$domains[0]) {
print_out("\nYou need to enter at least one domain name, press any key to continue...");
get_line();
main_menu();
}
print_out("\nCheck your information submitted: ");
$i = 1;
foreach ($domains as $k => $v) {
echo "($i)$v ";
$i++;
}
print_out("\n");
return $domains;
}
function option_ip() {
print_out("\nEnter the IP: ");
$line = get_line();
if (!$line) {
print_out("\nYou need to enter an IP, press any key to continue...");
get_line();
main_menu();
}
print_out("\nCheck your information submitted: $line\n");
return $line;
}
function option_confirm($info="") {
print_out("\nIs this information correct?\n$info\n");
print_out("Type 'return' to start over again, 'exit' to quit this application or any other key to continue...");
$line = get_line();
if (preg_match('/return/i',$line)) main_menu();
elseif (preg_match('/exit|quit|bye/i',$line)) exit;
else return;
}
function print_out($line="") {
if (!$line) return;
echo "$line";
}
function get_line() {
$fh = fopen("php://stdin","r");
$stdin = trim(fgets($fh));
fclose($fh);
return $stdin;
}
?> |
Sep 12, 2008 Ensim, Linux, Software
This tutorial will cover Moodle’s 1.9.2 installation on a server running Ensim 4.x – 10.x / PHP5 / MySQL 4.1 – 5.2 (as root)
“Moodle is a course management system (CMS) – a free, Open Source software package designed using sound pedagogical principles, to help educators create effective online learning communities.” For more info go to Moodle’s official website.
1. First check your server meets the specifications listed. You will need additional packages and can be found here.
2. wget http://download.moodle.org/stable19/moodle-1.9.2.tgz on /home/virtual/siteX/fst/var/www/html/
3. tar zxf moodle-1.9.2.tgz
4. chown -R adminX:adminX moodle
5. mkdir ../moodledata
6. chown -R apache:apache ../moodledata
7. Create a MySQL database for moodle. I.E. domain_com_moodle
8. Go to http://www.domain.com/moodle/install.php , select your language installation and ***WAIT***, check what it’s needed. Everything will look fine and you should only see 2 warnings about PHP low file uploads limit and PHP safe mode.
pico or vi /etc/php.ini and verify the following values are set like this:
safe_mode = Off
safe_mode_gid = Off
memory_limit = 24M ; Let moodle suck some memory;)
upload_max_filesize = 16M ; 8M is the default however is kinda small, set it to whatever you might need |
* If you don’t want to mess with global values then edit the php.ini located at /home/virtual/siteX/fst/etc/php.ini
9. Restart HTTPD: service httpd restart
10. Refresh the page http://www.domain.com/moodle/install.php and check everything is fine. If you still see the Safe Mode warning then edit /etc/httpd/conf/httpd20_app.conf and find the line “php_admin_flag safe_mode on”, change it to “php_admin_flag safe_mode off” and restart HTTPD again.
11. Refresh the page http://www.domain.com/moodle/install.php and EVERYTHING now should be fine, if not please go back to http://docs.moodle.org/en/Installing_Moodle and dig more.
12. Now you can continue with the installation process. It should go smooth and it will ask you to copy the config file because the script has no access to write. Just copy the text, create a file “config.php” on the moodle directory and chown adminX:adminX config.php , continue with installation.
13. Once installation is done you can go to http://www.domain.com/moodle and login as admin with password admin, get inside ASAP and change the login and admin password
Now your Moodle is up and running, have fun!
* For some users this mini-howto can be silly but still Ensim makes some applications hard to install because of it’s nature.
* If something goes wrong, don’t blame me, this is only an un-official guide.
Happy Moodlin’