<?php
require ('authentication_manager.php');
?>
<?php

/* 常用工具 */
/* 162100源码 - 162100.com */


if (POWER < 4) {
  err('该命令必须以管理员身份登陆！请重登陆。');
}
function confirm_mode($m) {
  global $web;
  //$m = str_replace('/', '', $m);
  if ($m && file_exists('inc/css/'.$m.'/index.php') && file_exists('inc/css/'.$m.'/list.php') && file_exists('inc/css/'.$m.'/article.php')) {
    return $m;
  }
  //return $web['sitemode'];
  return false;
}

  if (!confirm_mode($_GET['mode'])) { 
    err('<script> alert("模板出错！"); parent.delSubmitSafe(); </script>');
  }


/*
if (!$_POST['linkname'] || !$_POST['linkhttp']) {
  err('参数不全！');
}
*/
/*
if (count((array)$_POST['linkhttp']) > count(array_unique(array_filter((array)$_POST['linkhttp'])))) {
  err('相同的网址只允许加入一个！且不能写空值。');
}
*/

$link = array();
@ require ('inc/function/filter.php');
foreach ((array)$_POST['linkhttp'] as $key => $val) {
  //if (strstr($val, 'furuijinzhao.com') || strstr($val, '162100.com')) {
  //  continue;
  //}
  $linkname = filter1($_POST['linkname'][$key], true);
  if($linkname != '' && ($val = trim($val)) != '' && (strlen($val) < 100 && preg_match('/^[a-zA-Z]+\:\/\/[\w\-\.]+\S{2,}$/', $val))) {
    $link[] = "<a href=\"".$val."\" target=\"_blank\">".$linkname."</a>";
  }
  unset($linkname);
}


$text = (count($link) > 0 ? ''.@implode("  ", $link) : '');

@ require ('inc/function/write_file.php');
write_file('inc/css/'.$_GET['mode'].'/tools.txt', $text);
alert('常用工具设置成功！刷新首页显示', 'webmaster_central.php?mode='.$_GET['mode'].'&get=tools');


?>



