svn log parser - Parses SVN log files and groups log messages per date

July 7th, 2010

I've been looking for a nice svn log parser but I couldn't find one for the purpose I needed it.
You know that story, right ? :)

I needed an svn log parser that would give me log messages accumulated per day.
Here is what I came up with. Feel free to send me improvements.

Download svn-log-parser

Related

How to create a text-based carousel using jQuery and cycle plugin

May 8th, 2010

I was working on my classified ads site and realized that I will need a text-based carousel with prev/next buttons. I've seen in it Gmail and it's interesting because they add a quote among those adds and I can't wait to reach the quote.

Style 1

carousel11

Style 2

carousel2

Style 3

carousel3

Downloads

text-carousel.zip

Slavi’s Free Tools

May 7th, 2010

Hi All,

I just released a Slavi's Free Tools section at http://slavi.biz/tools/

I will be creating some interesting and hopefully useful tools there.

Slavi

A simple permanent (301) redirect using RedirectMatch in .htaccess

October 7th, 2009
RedirectMatch permanent /old-location/.* http://sub.domain.com

Related

Using Uploadify with Zend Framework

August 30th, 2009

update (2010-05-07): changed the regex to match 25-32 chars. Thanks Krzysztof from the comments.

A quote from http://www.uploadify.com site.

Uploadify is a jQuery plugin that allows the easy integration of a multiple (or single) file uploads on your website.  It requires Flash and any backend development language.  An array of options allow for full customization for advanced users, but basic implementation is so easy that even coding novices can do it.

This article assumes that you've already read the Uploadify docs and tried to integrate it.

Everything is pretty simple however you need to overcome one obstacle with flash and cookies.
More on the flash and cookies topic go to http://swfupload.org/forum/generaldiscussion/383

My Solution:

This article can be downloaded (TXT format)

Here is how to use the uploadify
I use a variable called "__tkn" in the url to pass the session variable.
Some of you may try to use 'scriptData' which didn't work for me.

<script type="text/javascript">
jQuery(document).ready(function() {
if (jQuery("#upl_feed_file_progress")) {
jQuery("#upl_feed_file_progress").uploadify({
'uploader': '/site/share/jquery/plugins/jquery.uploadify-v2.1.0/uploadify.swf',
//                'cancelImg': '/site/share/jquery/plugins/jquery.uploadify-v2.1.0/images/cancel.png',
'script': '/mymodule/mycontroller/myaction/__tkn/<?php echo Zend_Session::getId(); ?>',
'multi': false,
'simUploadLimit': 1,
'fileExt': '*.csv;*.txt',
'fileDesc': 'Feed Files (*.csv;*.txt)',
/                'fileDataName' : 'upl_feed_file', // in $_FILES
//                'scriptData': {'PHPSESSID' : '<?php echo Zend_Session::getId(); ?>'}, // This didn't work for me.
'height': 24,
'auto': true,
'onCancel' : function (event, queueID, fileObj, data) {
alert('Error: You have cancelled the file upload.');
},
'onError' : function (event, queueID, fileObj, errorObj) {
alert('Error during file upload. Maybe the file is too big ? Size: ' +  fileObj.size + ' Error:' +  errorObj.info());
},
'onComplete' : function (event, queueID, fileObj, response, data) {
if (response == '' || response == 0 || response == "0") {
alert('Error during with the upload');
} else {
perf_error('Success!');
}
}
});
}
});

</script>

This one goes in the template ..

....
<div id="upl_feed_file_progress">You have a problem with your javascript</div>
....

Insert this in the boostrap (usually index.php) file
It should be inserted before "Zend_Session::start();"

// ------------------------------------------ START -------------------------------------------

$sessName = "PHPSESSID";
$sessOptions = array('name' => $sessName);

// Flash has problems with cookies so we pass the PHPSESSID variable via get
// it'll be injected if it doesn't exist in _SERVER["HTTP_COOKIE"] e.g. '; PHPSESSID=hdi5u83hfnu7ltlvp5q3bb53k4'
if ((stripos($_SERVER['REQUEST_URI'], '__tkn') !== false)
//    &amp;&amp; preg_match('#^[a-z\d]{25,32}$#si', $_GET[$sessName])
&amp;&amp; preg_match('#__tkn/([a-z\d]{25,32})#si', $_SERVER['REQUEST_URI'], $matches)
&amp;&amp; (stripos($_SERVER["HTTP_COOKIE"], $matches[1]) === false)) {
$sid = $matches[1];

$prefix = '';
if (!empty($_SERVER["HTTP_COOKIE"])) {
$prefix = '; ';
}

$_SERVER["HTTP_COOKIE"] .= $prefix . $sessName . '=' . $sid;
$_COOKIE[$sessName] = $sid;

Zend_Session::setId($sid);
}

