Skip to content

Instantly share code, notes, and snippets.

@samsoir
Created May 13, 2009 15:51
Show Gist options
  • Select an option

  • Save samsoir/111096 to your computer and use it in GitHub Desktop.

Select an option

Save samsoir/111096 to your computer and use it in GitHub Desktop.
# most basic approach
find system -type f -exec sed -i -e "s/defined('SYSPATH') OR die('No direct access allowed.');//" '{}' \;
# case insensitive
find system -type f -exec sed -i -e "s/defined('SYSPATH') [oO][rR] die('No direct access allowed.');//" '{}' \;
# case insensitive with any die message
find system -type f -exec sed -i -e "s/defined('SYSPATH') [oO][rR] die('[^']\{0,\}');//" '{}' \;
# all the above and also remove extra whitespace and empty php directives
find system -type f -exec sed -i -e "{ s/^<?php\([ \t]\{1,\}\)defined('SYSPATH') [oO][rR] die('[^']\{0,\}');\(.\{0,\}\)$/<?php\1\2/ ; s/^<?php[ \t]\{1,\}$/<?php/ ; /^<?php[ \t]\{1,\}?>$/ d }" '{}' \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment