".ADLAN_CL_7." 
			
				
					 
				
					
						".LAN_PLUGIN." 
						".LAN_CHECK_16." 
						".$_POST['language']." 
						".LAN_OPTIONS." 
					 
				 
				
	";
	foreach($core_plugins as $plugs)
	{
		if(is_readable(e_PLUGIN.$plugs))
		{
			$text .= $lck->check_lanfiles('P',$plugs,"English",$_POST['language']);
		}
	}
	$text .= "
				 
			
		 
	";
	$text .= "
		
			".LAN_THEME." 
			
				
					 
				
					
						".LAN_CHECK_21." 
						".LAN_CHECK_16." 
						".$_POST['language']." 
						".LAN_OPTIONS." 
					 
				 
				
	";
	foreach($core_themes as $them)
	{
		if(is_readable(e_THEME.$them))
		{
			$text .= $lck->check_lanfiles('T',$them,"English",$_POST['language']);
		}
	}
	$text .= "
				 
			
		 
	";
	
	$mes = e107::getMessage();
	if($lck->error_count == 0)
	{
		e107::getConfig()->setPref('lancheck/'.$_POST['language'],1);
		e107::getConfig()->save(FALSE);
		$mes->addSuccess(LAN_CHECK_27.': '.$lck->error_count.' ');		
	}
	else  
	{
		$mes->addWarning(LAN_CHECK_27.': '.$lck->error_count.' ');
	}
	
	$ns->tablerender(LAN_THEMES, $mes->render(). $text);
	
	require_once(e_ADMIN."footer.php");
	exit;
}
*/
class lancheck
{
	public $core_plugins = array();
	public $core_themes = array("bootstrap3", "voux");
			
	private $errorsOnly = false;
	
	private $coreImage = array();
	private $transLanguage = '';
	private $thirdPartyPlugins = true;
	private $deprecatedFiles = array('lan_download.php', 'lan_parser_functions.php', 'lan_prefs.php', 'admin/lan_download.php', 'admin/lan_modcomment.php');
	private $installed_languages = array();
	function __construct()
	{
		$this->core_plugins = e107::getPlugin()->getCorePlugins();
	}
	public function thirdPartyPlugins($val)
	{
		$this->thirdPartyPlugins = $val;
	}
	public function errorsOnly($val)
	{
		$this->errorsOnly = (bool) $val;
	}
	
