. */ // Usage // ----- // Access this file in your browser and follow the instructions to update your site config files. error_reporting(E_ALL ^ E_NOTICE); ini_set("display_errors", 1); @set_time_limit(120); if (get_magic_quotes_gpc()) { $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); while (list($key, $val) = each($process)) { foreach ($val as $k => $v) { unset($process[$key][$k]); if (is_array($v)) { $process[$key][stripslashes($k)] = $v; $process[] = &$process[$key][stripslashes($k)]; } else { $process[$key][stripslashes($k)] = stripslashes($v); } } } unset($process); } require_once '../libraries/content-extractor/SiteConfig.php'; //////////////////////////////// // Load config file //////////////////////////////// $admin_page = 'edit-pattern'; require_once('../config.php'); require_once('require_login.php'); require_once('template.php'); tpl_header('Edit site patterns'); $version = include('../site_config/standard/version.php'); function filter_only_text($filename) { return (strtolower(substr($filename, -4)) == '.txt'); } function is_valid_hostname($host) { return preg_match('!^[a-z0-9_.-]+$!i', $host); } ///////////////////////////////// // Process changes ///////////////////////////////// if ($_SERVER['REQUEST_METHOD'] == 'POST') { // DELETE if (@$_POST['delete'] != '' && @$_POST['delete_dir'] != '') { if (is_valid_hostname($_POST['delete'])) { $delete = $_POST['delete']; if ($_POST['delete_dir'] == 'standard') { $delete = '../site_config/standard/'.$delete; } else { $delete = '../site_config/custom/'.$delete; } if (@unlink($delete)) { echo 'Deleted '.$delete.''; } else { echo 'Failed to delete '.$delete.''; } } exit; } // SAVE if (@$_POST['save'] != '' && isset($_POST['contents'])) { if (is_valid_hostname(trim($_POST['save']))) { $save = strtolower(trim($_POST['save'])); if (@$_POST['save_dir'] == 'standard') { $savepath = '../site_config/standard/'.$save.'.txt'; } else { $savepath = '../site_config/custom/'.$save.'.txt'; } // TODO: check if file exists, if it does, prompt user whether to overwrite if (file_put_contents($savepath, $_POST['contents']) !== false) { echo '
Saved to '.$savepath.'
'; // check caching if ($options->caching) { echo 'Note: caching is enabled — you may have to disable caching or delete cache files to see changes.
'; } if ($options->apc && function_exists('apc_delete') && function_exists('apc_cache_info')) { $_apc_data = apc_cache_info('user'); foreach ($_apc_data['cache_list'] as $_apc_item) { if (substr($_apc_item['info'], 0, 3) == 'sc.') { apc_delete($_apc_item['info']); } } echo '
Cleared site config cache in APC.
'; } SiteConfig::set_config_path(dirname($savepath)); $sconfig = SiteConfig::build($save, $exact_host_match=true); if ($sconfig) { if (!empty($sconfig->test_url)) { echo 'No test URLs found in config, if you supply one we\'ll give you a link to test how Full-Text RSS will extract it
'; } } else { echo 'Could not load/parse config file
'; } } else { echo 'Failed to save '.$savepath.'. Make sure the directory is writable.'; } } exit; } } ///////////////////////////////// // Show list of site config files ///////////////////////////////// if (!isset($_REQUEST['url']) || trim($_REQUEST['url']) == '') { $sc_files = array_merge(scandir('../site_config/standard/'), scandir('../site_config/custom/')); $sc_files = array_unique(array_filter($sc_files, 'filter_only_text')); ?>Note: This feature is for advanced users familiar with XPath. It allows you to override automatic article extraction and specify what Full-Text RSS should extract from specific domains. If you're uncomfortable writing your own, you can request one from us.
'; foreach ($sc_files as $file) { $file = basename($file, '.txt'); echo 'Loaded '.htmlspecialchars($exact_match).'
'; } else { $contents = end($matched); $file_location = array_pop(array_keys($matched)); echo 'Loaded '.htmlspecialchars($file_location).'
'; } if (isset($file_location)) unset($related[$file_location]); $save_locations = array( 'custom' => 'custom (recommended)', 'standard' => 'standard' ); echo ''; // DELETE option if (!empty($matched)) { echo 'Delete '.htmlspecialchars($file_location).'
'; echo ''; } // TEST URLs if (!empty($matched)) { if ($sconfig = SiteConfig::build_from_array(explode("\n", $contents))) { if (!empty($sconfig->test_url)) { echo '