@@ -1,6 +1,9 @@  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | class altsysUtils  | 
                                                        
| 3 | 3 |  { | 
                                                        
| 4 | + /**  | 
                                                        |
| 5 | + * @param string $name  | 
                                                        |
| 6 | + */  | 
                                                        |
| 4 | 7 | public static function getDelegateCallbackClassNames($name, $doRegist = true)  | 
                                                        
| 5 | 8 |      { | 
                                                        
| 6 | 9 | $names = array();  | 
                                                        
@@ -5,7 +5,7 @@ discard block  | 
                                                    ||
| 5 | 5 |      { | 
                                                        
| 6 | 6 | $names = array();  | 
                                                        
| 7 | 7 | |
| 8 | -        if (! class_exists('XCube_Delegate')) { | 
                                                        |
| 8 | +        if (!class_exists('XCube_Delegate')) { | 
                                                        |
| 9 | 9 | return $names;  | 
                                                        
| 10 | 10 | }  | 
                                                        
| 11 | 11 | |
@@ -23,7 +23,7 @@ discard block  | 
                                                    ||
| 23 | 23 |                  foreach (array_keys($callbacks) as $priority) { | 
                                                        
| 24 | 24 |                      foreach (array_keys($callbacks[$priority]) as $idx) { | 
                                                        
| 25 | 25 | $callback = $callbacks[$priority][$idx][0];  | 
                                                        
| 26 | - $_name = (is_array($callback))? ((is_object($callback[0]))? get_class($callback[0]) : $callback[0]) : $callback;  | 
                                                        |
| 26 | + $_name = (is_array($callback)) ? ((is_object($callback[0])) ? get_class($callback[0]) : $callback[0]) : $callback;  | 
                                                        |
| 27 | 27 | $names[$priority] = $_name;  | 
                                                        
| 28 | 28 | }  | 
                                                        
| 29 | 29 | }  | 
                                                        
@@ -60,7 +60,7 @@ discard block  | 
                                                    ||
| 60 | 60 | return htmlspecialchars($str, $flags, $encoding, $double_encode);  | 
                                                        
| 61 | 61 |          } else { | 
                                                        
| 62 | 62 | $ret = htmlspecialchars($str, $flags, $encoding);  | 
                                                        
| 63 | -            if (! $double_encode) { | 
                                                        |
| 63 | +            if (!$double_encode) { | 
                                                        |
| 64 | 64 |                  $ret = str_replace('&amp;', '&', $ret); | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | 66 | return $ret;  | 
                                                        
@@ -35,6 +35,9 @@  | 
                                                    ||
| 35 | 35 | }  | 
                                                        
| 36 | 36 | |
| 37 | 37 | |
| 38 | + /**  | 
                                                        |
| 39 | + * @param string $resource  | 
                                                        |
| 40 | + */  | 
                                                        |
| 38 | 41 | public function read($resource, $mydirname, $mytrustdirname = null, $read_once = true)  | 
                                                        
| 39 | 42 |      { | 
                                                        
| 40 | 43 | $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php' ;  | 
                                                        
@@ -3,102 +3,102 @@ discard block  | 
                                                    ||
| 3 | 3 | class D3LanguageManager  | 
                                                        
| 4 | 4 |  { | 
                                                        
| 5 | 5 | |
| 6 | - public $default_language = 'english' ;  | 
                                                        |
| 7 | - public $language = 'english' ;  | 
                                                        |
| 8 | - public $salt ;  | 
                                                        |
| 9 | - public $cache_path ;  | 
                                                        |
| 10 | - public $cache_prefix = 'lang' ;  | 
                                                        |
| 11 | - public $my_language = false ;  | 
                                                        |
| 6 | + public $default_language = 'english';  | 
                                                        |
| 7 | + public $language = 'english';  | 
                                                        |
| 8 | + public $salt;  | 
                                                        |
| 9 | + public $cache_path;  | 
                                                        |
| 10 | + public $cache_prefix = 'lang';  | 
                                                        |
| 11 | + public $my_language = false;  | 
                                                        |
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | //HACK by domifara  | 
                                                        
| 15 | 15 | //public function D3LanguageManager()  | 
                                                        
| 16 | 16 | public function __construct()  | 
                                                        
| 17 | 17 |  { | 
                                                        
| 18 | -    $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']) ; | 
                                                        |
| 19 | - $this->salt = substr(md5(XOOPS_ROOT_PATH . XOOPS_DB_USER . XOOPS_DB_PREFIX), 0, 6) ;  | 
                                                        |
| 20 | - $this->cache_path = XOOPS_TRUST_PATH.'/cache' ;  | 
                                                        |
| 18 | +    $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']); | 
                                                        |
| 19 | + $this->salt = substr(md5(XOOPS_ROOT_PATH.XOOPS_DB_USER.XOOPS_DB_PREFIX), 0, 6);  | 
                                                        |
| 20 | + $this->cache_path = XOOPS_TRUST_PATH.'/cache';  | 
                                                        |
| 21 | 21 | |
| 22 | 22 |      if (defined('ALTSYS_MYLANGUAGE_ROOT_PATH') && file_exists(ALTSYS_MYLANGUAGE_ROOT_PATH)) { | 
                                                        
| 23 | - $this->my_language = ALTSYS_MYLANGUAGE_ROOT_PATH ;  | 
                                                        |
| 23 | + $this->my_language = ALTSYS_MYLANGUAGE_ROOT_PATH;  | 
                                                        |
| 24 | 24 | }  | 
                                                        
| 25 | 25 | }  | 
                                                        
| 26 | 26 | //HACK by domifara for php5.3+  | 
                                                        
| 27 | 27 | //function &getInstance( $conn = null )  | 
                                                        
| 28 | 28 | public static function &getInstance($conn = null)  | 
                                                        
| 29 | 29 |  { | 
                                                        
| 30 | - static $instance ;  | 
                                                        |
| 31 | -    if (! isset($instance)) { | 
                                                        |
| 32 | - $instance = new D3LanguageManager() ;  | 
                                                        |
| 30 | + static $instance;  | 
                                                        |
| 31 | +    if (!isset($instance)) { | 
                                                        |
| 32 | + $instance = new D3LanguageManager();  | 
                                                        |
| 33 | 33 | }  | 
                                                        
| 34 | - return $instance ;  | 
                                                        |
| 34 | + return $instance;  | 
                                                        |
| 35 | 35 | }  | 
                                                        
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | public function read($resource, $mydirname, $mytrustdirname = null, $read_once = true)  | 
                                                        
| 39 | 39 |      { | 
                                                        
| 40 | - $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php' ;  | 
                                                        |
| 40 | + $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php';  | 
                                                        |
| 41 | 41 | |
| 42 | 42 |          if (empty($mytrustdirname) && file_exists($d3file)) { | 
                                                        
| 43 | - require $d3file ;  | 
                                                        |
| 43 | + require $d3file;  | 
                                                        |
| 44 | 44 | }  | 
                                                        
| 45 | 45 | |
| 46 | 46 |          if (empty($this->language)) { | 
                                                        
| 47 | -            $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']) ; | 
                                                        |
| 47 | +            $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']); | 
                                                        |
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | - $cache_file = $this->getCacheFileName($resource, $mydirname) ;  | 
                                                        |
| 51 | - $root_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->language.'/'.$resource ;  | 
                                                        |
| 50 | + $cache_file = $this->getCacheFileName($resource, $mydirname);  | 
                                                        |
| 51 | + $root_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->language.'/'.$resource;  | 
                                                        |
| 52 | 52 | |
| 53 | 53 | // language overriding by XOOPS_ROOT_PATH/my_language  | 
                                                        
| 54 | 54 |      if ($this->my_language) { | 
                                                        
| 55 | - $mylang_file = $this->my_language.'/modules/'.$mydirname.'/'.$this->language.'/'.$resource ;  | 
                                                        |
| 55 | + $mylang_file = $this->my_language.'/modules/'.$mydirname.'/'.$this->language.'/'.$resource;  | 
                                                        |
| 56 | 56 |          if (file_exists($mylang_file)) { | 
                                                        
| 57 | - require_once $mylang_file ;  | 
                                                        |
| 57 | + require_once $mylang_file;  | 
                                                        |
| 58 | 58 | }  | 
                                                        
| 59 | - $original_error_level = error_reporting() ;  | 
                                                        |
| 60 | - error_reporting($original_error_level & ~ E_NOTICE) ;  | 
                                                        |
| 59 | + $original_error_level = error_reporting();  | 
                                                        |
| 60 | + error_reporting($original_error_level & ~ E_NOTICE);  | 
                                                        |
| 61 | 61 | }  | 
                                                        
| 62 | 62 | |
| 63 | 63 |          if (empty($mytrustdirname)) { | 
                                                        
| 64 | 64 | // conventional module  | 
                                                        
| 65 | - $default_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->default_language.'/'.$resource ;  | 
                                                        |
| 65 | + $default_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->default_language.'/'.$resource;  | 
                                                        |
| 66 | 66 | |
| 67 | 67 |              if (file_exists($cache_file)) { | 
                                                        
| 68 | - require_once $cache_file ;  | 
                                                        |
| 68 | + require_once $cache_file;  | 
                                                        |
| 69 | 69 |              } elseif (file_exists($root_file)) { | 
                                                        
| 70 | - require_once $root_file ;  | 
                                                        |
| 70 | + require_once $root_file;  | 
                                                        |
| 71 | 71 |              } elseif (file_exists($default_file)) { | 
                                                        
| 72 | 72 | // fall back english  | 
                                                        
| 73 | - require_once $default_file ;  | 
                                                        |
| 73 | + require_once $default_file;  | 
                                                        |
| 74 | 74 | }  | 
                                                        
| 75 | 75 |          } else { | 
                                                        
| 76 | 76 | // D3 modules  | 
                                                        
| 77 | - $trust_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->language.'/'.$resource ;  | 
                                                        |
| 78 | - $default_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->default_language.'/'.$resource ;  | 
                                                        |
| 77 | + $trust_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->language.'/'.$resource;  | 
                                                        |
| 78 | + $default_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->default_language.'/'.$resource;  | 
                                                        |
| 79 | 79 | |
| 80 | 80 |              if (file_exists($cache_file)) { | 
                                                        
| 81 | - require_once $cache_file ;  | 
                                                        |
| 81 | + require_once $cache_file;  | 
                                                        |
| 82 | 82 |              } elseif (file_exists($root_file)) { | 
                                                        
| 83 | - require_once $root_file ;  | 
                                                        |
| 83 | + require_once $root_file;  | 
                                                        |
| 84 | 84 |              } elseif (file_exists($trust_file)) { | 
                                                        
| 85 | 85 |                  if ($read_once) { | 
                                                        
| 86 | - require_once $trust_file ;  | 
                                                        |
| 86 | + require_once $trust_file;  | 
                                                        |
| 87 | 87 |                  } else { | 
                                                        
| 88 | - require $trust_file ;  | 
                                                        |
| 88 | + require $trust_file;  | 
                                                        |
| 89 | 89 | }  | 
                                                        
| 90 | 90 |              } elseif (file_exists($default_file)) { | 
                                                        
| 91 | 91 | // fall back english  | 
                                                        
| 92 | 92 |              if ($read_once) { | 
                                                        
| 93 | - require_once $default_file ;  | 
                                                        |
| 93 | + require_once $default_file;  | 
                                                        |
| 94 | 94 |              } else { | 
                                                        
| 95 | - require $default_file ;  | 
                                                        |
| 95 | + require $default_file;  | 
                                                        |
| 96 | 96 | }  | 
                                                        
| 97 | 97 | }  | 
                                                        
| 98 | 98 | }  | 
                                                        
| 99 | 99 | |
| 100 | 100 |          if ($this->my_language) { | 
                                                        
| 101 | - error_reporting($original_error_level) ;  | 
                                                        |
| 101 | + error_reporting($original_error_level);  | 
                                                        |
| 102 | 102 | }  | 
                                                        
| 103 | 103 | }  | 
                                                        
| 104 | 104 | |
@@ -106,8 +106,8 @@ discard block  | 
                                                    ||
| 106 | 106 | public function getCacheFileName($resource, $mydirname, $language = null)  | 
                                                        
| 107 | 107 |      { | 
                                                        
| 108 | 108 |          if (empty($language)) { | 
                                                        
| 109 | - $language = $this->language ;  | 
                                                        |
| 109 | + $language = $this->language;  | 
                                                        |
| 110 | 110 | }  | 
                                                        
| 111 | - return $this->cache_path . '/' . $this->cache_prefix . '_' . $this->salt . '_' . $mydirname . '_' . $language . '_' . $resource ;  | 
                                                        |
| 111 | + return $this->cache_path.'/'.$this->cache_prefix.'_'.$this->salt.'_'.$mydirname.'_'.$language.'_'.$resource;  | 
                                                        |
| 112 | 112 | }  | 
                                                        
| 113 | 113 | }  | 
                                                        
@@ -261,6 +261,9 @@  | 
                                                    ||
| 261 | 261 | </form>\n" ;  | 
                                                        
| 262 | 262 | }  | 
                                                        
| 263 | 263 | |
| 264 | + /**  | 
                                                        |
| 265 | + * @param string $name  | 
                                                        |
| 266 | + */  | 
                                                        |
| 264 | 267 | public function get_select($name, $options, $current_value)  | 
                                                        
| 265 | 268 |      { | 
                                                        
| 266 | 269 | $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n" ;  | 
                                                        
@@ -2,40 +2,40 @@ discard block  | 
                                                    ||
| 2 | 2 | |
| 3 | 3 | class d3utilities  | 
                                                        
| 4 | 4 |  { | 
                                                        
| 5 | - public $dirname = '' ; // directory name under xoops_trust_path  | 
                                                        |
| 6 | - public $mydirname = '' ; // each directory name under xoops_root_path  | 
                                                        |
| 7 | - public $mid = 0 ; // id of each module instance  | 
                                                        |
| 8 | - public $table = '' ; // table with prefix and dirname  | 
                                                        |
| 9 | - public $primary_key = '' ; // column for primary_key  | 
                                                        |
| 10 | - public $cols = array() ; // settings of each columns  | 
                                                        |
| 11 | - public $form_mode = 'new' ; // 'new','edit' are available  | 
                                                        |
| 12 | - public $page_name = '' ; // controller's name eg) page=(controller) in URI  | 
                                                        |
| 13 | - public $action_base_hiddens = array() ;  | 
                                                        |
| 5 | + public $dirname = ''; // directory name under xoops_trust_path  | 
                                                        |
| 6 | + public $mydirname = ''; // each directory name under xoops_root_path  | 
                                                        |
| 7 | + public $mid = 0; // id of each module instance  | 
                                                        |
| 8 | + public $table = ''; // table with prefix and dirname  | 
                                                        |
| 9 | + public $primary_key = ''; // column for primary_key  | 
                                                        |
| 10 | + public $cols = array(); // settings of each columns  | 
                                                        |
| 11 | + public $form_mode = 'new'; // 'new','edit' are available  | 
                                                        |
| 12 | + public $page_name = ''; // controller's name eg) page=(controller) in URI  | 
                                                        |
| 13 | + public $action_base_hiddens = array();  | 
                                                        |
| 14 | 14 | |
| 15 | 15 | //HACK by domifara  | 
                                                        
| 16 | 16 | // public function D3Utilities( $mydirname , $table_body , $primary_key , $cols , $page_name , $action_base_hiddens )  | 
                                                        
| 17 | 17 | public function __construct($mydirname, $table_body, $primary_key, $cols, $page_name, $action_base_hiddens)  | 
                                                        
| 18 | 18 |      { | 
                                                        
| 19 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ;  | 
                                                        |
| 20 | -  | 
                                                        |
| 21 | - $this->dirname = basename(dirname(__DIR__)) ;  | 
                                                        |
| 22 | - $this->mydirname = $mydirname ;  | 
                                                        |
| 23 | - $this->table = $db->prefix($mydirname ? $mydirname . '_' . $table_body : $table_body) ;  | 
                                                        |
| 24 | - $this->primary_key = $primary_key ;  | 
                                                        |
| 25 | - $this->cols = $cols ;  | 
                                                        |
| 26 | -        $module_handler = xoops_getHandler('module') ; | 
                                                        |
| 27 | - $module = $module_handler->getByDirname($this->mydirname) ;  | 
                                                        |
| 28 | -        if (! empty($module)) { | 
                                                        |
| 19 | + $db = XoopsDatabaseFactory::getDatabaseConnection();  | 
                                                        |
| 20 | +  | 
                                                        |
| 21 | + $this->dirname = basename(dirname(__DIR__));  | 
                                                        |
| 22 | + $this->mydirname = $mydirname;  | 
                                                        |
| 23 | + $this->table = $db->prefix($mydirname ? $mydirname.'_'.$table_body : $table_body);  | 
                                                        |
| 24 | + $this->primary_key = $primary_key;  | 
                                                        |
| 25 | + $this->cols = $cols;  | 
                                                        |
| 26 | +        $module_handler = xoops_getHandler('module'); | 
                                                        |
| 27 | + $module = $module_handler->getByDirname($this->mydirname);  | 
                                                        |
| 28 | +        if (!empty($module)) { | 
                                                        |
| 29 | 29 |              $this->mid = (int)$module->getVar('mid'); | 
                                                        
| 30 | 30 | }  | 
                                                        
| 31 | - $this->page_name = $page_name ;  | 
                                                        |
| 32 | - $this->action_base_hiddens = $action_base_hiddens ;  | 
                                                        |
| 31 | + $this->page_name = $page_name;  | 
                                                        |
| 32 | + $this->action_base_hiddens = $action_base_hiddens;  | 
                                                        |
| 33 | 33 | }  | 
                                                        
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | public function get_language_constant($name)  | 
                                                        
| 37 | 37 |      { | 
                                                        
| 38 | -        return constant(strtoupper('_MD_A_' . $this->dirname . '_' . $this->page_name . '_' . $name)) ; | 
                                                        |
| 38 | +        return constant(strtoupper('_MD_A_'.$this->dirname.'_'.$this->page_name.'_'.$name)); | 
                                                        |
| 39 | 39 | }  | 
                                                        
| 40 | 40 | |
| 41 | 41 | |
@@ -45,22 +45,22 @@ discard block  | 
                                                    ||
| 45 | 45 | case 'text':  | 
                                                        
| 46 | 46 | case 'blob':  | 
                                                        
| 47 | 47 | $length = empty($col['length']) ? 65535 : (int)$col['length'];  | 
                                                        
| 48 | -                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ; | 
                                                        |
| 48 | +                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'"; | 
                                                        |
| 49 | 49 | case 'char':  | 
                                                        
| 50 | 50 | case 'varchar':  | 
                                                        
| 51 | 51 | case 'string':  | 
                                                        
| 52 | 52 | $length = empty($col['length']) ? 255 : (int)$col['length'];  | 
                                                        
| 53 | -                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ; | 
                                                        |
| 53 | +                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'"; | 
                                                        |
| 54 | 54 | case 'int':  | 
                                                        
| 55 | 55 | case 'integer':  | 
                                                        
| 56 | 56 | $value = (int)$value;  | 
                                                        
| 57 | -                if (! empty($col['max'])) { | 
                                                        |
| 58 | - $value = min($value, (int)$col['max']) ;  | 
                                                        |
| 57 | +                if (!empty($col['max'])) { | 
                                                        |
| 58 | + $value = min($value, (int)$col['max']);  | 
                                                        |
| 59 | 59 | }  | 
                                                        
| 60 | -                if (! empty($col['min'])) { | 
                                                        |
| 61 | - $value = max($value, (int)$col['min']) ;  | 
                                                        |
| 60 | +                if (!empty($col['min'])) { | 
                                                        |
| 61 | + $value = max($value, (int)$col['min']);  | 
                                                        |
| 62 | 62 | }  | 
                                                        
| 63 | -                return "`{$col['name']}`=$value" ; | 
                                                        |
| 63 | +                return "`{$col['name']}`=$value"; | 
                                                        |
| 64 | 64 | }  | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | 66 | |
@@ -68,29 +68,29 @@ discard block  | 
                                                    ||
| 68 | 68 | // single update or insert  | 
                                                        
| 69 | 69 | public function insert()  | 
                                                        
| 70 | 70 |      { | 
                                                        
| 71 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ;  | 
                                                        |
| 71 | + $db = XoopsDatabaseFactory::getDatabaseConnection();  | 
                                                        |
| 72 | 72 | |
| 73 | - $id = $this->init_default_values() ;  | 
                                                        |
| 73 | + $id = $this->init_default_values();  | 
                                                        |
| 74 | 74 | |
| 75 | - $set4sql = '' ;  | 
                                                        |
| 75 | + $set4sql = '';  | 
                                                        |
| 76 | 76 |          foreach ($this->cols as $col) { | 
                                                        
| 77 | 77 |              if (empty($col['edit_edit'])) { | 
                                                        
| 78 | - continue ;  | 
                                                        |
| 78 | + continue;  | 
                                                        |
| 79 | 79 | }  | 
                                                        
| 80 | 80 |              if ($col['name'] == $this->primary_key) { | 
                                                        
| 81 | - continue ;  | 
                                                        |
| 81 | + continue;  | 
                                                        |
| 82 | 82 | }  | 
                                                        
| 83 | - $set4sql .= $this->get_set4sql(@$_POST[ $col['name'] ], $col) . ',' ;  | 
                                                        |
| 83 | + $set4sql .= $this->get_set4sql(@$_POST[$col['name']], $col).',';  | 
                                                        |
| 84 | 84 | }  | 
                                                        
| 85 | -        if (! empty($set4sql)) { | 
                                                        |
| 85 | +        if (!empty($set4sql)) { | 
                                                        |
| 86 | 86 |              if ($id > 0) { | 
                                                        
| 87 | 87 | // UPDATE  | 
                                                        
| 88 | -                $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key='".addslashes($id)."'") ; | 
                                                        |
| 89 | - return array( $id , 'update' ) ;  | 
                                                        |
| 88 | +                $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key='".addslashes($id)."'"); | 
                                                        |
| 89 | + return array($id, 'update');  | 
                                                        |
| 90 | 90 |              } else { | 
                                                        
| 91 | 91 | // INSERT  | 
                                                        
| 92 | -                $db->queryF("INSERT INTO $this->table SET ".substr($set4sql, 0, -1)) ; | 
                                                        |
| 93 | - return array( $db->getInsertId() , 'insert' ) ;  | 
                                                        |
| 92 | +                $db->queryF("INSERT INTO $this->table SET ".substr($set4sql, 0, -1)); | 
                                                        |
| 93 | + return array($db->getInsertId(), 'insert');  | 
                                                        |
| 94 | 94 | }  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | }  | 
                                                        
@@ -99,156 +99,156 @@ discard block  | 
                                                    ||
| 99 | 99 | // multiple update  | 
                                                        
| 100 | 100 | public function update()  | 
                                                        
| 101 | 101 |      { | 
                                                        
| 102 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ;  | 
                                                        |
| 102 | + $db = XoopsDatabaseFactory::getDatabaseConnection();  | 
                                                        |
| 103 | 103 | |
| 104 | 104 | // search appropriate column for getting primary_key  | 
                                                        
| 105 | 105 |          foreach ($this->cols as $col) { | 
                                                        
| 106 | -            if (in_array(@$col['list_edit'], array( 'text', 'textarea', 'hidden' ))) { | 
                                                        |
| 107 | - $column4key = $col['name'] ;  | 
                                                        |
| 108 | - break ;  | 
                                                        |
| 106 | +            if (in_array(@$col['list_edit'], array('text', 'textarea', 'hidden'))) { | 
                                                        |
| 107 | + $column4key = $col['name'];  | 
                                                        |
| 108 | + break;  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | }  | 
                                                        
| 111 | 111 |          if (empty($column4key)) { | 
                                                        
| 112 | - $column4key = $this->cols[0]['name'] ;  | 
                                                        |
| 112 | + $column4key = $this->cols[0]['name'];  | 
                                                        |
| 113 | 113 | }  | 
                                                        
| 114 | 114 | |
| 115 | - $ret = array() ;  | 
                                                        |
| 115 | + $ret = array();  | 
                                                        |
| 116 | 116 |          foreach (array_keys($_POST[$column4key]) as $id) { | 
                                                        
| 117 | - $id = (int)$id; // primary_key should be 'integer'  | 
                                                        |
| 118 | - $set4sql = '' ;  | 
                                                        |
| 117 | + $id = (int)$id; // primary_key should be 'integer'  | 
                                                        |
| 118 | + $set4sql = '';  | 
                                                        |
| 119 | 119 |              foreach ($this->cols as $col) { | 
                                                        
| 120 | 120 |                  if (empty($col['list_edit'])) { | 
                                                        
| 121 | - continue ;  | 
                                                        |
| 121 | + continue;  | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | 123 |                  if ($col['name'] == $this->primary_key) { | 
                                                        
| 124 | - continue ;  | 
                                                        |
| 124 | + continue;  | 
                                                        |
| 125 | 125 | }  | 
                                                        
| 126 | - $set4sql .= $this->get_set4sql(@$_POST[ $col['name'] ][$id], $col) . ',' ;  | 
                                                        |
| 126 | + $set4sql .= $this->get_set4sql(@$_POST[$col['name']][$id], $col).',';  | 
                                                        |
| 127 | 127 | }  | 
                                                        
| 128 | -            if (! empty($set4sql)) { | 
                                                        |
| 129 | -                $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; | 
                                                        |
| 128 | +            if (!empty($set4sql)) { | 
                                                        |
| 129 | +                $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); | 
                                                        |
| 130 | 130 |                  if ($db->getRowsNum($result) == 1) { | 
                                                        
| 131 | -                    $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key=$id") ; | 
                                                        |
| 131 | +                    $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key=$id"); | 
                                                        |
| 132 | 132 |                      if ($db->getAffectedRows() == 1) { | 
                                                        
| 133 | - $ret[ $id ] = $db->fetchArray($result) ;  | 
                                                        |
| 133 | + $ret[$id] = $db->fetchArray($result);  | 
                                                        |
| 134 | 134 | }  | 
                                                        
| 135 | 135 | }  | 
                                                        
| 136 | 136 | }  | 
                                                        
| 137 | 137 | }  | 
                                                        
| 138 | 138 | |
| 139 | - return $ret ;  | 
                                                        |
| 139 | + return $ret;  | 
                                                        |
| 140 | 140 | }  | 
                                                        
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | public function delete($delete_comments = false, $delete_notifications = false)  | 
                                                        
| 144 | 144 |      { | 
                                                        
| 145 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ;  | 
                                                        |
| 145 | + $db = XoopsDatabaseFactory::getDatabaseConnection();  | 
                                                        |
| 146 | 146 | |
| 147 | - $ret = array() ;  | 
                                                        |
| 147 | + $ret = array();  | 
                                                        |
| 148 | 148 |          foreach (array_keys($_POST['admin_main_checkboxes']) as $id) { | 
                                                        
| 149 | - $id = (int)$id; // primary_key should be 'integer'  | 
                                                        |
| 150 | -            $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; | 
                                                        |
| 149 | + $id = (int)$id; // primary_key should be 'integer'  | 
                                                        |
| 150 | +            $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); | 
                                                        |
| 151 | 151 |              if ($db->getRowsNum($result) == 1) { | 
                                                        
| 152 | - $ret[ $id ] = $db->fetchArray($result) ;  | 
                                                        |
| 152 | + $ret[$id] = $db->fetchArray($result);  | 
                                                        |
| 153 | 153 | |
| 154 | -                $db->queryF("DELETE FROM $this->table WHERE $this->primary_key=$id") ; | 
                                                        |
| 154 | +                $db->queryF("DELETE FROM $this->table WHERE $this->primary_key=$id"); | 
                                                        |
| 155 | 155 |                  if ($delete_comments) { | 
                                                        
| 156 | 156 | // remove comments  | 
                                                        
| 157 | -                    $db->queryF('DELETE FROM ' . $db->prefix('xoopscomments') . " WHERE com_modid=$this->mid AND com_itemid=$id") ; | 
                                                        |
| 157 | +                    $db->queryF('DELETE FROM '.$db->prefix('xoopscomments')." WHERE com_modid=$this->mid AND com_itemid=$id"); | 
                                                        |
| 158 | 158 | }  | 
                                                        
| 159 | 159 | |
| 160 | 160 |                  if ($delete_notifications) { | 
                                                        
| 161 | 161 | // remove notifications  | 
                                                        
| 162 | -                    $db->queryF('DELETE FROM ' . $db->prefix('xoopsnotifications') . " WHERE not_modid=$this->mid AND not_itemid=$id") ; | 
                                                        |
| 162 | +                    $db->queryF('DELETE FROM '.$db->prefix('xoopsnotifications')." WHERE not_modid=$this->mid AND not_itemid=$id"); | 
                                                        |
| 163 | 163 | }  | 
                                                        
| 164 | 164 | }  | 
                                                        
| 165 | 165 | }  | 
                                                        
| 166 | 166 | |
| 167 | - return $ret ;  | 
                                                        |
| 167 | + return $ret;  | 
                                                        |
| 168 | 168 | }  | 
                                                        
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | public function init_default_values()  | 
                                                        
| 172 | 172 |      { | 
                                                        
| 173 | - $db = XoopsDatabaseFactory::getDatabaseConnection() ;  | 
                                                        |
| 173 | + $db = XoopsDatabaseFactory::getDatabaseConnection();  | 
                                                        |
| 174 | 174 | |
| 175 | 175 |          if (@$_GET['id']) { | 
                                                        
| 176 | 176 | $id = (int)$_GET['id'];  | 
                                                        
| 177 | -            $rs = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; | 
                                                        |
| 177 | +            $rs = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); | 
                                                        |
| 178 | 178 |              if ($db->getRowsNum($rs) == 1) { | 
                                                        
| 179 | - $row = $db->fetchArray($rs) ;  | 
                                                        |
| 179 | + $row = $db->fetchArray($rs);  | 
                                                        |
| 180 | 180 |                  foreach (array_keys($this->cols) as $key) { | 
                                                        
| 181 | 181 |                      if (empty($this->cols[$key]['edit_show'])) { | 
                                                        
| 182 | - continue ;  | 
                                                        |
| 182 | + continue;  | 
                                                        |
| 183 | 183 | }  | 
                                                        
| 184 | - $this->cols[$key]['default_value'] = $row[ $this->cols[$key]['name'] ] ;  | 
                                                        |
| 184 | + $this->cols[$key]['default_value'] = $row[$this->cols[$key]['name']];  | 
                                                        |
| 185 | 185 | }  | 
                                                        
| 186 | - $this->form_mode = 'edit' ;  | 
                                                        |
| 187 | - return $id ;  | 
                                                        |
| 186 | + $this->form_mode = 'edit';  | 
                                                        |
| 187 | + return $id;  | 
                                                        |
| 188 | 188 | }  | 
                                                        
| 189 | 189 | }  | 
                                                        
| 190 | 190 | |
| 191 | - $this->form_mode = 'new' ;  | 
                                                        |
| 192 | - return 0 ;  | 
                                                        |
| 191 | + $this->form_mode = 'new';  | 
                                                        |
| 192 | + return 0;  | 
                                                        |
| 193 | 193 | }  | 
                                                        
| 194 | 194 | |
| 195 | 195 | |
| 196 | 196 | public function get_view_edit()  | 
                                                        
| 197 | 197 |      { | 
                                                        
| 198 | - $id = $this->init_default_values() ;  | 
                                                        |
| 198 | + $id = $this->init_default_values();  | 
                                                        |
| 199 | 199 | |
| 200 | - $lines = array() ;  | 
                                                        |
| 200 | + $lines = array();  | 
                                                        |
| 201 | 201 |          foreach ($this->cols as $col) { | 
                                                        
| 202 | 202 |              if (empty($col['edit_show'])) { | 
                                                        
| 203 | - continue ;  | 
                                                        |
| 203 | + continue;  | 
                                                        |
| 204 | 204 | }  | 
                                                        
| 205 | -            if (! isset($col['default_value'])) { | 
                                                        |
| 205 | +            if (!isset($col['default_value'])) { | 
                                                        |
| 206 | 206 |                  switch ($col['type']) { | 
                                                        
| 207 | 207 | case 'int':  | 
                                                        
| 208 | 208 | case 'integer':  | 
                                                        
| 209 | - $col['default_value'] = 0 ;  | 
                                                        |
| 210 | - break ;  | 
                                                        |
| 209 | + $col['default_value'] = 0;  | 
                                                        |
| 210 | + break;  | 
                                                        |
| 211 | 211 | default:  | 
                                                        
| 212 | - $col['default_value'] = '' ;  | 
                                                        |
| 213 | - break ;  | 
                                                        |
| 212 | + $col['default_value'] = '';  | 
                                                        |
| 213 | + break;  | 
                                                        |
| 214 | 214 | }  | 
                                                        
| 215 | 215 | }  | 
                                                        
| 216 | 216 |              switch ($col['edit_edit']) { | 
                                                        
| 217 | 217 | case 'checkbox':  | 
                                                        
| 218 | - $checked = empty($col['default_value']) ? '' : "checked='checked'" ;  | 
                                                        |
| 219 | - $value = empty($col['checkbox_value']) ? 1 : htmlspecialchars($col['checkbox_value'], ENT_QUOTES) ;  | 
                                                        |
| 218 | + $checked = empty($col['default_value']) ? '' : "checked='checked'";  | 
                                                        |
| 219 | + $value = empty($col['checkbox_value']) ? 1 : htmlspecialchars($col['checkbox_value'], ENT_QUOTES);  | 
                                                        |
| 220 | 220 | |
| 221 | -                    $lines[ $col['name'] ] = "<input type='checkbox' name='{$col['name']}' value='$value' $checked />" ; | 
                                                        |
| 222 | - break ;  | 
                                                        |
| 221 | +                    $lines[$col['name']] = "<input type='checkbox' name='{$col['name']}' value='$value' $checked />"; | 
                                                        |
| 222 | + break;  | 
                                                        |
| 223 | 223 | case 'text':  | 
                                                        
| 224 | 224 | default:  | 
                                                        
| 225 | 225 | $size = empty($col['edit_size']) ? 32 : (int)$col['edit_size'];  | 
                                                        
| 226 | 226 | $length = empty($col['length']) ? 255 : (int)$col['length'];  | 
                                                        
| 227 | -                    $lines[ $col['name'] ] = "<input type='text' name='{$col['name']}' size='$size' maxlength='$length' value='".htmlspecialchars($col['default_value'], ENT_QUOTES)."' />" ; | 
                                                        |
| 228 | - break ;  | 
                                                        |
| 227 | +                    $lines[$col['name']] = "<input type='text' name='{$col['name']}' size='$size' maxlength='$length' value='".htmlspecialchars($col['default_value'], ENT_QUOTES)."' />"; | 
                                                        |
| 228 | + break;  | 
                                                        |
| 229 | 229 | case false:  | 
                                                        
| 230 | - $lines[ $col['name'] ] = htmlspecialchars($col['default_value'], ENT_QUOTES) ;  | 
                                                        |
| 231 | - break ;  | 
                                                        |
| 230 | + $lines[$col['name']] = htmlspecialchars($col['default_value'], ENT_QUOTES);  | 
                                                        |
| 231 | + break;  | 
                                                        |
| 232 | 232 | }  | 
                                                        
| 233 | 233 | }  | 
                                                        
| 234 | 234 | |
| 235 | - return array( $id , $lines ) ;  | 
                                                        |
| 235 | + return array($id, $lines);  | 
                                                        |
| 236 | 236 | }  | 
                                                        
| 237 | 237 | |
| 238 | 238 | |
| 239 | 239 | public function get_control_form($controllers)  | 
                                                        
| 240 | 240 |      { | 
                                                        
| 241 | - $hiddens = '' ;  | 
                                                        |
| 241 | + $hiddens = '';  | 
                                                        |
| 242 | 242 |          foreach ($this->action_base_hiddens as $key => $val) { | 
                                                        
| 243 | - $key4disp = htmlspecialchars($key, ENT_QUOTES) ;  | 
                                                        |
| 244 | - $val4disp = htmlspecialchars($val, ENT_QUOTES) ;  | 
                                                        |
| 245 | - $hiddens .= "<input type='hidden' name='$key4disp' value='$val4disp' />\n" ;  | 
                                                        |
| 243 | + $key4disp = htmlspecialchars($key, ENT_QUOTES);  | 
                                                        |
| 244 | + $val4disp = htmlspecialchars($val, ENT_QUOTES);  | 
                                                        |
| 245 | + $hiddens .= "<input type='hidden' name='$key4disp' value='$val4disp' />\n";  | 
                                                        |
| 246 | 246 | }  | 
                                                        
| 247 | 247 | |
| 248 | - $controllers_html = '' ;  | 
                                                        |
| 248 | + $controllers_html = '';  | 
                                                        |
| 249 | 249 |          foreach ($controllers as $type => $body) { | 
                                                        
| 250 | 250 |              if ($type == 'num') { | 
                                                        
| 251 | -                $controllers_html .= $this->get_select('num', $body, $GLOBALS['num']) ; | 
                                                        |
| 251 | +                $controllers_html .= $this->get_select('num', $body, $GLOBALS['num']); | 
                                                        |
| 252 | 252 | }  | 
                                                        
| 253 | 253 | }  | 
                                                        
| 254 | 254 | |
@@ -262,13 +262,13 @@ discard block  | 
                                                    ||
| 262 | 262 | |
| 263 | 263 | public function get_select($name, $options, $current_value)  | 
                                                        
| 264 | 264 |      { | 
                                                        
| 265 | - $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n" ;  | 
                                                        |
| 265 | + $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n";  | 
                                                        |
| 266 | 266 |          foreach ($options as $key => $val) { | 
                                                        
| 267 | 267 | $selected = $val == $current_value ? "selected='selected'" : '';  | 
                                                        
| 268 | - $ret .= "<option value='".htmlspecialchars($key, ENT_QUOTES)."' $selected>".htmlspecialchars($val, ENT_QUOTES)."</option>\n" ;  | 
                                                        |
| 268 | + $ret .= "<option value='".htmlspecialchars($key, ENT_QUOTES)."' $selected>".htmlspecialchars($val, ENT_QUOTES)."</option>\n";  | 
                                                        |
| 269 | 269 | }  | 
                                                        
| 270 | - $ret .= "</select>\n" ;  | 
                                                        |
| 270 | + $ret .= "</select>\n";  | 
                                                        |
| 271 | 271 | |
| 272 | - return $ret ;  | 
                                                        |
| 272 | + return $ret;  | 
                                                        |
| 273 | 273 | }  | 
                                                        
| 274 | 274 | }  | 
                                                        
@@ -47,6 +47,10 @@  | 
                                                    ||
| 47 | 47 | parent::prepare();  | 
                                                        
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | + /**  | 
                                                        |
| 51 | + * @param string $dirname  | 
                                                        |
| 52 | + * @param string $fileBodyName  | 
                                                        |
| 53 | + */  | 
                                                        |
| 50 | 54 | public function _loadLanguage($dirname, $fileBodyName)  | 
                                                        
| 51 | 55 |      { | 
                                                        
| 52 | 56 | // read/check once (selected_theme)/language/(lang).php  | 
                                                        
@@ -1,15 +1,15 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | -if (! defined('XOOPS_ROOT_PATH')) { | 
                                                        |
| 4 | - exit ;  | 
                                                        |
| 3 | +if (!defined('XOOPS_ROOT_PATH')) { | 
                                                        |
| 4 | + exit;  | 
                                                        |
| 5 | 5 | }  | 
                                                        
| 6 | 6 | |
| 7 | -if (! defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') { | 
                                                        |
| 8 | -    header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php') ; | 
                                                        |
| 9 | - exit ;  | 
                                                        |
| 7 | +if (!defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') { | 
                                                        |
| 8 | +    header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php'); | 
                                                        |
| 9 | + exit;  | 
                                                        |
| 10 | 10 | }  | 
                                                        
| 11 | 11 | |
| 12 | -define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH . '/my_language'); | 
                                                        |
| 12 | +define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH.'/my_language'); | 
                                                        |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | class SetupAltsysLangMgr extends XCube_ActionFilter  | 
                                                        
@@ -26,23 +26,23 @@ discard block  | 
                                                    ||
| 26 | 26 | }  | 
                                                        
| 27 | 27 | |
| 28 | 28 | |
| 29 | -require_once XOOPS_ROOT_PATH . '/core/XCube_LanguageManager.class.php';  | 
                                                        |
| 30 | -require_once XOOPS_ROOT_PATH . '/modules/legacy/kernel/Legacy_LanguageManager.class.php';  | 
                                                        |
| 29 | +require_once XOOPS_ROOT_PATH.'/core/XCube_LanguageManager.class.php';  | 
                                                        |
| 30 | +require_once XOOPS_ROOT_PATH.'/modules/legacy/kernel/Legacy_LanguageManager.class.php';  | 
                                                        |
| 31 | 31 | |
| 32 | 32 | class AltsysLangMgr_LanguageManager extends Legacy_LanguageManager  | 
                                                        
| 33 | 33 |  { | 
                                                        
| 34 | - public $langman = null ;  | 
                                                        |
| 35 | - public $theme_lang_checked = false ;  | 
                                                        |
| 34 | + public $langman = null;  | 
                                                        |
| 35 | + public $theme_lang_checked = false;  | 
                                                        |
| 36 | 36 | |
| 37 | 37 | public function prepare()  | 
                                                        
| 38 | 38 |      { | 
                                                        
| 39 | - $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ;  | 
                                                        |
| 40 | -        if (! file_exists($langmanpath)) { | 
                                                        |
| 41 | -            die('install the latest altsys') ; | 
                                                        |
| 39 | + $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php';  | 
                                                        |
| 40 | +        if (!file_exists($langmanpath)) { | 
                                                        |
| 41 | +            die('install the latest altsys'); | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | require_once $langmanpath;  | 
                                                        
| 44 | - $this->langman = D3LanguageManager::getInstance() ;  | 
                                                        |
| 45 | - $this->langman->language = $this->mLanguageName ;  | 
                                                        |
| 44 | + $this->langman = D3LanguageManager::getInstance();  | 
                                                        |
| 45 | + $this->langman->language = $this->mLanguageName;  | 
                                                        |
| 46 | 46 | |
| 47 | 47 | parent::prepare();  | 
                                                        
| 48 | 48 | }  | 
                                                        
@@ -50,40 +50,40 @@ discard block  | 
                                                    ||
| 50 | 50 | public function _loadLanguage($dirname, $fileBodyName)  | 
                                                        
| 51 | 51 |      { | 
                                                        
| 52 | 52 | // read/check once (selected_theme)/language/(lang).php  | 
                                                        
| 53 | -        if (! $this->theme_lang_checked) { | 
                                                        |
| 54 | - $root = XCube_Root::getSingleton() ;  | 
                                                        |
| 55 | -            if (! empty($root->mContext->mXoopsConfig['theme_set'])) { | 
                                                        |
| 56 | - $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language' ;  | 
                                                        |
| 53 | +        if (!$this->theme_lang_checked) { | 
                                                        |
| 54 | + $root = XCube_Root::getSingleton();  | 
                                                        |
| 55 | +            if (!empty($root->mContext->mXoopsConfig['theme_set'])) { | 
                                                        |
| 56 | + $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language';  | 
                                                        |
| 57 | 57 |                  if (file_exists($langdir)) { | 
                                                        
| 58 | - $langfile = $langdir.'/'.$this->mLanguageName.'.php' ;  | 
                                                        |
| 59 | - $engfile = $langdir.'/english.php' ;  | 
                                                        |
| 58 | + $langfile = $langdir.'/'.$this->mLanguageName.'.php';  | 
                                                        |
| 59 | + $engfile = $langdir.'/english.php';  | 
                                                        |
| 60 | 60 |                      if (file_exists($langfile)) { | 
                                                        
| 61 | - require_once $langfile ;  | 
                                                        |
| 61 | + require_once $langfile;  | 
                                                        |
| 62 | 62 |                      } elseif (file_exists($engfile)) { | 
                                                        
| 63 | - require_once $engfile ;  | 
                                                        |
| 63 | + require_once $engfile;  | 
                                                        |
| 64 | 64 | }  | 
                                                        
| 65 | 65 | }  | 
                                                        
| 66 | - $this->theme_lang_checked = true ;  | 
                                                        |
| 66 | + $this->theme_lang_checked = true;  | 
                                                        |
| 67 | 67 | }  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
| 70 | 70 | // read normal  | 
                                                        
| 71 | - $this->langman->read($fileBodyName.'.php', $dirname) ;  | 
                                                        |
| 71 | + $this->langman->read($fileBodyName.'.php', $dirname);  | 
                                                        |
| 72 | 72 | }  | 
                                                        
| 73 | 73 | |
| 74 | 74 | public function loadPageTypeMessageCatalog($type)  | 
                                                        
| 75 | 75 |      { | 
                                                        
| 76 | 76 | // I dare not to use langman...  | 
                                                        
| 77 | 77 |          if (strpos($type, '.') === false && $this->langman->my_language) { | 
                                                        
| 78 | - $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php' ;  | 
                                                        |
| 78 | + $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php';  | 
                                                        |
| 79 | 79 |              if (file_exists($mylang_file)) { | 
                                                        
| 80 | - require_once $mylang_file ;  | 
                                                        |
| 80 | + require_once $mylang_file;  | 
                                                        |
| 81 | 81 | }  | 
                                                        
| 82 | 82 | }  | 
                                                        
| 83 | - $original_error_level = error_reporting() ;  | 
                                                        |
| 84 | - error_reporting($original_error_level & ~ E_NOTICE) ;  | 
                                                        |
| 83 | + $original_error_level = error_reporting();  | 
                                                        |
| 84 | + error_reporting($original_error_level & ~ E_NOTICE);  | 
                                                        |
| 85 | 85 | parent::loadPageTypeMessageCatalog($type);  | 
                                                        
| 86 | - error_reporting($original_error_level) ;  | 
                                                        |
| 86 | + error_reporting($original_error_level);  | 
                                                        |
| 87 | 87 | }  | 
                                                        
| 88 | 88 | |
| 89 | 89 | public function loadGlobalMessageCatalog()  | 
                                                        
@@ -91,7 +91,7 @@ discard block  | 
                                                    ||
| 91 | 91 |          /* if (!$this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/" . $this->mLanguageName . "/global.php")) { | 
                                                        
| 92 | 92 | $this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/english/global.php");  | 
                                                        
| 93 | 93 | } */  | 
                                                        
| 94 | -        $this->_loadLanguage('legacy', 'global') ; | 
                                                        |
| 94 | +        $this->_loadLanguage('legacy', 'global'); | 
                                                        |
| 95 | 95 | |
| 96 | 96 | //  | 
                                                        
| 97 | 97 | // Now, if XOOPS_USE_MULTIBYTES isn't defined, set zero to it.  | 
                                                        
@@ -103,6 +103,12 @@  | 
                                                    ||
| 103 | 103 | }  | 
                                                        
| 104 | 104 | |
| 105 | 105 | |
| 106 | +/**  | 
                                                        |
| 107 | + * @param integer $mid  | 
                                                        |
| 108 | + * @param integer $coretype  | 
                                                        |
| 109 | + *  | 
                                                        |
| 110 | + * @return string  | 
                                                        |
| 111 | + */  | 
                                                        |
| 106 | 112 | function altsys_get_link2modpreferences($mid, $coretype)  | 
                                                        
| 107 | 113 |  { | 
                                                        
| 108 | 114 |      switch ($coretype) { | 
                                                        
@@ -1,46 +1,46 @@ discard block  | 
                                                    ||
| 1 | 1 | <?php  | 
                                                        
| 2 | 2 | |
| 3 | -altsys_set_module_config() ;  | 
                                                        |
| 3 | +altsys_set_module_config();  | 
                                                        |
| 4 | 4 | |
| 5 | 5 | function altsys_set_module_config()  | 
                                                        
| 6 | 6 |  { | 
                                                        
| 7 | - global $altsysModuleConfig , $altsysModuleId ;  | 
                                                        |
| 7 | + global $altsysModuleConfig, $altsysModuleId;  | 
                                                        |
| 8 | 8 | |
| 9 | -    $module_handler = xoops_getHandler('module') ; | 
                                                        |
| 10 | -    $module = $module_handler->getByDirname('altsys') ; | 
                                                        |
| 9 | +    $module_handler = xoops_getHandler('module'); | 
                                                        |
| 10 | +    $module = $module_handler->getByDirname('altsys'); | 
                                                        |
| 11 | 11 |      if (is_object($module)) { | 
                                                        
| 12 | -        $config_handler = xoops_getHandler('config') ; | 
                                                        |
| 13 | -        $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')) ; | 
                                                        |
| 14 | -        $altsysModuleId = $module->getVar('mid') ; | 
                                                        |
| 12 | +        $config_handler = xoops_getHandler('config'); | 
                                                        |
| 13 | +        $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')); | 
                                                        |
| 14 | +        $altsysModuleId = $module->getVar('mid'); | 
                                                        |
| 15 | 15 |      } else { | 
                                                        
| 16 | - $altsysModuleConfig = array() ;  | 
                                                        |
| 17 | - $altsysModuleId = 0 ;  | 
                                                        |
| 16 | + $altsysModuleConfig = array();  | 
                                                        |
| 17 | + $altsysModuleId = 0;  | 
                                                        |
| 18 | 18 | }  | 
                                                        
| 19 | 19 | |
| 20 | 20 | // for RTL users  | 
                                                        
| 21 | -    @define('_GLOBAL_LEFT', @_ADM_USE_RTL == 1 ? 'right' : 'left') ; | 
                                                        |
| 22 | -    @define('_GLOBAL_RIGHT', @_ADM_USE_RTL == 1 ? 'left' : 'right') ; | 
                                                        |
| 21 | +    @define('_GLOBAL_LEFT', @_ADM_USE_RTL == 1 ? 'right' : 'left'); | 
                                                        |
| 22 | +    @define('_GLOBAL_RIGHT', @_ADM_USE_RTL == 1 ? 'left' : 'right'); | 
                                                        |
| 23 | 23 | }  | 
                                                        
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | function altsys_include_mymenu()  | 
                                                        
| 27 | 27 |  { | 
                                                        
| 28 | - global $xoopsModule , $xoopsConfig , $mydirname , $mydirpath , $mytrustdirname , $mytrustdirpath , $mymenu_fake_uri ;  | 
                                                        |
| 28 | + global $xoopsModule, $xoopsConfig, $mydirname, $mydirpath, $mytrustdirname, $mytrustdirpath, $mymenu_fake_uri;  | 
                                                        |
| 29 | 29 | |
| 30 | 30 | $mymenu_find_paths = array(  | 
                                                        
| 31 | - $mydirpath.'/admin/mymenu.php' ,  | 
                                                        |
| 32 | - $mydirpath.'/mymenu.php' ,  | 
                                                        |
| 33 | - $mytrustdirpath.'/admin/mymenu.php' ,  | 
                                                        |
| 31 | + $mydirpath.'/admin/mymenu.php',  | 
                                                        |
| 32 | + $mydirpath.'/mymenu.php',  | 
                                                        |
| 33 | + $mytrustdirpath.'/admin/mymenu.php',  | 
                                                        |
| 34 | 34 | $mytrustdirpath.'/mymenu.php'  | 
                                                        
| 35 | - ) ;  | 
                                                        |
| 35 | + );  | 
                                                        |
| 36 | 36 | |
| 37 | 37 |      foreach ($mymenu_find_paths as $mymenu_find_path) { | 
                                                        
| 38 | 38 |          if (file_exists($mymenu_find_path)) { | 
                                                        
| 39 | - include $mymenu_find_path ;  | 
                                                        |
| 40 | - include_once __DIR__.'/adminmenu_functions.php' ;  | 
                                                        |
| 41 | - altsys_adminmenu_insert_mymenu($xoopsModule) ;  | 
                                                        |
| 42 | - altsys_adminmenu_hack_ft() ;  | 
                                                        |
| 43 | - break ;  | 
                                                        |
| 39 | + include $mymenu_find_path;  | 
                                                        |
| 40 | + include_once __DIR__.'/adminmenu_functions.php';  | 
                                                        |
| 41 | + altsys_adminmenu_insert_mymenu($xoopsModule);  | 
                                                        |
| 42 | + altsys_adminmenu_hack_ft();  | 
                                                        |
| 43 | + break;  | 
                                                        |
| 44 | 44 | }  | 
                                                        
| 45 | 45 | }  | 
                                                        
| 46 | 46 | }  | 
                                                        
@@ -48,58 +48,58 @@ discard block  | 
                                                    ||
| 48 | 48 | |
| 49 | 49 | function altsys_include_language_file($type)  | 
                                                        
| 50 | 50 |  { | 
                                                        
| 51 | - $mylang = $GLOBALS['xoopsConfig']['language'] ;  | 
                                                        |
| 51 | + $mylang = $GLOBALS['xoopsConfig']['language'];  | 
                                                        |
| 52 | 52 | |
| 53 | 53 |      if (file_exists(XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php')) { | 
                                                        
| 54 | - include_once XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php' ;  | 
                                                        |
| 54 | + include_once XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php';  | 
                                                        |
| 55 | 55 |      } elseif (file_exists(XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php')) { | 
                                                        
| 56 | - include_once XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php' ;  | 
                                                        |
| 56 | + include_once XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php';  | 
                                                        |
| 57 | 57 |      } elseif (file_exists(XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php')) { | 
                                                        
| 58 | - include_once XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php' ;  | 
                                                        |
| 58 | + include_once XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php';  | 
                                                        |
| 59 | 59 |      } elseif (file_exists(XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php')) { | 
                                                        
| 60 | - include_once XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php' ;  | 
                                                        |
| 60 | + include_once XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php';  | 
                                                        |
| 61 | 61 | }  | 
                                                        
| 62 | 62 | }  | 
                                                        
| 63 | 63 | |
| 64 | 64 | |
| 65 | -define('ALTSYS_CORE_TYPE_X20', 1) ; // 2.0.0-2.0.13 and 2.0.x-JP | 
                                                        |
| 66 | -define('ALTSYS_CORE_TYPE_X20S', 2) ; // 2.0.14- from xoops.org (Skalpa's S) | 
                                                        |
| 67 | -define('ALTSYS_CORE_TYPE_ORE', 4) ; // ORETEKI by marijuana | 
                                                        |
| 68 | -define('ALTSYS_CORE_TYPE_X22', 8) ; // 2.2 from xoops.org | 
                                                        |
| 69 | -define('ALTSYS_CORE_TYPE_X23P', 10) ; // 2.3 from xoops.org (phppp's P) | 
                                                        |
| 70 | -define('ALTSYS_CORE_TYPE_X25', 11) ; // 2.5 from xoops.org | 
                                                        |
| 71 | -define('ALTSYS_CORE_TYPE_ICMS', 12) ; // ImpressCMS | 
                                                        |
| 72 | -define('ALTSYS_CORE_TYPE_XCL21', 16) ; // XOOPS Cube 2.1 Legacy | 
                                                        |
| 65 | +define('ALTSYS_CORE_TYPE_X20', 1); // 2.0.0-2.0.13 and 2.0.x-JP | 
                                                        |
| 66 | +define('ALTSYS_CORE_TYPE_X20S', 2); // 2.0.14- from xoops.org (Skalpa's S) | 
                                                        |
| 67 | +define('ALTSYS_CORE_TYPE_ORE', 4); // ORETEKI by marijuana | 
                                                        |
| 68 | +define('ALTSYS_CORE_TYPE_X22', 8); // 2.2 from xoops.org | 
                                                        |
| 69 | +define('ALTSYS_CORE_TYPE_X23P', 10); // 2.3 from xoops.org (phppp's P) | 
                                                        |
| 70 | +define('ALTSYS_CORE_TYPE_X25', 11); // 2.5 from xoops.org | 
                                                        |
| 71 | +define('ALTSYS_CORE_TYPE_ICMS', 12); // ImpressCMS | 
                                                        |
| 72 | +define('ALTSYS_CORE_TYPE_XCL21', 16); // XOOPS Cube 2.1 Legacy | 
                                                        |
| 73 | 73 | |
| 74 | 74 | function altsys_get_core_type()  | 
                                                        
| 75 | 75 |  { | 
                                                        
| 76 | - static $result = null ;  | 
                                                        |
| 76 | + static $result = null;  | 
                                                        |
| 77 | 77 | |
| 78 | 78 |      if (empty($result)) { | 
                                                        
| 79 | 79 |          if (defined('XOOPS_ORETEKI')) { | 
                                                        
| 80 | - $result = ALTSYS_CORE_TYPE_ORE ;  | 
                                                        |
| 80 | + $result = ALTSYS_CORE_TYPE_ORE;  | 
                                                        |
| 81 | 81 |          } elseif (defined('XOOPS_CUBE_LEGACY')) { | 
                                                        
| 82 | - $result = ALTSYS_CORE_TYPE_XCL21 ;  | 
                                                        |
| 82 | + $result = ALTSYS_CORE_TYPE_XCL21;  | 
                                                        |
| 83 | 83 |          } elseif (defined('ICMS_VERSION_NAME')) { | 
                                                        
| 84 | - $result = ALTSYS_CORE_TYPE_ICMS ;  | 
                                                        |
| 84 | + $result = ALTSYS_CORE_TYPE_ICMS;  | 
                                                        |
| 85 | 85 |          } elseif (strstr(XOOPS_VERSION, 'JP')) { | 
                                                        
| 86 | - $result = ALTSYS_CORE_TYPE_X20 ;  | 
                                                        |
| 86 | + $result = ALTSYS_CORE_TYPE_X20;  | 
                                                        |
| 87 | 87 |          } else { | 
                                                        
| 88 | -            $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))) ; | 
                                                        |
| 88 | +            $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))); | 
                                                        |
| 89 | 89 |              if ($versions[0] == 2 && $versions[1] == 2) { | 
                                                        
| 90 | - $result = ALTSYS_CORE_TYPE_X22 ;  | 
                                                        |
| 90 | + $result = ALTSYS_CORE_TYPE_X22;  | 
                                                        |
| 91 | 91 |              } elseif ($versions[0] == 2 && $versions[1] == 0 && $versions[2] > 13) { | 
                                                        
| 92 | - $result = ALTSYS_CORE_TYPE_X20S ;  | 
                                                        |
| 92 | + $result = ALTSYS_CORE_TYPE_X20S;  | 
                                                        |
| 93 | 93 |              } elseif ($versions[0] == 2 && $versions[1] >= 5) { | 
                                                        
| 94 | - $result = ALTSYS_CORE_TYPE_X25 ;  | 
                                                        |
| 94 | + $result = ALTSYS_CORE_TYPE_X25;  | 
                                                        |
| 95 | 95 |              } elseif ($versions[0] == 2 && $versions[1] > 2) { | 
                                                        
| 96 | - $result = ALTSYS_CORE_TYPE_X23P ;  | 
                                                        |
| 96 | + $result = ALTSYS_CORE_TYPE_X23P;  | 
                                                        |
| 97 | 97 |              } else { | 
                                                        
| 98 | - $result = ALTSYS_CORE_TYPE_X20 ;  | 
                                                        |
| 98 | + $result = ALTSYS_CORE_TYPE_X20;  | 
                                                        |
| 99 | 99 | }  | 
                                                        
| 100 | 100 | }  | 
                                                        
| 101 | 101 | }  | 
                                                        
| 102 | - return $result ;  | 
                                                        |
| 102 | + return $result;  | 
                                                        |
| 103 | 103 | }  | 
                                                        
| 104 | 104 | |
| 105 | 105 | |
@@ -113,36 +113,36 @@ discard block  | 
                                                    ||
| 113 | 113 | case ALTSYS_CORE_TYPE_X23P:  | 
                                                        
| 114 | 114 | case ALTSYS_CORE_TYPE_ICMS:  | 
                                                        
| 115 | 115 | default:  | 
                                                        
| 116 | - return XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid ;  | 
                                                        |
| 116 | + return XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid;  | 
                                                        |
| 117 | 117 | case ALTSYS_CORE_TYPE_XCL21:  | 
                                                        
| 118 | - return XOOPS_URL.'/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id='.$mid ;  | 
                                                        |
| 118 | + return XOOPS_URL.'/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id='.$mid;  | 
                                                        |
| 119 | 119 | }  | 
                                                        
| 120 | 120 | }  | 
                                                        
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | function altsys_template_touch($tpl_id)  | 
                                                        
| 124 | 124 |  { | 
                                                        
| 125 | -    if (in_array(altsys_get_core_type(), array( ALTSYS_CORE_TYPE_X20S, ALTSYS_CORE_TYPE_X23P, ALTSYS_CORE_TYPE_X25 ))) { | 
                                                        |
| 125 | +    if (in_array(altsys_get_core_type(), array(ALTSYS_CORE_TYPE_X20S, ALTSYS_CORE_TYPE_X23P, ALTSYS_CORE_TYPE_X25))) { | 
                                                        |
| 126 | 126 | // need to delete all files under templates_c/  | 
                                                        
| 127 | - altsys_clear_templates_c() ;  | 
                                                        |
| 127 | + altsys_clear_templates_c();  | 
                                                        |
| 128 | 128 |      } else { | 
                                                        
| 129 | 129 | // just touch the template  | 
                                                        
| 130 | - xoops_template_touch($tpl_id) ;  | 
                                                        |
| 130 | + xoops_template_touch($tpl_id);  | 
                                                        |
| 131 | 131 | }  | 
                                                        
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | function altsys_clear_templates_c()  | 
                                                        
| 136 | 136 |  { | 
                                                        
| 137 | - $dh = opendir(XOOPS_COMPILE_PATH) ;  | 
                                                        |
| 137 | + $dh = opendir(XOOPS_COMPILE_PATH);  | 
                                                        |
| 138 | 138 |      while ($file = readdir($dh)) { | 
                                                        
| 139 | 139 |          if (substr($file, 0, 1) == '.') { | 
                                                        
| 140 | - continue ;  | 
                                                        |
| 140 | + continue;  | 
                                                        |
| 141 | 141 | }  | 
                                                        
| 142 | 142 |          if (substr($file, -4) != '.php') { | 
                                                        
| 143 | - continue ;  | 
                                                        |
| 143 | + continue;  | 
                                                        |
| 144 | 144 | }  | 
                                                        
| 145 | - @unlink(XOOPS_COMPILE_PATH.'/'.$file) ;  | 
                                                        |
| 145 | + @unlink(XOOPS_COMPILE_PATH.'/'.$file);  | 
                                                        |
| 146 | 146 | }  | 
                                                        
| 147 | - closedir($dh) ;  | 
                                                        |
| 147 | + closedir($dh);  | 
                                                        |
| 148 | 148 | }  | 
                                                        
@@ -233,6 +233,9 @@  | 
                                                    ||
| 233 | 233 |          echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>' . sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()) . $table . $form . '</body></html>' ; | 
                                                        
| 234 | 234 | }  | 
                                                        
| 235 | 235 | |
| 236 | + /**  | 
                                                        |
| 237 | + * @param string $key_name  | 
                                                        |
| 238 | + */  | 
                                                        |
| 236 | 239 | public function extract_post_recursive($key_name, $tmp_array)  | 
                                                        
| 237 | 240 |          { | 
                                                        
| 238 | 241 | $table = '' ;  | 
                                                        
@@ -2,149 +2,149 @@ discard block  | 
                                                    ||
| 2 | 2 | // GIJOE's Ticket Class (based on Marijuana's Oreteki XOOPS)  | 
                                                        
| 3 | 3 | // nobunobu's suggestions are applied  | 
                                                        
| 4 | 4 | |
| 5 | -if (! class_exists('XoopsGTicket')) { | 
                                                        |
| 5 | +if (!class_exists('XoopsGTicket')) { | 
                                                        |
| 6 | 6 | class XoopsGTicket  | 
                                                        
| 7 | 7 |      { | 
                                                        
| 8 | - public $_errors = array() ;  | 
                                                        |
| 9 | - public $_latest_token = '' ;  | 
                                                        |
| 10 | - public $messages = array() ;  | 
                                                        |
| 8 | + public $_errors = array();  | 
                                                        |
| 9 | + public $_latest_token = '';  | 
                                                        |
| 10 | + public $messages = array();  | 
                                                        |
| 11 | 11 | |
| 12 | 12 | public function __construct()  | 
                                                        
| 13 | 13 |          { | 
                                                        
| 14 | - global $xoopsConfig ;  | 
                                                        |
| 14 | + global $xoopsConfig;  | 
                                                        |
| 15 | 15 | |
| 16 | 16 | // language file  | 
                                                        
| 17 | -        if (defined('XOOPS_ROOT_PATH') && ! empty($xoopsConfig['language']) && ! strstr($xoopsConfig['language'], '/')) { | 
                                                        |
| 18 | -            if (file_exists(dirname(__DIR__) . '/language/' . $xoopsConfig['language'] . '/gticket_messages.phtml')) { | 
                                                        |
| 19 | - include dirname(__DIR__) . '/language/' . $xoopsConfig['language'] . '/gticket_messages.phtml' ;  | 
                                                        |
| 17 | +        if (defined('XOOPS_ROOT_PATH') && !empty($xoopsConfig['language']) && !strstr($xoopsConfig['language'], '/')) { | 
                                                        |
| 18 | +            if (file_exists(dirname(__DIR__).'/language/'.$xoopsConfig['language'].'/gticket_messages.phtml')) { | 
                                                        |
| 19 | + include dirname(__DIR__).'/language/'.$xoopsConfig['language'].'/gticket_messages.phtml';  | 
                                                        |
| 20 | 20 | }  | 
                                                        
| 21 | 21 | }  | 
                                                        
| 22 | 22 | |
| 23 | 23 | // default messages  | 
                                                        
| 24 | 24 |          if (empty($this->messages)) { | 
                                                        
| 25 | 25 | $this->messages = array(  | 
                                                        
| 26 | - 'err_general' => 'GTicket Error' ,  | 
                                                        |
| 27 | - 'err_nostubs' => 'No stubs found' ,  | 
                                                        |
| 28 | - 'err_noticket' => 'No ticket found' ,  | 
                                                        |
| 29 | - 'err_nopair' => 'No valid ticket-stub pair found' ,  | 
                                                        |
| 30 | - 'err_timeout' => 'Time out' ,  | 
                                                        |
| 31 | - 'err_areaorref' => 'Invalid area or referer' ,  | 
                                                        |
| 32 | - 'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?' ,  | 
                                                        |
| 26 | + 'err_general' => 'GTicket Error',  | 
                                                        |
| 27 | + 'err_nostubs' => 'No stubs found',  | 
                                                        |
| 28 | + 'err_noticket' => 'No ticket found',  | 
                                                        |
| 29 | + 'err_nopair' => 'No valid ticket-stub pair found',  | 
                                                        |
| 30 | + 'err_timeout' => 'Time out',  | 
                                                        |
| 31 | + 'err_areaorref' => 'Invalid area or referer',  | 
                                                        |
| 32 | + 'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?',  | 
                                                        |
| 33 | 33 | 'btn_repost' => 'repost'  | 
                                                        
| 34 | - ) ;  | 
                                                        |
| 34 | + );  | 
                                                        |
| 35 | 35 | }  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | |
| 38 | 38 | // render form as plain html  | 
                                                        
| 39 | 39 | public function getTicketHtml($salt = '', $timeout = 1800, $area = '')  | 
                                                        
| 40 | 40 |      { | 
                                                        
| 41 | - return '<input type="hidden" name="XOOPS_G_TICKET" value="'.$this->issue($salt, $timeout, $area).'" />' ;  | 
                                                        |
| 41 | + return '<input type="hidden" name="XOOPS_G_TICKET" value="'.$this->issue($salt, $timeout, $area).'" />';  | 
                                                        |
| 42 | 42 | }  | 
                                                        
| 43 | 43 | |
| 44 | 44 | // returns an object of XoopsFormHidden including theh ticket  | 
                                                        
| 45 | 45 | public function getTicketXoopsForm($salt = '', $timeout = 1800, $area = '')  | 
                                                        
| 46 | 46 |      { | 
                                                        
| 47 | -        return new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area)) ; | 
                                                        |
| 47 | +        return new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area)); | 
                                                        |
| 48 | 48 | }  | 
                                                        
| 49 | 49 | |
| 50 | 50 | // add a ticket as Hidden Element into XoopsForm  | 
                                                        
| 51 | 51 | public function addTicketXoopsFormElement(&$form, $salt = '', $timeout = 1800, $area = '')  | 
                                                        
| 52 | 52 |      { | 
                                                        
| 53 | -        $form->addElement(new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area))) ; | 
                                                        |
| 53 | +        $form->addElement(new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area))); | 
                                                        |
| 54 | 54 | }  | 
                                                        
| 55 | 55 | |
| 56 | 56 | // returns an array for xoops_confirm() ;  | 
                                                        
| 57 | 57 | public function getTicketArray($salt = '', $timeout = 1800, $area = '')  | 
                                                        
| 58 | 58 |      { | 
                                                        
| 59 | - return array( 'XOOPS_G_TICKET' => $this->issue($salt, $timeout, $area) ) ;  | 
                                                        |
| 59 | +        return array('XOOPS_G_TICKET' => $this->issue($salt, $timeout, $area)); | 
                                                        |
| 60 | 60 | }  | 
                                                        
| 61 | 61 | |
| 62 | 62 | // return GET parameter string.  | 
                                                        
| 63 | - public function getTicketParamString($salt = '', $noamp = false, $timeout=1800, $area = '')  | 
                                                        |
| 63 | + public function getTicketParamString($salt = '', $noamp = false, $timeout = 1800, $area = '')  | 
                                                        |
| 64 | 64 |      { | 
                                                        
| 65 | - return ($noamp ? '' : '&') . 'XOOPS_G_TICKET=' . $this->issue($salt, $timeout, $area) ;  | 
                                                        |
| 65 | + return ($noamp ? '' : '&').'XOOPS_G_TICKET='.$this->issue($salt, $timeout, $area);  | 
                                                        |
| 66 | 66 | }  | 
                                                        
| 67 | 67 | |
| 68 | 68 | // issue a ticket  | 
                                                        
| 69 | 69 | public function issue($salt = '', $timeout = 1800, $area = '')  | 
                                                        
| 70 | 70 |      { | 
                                                        
| 71 | - global $xoopsModule ;  | 
                                                        |
| 71 | + global $xoopsModule;  | 
                                                        |
| 72 | 72 |          if ('' === $salt) { | 
                                                        
| 73 | 73 | // $salt = '$2y$07$' . strtr(base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM)), '+', '.');  | 
                                                        
| 74 | -            $salt= '$2y$07$' . str_replace('+', '.', base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM))); | 
                                                        |
| 74 | +            $salt = '$2y$07$'.str_replace('+', '.', base64_encode(mcrypt_create_iv(16, MCRYPT_DEV_URANDOM))); | 
                                                        |
| 75 | 75 | }  | 
                                                        
| 76 | 76 | // create a token  | 
                                                        
| 77 | -        list($usec, $sec) = explode(' ', microtime()) ; | 
                                                        |
| 78 | - $appendix_salt = empty($_SERVER['PATH']) ? XOOPS_DB_NAME : $_SERVER['PATH'] ;  | 
                                                        |
| 79 | - $token = crypt($salt . $usec . $appendix_salt . $sec, $salt) ;  | 
                                                        |
| 80 | - $this->_latest_token = $token ;  | 
                                                        |
| 77 | +        list($usec, $sec) = explode(' ', microtime()); | 
                                                        |
| 78 | + $appendix_salt = empty($_SERVER['PATH']) ? XOOPS_DB_NAME : $_SERVER['PATH'];  | 
                                                        |
| 79 | + $token = crypt($salt.$usec.$appendix_salt.$sec, $salt);  | 
                                                        |
| 80 | + $this->_latest_token = $token;  | 
                                                        |
| 81 | 81 | |
| 82 | 82 |          if (empty($_SESSION['XOOPS_G_STUBS'])) { | 
                                                        
| 83 | - $_SESSION['XOOPS_G_STUBS'] = array() ;  | 
                                                        |
| 83 | + $_SESSION['XOOPS_G_STUBS'] = array();  | 
                                                        |
| 84 | 84 | }  | 
                                                        
| 85 | 85 | |
| 86 | 86 | // limit max stubs 10  | 
                                                        
| 87 | 87 |          if (count($_SESSION['XOOPS_G_STUBS']) > 10) { | 
                                                        
| 88 | - $_SESSION['XOOPS_G_STUBS'] = array_slice($_SESSION['XOOPS_G_STUBS'], -10) ;  | 
                                                        |
| 88 | + $_SESSION['XOOPS_G_STUBS'] = array_slice($_SESSION['XOOPS_G_STUBS'], -10);  | 
                                                        |
| 89 | 89 | }  | 
                                                        
| 90 | 90 | |
| 91 | 91 | // record referer if browser send it  | 
                                                        
| 92 | - $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['REQUEST_URI'] ;  | 
                                                        |
| 92 | + $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['REQUEST_URI'];  | 
                                                        |
| 93 | 93 | |
| 94 | 94 | // area as module's dirname  | 
                                                        
| 95 | -        if (! $area && is_object(@$xoopsModule)) { | 
                                                        |
| 96 | -            $area = $xoopsModule->getVar('dirname') ; | 
                                                        |
| 95 | +        if (!$area && is_object(@$xoopsModule)) { | 
                                                        |
| 96 | +            $area = $xoopsModule->getVar('dirname'); | 
                                                        |
| 97 | 97 | }  | 
                                                        
| 98 | 98 | |
| 99 | 99 | // store stub  | 
                                                        
| 100 | 100 | $_SESSION['XOOPS_G_STUBS'][] = array(  | 
                                                        
| 101 | - 'expire' => time() + $timeout ,  | 
                                                        |
| 102 | - 'referer' => $referer ,  | 
                                                        |
| 103 | - 'area' => $area ,  | 
                                                        |
| 101 | + 'expire' => time() + $timeout,  | 
                                                        |
| 102 | + 'referer' => $referer,  | 
                                                        |
| 103 | + 'area' => $area,  | 
                                                        |
| 104 | 104 | 'token' => $token  | 
                                                        
| 105 | - ) ;  | 
                                                        |
| 105 | + );  | 
                                                        |
| 106 | 106 | |
| 107 | 107 | // paid md5ed token as a ticket  | 
                                                        
| 108 | - return md5($token . XOOPS_DB_PREFIX) ;  | 
                                                        |
| 108 | + return md5($token.XOOPS_DB_PREFIX);  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 | // check a ticket  | 
                                                        
| 112 | 112 | public function check($post = true, $area = '', $allow_repost = true)  | 
                                                        
| 113 | 113 |      { | 
                                                        
| 114 | - global $xoopsModule ;  | 
                                                        |
| 114 | + global $xoopsModule;  | 
                                                        |
| 115 | 115 | |
| 116 | - $this->_errors = array() ;  | 
                                                        |
| 116 | + $this->_errors = array();  | 
                                                        |
| 117 | 117 | |
| 118 | 118 | // CHECK: stubs are not stored in session  | 
                                                        
| 119 | -        if (! is_array(@$_SESSION['XOOPS_G_STUBS'])) { | 
                                                        |
| 120 | - $this->_errors[] = $this->messages['err_nostubs'] ;  | 
                                                        |
| 121 | - $_SESSION['XOOPS_G_STUBS'] = array() ;  | 
                                                        |
| 119 | +        if (!is_array(@$_SESSION['XOOPS_G_STUBS'])) { | 
                                                        |
| 120 | + $this->_errors[] = $this->messages['err_nostubs'];  | 
                                                        |
| 121 | + $_SESSION['XOOPS_G_STUBS'] = array();  | 
                                                        |
| 122 | 122 | }  | 
                                                        
| 123 | 123 | |
| 124 | 124 | // get key&val of the ticket from a user's query  | 
                                                        
| 125 | - $ticket = $post ? @$_POST['XOOPS_G_TICKET'] : @$_GET['XOOPS_G_TICKET'] ;  | 
                                                        |
| 125 | + $ticket = $post ? @$_POST['XOOPS_G_TICKET'] : @$_GET['XOOPS_G_TICKET'];  | 
                                                        |
| 126 | 126 | |
| 127 | 127 | // CHECK: no tickets found  | 
                                                        
| 128 | 128 |          if (empty($ticket)) { | 
                                                        
| 129 | - $this->_errors[] = $this->messages['err_noticket'] ;  | 
                                                        |
| 129 | + $this->_errors[] = $this->messages['err_noticket'];  | 
                                                        |
| 130 | 130 | }  | 
                                                        
| 131 | 131 | |
| 132 | 132 | // gargage collection & find a right stub  | 
                                                        
| 133 | - $stubs_tmp = $_SESSION['XOOPS_G_STUBS'] ;  | 
                                                        |
| 134 | - $_SESSION['XOOPS_G_STUBS'] = array() ;  | 
                                                        |
| 133 | + $stubs_tmp = $_SESSION['XOOPS_G_STUBS'];  | 
                                                        |
| 134 | + $_SESSION['XOOPS_G_STUBS'] = array();  | 
                                                        |
| 135 | 135 |          foreach ($stubs_tmp as $stub) { | 
                                                        
| 136 | 136 | // default lifetime 30min  | 
                                                        
| 137 | 137 |              if ($stub['expire'] >= time()) { | 
                                                        
| 138 | -                if (md5($stub['token'] . XOOPS_DB_PREFIX) === $ticket) { | 
                                                        |
| 139 | - $found_stub = $stub ;  | 
                                                        |
| 138 | +                if (md5($stub['token'].XOOPS_DB_PREFIX) === $ticket) { | 
                                                        |
| 139 | + $found_stub = $stub;  | 
                                                        |
| 140 | 140 |                  } else { | 
                                                        
| 141 | 141 | // store the other valid stubs into session  | 
                                                        
| 142 | - $_SESSION['XOOPS_G_STUBS'][] = $stub ;  | 
                                                        |
| 142 | + $_SESSION['XOOPS_G_STUBS'][] = $stub;  | 
                                                        |
| 143 | 143 | }  | 
                                                        
| 144 | 144 |              } else { | 
                                                        
| 145 | -                if (md5($stub['token'] . XOOPS_DB_PREFIX) === $ticket) { | 
                                                        |
| 145 | +                if (md5($stub['token'].XOOPS_DB_PREFIX) === $ticket) { | 
                                                        |
| 146 | 146 | // not CSRF but Time-Out  | 
                                                        
| 147 | - $timeout_flag = true ;  | 
                                                        |
| 147 | + $timeout_flag = true;  | 
                                                        |
| 148 | 148 | }  | 
                                                        
| 149 | 149 | }  | 
                                                        
| 150 | 150 | }  | 
                                                        
@@ -152,40 +152,40 @@ discard block  | 
                                                    ||
| 152 | 152 | // CHECK: the right stub found or not  | 
                                                        
| 153 | 153 |          if (empty($found_stub)) { | 
                                                        
| 154 | 154 |              if (empty($timeout_flag)) { | 
                                                        
| 155 | - $this->_errors[] = $this->messages['err_nopair'] ;  | 
                                                        |
| 155 | + $this->_errors[] = $this->messages['err_nopair'];  | 
                                                        |
| 156 | 156 |              } else { | 
                                                        
| 157 | - $this->_errors[] = $this->messages['err_timeout'] ;  | 
                                                        |
| 157 | + $this->_errors[] = $this->messages['err_timeout'];  | 
                                                        |
| 158 | 158 | }  | 
                                                        
| 159 | 159 |          } else { | 
                                                        
| 160 | 160 | |
| 161 | 161 | // set area if necessary  | 
                                                        
| 162 | 162 | // area as module's dirname  | 
                                                        
| 163 | -            if (! $area && is_object(@$xoopsModule)) { | 
                                                        |
| 164 | -                $area = $xoopsModule->getVar('dirname') ; | 
                                                        |
| 163 | +            if (!$area && is_object(@$xoopsModule)) { | 
                                                        |
| 164 | +                $area = $xoopsModule->getVar('dirname'); | 
                                                        |
| 165 | 165 | }  | 
                                                        
| 166 | 166 | |
| 167 | 167 | // check area or referer  | 
                                                        
| 168 | 168 |              if (@$found_stub['area'] == $area) { | 
                                                        
| 169 | - $area_check = true ;  | 
                                                        |
| 169 | + $area_check = true;  | 
                                                        |
| 170 | 170 | }  | 
                                                        
| 171 | -            if (! empty($found_stub['referer']) && strstr(@$_SERVER['HTTP_REFERER'], $found_stub['referer'])) { | 
                                                        |
| 172 | - $referer_check = true ;  | 
                                                        |
| 171 | +            if (!empty($found_stub['referer']) && strstr(@$_SERVER['HTTP_REFERER'], $found_stub['referer'])) { | 
                                                        |
| 172 | + $referer_check = true;  | 
                                                        |
| 173 | 173 | }  | 
                                                        
| 174 | 174 | |
| 175 | 175 |              if (empty($area_check) && empty($referer_check)) { // loose | 
                                                        
| 176 | - $this->_errors[] = $this->messages['err_areaorref'] ;  | 
                                                        |
| 176 | + $this->_errors[] = $this->messages['err_areaorref'];  | 
                                                        |
| 177 | 177 | }  | 
                                                        
| 178 | 178 | }  | 
                                                        
| 179 | 179 | |
| 180 | -        if (! empty($this->_errors)) { | 
                                                        |
| 180 | +        if (!empty($this->_errors)) { | 
                                                        |
| 181 | 181 |              if ($allow_repost) { | 
                                                        
| 182 | 182 | // repost form  | 
                                                        
| 183 | - $this->draw_repost_form($area) ;  | 
                                                        |
| 184 | - exit ;  | 
                                                        |
| 183 | + $this->draw_repost_form($area);  | 
                                                        |
| 184 | + exit;  | 
                                                        |
| 185 | 185 |              } else { | 
                                                        
| 186 | 186 | // failed  | 
                                                        
| 187 | - $this->clear() ;  | 
                                                        |
| 188 | - return false ;  | 
                                                        |
| 187 | + $this->clear();  | 
                                                        |
| 188 | + return false;  | 
                                                        |
| 189 | 189 | }  | 
                                                        
| 190 | 190 |          } else { | 
                                                        
| 191 | 191 | // all green  | 
                                                        
@@ -198,78 +198,78 @@ discard block  | 
                                                    ||
| 198 | 198 |      { | 
                                                        
| 199 | 199 | // Notify which file is broken  | 
                                                        
| 200 | 200 |          if (headers_sent()) { | 
                                                        
| 201 | - restore_error_handler() ;  | 
                                                        |
| 202 | - set_error_handler(array( &$this, 'errorHandler4FindOutput' )) ;  | 
                                                        |
| 203 | -            header('Dummy: for warning') ; | 
                                                        |
| 204 | - restore_error_handler() ;  | 
                                                        |
| 205 | - exit ;  | 
                                                        |
| 201 | + restore_error_handler();  | 
                                                        |
| 202 | + set_error_handler(array(&$this, 'errorHandler4FindOutput'));  | 
                                                        |
| 203 | +            header('Dummy: for warning'); | 
                                                        |
| 204 | + restore_error_handler();  | 
                                                        |
| 205 | + exit;  | 
                                                        |
| 206 | 206 | }  | 
                                                        
| 207 | 207 | |
| 208 | - $table = '<table>' ;  | 
                                                        |
| 209 | - $form = '<form action="?'.htmlspecialchars(@$_SERVER['QUERY_STRING'], ENT_QUOTES).'" method="post" >' ;  | 
                                                        |
| 208 | + $table = '<table>';  | 
                                                        |
| 209 | + $form = '<form action="?'.htmlspecialchars(@$_SERVER['QUERY_STRING'], ENT_QUOTES).'" method="post" >';  | 
                                                        |
| 210 | 210 |          foreach ($_POST as $key => $val) { | 
                                                        
| 211 | 211 |              if ($key == 'XOOPS_G_TICKET') { | 
                                                        
| 212 | - continue ;  | 
                                                        |
| 212 | + continue;  | 
                                                        |
| 213 | 213 | }  | 
                                                        
| 214 | 214 |              if (get_magic_quotes_gpc()) { | 
                                                        
| 215 | - $key = stripslashes($key) ;  | 
                                                        |
| 215 | + $key = stripslashes($key);  | 
                                                        |
| 216 | 216 | }  | 
                                                        
| 217 | 217 |              if (is_array($val)) { | 
                                                        
| 218 | - list($tmp_table, $tmp_form) = $this->extract_post_recursive(htmlspecialchars($key, ENT_QUOTES), $val) ;  | 
                                                        |
| 219 | - $table .= $tmp_table ;  | 
                                                        |
| 220 | - $form .= $tmp_form ;  | 
                                                        |
| 218 | + list($tmp_table, $tmp_form) = $this->extract_post_recursive(htmlspecialchars($key, ENT_QUOTES), $val);  | 
                                                        |
| 219 | + $table .= $tmp_table;  | 
                                                        |
| 220 | + $form .= $tmp_form;  | 
                                                        |
| 221 | 221 |              } else { | 
                                                        
| 222 | 222 |                  if (get_magic_quotes_gpc()) { | 
                                                        
| 223 | - $val = stripslashes($val) ;  | 
                                                        |
| 223 | + $val = stripslashes($val);  | 
                                                        |
| 224 | 224 | }  | 
                                                        
| 225 | - $table .= '<tr><th>'.htmlspecialchars($key, ENT_QUOTES).'</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n" ;  | 
                                                        |
| 226 | - $form .= '<input type="hidden" name="'.htmlspecialchars($key, ENT_QUOTES).'" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n" ;  | 
                                                        |
| 225 | + $table .= '<tr><th>'.htmlspecialchars($key, ENT_QUOTES).'</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n";  | 
                                                        |
| 226 | + $form .= '<input type="hidden" name="'.htmlspecialchars($key, ENT_QUOTES).'" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n";  | 
                                                        |
| 227 | 227 | }  | 
                                                        
| 228 | 228 | }  | 
                                                        
| 229 | - $table .= '</table>' ;  | 
                                                        |
| 230 | - $form .= $this->getTicketHtml(__LINE__, 300, $area).'<input type="submit" value="'.$this->messages['btn_repost'].'" /></form>' ;  | 
                                                        |
| 229 | + $table .= '</table>';  | 
                                                        |
| 230 | + $form .= $this->getTicketHtml(__LINE__, 300, $area).'<input type="submit" value="'.$this->messages['btn_repost'].'" /></form>';  | 
                                                        |
| 231 | 231 | |
| 232 | - error_reporting(0) ;  | 
                                                        |
| 232 | + error_reporting(0);  | 
                                                        |
| 233 | 233 | while (@ob_get_level() && @ob_end_clean());  | 
                                                        
| 234 | 234 | |
| 235 | -        echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>' . sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()) . $table . $form . '</body></html>' ; | 
                                                        |
| 235 | +        echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>'.sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()).$table.$form.'</body></html>'; | 
                                                        |
| 236 | 236 | }  | 
                                                        
| 237 | 237 | |
| 238 | 238 | public function extract_post_recursive($key_name, $tmp_array)  | 
                                                        
| 239 | 239 |          { | 
                                                        
| 240 | - $table = '' ;  | 
                                                        |
| 241 | - $form = '' ;  | 
                                                        |
| 240 | + $table = '';  | 
                                                        |
| 241 | + $form = '';  | 
                                                        |
| 242 | 242 |              foreach ($tmp_array as $key => $val) { | 
                                                        
| 243 | 243 |                  if (get_magic_quotes_gpc()) { | 
                                                        
| 244 | - $key = stripslashes($key) ;  | 
                                                        |
| 244 | + $key = stripslashes($key);  | 
                                                        |
| 245 | 245 | }  | 
                                                        
| 246 | 246 |                  if (is_array($val)) { | 
                                                        
| 247 | - list($tmp_table, $tmp_form) = $this->extract_post_recursive($key_name.'['.htmlspecialchars($key, ENT_QUOTES).']', $val) ;  | 
                                                        |
| 248 | - $table .= $tmp_table ;  | 
                                                        |
| 249 | - $form .= $tmp_form ;  | 
                                                        |
| 247 | + list($tmp_table, $tmp_form) = $this->extract_post_recursive($key_name.'['.htmlspecialchars($key, ENT_QUOTES).']', $val);  | 
                                                        |
| 248 | + $table .= $tmp_table;  | 
                                                        |
| 249 | + $form .= $tmp_form;  | 
                                                        |
| 250 | 250 |                  } else { | 
                                                        
| 251 | 251 |                      if (get_magic_quotes_gpc()) { | 
                                                        
| 252 | - $val = stripslashes($val) ;  | 
                                                        |
| 252 | + $val = stripslashes($val);  | 
                                                        |
| 253 | 253 | }  | 
                                                        
| 254 | - $table .= '<tr><th>'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n" ;  | 
                                                        |
| 255 | - $form .= '<input type="hidden" name="'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n" ;  | 
                                                        |
| 254 | + $table .= '<tr><th>'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n";  | 
                                                        |
| 255 | + $form .= '<input type="hidden" name="'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n";  | 
                                                        |
| 256 | 256 | }  | 
                                                        
| 257 | 257 | }  | 
                                                        
| 258 | - return array( $table , $form ) ;  | 
                                                        |
| 258 | + return array($table, $form);  | 
                                                        |
| 259 | 259 | }  | 
                                                        
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | // clear all stubs  | 
                                                        
| 263 | 263 | public function clear()  | 
                                                        
| 264 | 264 |      { | 
                                                        
| 265 | - $_SESSION['XOOPS_G_STUBS'] = array() ;  | 
                                                        |
| 265 | + $_SESSION['XOOPS_G_STUBS'] = array();  | 
                                                        |
| 266 | 266 | }  | 
                                                        
| 267 | 267 | |
| 268 | 268 | |
| 269 | 269 | // Ticket Using  | 
                                                        
| 270 | 270 | public function using()  | 
                                                        
| 271 | 271 |      { | 
                                                        
| 272 | -        if (! empty($_SESSION['XOOPS_G_STUBS'])) { | 
                                                        |
| 272 | +        if (!empty($_SESSION['XOOPS_G_STUBS'])) { | 
                                                        |
| 273 | 273 | return true;  | 
                                                        
| 274 | 274 |          } else { | 
                                                        
| 275 | 275 | return false;  | 
                                                        
@@ -281,39 +281,39 @@ discard block  | 
                                                    ||
| 281 | 281 | public function getErrors($ashtml = true)  | 
                                                        
| 282 | 282 |      { | 
                                                        
| 283 | 283 |          if ($ashtml) { | 
                                                        
| 284 | - $ret = '' ;  | 
                                                        |
| 284 | + $ret = '';  | 
                                                        |
| 285 | 285 |              foreach ($this->_errors as $msg) { | 
                                                        
| 286 | - $ret .= "$msg<br />\n" ;  | 
                                                        |
| 286 | + $ret .= "$msg<br />\n";  | 
                                                        |
| 287 | 287 | }  | 
                                                        
| 288 | 288 |          } else { | 
                                                        
| 289 | - $ret = $this->_errors ;  | 
                                                        |
| 289 | + $ret = $this->_errors;  | 
                                                        |
| 290 | 290 | }  | 
                                                        
| 291 | - return $ret ;  | 
                                                        |
| 291 | + return $ret;  | 
                                                        |
| 292 | 292 | }  | 
                                                        
| 293 | 293 | |
| 294 | 294 | public function errorHandler4FindOutput($errNo, $errStr, $errFile, $errLine)  | 
                                                        
| 295 | 295 |          { | 
                                                        
| 296 | 296 |              if (preg_match('?'.preg_quote(XOOPS_ROOT_PATH).'([^:]+)\:(\d+)?', $errStr, $regs)) { | 
                                                        
| 297 | - echo 'Irregular output! check the file ' . htmlspecialchars($regs[1]) . ' line ' . htmlspecialchars($regs[2]) ;  | 
                                                        |
| 297 | + echo 'Irregular output! check the file '.htmlspecialchars($regs[1]).' line '.htmlspecialchars($regs[2]);  | 
                                                        |
| 298 | 298 |              } else { | 
                                                        
| 299 | 299 | echo 'Irregular output! check language files etc.';  | 
                                                        
| 300 | 300 | }  | 
                                                        
| 301 | - return ;  | 
                                                        |
| 301 | + return;  | 
                                                        |
| 302 | 302 | }  | 
                                                        
| 303 | 303 | // end of class  | 
                                                        
| 304 | 304 | }  | 
                                                        
| 305 | 305 | |
| 306 | 306 | // create a instance in global scope  | 
                                                        
| 307 | -$GLOBALS['xoopsGTicket'] = new XoopsGTicket() ;  | 
                                                        |
| 307 | +$GLOBALS['xoopsGTicket'] = new XoopsGTicket();  | 
                                                        |
| 308 | 308 | }  | 
                                                        
| 309 | 309 | |
| 310 | -if (! function_exists('admin_refcheck')) { | 
                                                        |
| 310 | +if (!function_exists('admin_refcheck')) { | 
                                                        |
| 311 | 311 | |
| 312 | 312 | //Admin Referer Check By Marijuana(Rev.011)  | 
                                                        
| 313 | 313 | function admin_refcheck($chkref = '')  | 
                                                        
| 314 | 314 |  { | 
                                                        
| 315 | 315 |      if (empty($_SERVER['HTTP_REFERER'])) { | 
                                                        
| 316 | - return true ;  | 
                                                        |
| 316 | + return true;  | 
                                                        |
| 317 | 317 |      } else { | 
                                                        
| 318 | 318 | $ref = $_SERVER['HTTP_REFERER'];  | 
                                                        
| 319 | 319 | }  | 
                                                        
@@ -441,6 +441,7 @@ discard block  | 
                                                    ||
| 441 | 441 | * the two files do not match, and likewise that the last lines do not  | 
                                                        
| 442 | 442 | * match. The caller must trim matching lines from the beginning and end  | 
                                                        
| 443 | 443 | * of the portions it is going to specify.  | 
                                                        
| 444 | + * @param double $nchunks  | 
                                                        |
| 444 | 445 | */  | 
                                                        
| 445 | 446 | public function _diag($xoff, $xlim, $yoff, $ylim, $nchunks)  | 
                                                        
| 446 | 447 |      { | 
                                                        
@@ -561,6 +562,10 @@ discard block  | 
                                                    ||
| 561 | 562 | *  | 
                                                        
| 562 | 563 | * Note that XLIM, YLIM are exclusive bounds. All line numbers are  | 
                                                        
| 563 | 564 | * origin-0 and discarded lines are not counted.  | 
                                                        
| 565 | + * @param integer $xoff  | 
                                                        |
| 566 | + * @param integer $xlim  | 
                                                        |
| 567 | + * @param integer $yoff  | 
                                                        |
| 568 | + * @param integer $ylim  | 
                                                        |
| 564 | 569 | */  | 
                                                        
| 565 | 570 | public function _compareseq($xoff, $xlim, $yoff, $ylim)  | 
                                                        
| 566 | 571 |      { | 
                                                        
@@ -281,17 +281,17 @@  | 
                                                    ||
| 281 | 281 | $edits = array();  | 
                                                        
| 282 | 282 |          foreach ($diff as $line) { | 
                                                        
| 283 | 283 |              switch ($line[0]) { | 
                                                        
| 284 | - case ' ':  | 
                                                        |
| 285 | - $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));  | 
                                                        |
| 286 | - break;  | 
                                                        |
| 284 | + case ' ':  | 
                                                        |
| 285 | + $edits[] = new Text_Diff_Op_copy(array(substr($line, 1)));  | 
                                                        |
| 286 | + break;  | 
                                                        |
| 287 | 287 | |
| 288 | - case '+':  | 
                                                        |
| 289 | - $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));  | 
                                                        |
| 290 | - break;  | 
                                                        |
| 288 | + case '+':  | 
                                                        |
| 289 | + $edits[] = new Text_Diff_Op_add(array(substr($line, 1)));  | 
                                                        |
| 290 | + break;  | 
                                                        |
| 291 | 291 | |
| 292 | - case '-':  | 
                                                        |
| 293 | - $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));  | 
                                                        |
| 294 | - break;  | 
                                                        |
| 292 | + case '-':  | 
                                                        |
| 293 | + $edits[] = new Text_Diff_Op_delete(array(substr($line, 1)));  | 
                                                        |
| 294 | + break;  | 
                                                        |
| 295 | 295 | }  | 
                                                        
| 296 | 296 | }  | 
                                                        
| 297 | 297 | |
@@ -465,7 +465,7 @@ discard block  | 
                                                    ||
| 465 | 465 | }  | 
                                                        
| 466 | 466 | |
| 467 | 467 | $this->lcs = 0;  | 
                                                        
| 468 | - $this->seq[0]= $yoff - 1;  | 
                                                        |
| 468 | + $this->seq[0] = $yoff - 1;  | 
                                                        |
| 469 | 469 | $this->in_seq = array();  | 
                                                        
| 470 | 470 | $ymids[0] = array();  | 
                                                        
| 471 | 471 | |
@@ -478,7 +478,7 @@ discard block  | 
                                                    ||
| 478 | 478 | }  | 
                                                        
| 479 | 479 | }  | 
                                                        
| 480 | 480 | |
| 481 | - $x1 = $xoff + (int)(($numer + ($xlim-$xoff)*$chunk) / $nchunks);  | 
                                                        |
| 481 | + $x1 = $xoff + (int)(($numer + ($xlim - $xoff) * $chunk) / $nchunks);  | 
                                                        |
| 482 | 482 |              for (; $x < $x1; $x++) { | 
                                                        
| 483 | 483 | $line = $flip ? $this->yv[$x] : $this->xv[$x];  | 
                                                        
| 484 | 484 |                  if (empty($ymatches[$line])) { | 
                                                        
@@ -646,7 +646,7 @@ discard block  | 
                                                    ||
| 646 | 646 | $j++;  | 
                                                        
| 647 | 647 | }  | 
                                                        
| 648 | 648 | |
| 649 | -            while ($i < $len && ! $changed[$i]) { | 
                                                        |
| 649 | +            while ($i < $len && !$changed[$i]) { | 
                                                        |
| 650 | 650 |                  assert('$j < $other_len && ! $other_changed[$j]'); | 
                                                        
| 651 | 651 | $i++;  | 
                                                        
| 652 | 652 | $j++;  | 
                                                        
@@ -125,6 +125,12 @@ discard block  | 
                                                    ||
| 125 | 125 | return $output . $this->_endDiff();  | 
                                                        
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | + /**  | 
                                                        |
| 129 | + * @param integer $xbeg  | 
                                                        |
| 130 | + * @param integer $xlen  | 
                                                        |
| 131 | + * @param integer $ybeg  | 
                                                        |
| 132 | + * @param integer $ylen  | 
                                                        |
| 133 | + */  | 
                                                        |
| 128 | 134 | public function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)  | 
                                                        
| 129 | 135 |      { | 
                                                        
| 130 | 136 | $output = $this->_startBlock($this->_blockHeader($xbeg, $xlen, $ybeg, $ylen));  | 
                                                        
@@ -174,6 +180,9 @@ discard block  | 
                                                    ||
| 174 | 180 | return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;  | 
                                                        
| 175 | 181 | }  | 
                                                        
| 176 | 182 | |
| 183 | + /**  | 
                                                        |
| 184 | + * @param string $header  | 
                                                        |
| 185 | + */  | 
                                                        |
| 177 | 186 | public function _startBlock($header)  | 
                                                        
| 178 | 187 |      { | 
                                                        
| 179 | 188 | return $header . "\n";  | 
                                                        
@@ -89,8 +89,8 @@ discard block  | 
                                                    ||
| 89 | 89 | $block[] = new Text_Diff_Op_copy($context);  | 
                                                        
| 90 | 90 | }  | 
                                                        
| 91 | 91 | $output .= $this->_block($x0, $ntrail + $xi - $x0,  | 
                                                        
| 92 | - $y0, $ntrail + $yi - $y0,  | 
                                                        |
| 93 | - $block);  | 
                                                        |
| 92 | + $y0, $ntrail + $yi - $y0,  | 
                                                        |
| 93 | + $block);  | 
                                                        |
| 94 | 94 | $block = false;  | 
                                                        
| 95 | 95 | }  | 
                                                        
| 96 | 96 | }  | 
                                                        
@@ -118,8 +118,8 @@ discard block  | 
                                                    ||
| 118 | 118 | |
| 119 | 119 |          if (is_array($block)) { | 
                                                        
| 120 | 120 | $output .= $this->_block($x0, $xi - $x0,  | 
                                                        
| 121 | - $y0, $yi - $y0,  | 
                                                        |
| 122 | - $block);  | 
                                                        |
| 121 | + $y0, $yi - $y0,  | 
                                                        |
| 122 | + $block);  | 
                                                        |
| 123 | 123 | }  | 
                                                        
| 124 | 124 | |
| 125 | 125 | return $output . $this->_endDiff();  | 
                                                        
@@ -131,21 +131,21 @@  | 
                                                    ||
| 131 | 131 | |
| 132 | 132 |          foreach ($edits as $edit) { | 
                                                        
| 133 | 133 |              switch (strtolower(get_class($edit))) { | 
                                                        
| 134 | - case 'text_diff_op_copy':  | 
                                                        |
| 135 | - $output .= $this->_context($edit->orig);  | 
                                                        |
| 136 | - break;  | 
                                                        |
| 134 | + case 'text_diff_op_copy':  | 
                                                        |
| 135 | + $output .= $this->_context($edit->orig);  | 
                                                        |
| 136 | + break;  | 
                                                        |
| 137 | 137 | |
| 138 | - case 'text_diff_op_add':  | 
                                                        |
| 139 | - $output .= $this->_added($edit->final);  | 
                                                        |
| 140 | - break;  | 
                                                        |
| 138 | + case 'text_diff_op_add':  | 
                                                        |
| 139 | + $output .= $this->_added($edit->final);  | 
                                                        |
| 140 | + break;  | 
                                                        |
| 141 | 141 | |
| 142 | - case 'text_diff_op_delete':  | 
                                                        |
| 143 | - $output .= $this->_deleted($edit->orig);  | 
                                                        |
| 144 | - break;  | 
                                                        |
| 142 | + case 'text_diff_op_delete':  | 
                                                        |
| 143 | + $output .= $this->_deleted($edit->orig);  | 
                                                        |
| 144 | + break;  | 
                                                        |
| 145 | 145 | |
| 146 | - case 'text_diff_op_change':  | 
                                                        |
| 147 | - $output .= $this->_changed($edit->orig, $edit->final);  | 
                                                        |
| 148 | - break;  | 
                                                        |
| 146 | + case 'text_diff_op_change':  | 
                                                        |
| 147 | + $output .= $this->_changed($edit->orig, $edit->final);  | 
                                                        |
| 148 | + break;  | 
                                                        |
| 149 | 149 | }  | 
                                                        
| 150 | 150 | }  | 
                                                        
| 151 | 151 | |
@@ -36,7 +36,7 @@ discard block  | 
                                                    ||
| 36 | 36 | public function __construct($params = array())  | 
                                                        
| 37 | 37 |      { | 
                                                        
| 38 | 38 |          foreach ($params as $param => $value) { | 
                                                        
| 39 | - $v = '_' . $param;  | 
                                                        |
| 39 | + $v = '_'.$param;  | 
                                                        |
| 40 | 40 |              if (isset($this->$v)) { | 
                                                        
| 41 | 41 | $this->$v = $value;  | 
                                                        
| 42 | 42 | }  | 
                                                        
@@ -122,7 +122,7 @@ discard block  | 
                                                    ||
| 122 | 122 | $block);  | 
                                                        
| 123 | 123 | }  | 
                                                        
| 124 | 124 | |
| 125 | - return $output . $this->_endDiff();  | 
                                                        |
| 125 | + return $output.$this->_endDiff();  | 
                                                        |
| 126 | 126 | }  | 
                                                        
| 127 | 127 | |
| 128 | 128 | public function _block($xbeg, $xlen, $ybeg, $ylen, &$edits)  | 
                                                        
@@ -149,7 +149,7 @@ discard block  | 
                                                    ||
| 149 | 149 | }  | 
                                                        
| 150 | 150 | }  | 
                                                        
| 151 | 151 | |
| 152 | - return $output . $this->_endBlock();  | 
                                                        |
| 152 | + return $output.$this->_endBlock();  | 
                                                        |
| 153 | 153 | }  | 
                                                        
| 154 | 154 | |
| 155 | 155 | public function _startDiff()  | 
                                                        
@@ -165,18 +165,18 @@ discard block  | 
                                                    ||
| 165 | 165 | public function _blockHeader($xbeg, $xlen, $ybeg, $ylen)  | 
                                                        
| 166 | 166 |      { | 
                                                        
| 167 | 167 |          if ($xlen > 1) { | 
                                                        
| 168 | - $xbeg .= ',' . ($xbeg + $xlen - 1);  | 
                                                        |
| 168 | + $xbeg .= ','.($xbeg + $xlen - 1);  | 
                                                        |
| 169 | 169 | }  | 
                                                        
| 170 | 170 |          if ($ylen > 1) { | 
                                                        
| 171 | - $ybeg .= ',' . ($ybeg + $ylen - 1);  | 
                                                        |
| 171 | + $ybeg .= ','.($ybeg + $ylen - 1);  | 
                                                        |
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | - return $xbeg . ($xlen ? ($ylen ? 'c' : 'd') : 'a') . $ybeg;  | 
                                                        |
| 174 | + return $xbeg.($xlen ? ($ylen ? 'c' : 'd') : 'a').$ybeg;  | 
                                                        |
| 175 | 175 | }  | 
                                                        
| 176 | 176 | |
| 177 | 177 | public function _startBlock($header)  | 
                                                        
| 178 | 178 |      { | 
                                                        
| 179 | - return $header . "\n";  | 
                                                        |
| 179 | + return $header."\n";  | 
                                                        |
| 180 | 180 | }  | 
                                                        
| 181 | 181 | |
| 182 | 182 | public function _endBlock()  | 
                                                        
@@ -186,7 +186,7 @@ discard block  | 
                                                    ||
| 186 | 186 | |
| 187 | 187 | public function _lines($lines, $prefix = ' ')  | 
                                                        
| 188 | 188 |      { | 
                                                        
| 189 | -        return $prefix . implode("\n$prefix", $lines) . "\n"; | 
                                                        |
| 189 | +        return $prefix.implode("\n$prefix", $lines)."\n"; | 
                                                        |
| 190 | 190 | }  | 
                                                        
| 191 | 191 | |
| 192 | 192 | public function _context($lines)  | 
                                                        
@@ -206,6 +206,6 @@ discard block  | 
                                                    ||
| 206 | 206 | |
| 207 | 207 | public function _changed($orig, $final)  | 
                                                        
| 208 | 208 |      { | 
                                                        
| 209 | - return $this->_deleted($orig) . "---\n" . $this->_added($final);  | 
                                                        |
| 209 | + return $this->_deleted($orig)."---\n".$this->_added($final);  | 
                                                        |
| 210 | 210 | }  | 
                                                        
| 211 | 211 | }  | 
                                                        
@@ -63,6 +63,9 @@ discard block  | 
                                                    ||
| 63 | 63 | return $header;  | 
                                                        
| 64 | 64 | }  | 
                                                        
| 65 | 65 | |
| 66 | + /**  | 
                                                        |
| 67 | + * @param string[] $lines  | 
                                                        |
| 68 | + */  | 
                                                        |
| 66 | 69 | public function _lines($lines, $prefix = ' ', $encode = true)  | 
                                                        
| 67 | 70 |      { | 
                                                        
| 68 | 71 |          if ($encode) { | 
                                                        
@@ -128,6 +131,9 @@ discard block  | 
                                                    ||
| 128 | 131 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n";  | 
                                                        
| 129 | 132 | }  | 
                                                        
| 130 | 133 | |
| 134 | + /**  | 
                                                        |
| 135 | + * @param string $string  | 
                                                        |
| 136 | + */  | 
                                                        |
| 131 | 137 | public function _splitOnWords($string, $newlineEscape = "\n")  | 
                                                        
| 132 | 138 |      { | 
                                                        
| 133 | 139 | $words = array();  | 
                                                        
@@ -118,11 +118,11 @@  | 
                                                    ||
| 118 | 118 | * preserve whitespace as well. Therefore we split on words,  | 
                                                        
| 119 | 119 | * but include all blocks of whitespace in the wordlist. */  | 
                                                        
| 120 | 120 | $diff = new Text_Diff($this->_splitOnWords($text1, $nl),  | 
                                                        
| 121 | - $this->_splitOnWords($text2, $nl));  | 
                                                        |
| 121 | + $this->_splitOnWords($text2, $nl));  | 
                                                        |
| 122 | 122 | |
| 123 | 123 | /* Get the diff in inline format. */  | 
                                                        
| 124 | 124 | $renderer = new Text_Diff_Renderer_inline(array_merge($this->getParams(),  | 
                                                        
| 125 | -                                                               array('split_level' => 'words'))); | 
                                                        |
| 125 | +                                                                array('split_level' => 'words'))); | 
                                                        |
| 126 | 126 | |
| 127 | 127 | /* Run the diff and get the output. */  | 
                                                        
| 128 | 128 | return str_replace($nl, "\n", $renderer->render($diff)) . "\n";  | 
                                                        
@@ -72,14 +72,14 @@ discard block  | 
                                                    ||
| 72 | 72 |          if ($this->_split_level == 'words') { | 
                                                        
| 73 | 73 |              return implode('', $lines); | 
                                                        
| 74 | 74 |          } else { | 
                                                        
| 75 | -            return implode("\n", $lines) . "\n"; | 
                                                        |
| 75 | +            return implode("\n", $lines)."\n"; | 
                                                        |
| 76 | 76 | }  | 
                                                        
| 77 | 77 | }  | 
                                                        
| 78 | 78 | |
| 79 | 79 | public function _added($lines)  | 
                                                        
| 80 | 80 |      { | 
                                                        
| 81 | 81 | array_walk($lines, array(&$this, '_encode'));  | 
                                                        
| 82 | - $lines[0] = $this->_ins_prefix . $lines[0];  | 
                                                        |
| 82 | + $lines[0] = $this->_ins_prefix.$lines[0];  | 
                                                        |
| 83 | 83 | $lines[count($lines) - 1] .= $this->_ins_suffix;  | 
                                                        
| 84 | 84 | return $this->_lines($lines, ' ', false);  | 
                                                        
| 85 | 85 | }  | 
                                                        
@@ -87,7 +87,7 @@ discard block  | 
                                                    ||
| 87 | 87 | public function _deleted($lines, $words = false)  | 
                                                        
| 88 | 88 |      { | 
                                                        
| 89 | 89 | array_walk($lines, array(&$this, '_encode'));  | 
                                                        
| 90 | - $lines[0] = $this->_del_prefix . $lines[0];  | 
                                                        |
| 90 | + $lines[0] = $this->_del_prefix.$lines[0];  | 
                                                        |
| 91 | 91 | $lines[count($lines) - 1] .= $this->_del_suffix;  | 
                                                        
| 92 | 92 | return $this->_lines($lines, ' ', false);  | 
                                                        
| 93 | 93 | }  | 
                                                        
@@ -105,7 +105,7 @@ discard block  | 
                                                    ||
| 105 | 105 | $orig[0] = substr($orig[0], 1);  | 
                                                        
| 106 | 106 | $final[0] = substr($final[0], 1);  | 
                                                        
| 107 | 107 | }  | 
                                                        
| 108 | - return $prefix . $this->_deleted($orig) . $this->_added($final);  | 
                                                        |
| 108 | + return $prefix.$this->_deleted($orig).$this->_added($final);  | 
                                                        |
| 109 | 109 | }  | 
                                                        
| 110 | 110 | |
| 111 | 111 |          $text1 = implode("\n", $orig); | 
                                                        
@@ -125,7 +125,7 @@ discard block  | 
                                                    ||
| 125 | 125 |                                                                 array('split_level' => 'words'))); | 
                                                        
| 126 | 126 | |
| 127 | 127 | /* Run the diff and get the output. */  | 
                                                        
| 128 | - return str_replace($nl, "\n", $renderer->render($diff)) . "\n";  | 
                                                        |
| 128 | + return str_replace($nl, "\n", $renderer->render($diff))."\n";  | 
                                                        |
| 129 | 129 | }  | 
                                                        
| 130 | 130 | |
| 131 | 131 | public function _splitOnWords($string, $newlineEscape = "\n")  |