public function __construct($module_name)
 {
     $this->_module_name = trim($module_name);
     $this->_mod = \cms_utils::get_module($module_name);
     if (!$this->_mod) {
         throw new \RuntimeException(cgex_lang('err_modulenotfound', $module_name));
     }
     $dir = $this->_mod->GetModulePath();
     $this->_c1dat = $dir . '/_c1.dat';
     $this->_d1dat = $dir . '/_d1.dat';
     if (!is_writable($dir)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_dirwritable', $module_name));
     }
     if (is_file($this->_c1dat) && !is_writable($this->_c1dat)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_filewritable', $this->_c1dat));
     }
     if (is_file($this->_d1dat) && !is_writable($this->_d1dat)) {
         throw new \RuntimeException(cgex_lang('err_vrfy_filewritable', $this->_d1dat));
     }
 }
 protected final function get_checksum_value($filename)
 {
     if (!is_file($filename)) {
         throw new \LogicException(cgex_lang('err_vrfy_filenotfound', $filename));
     }
     $dir = $this->_mod->GetModulePath();
     if (!startswith($filename, $dir)) {
         throw new \LogicException(cgex_lang('err_vrfy_rootpath', $filename));
     }
     $salt = $this->get_salt();
     $md5 = md5_file($filename);
     $inp = "{$salt}::{$md5}\n";
     $val = md5($inp);
     return $val;
 }
 public function check_module_integrity()
 {
     if (!is_file($this->_cdat) || !is_file($this->_ddat)) {
         throw new \cg_notfoundexception(cgex_lang('err_vrfy_nochecksumdata', $this->_module_name));
     }
     // now validate the _c.dat with the _d.dat
     $this->check_checksum_integrity();
     if ($this->get_verify_code() != $this->get_signature()) {
         return FALSE;
     }
     return TRUE;
 }
 public static function load($id)
 {
     $id = (int) $id;
     $list = self::load_all();
     if (isset($list[$id])) {
         return $list[$id];
     }
     throw new \RuntimeException(cgex_lang('error_itemnotfound'));
 }