Project

General

Profile

« Previous | Next » 

Revision ff8b4019

Added by Renato Botelho over 7 years ago

Do no try to lock when file doesn't exist

View differences:

src/etc/inc/captiveportal.inc
1772 1772

  
1773 1773
	$removed_pipes = array();
1774 1774

  
1775
	if (!file_exists("{$g['vardb_path']}/captiveportaldn.rules")) {
1776
		return $removed_pipes;
1777
	}
1778

  
1775 1779
	if (!$dry_run) {
1776 1780
		$cpruleslck = lock("captiveportalrulesdn", LOCK_EX);
1777 1781
	}
1778
	if (file_exists("{$g['vardb_path']}/captiveportaldn.rules")) {
1779
		$rules = unserialize(file_get_contents(
1780
		    "{$g['vardb_path']}/captiveportaldn.rules"));
1781
		$ridx = $rulenos_start;
1782
		while ($ridx < $rulenos_range_max) {
1783
			if ($rules[$ridx] == $cpzone) {
1784
				if (!$dry_run) {
1785
					$rules[$ridx] = false;
1786
				}
1787
				$removed_pipes[] = $ridx;
1788
				$ridx++;
1789
				if (!$dry_run) {
1790
					$rules[$ridx] = false;
1791
				}
1792
				$removed_pipes[] = $ridx;
1793
				$ridx++;
1794
			} else {
1795
				$ridx += 2;
1782

  
1783
	$rules = unserialize(file_get_contents(
1784
	    "{$g['vardb_path']}/captiveportaldn.rules"));
1785
	$ridx = $rulenos_start;
1786
	while ($ridx < $rulenos_range_max) {
1787
		if ($rules[$ridx] == $cpzone) {
1788
			if (!$dry_run) {
1789
				$rules[$ridx] = false;
1796 1790
			}
1791
			$removed_pipes[] = $ridx;
1792
			$ridx++;
1793
			if (!$dry_run) {
1794
				$rules[$ridx] = false;
1795
			}
1796
			$removed_pipes[] = $ridx;
1797
			$ridx++;
1798
		} else {
1799
			$ridx += 2;
1797 1800
		}
1798
		if (!$dry_run) {
1799
			file_put_contents(
1800
			    "{$g['vardb_path']}/captiveportaldn.rules",
1801
			    serialize($rules));
1802
		}
1803
		unset($rules);
1804 1801
	}
1802

  
1805 1803
	if (!$dry_run) {
1804
		file_put_contents("{$g['vardb_path']}/captiveportaldn.rules",
1805
		    serialize($rules));
1806 1806
		unlock($cpruleslck);
1807 1807
	}
1808 1808

  
1809
	unset($rules);
1810

  
1809 1811
	return $removed_pipes;
1810 1812
}
1811 1813

  

Also available in: Unified diff