	public function init()
	{
		$mode   = varset($_GET['sub']);
		$lan    = varset($_GET['lan']);
		$file   = varset($_GET['file']);
		$this->transLanguage = $lan;
		$ns = e107::getRender();
		$tp = e107::getParser();
		$pref = e107::getPref();
		
		// Check current theme also (but do NOT add to generated zip)
		if(deftrue('e_DEBUG'))
		{
			$this->core_themes[] = $pref['sitetheme'];
			$this->core_themes = array_unique($this->core_themes);
		}/*
		if(E107_DEBUG_LEVEL > 0)
		{
			print_a($this->core_plugins);
		}*/
		$acceptedLans = explode(",",e_LANLIST);
	
		if(!empty($_POST['ziplang']))
		{
			$lang = key($_POST['ziplang']);
			return $this->zipLang($lang);
		}
		// Verify
		if($mode == 'verify' && !empty($lan))
		{
			// $_SESSION['lancheck-errors-only'] 	= ($_POST['errorsonly']==1 ) ?  1 : 0;
			// $this->errorsOnly 					= ($_POST['errorsonly']==1) ?  TRUE : FALSE;
			return $this->check_all('render', $lan);
		}
		
		// Write the language file.
		if(isset($_POST['saveLanguageFile']) && vartrue($_POST['lan']) && in_array($_POST['lan'],$acceptedLans))
		{
			
			$this->write_lanfile($_POST['lan']);	
			return true;
		} 
		
		// Edit the Language File.
		if($mode == 'edit' && vartrue($file) && !empty($lan) && in_array($lan, $acceptedLans))
		{
			
			if (empty($_GET['type']))
			{
				$dir1 =  e_LANGUAGEDIR."English/";
				$f1= $tp->toDB($file);
				$dir2 =  e_LANGUAGEDIR.$lan."/";
				$f2= $tp->toDB($file);
			}
			else
			{
				$fullpath_orig = $tp->toDB($file);
				$fullpath_trans = str_replace("English", $lan, $tp->toDB($file));
		
				$f1 = basename($fullpath_orig);
				$f2 = basename($fullpath_trans);
				$dir1 = dirname($fullpath_orig)."/";
				$dir2 = dirname($fullpath_trans)."/";
			}
			
			return $this->edit_lanfiles($dir1,$dir2,$f1,$f2,$lan, varset($_GET['type']));
			// return true;
		}	
		
		return false;
	}
	
	
	function countFiles($array)
	{
		foreach($array as $k=>$val)
		{
			if(is_array($val))
			{
				$key = key($val);
				$this->coreImage[$key] = $val;
			}
		/*	elseif($val)
			{
				$this->totalFiles++;
			}	
			*/
		}	
	}
	/**
	 * @param $language
	 * @return array|string
	 */
	function zipLang($language)
	{
		$mes = e107::getMessage();
		/* NO LONGER USED
		$certVal = isset($_POST['contribute_pack']) ? 1 : 0;
		if(!varset($_COOKIE['e107_certified']))
		{
			cookie('e107_certified',$certVal,(time() + 3600 * 24 * 30));
		}
		else
		{
			$_COOKIE['e107_certified'] = $certVal;
		}*/
		//	$_POST['language'] = key($_POST['ziplang']);
		// If no session data, scan before zipping.
		if(!isset($_SESSION['lancheck'][$language]['total']) || $_SESSION['lancheck'][$language]['total']!='0')
		{
			$this->check_all('norender', $language);
		}
		$status = $this->makeLanguagePack($language);
		//print_a($status);
		if($status['error'] == FALSE)
		{
			$srch = array('[', ']');
			$rpl = array("", " ");
			$text = str_replace($srch, $rpl, LANG_LAN_154);
			$text .= "".SITENAME." 
	";
			$text .= defined('LANG_LAN_EML') ?  "
".LANG_LAN_EML." " : "
There was a problem sending the language-pack. Please email your verified language pack to: ";
			$text .= " 
".$send_to." ";
			$text .= "
Pack Sent to e107 Inc. A confirmation email will be sent to ".$pref['siteadminemail']." once it is received.
";
		}
	}
	/**
	 * @param $language
	 * @return bool|string
	 */
	private function findLocale($language)
	{
		if(!is_readable(e_LANGUAGEDIR.$language."/".$language.".php"))
		{
			return FALSE;
		}
		$code = file_get_contents(e_LANGUAGEDIR.$language."/".$language.".php");
		$tmp = explode("\n",$code);
		$srch = array("define","'",'"',"(",")",";","CORE_LC2","CORE_LC",",");
		foreach($tmp as $line)
		{
			if(strpos($line,"CORE_LC") !== FALSE && (strpos($line,"CORE_LC2") === FALSE))
			{
				$lc = trim(str_replace($srch,"",$line));
			}
			elseif(strpos($line,"CORE_LC2") !== FALSE)
			{
				$lc2 = trim(str_replace($srch,"",$line));
			}
		}
		if(!isset($lc) || !isset($lc2) || $lc=="" || $lc2=="")
		{
			return FALSE;
		}
		return substr($lc,0,2)."_".strtoupper(substr($lc2,0,2));
		//
	}
	/**
	 * @param $language
	 * @return array
	 */
	private function makeLanguagePack($language)
	{
		$tp = e107::getParser();
		$ret = array();
		$ret['file'] = "";
		if($_SESSION['lancheck'][$language]['total'] > 0 && !E107_DEBUG_LEVEL)
		{
			$ret = array();
			$ret['error'] = TRUE;
			$message = LANG_LAN_115;
			$ret['message'] = str_replace("[x]",$_SESSION['lancheck'][$language]['total'],$message);
			return $ret;
		}
		if(!isset($_SESSION['lancheck'][$language]))
		{
			$ret = array();
			$ret['error'] = TRUE;
			$ret['message'] = LANG_LAN_116;
			return $ret;
		}
		if(varset($_POST['contribute_pack']) && varset($_SESSION['lancheck'][$language]['total']) !='0')
		{
			$ret['error'] = TRUE;
			$ret['message'] = LANG_LAN_117;
			$ret['message']	 .= "
 ';
			if(file_put_contents($fileName,$fileData))
			{
				$addTag = $archive->add($fileName, PCLZIP_OPT_ADD_PATH, 'e107_languages/'.$language, PCLZIP_OPT_REMOVE_PATH, e_FILE.'public/');
				$_SESSION['lancheck'][$language]['xml'] = "Yes";
			}
			else
			{
				$_SESSION['lancheck'][$language]['xml'] = "No";
			}
			@unlink($fileName);
			$ret['file']  = $newfile;
			$ret['message'] = str_replace("../", "", e_MEDIA_FILE)."".basename($newfile)." ";
			$ret['error'] = FALSE;
			return $ret;
		}
	}
	private function getFileList($language)
	{
		if(empty($language))
		{
			return false;
		}
		$PLUGINS_DIRECTORY      = e107::getFolder('plugins');
		$THEMES_DIRECTORY       = e107::getFolder('themes');
		$HELP_DIRECTORY         = e107::getFolder('help');
		$HANDLERS_DIRECTORY     = e107::getFolder('handlers');
		$core       = $this->getFilePaths(e_LANGUAGEDIR.$language."/", $language,''); // includes admin area.
	//	$core_admin = $this->getFilePaths(e_BASE.$LANGUAGES_DIRECTORY.$language."/admin/", $language,'');
		$core_admin = array();
		$plugs      = $this->getFilePaths(e_BASE.$PLUGINS_DIRECTORY, $language, $this->core_plugins); // standardized path.
		$theme      = $this->getFilePaths(e_BASE.$THEMES_DIRECTORY, $language, $this->core_themes);
		$docs       = $this->getFilePaths(e_BASE.$HELP_DIRECTORY,$language);
		$handlers   = $this->getFilePaths(e_BASE.$HANDLERS_DIRECTORY,$language); // standardized path.
		$file = array_merge($core,$core_admin, $plugs, $theme, $docs, $handlers);
		$file = array_unique($file);
		return $file;
	}
	/** todo */
	/*function removeLanguagePack($language)
	{
		$files = $this->getFileList($language);
	}*/
	/**
	 * @param $path
	 * @param $language
	 * @param string $filter
	 * @return array|bool
	 */
	public function getFilePaths($path, $language, $restrict=array())
	{
		$fl = e107::getFile();
		if ($lanlist = $fl->get_files($path, "", "standard", 4)) // (\.php|\.xml)$
		{
			sort($lanlist);
		}
		else
		{
			return array();
		}
		$pzip = array();
		foreach ($lanlist as $p)
		{
			$fullpath = $p['path'].$p['fname'];
			if (strpos($fullpath, $language) !== false)
			{
				$pzip[] = $fullpath;
			}
		}
		if(!empty($restrict)) // strip the list according to inclusion list.
		{
			$newlist = array();
			foreach($pzip as $k=>$p)
			{
				foreach($restrict as $accept)
				{
					if(strpos($p, '/'.$accept.'/')!==false)
					{
						$newlist[] = $p;
					}
				}
			}
			$pzip = $newlist;
		}
		return $pzip;
	}
	/**
	 * Get Installed Language-Pack Meta Data.
	 * @return array
	 */
	function getLocalLanguagePacks()
	{
		$this->installed_languages = e107::getLanguage()->installed();
		$xml = e107::getXml();
		$arr = array();
		foreach($this->installed_languages as $language)
		{
			if($language == "English")
			{
				continue;
			}
			$metaFile = e_LANGUAGEDIR.$language."/".$language.".xml";
			if(is_readable($metaFile))
			{
				$rawData = $xml->loadXMLfile($metaFile,true);
				if($rawData)
				{
					$value = $rawData['@attributes'];
				}
				else
				{
					$value = array(
						'date' 			=> " ",
						'compatibility' => ' '
					);
				}
			}
			else
			{
				$value = array(
					'date' 			=> " ",
					'compatibility' => ' '
				);
			}
			$value['type'] = 'local';
			$arr[$language] = $value;
		}
		return $arr;
	}
	/**
	 * Get Online Language-Pack Meta Data.
	 * @return array|bool
	 */
	public function getOnlineLanguagePacks()
	{
		$xml = e107::getXml();
		$feed = 'https://e107.org/languagepacks.xml';
		$version = e_VERSION;
		if(!empty($version))
		{
			$tmp = explode("-", $version);
			$ver = varset($tmp[0]); 
			$feed .= "?ver=". preg_replace('/[^\d\.]/','', $ver);
		}
		e107::getDebug()->log("Language Pack Feed: ".$feed);
		$languages = array();
		if($rawData = $xml -> loadXMLfile($feed, true))
		{
			if(empty($rawData['language']))
			{
				return false;
			}
			foreach($rawData['language'] as $key => $att)
			{
				// issue #3059 in case array @attributes is in $att
				if (is_int($key) && is_array($att) && array_key_exists('@attributes', $att))
				{
					$att = $att['@attributes'];
				}
				// issue #3059 Language list didn't load
				elseif ($key != '@attributes')
				{
					continue;
				}
				$id = $att['name'];
				// fix github double url bug...
				if (stripos($att['url'], 'https://github.comhttps://github.com') !== false)
				{
					$att['url'] = str_ireplace('https://github.comhttps://github.com', 'https://github.com', $att['url']);
				}
				if (stripos($att['infourl'], 'https://github.comhttps://github.com') !== false)
				{
					$att['infourl'] = str_ireplace('https://github.comhttps://github.com', 'https://github.com', $att['infourl']);
				}
				$languages[$id] = array(
					'name'          => $att['name'],
					'author'        => varset($att['author']),
					'infoURL'       => $att['infourl'],
					'tag'           => $att['tag'],
				//	'folder'        => $att['folder'],
					'version'       => $att['version'],
					'date'          => $att['date'],
					'compatibility' => $att['compatibility'],
					'url'           => $att['url'],
					'type'          => 'online'
				);
			}
		}
		else
		{
			e107::getDebug()->log("Language Pack Feed Failed: ".$xml->getLastErrorMessage());
		}
		return $languages;
	}
	function check_all($mode='render', $lan=null)
	{
		// global $ns,$tp;
		$mes = e107::getMessage();
		$tp = e107::getParser();
		if(empty($lan))
		{
			echo "debug: ".__METHOD__." missing \$lan";
			return false;
		}
			
	//	$lan = key($_POST['language_sel']);
		$_SESSION['lancheck'][$lan] = array();
		$_SESSION['lancheck'][$lan]['file']	= 0;
		$_SESSION['lancheck'][$lan]['def']	= 0;
		$_SESSION['lancheck'][$lan]['bom']	= 0;
		$_SESSION['lancheck'][$lan]['utf']	= 0;
		$_SESSION['lancheck'][$lan]['total']	= 0;
	
	
		$core_text 	= $this->check_core_lanfiles($lan);
		$core_admin = $this->check_core_lanfiles($lan,"admin/");
		$plug_text = "";
		$theme_text = "";
	
	
		// Plugins -------------
		$plug_header = "
		
		".LAN_PLUGIN." 
		".LAN_CHECK_16." 
		".$lan." 
		".LAN_OPTIONS."  ";
	
		foreach($this->core_plugins as $plugs)
		{
			if(is_readable(e_PLUGIN.$plugs))
			{
				$plug_text .= $this->check_lanfiles('P',$plugs,"English",$lan);
			}
		}
		
		$plug_footer = "
";
	
		// Themes  -------------
		$theme_header = "
		
		".LAN_THEME." 
		".LAN_CHECK_16." 
		".$lan." 
		".LAN_OPTIONS."  ";
		foreach($this->core_themes as $them)
		{
			if(is_readable(e_THEME.$them))
			{
				$theme_text .= $this->check_lanfiles('T',$them,"English",$lan);
			}
		}
		$theme_footer = "
";
		
		// -------------------------
		
		
		
		if($mode != 'render')
		{
			 return null;
		}
	
		$message = "
		
		";
		
//	print_a($_SESSION['lancheck'][$lan]);
		$plug_text = ($plug_text) ? $plug_header.$plug_text.$plug_footer : "".LAN_OK."
";
		$theme_text = ($theme_text) ? $theme_header.$theme_text.$theme_footer : "".LAN_OK."
";
		$mesStatus = ($_SESSION['lancheck'][$lan]['total']>0) ? E_MESSAGE_INFO : E_MESSAGE_SUCCESS;
			
		$mes->add($message, $mesStatus);	
			
	//	$ns -> tablerender(LAN_SUMMARY.": ".$lan,$message);
		$ret = array();
		$ret['text'] = $mes->render();
		$tabs = array(
			'core'   => array('caption'=> LAN_CHECK_26, 'text'=>$core_text),
			'admin'  => array('caption'=> LAN_ADMIN,    'text'=>$core_admin),
			'plugin' => array('caption'=> ADLAN_CL_7,   'text'=>$plug_text),
			'theme'  => array('caption'=> LAN_THEMES,   'text'=>$theme_text),
		);
		$ret['text'] .= e107::getForm()->tabs($tabs);
		$ret['caption'] = LAN_CHECK_2.SEP.$lan;
		return $ret;
/*
		$ns -> tablerender(LANG_LAN_21.SEP.$lan.SEP.LAN_CHECK_2, $core_text);
		$ns -> tablerender(LAN_CHECK_3.": ".$lan."/admin", $core_admin);
		$ns -> tablerender(ADLAN_CL_7, $plug_text);
		$ns -> tablerender(LAN_THEMES, $theme_text);	*/
		//TODO Add a return statement here.
	}
	
