Released under the terms of the GNU General Public License. You should have received a copy of the GNU General Public License, along with this software. In the main directory, see: /licensing/ If not, see: . */ /* Direct access denial. */ if (realpath (__FILE__) === realpath ($_SERVER["SCRIPT_FILENAME"])) exit ("Do not access this file directly."); /* Function that handles readme.txt parsing. */ if (!function_exists ("ws_widget__ad_codes_parse_readme")) { function ws_widget__ad_codes_parse_readme ($specific_path = FALSE) { if (!($path = $specific_path)) /* Was a specific path passed in? */ { $path = dirname (dirname (dirname (__FILE__))) . "/readme.txt"; $dev_path = dirname (dirname (dirname (__FILE__))) . "/readme-dev.txt"; $path = (file_exists ($dev_path)) ? $dev_path : $path; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action ("ws_widget__ad_codes_before_parse_readme", get_defined_vars ()); unset ($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if (file_exists ($path)) /* Give hooks a chance. */ { $o_pcre = ini_get ("pcre.backtrack_limit"); ini_set ("pcre.backtrack_limit", 10000000); /**/ if (!function_exists ("NC_Markdown")) include_once dirname (dirname (__FILE__)) . "/markdown/nc-markdown.inc.php"; /**/ $rm = file_get_contents ($path); /* Get readme.txt file contents. */ $mb = function_exists ("mb_convert_encoding") ? @mb_convert_encoding ($rm, "UTF-8",@mb_detect_encoding ($rm, "WINDOWS-1252, UTF-8")) : $rm; $rm = ($mb) ? $mb : $rm; /* Double check this, just in case conversion fails on an unpredicted charset. */ /**/ $rm = preg_replace ("/(\=\=\=)( )(.+?)( )(\=\=\=)/", "

Specifications

", $rm); $rm = preg_replace ("/(\=\=)( )(.+?)( )(\=\=)/", "

$3

", $rm); $rm = preg_replace ("/(\=)( )(.+?)( )(\=)/", "

$3

", $rm); $rm = NC_Markdown ($rm); /* Parse out the Markdown syntax now. */ /**/ $r1 = "/(\)(.+?)(\<\/h2\>)(.+?)(\|$)/si"; $r2 = "/(\<\/div\>)(\)(.+?)(\<\/h2\>)(.+?)(\
\|$)/si"; $r3 = "/(\
)(\)(Specifications)(\<\/h2\>)(\
)(.+?)(\<\/div\>\<\/div\>)/sei"; $r4 = "/(\
)(\)(Screenshots)(\<\/h2\>)(\
)(.+?)(\<\/div\>\<\/div\>)/si"; $r5 = "/(\' . "$1$2$3" . '
' . "$4" . '
' . "$5", $rm); $rm = preg_replace ($r2, "$1" . '
' . "$2$3$4" . '
' . "$5" . '
' . "$6", $rm); $rm = stripslashes (preg_replace ($r3, "'\\1\\2\\3\\4\\5'._ws_widget__ad_codes_parse_readme_specs('\\6').'\\7'", $rm, 1)); $rm = stripslashes (preg_replace ($r4, "", $rm, 1)); /* Here we just remove the screenshots completely. */ $rm = preg_replace ($r5, "$1" . ' target="_blank" rel="nofollow external"' . "$2", $rm); /**/ ini_set ("pcre.backtrack_limit", $o_pcre); /**/ $readme = '
' . "\n"; $readme .= $rm . "\n"; /* Content. */ $readme .= '
' . "\n"; /**/ return apply_filters ("ws_widget__ad_codes_parse_readme", $readme, get_defined_vars ()); } else /* In case readme.txt is deleted. */ { return "Unable to parse /readme.txt."; } } } /* Callback function that helps readme file parsing with specs. */ if (!function_exists ("_ws_widget__ad_codes_parse_readme_specs")) { function _ws_widget__ad_codes_parse_readme_specs ($str = FALSE) { do_action ("_ws_widget__ad_codes_before_parse_readme_specs", get_defined_vars ()); /**/ $str = preg_replace ("/(\|^)(.+?)(\:)( )(.+?)($|\<\/p\>)/mi", "$1" . '
  • ' . "$2" . '' . "$3" . '    ' . "$5" . '
  • ' . "$6", $str); $str = preg_replace ("/\\/i", '
    • ', $str); /* Open the list items. */ $str = preg_replace ("/\<\/li\>\<\/p\>/i", '

    ', $str); /**/ return apply_filters ("_ws_widget__ad_codes_parse_readme_specs", $str, get_defined_vars ()); } } /* Function for parsing readme.txt files and returning a key value. */ if (!function_exists ("ws_widget__ad_codes_parse_readme_value")) { function ws_widget__ad_codes_parse_readme_value ($key = FALSE, $specific_path = FALSE) { static $readme = array (); /* For repeated lookups across different paths. */ /**/ if (!($path = $specific_path)) /* Was a specific path passed in? */ { $path = dirname (dirname (dirname (__FILE__))) . "/readme.txt"; $dev_path = dirname (dirname (dirname (__FILE__))) . "/readme-dev.txt"; $path = (file_exists ($dev_path)) ? $dev_path : $path; } /**/ eval('foreach(array_keys(get_defined_vars())as$__v)$__refs[$__v]=&$$__v;'); do_action ("ws_widget__ad_codes_before_parse_readme_value", get_defined_vars ()); unset ($__refs, $__v); /* Unset defined __refs, __v. */ /**/ if ($readme[$path] || file_exists ($path)) { if (!$readme[$path]) /* If not already opened, we need open it up now. */ { $readme[$path] = file_get_contents ($path); /* Get readme.txt file contents. */ $mb = function_exists ("mb_convert_encoding") ? @mb_convert_encoding ($readme[$path], "UTF-8",@mb_detect_encoding ($readme[$path], "WINDOWS-1252, UTF-8")) : $readme[$path]; $readme[$path] = ($mb) ? $mb : $readme[$path]; /* Double check this, just in case conversion fails on an unpredicted charset. */ } /**/ preg_match ("/(^)(" . preg_quote ($key, "/") . ")(\:)( )(.+?)($)/m", $readme[$path], $m); /**/ return strlen ($m[5] = trim ($m[5])) ? apply_filters ("ws_widget__ad_codes_parse_readme_value", $m[5], get_defined_vars ()) : false; } else /* Nope. */ return false; } } ?>