How to remove Captcha from Phpmotion v3

Video site for personal videos
I have been looking around for a Youtube style video script for a while, and after trying a few, including Joomla and WordPress with video plugins, I decided to give Phpmotion a go. The main reason is that I want a site that will just play local avi/divx/mpg/mp4 videos from a local /videos directory, NOT from Youtube and other “hosted” video sites.

Problems
Phpmotion has caused me no end of problems so far, but i’m intending to see it through, as it is quite a nice site once you hack it to get it working.

Squeeze and Php 5.3 –> Lenny 5.2 and Php 5.2
1. Doesn’t support Php 5.3 yet, which is a pain as we have just upgraded all our work and home servers to Debian Squeeze, so I had to install a Debian Lenny on our work Kvm machine. Also it doesn’t look like the Phpmotion developer is going to upgrade any time soon: http://phpmotion.com/forum/index.php?topic=19028.0

Captcha is borked
2. The Captcha on phpmotion is borked, and there are a lot of support requests on the forums regarding this problem:
Google: site:phpmotion.com/forum captcha+doesn’t+show
The solution offered by the devs is “Just downgrade to Php 5.2”.
It appears the best way is to just remove it. (Hence the title of this post)

X doesn’t exist on this server
3. As I type, there are still files and directories that are be reported as not found, when clearly they are there, and have the correct permissions.

a) I created a new test account, logged in (account exists), then went to my profile http://domain/phpmotion/members/test only to get a 404 error page:
Not Found
The requested URL /phpmotion/members/test was not found on this server.

b) As administrator, I tried to upload a test video, only to be told that /cgi-bin/uu_upload.pl doesn’t exist, as you can see below it plainly does!.
test@lennyapache:/var/www/phpmotion/cgi-bin$ ls
audio uu_default_config.pm uu_ini_status.pl uu_lib.pm uu_upload.pl

c) There is more, profile directories that don’t exist, upload directories that don’t exist, phpmotion files that don’t exist etc etc. But anyway, i’ll keep hacking until I get some sort of functionality.

PS: If you want to have a Captcha-free Phpmotion, rename this “inner_signup_form.txt” to “inner_signup_form.htm” and upload it to your “phpmotion/themes/default/templates” directory 🙂

Shopt for Bash – Cdspell for cd dir change mistypes

What is shopt? A marvellous BASH builtin command, that’s what it is!

I’ve added the whole shopt list to my .bashrc below, but i’m only going to talk about CDSPELL for cd dir change mistypes. One thing to remember is that if you issue a shopt command manually as a user or root, then close your terminal, it will revert back to OFF. I have added the shopt options to my .bashrc so that I can enable and disable the specific options i need. There are a few that are enabled by default, so if you decide you want them disabled permanently you just add a -u switch before them.
See the syntax below for enabling and disabling shopt options.

Issuing shopt SET or UNSET commands: From http://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html

Syntax
shopt [-pqsu] [-o] [optname …]

Options
-s Enable (set) each optname

-u Disable (unset) each optname.

-p Display a list of all settable options, with an indication of
whether or not each is set. The output is displayed in a form
that may be reused as input. (-p is the default action)

-q Suppresses normal output; the return status indicates whether the optname
is set or unset. If multiple optname arguments are given with `-q’,
the return status is zero if all optnames are enabled; non-zero otherwise.

-o Restricts the values of optname to be those defined for the `-o’ option to
the set builtin.

The cdspell bash builtin:
As you can see below, apart from the autoset options, I have manually set cdspell. If you spend a lot of time navigating directories via the terminal, you will often make spelling mistakes like “/ect”or “/Etc” instead of “/etc”, with cdspell enabled, bash will autocorrect the mistake and allow you to hit enter and still get to your destination. This saves a lot of time having to keep going back back and correcting directory paths.

My .bashrc shopt section:
############################
#
# SHOPT AUTOSTARTS
#
############################
# autocd
# cdable_vars
shopt -s cdspell # on MANUAL
#checkhash off
#checkjobs off
#checkwinsize on AUTO
#cmdhist on AUTO
#compat31 off
#compat32 off
#compat40 off
#dirspell off
#dotglob off
#execfail off
#expand_aliases on AUTO
#extdebug off
#extglob on AUTO
#extquote on AUTO
#failglob off
#force_fignore on AUTO
#globstar off
#gnu_errfmt off
#histappend on AUTO
#histreedit off
#histverify off
#hostcomplete off
#huponexit off
#interactive_comments on AUTO
#lithist off
#login_shell off
#mailwarn off
#no_empty_cmd_completion off
#nocaseglob off
#nocasematch off
#nullglob off
#progcomp on AUTO
#promptvars on AUTO
#restricted_shell off
#shift_verbose off
#sourcepath on AUTO
#xpg_echo off
############################

Perl Functions to memorize

Remembering Perl functions
Been working my way through this Perl Functions list for a while now. I just take a “Function of the day”, do a search on perldoc or man, and put together a couple of basic for each one.

As the old adage goes:

I hear and I forget. I see and I remember. I do and I understand.” — Confucius

Other Resources:
Sometimes you’ll get something that’s a bit vague, and neither man nor perldoc gives you enough to fully understand the power of a certain function. I’ve got a collection of Perl books and .pdfs, but I still take advantage of a great resource when i’m looking for working examples of Perl-foo. Perl Monks is an awesome community of Perl…. er monks 🙂
http://www.perlmonks.org/

Here’s a few Perl Functions to memorize:

Scalar manipulation
chomp, chop, chr, crypt, hex, index, lc, lcfirst, length, oct, ord, pack, q//, qq//, reverse, rindex, sprintf, substr, tr///, uc, ucfirst, y///

Regular expressions and pattern matching
m//, pos, qr//, quotemeta, s///, split, study