	function write_lanfile($lan='')
	{
		if(!$lan){ 	return; }
		global $ns;
		
		unset($input);
		$kom_start = chr(47)."*";
		$kom_end = "*".chr(47);
	
		if(!empty($_SESSION['lancheck-edit-file']))
		{
			$writeit = $_SESSION['lancheck-edit-file'];
		}
		else
		{
			e107::getMessage()->addError("There is a problem with sessions");
			return;
		}
	
		$old_kom = "";
		$in_kom=0;
		
		if(is_readable($writeit)) // File Exists; 
		{
			$data = file($writeit);
			foreach($data as $line)
			{
		
				if (strpos($line,$kom_start) !== False && $old_kom == "")
				{
					$in_kom=1;
				}
				if ($in_kom) { $old_kom .= $line; }
				if (strpos($line,$kom_end) !== False && $in_kom) {$in_kom = 0;}
			}	
		}
		
	
	
		$message = "
";
		/*
		 $input .= "\n\n?>";
		*/
		// Write to file.
		
		$writeit = str_replace("//","/",$writeit); // Quick Fix. 
		
		$fp = @fopen($writeit,"w");
		if(!@fwrite($fp, $input))
		{
			$caption = LAN_ERROR;
			$message = LAN_CHECK_17;
			$status = e107::getMessage()->addError($caption)->render();
		}
		else
		{
		//	$caption = LAN_SAVED." ".$lan."/".$writeit." ";
			$caption = LAN_SAVED." ".str_replace('..','',$writeit)." ";
			$status = e107::getMessage()->addSuccess($caption)->render();
		}
		fclose($fp);
	/*
		$message .= "";*/
	
		unset($_SESSION['lancheck-edit-file']);
		$ns->tablerender($caption, $status. $message);
	}
	
		
		
		
	function check_core_lanfiles($checklan,$subdir='')
	{
		$tp = e107::getParser();
	//	$sql->db_Mark_Time('Start Get Core Lan Phrases English');
		$English = $this->get_comp_lan_phrases(e_LANGUAGEDIR."English/".$subdir,"English");
		
	//	$sql->db_Mark_Time('End Get Core Lan Phrases English');
		$check = $this->get_comp_lan_phrases(e_LANGUAGEDIR.$checklan."/".$subdir,$checklan);
		
	//	print_a($check);
	//	return;
		$text = "";
	
		$header = "
		
		".LAN_CHECK_16." 
		".$this->transLanguage." ".LAN_FILE." 
		".LAN_OPTIONS."  ";
	
		$keys = array_keys($English);
	
		sort($keys);
		$er = "";
	
		foreach($keys as $k)
		{
			if($k == 'bom')
			{
				continue;
			}
				$lnk = $k;
				$k_check = str_replace("English",$checklan,$k);
				if(array_key_exists($k,$check))
				{
					// $text .= "";
					$subkeys = array_keys($English[$k]);
	
					$er="";
					$utf_error = "";
	
					$bomkey = str_replace(".php","",$k_check);
	
					if(!empty($check['bom'][$bomkey]))
					{
						$bom_error = "".$tp->lanVars(LAN_CHECK_15,array("'<?php'","'?>'"))." ".LAN_CHECK_19."  ";
					$style = ($er) ? "forumheader2" : "forumheader3";
					$text .= "";
					$text .= $bom_error . $utf_error;
					$text .= (!$er && !$bom_error && !$utf_error) ? defset('ADMIN_TRUE_ICON') : $er."
 
					
					"; // file missing.
				}
				// Leave in EDIT button for all entries - to allow re-translation of bad entries.
				$subpath = ($subdir!='') ? $subdir.$k : $k;
				$parms = $_GET;
				$parms['sub'] = 'edit';
				$parms['file'] = $subpath;
				$parms['lan'] = $this->transLanguage;
				$parms['iframe'] = 1;
				$editUrl = e_REQUEST_SELF."?".http_build_query($parms,'&');
				$text .="
				".LAN_EDIT." ";
				$text .="  ";
		}
		$footer = "
";
		
		if($text)
		{
			return $header.$text.$footer;	
		}
		else
		{
		 	return "".LAN_OK."
";
		}
	}
	
	function check_lan_errors($english,$translation,$def, $opts=array())
	{
		$eng_line = $english[$def];
		$trans_line = !empty($translation[$def]) ? $translation[$def] : '';
		
		// return $eng_line."".$def. ": ".LAN_CHECK_29." ";
		}
		
		if((strpos($eng_line,"[link=")!==FALSE && strpos($trans_line,"[link=")===FALSE) || (strpos($eng_line,"[b]")!==FALSE && strpos($trans_line,"[b]")===FALSE))
		{
			$error[] = $def. ": ".LAN_CHECK_30;
		}
		elseif((strpos($eng_line,"[")!==FALSE && strpos($trans_line,"[")===FALSE) || (strpos($eng_line,"]")!==FALSE && strpos($trans_line, "]")===FALSE))
		{
			$error[] = $def. ": ".LAN_CHECK_31;
		}
		
		if((strpos($eng_line,"--LINK--")!==false && strpos($trans_line,"--LINK--")===false))
		{
			$error[] = $def. ": Missing --LINK--";
		}
		
		if((strpos($eng_line,"e107.org")!==false && strpos($trans_line,"e107.org")===false))
		{
			$error[] = $def. ": Missing e107.org URL";
		}
		
		if((strpos($eng_line,"e107coders.org")!==FALSE && strpos($trans_line,"e107coders.org")===false))
		{
			$error[] = $def. ": Missing e107coders.org URL";
		}
		
		if(strip_tags($eng_line) != $eng_line)
		{
			$stripped = strip_tags($trans_line);
					
			if(($stripped == $trans_line))
			{					
				// echo "".$tp->lanVars(LAN_CHECK_15,array("'<?php'","'?>'"))." ".LAN_CHECK_15." ".LAN_CHECK_19." 
				
				";
	
				$style = ($er) ? "forumheader2" : "forumheader3";
				$text .= "";
				$text .= $bom_error . $utf_error;
				$text .= (!$er && !$bom_error && !$utf_error) ? defset('ADMIN_TRUE_ICON') : $er."
 
				
				
				";
			}
	
			$text .=" ";
		}
	
	
	
		// if (!$known) {$text = LAN_CHECK_18." : --> ".$fname." :: ".$dname;}
		return $text;
	}
	