Zend_Session::setOptions($sessOptions);
// ------------------------------------------ END -------------------------------------------

Your 'myaction' (/mymodule/mycontroller/myaction) should return 0 or 1.

The following code should be useful.

$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setNoRender();

// Skipping the templates
Zend_Layout::getMvcInstance()->disableLayout();

Please share your thoughts.
Are there any security holes in this approach ?


Related Resources

Quick ‘n’ Dirty Way to Debug without showing debug info to your visits.

August 27th, 2009

Sometimes we are required to do some troubleshooting on a production site.
In order to do that *safely* we'll show debug information only for us.
This could be put into a safe_debug function for later use by the way.
On development/staging servers I recommend installing debuggers such as Zend Debugger, xdebug etc and enabling errors (E_ALL).

if ($_SERVER['REMOTE_ADDR'] == '1.2.3.4' || preg_match('#^192\.#', $_SERVER['REMOTE_ADDR'])) {
echo "Dev dump";
echo "<pre>";
var_dump($params);
echo "</pre>";
echo __FILE__ . ':' . __LINE__;
}

Of course one should be extra careful for opening and closing php tags otherwise this will product fatal errors.

Happy debugging!

How to (always) get your server’s IP address

August 25th, 2009

Here is how to (always) get your server's a IP address. Works on Unix/Linux.

<?php
if (empty($_SERVER['SERVER_ADDR'])) {
$server_host = `hostname -f`;
$server_ip = `host $server_host`;

if (preg_match('#(\d+\.\d+\.\d+\.\d+)#', $server_ip, $matches)) {
$server_ip = $matches[1];
} else {
$server_ip = '127.0.0.1';
}
} else {
$server_ip = $_SERVER['SERVER_ADDR'];
}

echo $server_ip;
?>

How to delete .SVN files/directories

August 13th, 2009

This is so common situation when somebody decides to copy a directory that contains SVN files which also has locally modified files.
Therefore a clean export won't do the job.
Here is what I do to clean up the new folder from the SVN files.

This command will display all the .SVN folders starting from the current folder.

Be yourself i.e. not root :D just in case.

find . -type d -name '*.svn' -print

Example Output:

./js/.svn
./templates/.svn
./.svn
./css/.svn
./images/.svn

What I do is check the folders visually and then use my editor to search & replace:
"./" and replace it with "rm -rf ./"

Result:

rm -rf ./js/.svn
rm -rf ./templates/.svn
rm -rf ./.svn
rm -rf ./css/.svn
rm -rf ./images/.svn

Then I paste this in the console window.

rm is a dangerous command so be careful!
Your precious work could be gone in a fraction of a second!

How to find which flash player version you have ?

July 17th, 2009

In order to find the currently installed flash player version go to http://kb2.adobe.com/cps/155/tn_15507.html

Is your blog protected against brute force attack ?

July 17th, 2009

Here is an explanation about brute force attack from Wikipedia

In computer science, brute-force search or exhaustive search, also known as generate and test, is a trivial but very general problem-solving technique that consists of systematically enumerating all possible candidates for the solution and checking whether each candidate satisfies the problem's statement.

Donncha O Caoimh's posting has 2 really good ideas.

1) Use a small script to log some *unusual* POST requests
By using the script Donncha was notified when somebody was trying to get into his wordpress blogs.

Credits: Donncha O Caoimh

if ( ( isset( $HTTP_RAW_POST_DATA ) || !empty( $_POST ) ) && $_SERVER[ 'REQUEST_URI' ] != '/wp-cron.php?doing_wp_cron' && $_SERVER[ 'SCRIPT_NAME' ] != '/wp-comments-post.php' && substr( $_SERVER[ 'REQUEST_URI' ], -10 ) != '/trackback' && substr( $_SERVER[ 'REQUEST_URI' ], -11 ) != '/trackback/' ) {
mail( "MYEMAIL@gmail.com", $_SERVER[ 'HTTP_HOST' ] . " POST request: " . $_SERVER[ 'REMOTE_ADDR' ], "URL: {$_SERVER[ 'REQUEST_URI' ]}\nPOST: " . print_r( $_POST, 1 ) . "\nCOOKIES: " . print_r( $_COOKIE, 1 ) . "\nHTTP_RAW_POST_DATA: $HTTP_RAW_POST_DATA" );
}

2) Use the limit login attempts Wordpress plugin

Here is some info about the plugin
Limit Login Attempts blocks an Internet address from making further attempts after a specified limit on retries is reached, making a brute-force attack difficult or impossible.