Numeric functions
abs, atan2, cos, exp, hex, int, log, oct, rand, sin, sqrt, srand

Array processing
pop, push, shift, splice, unshift

List processing
grep, join, map, qw//, reverse, sort, unpack

Hash processing
delete, each, exists, keys, values

Input and output
binmode, close, closedir, dbmclose, dbmopen, die, eof, fileno, flock, format, getc, print, printf, read, readdir, rewinddir, seek, seekdir, select, syscall, sysread, sysseek, syswrite, tell, telldir, truncate, warn, write

Fixed-length data and records
pack, read, syscall, sysread, syswrite, unpack, vec

Filehandles, files, and directories
chdir, chmod, chown, chroot, fcntl, glob, ioctl, link, lstat, mkdir, open, opendir, readlink, rename, rmdir, stat, symlink, sysopen, umask, unlink, utime

Flow of program control
caller, continue, die, do, dump, eval, exit, goto, last, next, redo, return, sub, wantarray

Scoping
caller, import, local, my, package, use

Miscellaneous
defined, dump, eval, formline, local, my, prototype, reset, scalar, undef, wantarray

Processes and process groups
alarm, exec, fork, getpgrp, getppid, getpriority, kill, pipe, qx//, setpgrp, setpriority, sleep, system, times, wait, waitpid

Library modules
do, import, no, package, require, use

Classes and objects
bless, dbmclose, dbmopen, package, ref, tie, tied, untie, use

Low-level socket access
accept, bind, connect, getpeername, getsockname, getsockopt, listen, recv, send, setsockopt, shutdown, socket, socketpair

System V interprocess communication
msgctl, msgget, msgrcv, msgsnd, semctl, semget, semop, shmctl, shmget, shmread, shmwrite

Fetching user and group information
endgrent, endhostent, endnetent, endpwent, getgrent, getgrgid, getgrnam, getlogin, getpwent, getpwnam, getpwuid, setgrent, setpwent

Fetching network information
endprotoent, endservent, gethostbyaddr, gethostbyname, gethostent, getnetbyaddr, getnetbyname, getnetent, getprotobyname, getprotobynumber, getprotoent, getservbyname, getservbyport, getservent, sethostent, setnetent, setprotoent, setservent

Time
gmtime, localtime, time, times

Script to edit first letters of multiple files

This is a simple one, and there are just loads of ways to replace lines/characters/spaces with Perl one-liners and Bash.

The main point of this script is when I install a new distro and want to shutdown services that startup automatically on each run level, for Ubuntu in the directories rcS.d, rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, rc6.d

Each item begins with an “S” for START or a “K” for KILL with a number that pertains to the order of priority (ie S25bluetooth). And depending on the run-level, and how many apps you have installed, this could be 10-20 services launched at boot.

#!/bin/bash
############################################
#KILL STARTUP SERVICES
############################################
#By richs-lxh – http://richs-lxh.com
############################################
#CHANGE “ONLY” THE “FIRST” CHARACTERS AT THE
#BEGINNING OF A FILE (EG FILES S20* to K20* )
############################################
for i in S* ;
do mv “$i” “${i//S/K}”;
done

So if you want to kill all the processes that start with S20, it would be:
for i in S20* ;
do mv “$i” “${i//S20/K20}”;
done

The reason I posted this little script is that when you Google search for scripts and one-liners to edit filenames via the CLI, practically every guide offers newbies an example of how to change the “suffixes” (ie replace .html with .htm) but no clue on how to batch-replace the beginning of filenames.

Squeeze and IpV6 mean a fun 2011 for Debian server admins

Bye bye IpV4
Well, it looks like our good old fashioned, 4-digited IP addresses are about to meet their maker and go to the digit matrix in the sky for good. There has been a lot of talk about the v4 to v6 doomsday, but everybody was hanging on until the last minute before making any changes.

I for one have spent years removing IpV6 from the network settings on my Debian desktop as there was a notable speed difference. But that was only because there was slowdown caused by a search for non-existent IpV6 addresses before the IpV4 search. Now it seems this will no longer be necessary as everybody slowly converts to IpV6.

2011 – Big year for Debian server admins
I work as a Debian server Admin, and 2011 is going to be a memorable year for my colleagues and I. Firstly, Debian Squeeze (6.0) was released as “Stable” yesterday (Feb 6th), which means we will start upgrading all our clients’ servers pretty soon, although we do still have a year of Security updates. And now we are facing more future changes with the changeover to IpV6.

Google and World IpV6 Day

In the same way your phone is associated with a unique number, your computer is assigned a unique Internet Protocol (IP) address when you connect to the Internet. The current protocol, IPv4, allows for approximately 4 billion unique addresses—and that number is about to run out.

This morning the Internet Corporation for Assigned Names and Numbers (ICANN) announced (PDF) that it has distributed the last batch of its remaining IPv4 addresses to the world’s five Regional Internet Registries, the organizations that manage IP addresses in different regions. These Registries will begin assigning the final IPv4 addresses within their regions until they run out completely, which could come as soon as early 2012.

As the last blocks of IPv4 addresses are assigned, adoption of a new protocol—IPv6—is essential to the continued growth of the open Internet. IPv6 will expand Internet address space to 128 bits, making room for approximately 340 trillion trillion trillion addresses (enough to last us for the foreseeable future).

Google, along with others, has been working for years to implement the larger IPv6 format. They’re also participating in the planned World IPv6 Day, scheduled for June 8, 2011. On this day, all of the participating organizations will enable access to as many services as possible via IPv6.

Today’s ICANN announcement marks a major milestone in the history of the Internet. IPv6, the next chapter, is now under way.
http://googleblog.blogspot.com/2011/02/ipv6-marks-next-chapter-in-history-of.html