	function newFile($lnk,$target_lan)
	{
		if($target_lan == 'English') 
		{
			return;	
		}
				
		$newfile = str_replace("English",$target_lan,$lnk);
		$dir = dirname($newfile);
				
		if($dir != '.' && !is_dir($dir))
		{
		//	echo "Raw Data ".$type." ";
		echo htmlentities($data);
		echo " ";	
	
		*/
			
	}
	
	
	
	//--------------------------------------------------------------------
	
	
	function is_utf8($str) {
		/*
		* @see http://hsivonen.iki.fi/php-utf8/   validation.php
		*/
		if(strtolower(CHARSET) != "utf-8" || $str == "")
		{
			return TRUE;
		}
	
		return (preg_match('/^./us',$str,$ar) == 1);
	}
	
	/**
	 * Clean-up definitions in a language file removed closing php tags and strip specific html..
	 * @param array $defKeys array of constants to comment out.
	 * @param string $path path to the language file to edit.
	 */
	function cleanFile($path, $defKeys=null)
	{
		if(empty($path) || !file_exists($path) || stripos($path,'English')!==false)
		{
			return null;
		}
		$content = file_get_contents($path);
		$lines = explode("\n",$content);
		$srch = array();
		$repl = array();
		$srch[] = '';
		$srch[] = ' ';
		$repl[] = '[b]';
		$repl[] = '[/b]';
		if(!empty($defKeys))
		{
			foreach($defKeys as $const)
			{
				$srch[] = "define('".$const."'";
				$srch[] = 'define("'.$const.'"';
				$repl[] = "// define('".$const."'";
				$repl[] = '// define("'.$const.'"';
			}
		}
		$new = '';
		foreach($lines as $ln)
		{
			if(strpos($ln,'?>') !==false)
			{   continue;
			}
			if(strpos($ln, '""') !== false || strpos($ln, "''") !== false) // empty
			{
				continue;
			}
			if(strpos($ln,'//') !==false)
			{
				$new .= $ln."\n";
				continue;
			}
			if(!empty($srch))
			{
				$new .= str_replace($srch,$repl,$ln)."\n";
			}
			else
			{
				$new .= $ln."\n";
			}
		}
		if(file_put_contents($path,$new))
		{
			return true;
		}
		return false;
	}
}