Skip to content

Commit

Permalink
initialize to emty array if unserialized data is not array
Browse files Browse the repository at this point in the history
  • Loading branch information
ssahara committed Apr 10, 2017
1 parent e794b11 commit 1e085cd
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class admin_plugin_preregister extends DokuWiki_Admin_Plugin {
var $output = '';
private $metaFn;

function __construct() {
function __construct() {
$metafile= 'preregister:db';
$this->metaFn = metaFN($metafile,'.ser');
}
Expand Down Expand Up @@ -80,7 +80,8 @@ function getConfirmList() {
}
}

$data = unserialize(io_readFile($this->metaFn,false));
$data = unserialize(io_readFile($this->metaFn,false));
if (!is_array($data)) $data = array();
$hidden = array();
$result = "<table cellspacing='2'><th>login</th><th>email</th><th>name</th><th>save time</th><th>age</th>";
$current_time = time();
Expand All @@ -104,7 +105,7 @@ function getConfirmList() {
}
return $result ."\n";
}

function secure_datafile() {
$perm = substr(sprintf('%o', fileperms($this->metaFn )), -4);
if(preg_match('/\d\d(\d)/',$perm,$matches)) {
Expand All @@ -117,16 +118,19 @@ function secure_datafile() {
}
}
}

function prune_datafile($which) {
$data = unserialize(io_readFile($this->metaFn,false));
$data = unserialize(io_readFile($this->metaFn,false));
if (!is_array($data)) $data = array();
foreach($data as $index=>$entry) {
if(in_array($index,$which)) {
unset($data[$index]);
}
}
}
}

io_saveFile($this->metaFn,serialize($data));
}

function js() {
echo <<<SCRIPT
<script type="text/javascript">
Expand Down

0 comments on commit 1e085cd

Please sign in to comment.