public static function jsonEncode($arr) { $Services_JSON = new pjServices_JSON(); return $Services_JSON->encode($arr); }
/** * array-walking function for use in generating JSON-formatted name-value pairs * * @param string $name name of key to use * @param mixed $value reference to an array element to be encoded * * @return string JSON-formatted name-value pair, like '"name":value' * @access private */ function name_value($name, $value) { $encoded_value = $this->encode($value); if (pjServices_JSON::isError($encoded_value)) { return $encoded_value; } return $this->encode(strval($name)) . ':' . $encoded_value; }
public function pjActionHash() { @set_time_limit(0); if (!function_exists('md5_file')) { die("Function <b>md5_file</b> doesn't exists"); } require 'app/config/config.inc.php'; # Origin hash ------------- if (!is_file(PJ_CONFIG_PATH . 'files.check')) { die("File <b>files.check</b> is missing"); } $json = @file_get_contents(PJ_CONFIG_PATH . 'files.check'); $Services_JSON = new pjServices_JSON(); $data = $Services_JSON->decode($json); if (is_null($data)) { die("File <b>files.check</b> is empty or broken"); } $origin = get_object_vars($data); # Current hash ------------ $data = array(); pjUtil::readDir($data, PJ_INSTALL_PATH); $current = array(); foreach ($data as $file) { $current[str_replace(PJ_INSTALL_PATH, '', $file)] = md5_file($file); } $html = '<style type="text/css"> table{border: solid 1px #000; border-collapse: collapse; font-family: Verdana, Arial, sans-serif; font-size: 14px} td{border: solid 1px #000; padding: 3px 5px; background-color: #fff; color: #000} .diff{background-color: #0066FF; color: #fff} .miss{background-color: #CC0000; color: #fff} </style> <table cellpadding="0" cellspacing="0"> <tr><td><strong>Filename</strong></td><td><strong>Status</strong></td></tr> '; foreach ($origin as $file => $hash) { if (isset($current[$file])) { if ($current[$file] == $hash) { } else { $html .= '<tr><td>' . $file . '</td><td class="diff">changed</td></tr>'; } } else { $html .= '<tr><td>' . $file . '</td><td class="miss">missing</td></tr>'; } } $html .= '<table>'; echo $html; exit; }