@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | ?> |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if( ! defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
2 | +if (!defined('IN_MANAGER_MODE') || IN_MANAGER_MODE !== true) { |
|
3 | 3 | die("<b>INCLUDE_ORDERING_ERROR</b><br /><br />Please use the EVO Content Manager instead of accessing this file directly."); |
4 | 4 | } |
5 | 5 | ?> |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | foreach ($_ as $collation=>$selected) { |
51 | 51 | $collation = htmlentities($collation); |
52 | 52 | // if(substr($collation,0,4)!=='utf8') continue; |
53 | - if (strpos($collation, 'sjis')===0) { |
|
53 | + if (strpos($collation, 'sjis') === 0) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | - if ($collation=='recommend') { |
|
56 | + if ($collation == 'recommend') { |
|
57 | 57 | $output .= '<optgroup label="recommend">'; |
58 | - } elseif ($collation=='unrecommend') { |
|
58 | + } elseif ($collation == 'unrecommend') { |
|
59 | 59 | $output .= '</optgroup><optgroup label="unrecommend">'; |
60 | 60 | } else { |
61 | 61 | $output .= sprintf('<option value="%s" %s>%s</option>', $collation, $selected, $collation); |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | echo $output; |
68 | 68 | exit; |
69 | 69 | |
70 | -function sortItem($array=array(), $order='utf8mb4,utf8') |
|
70 | +function sortItem($array = array(), $order = 'utf8mb4,utf8') |
|
71 | 71 | { |
72 | 72 | $rs = array('recommend'=>''); |
73 | 73 | $order = explode(',', $order); |
74 | 74 | foreach ($order as $v) { |
75 | 75 | foreach ($array as $name=>$sel) { |
76 | - if (strpos($name, $v)!==false) { |
|
76 | + if (strpos($name, $v) !== false) { |
|
77 | 77 | $rs[$name] = $array[$name]; |
78 | 78 | unset($array[$name]); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | } |
82 | - $rs['unrecommend']=''; |
|
82 | + $rs['unrecommend'] = ''; |
|
83 | 83 | return $rs + $array; |
84 | 84 | } |
85 | 85 | \ No newline at end of file |
@@ -33,6 +33,10 @@ |
||
33 | 33 | } |
34 | 34 | |
35 | 35 | if( ! function_exists('parse')) { |
36 | + |
|
37 | + /** |
|
38 | + * @param string $src |
|
39 | + */ |
|
36 | 40 | function parse($src, $ph, $left = '[+', $right = '+]') |
37 | 41 | { |
38 | 42 | foreach ($ph as $k => $v) { |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if( ! function_exists('install_sessionCheck')) { |
|
2 | +if (!function_exists('install_sessionCheck')) { |
|
3 | 3 | function install_sessionCheck() |
4 | 4 | { |
5 | 5 | global $_lang; |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | </head> |
22 | 22 | <body> |
23 | 23 | <div class="install"> |
24 | - <p>' . $_lang["session_problem"] . '</p> |
|
25 | - <p><a href="./">' . $_lang["session_problem_try_again"] . '</a></p> |
|
24 | + <p>' . $_lang["session_problem"].'</p> |
|
25 | + <p><a href="./">' . $_lang["session_problem_try_again"].'</a></p> |
|
26 | 26 | </div> |
27 | 27 | </body> |
28 | 28 | </html>'; |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | -if( ! function_exists('parse')) { |
|
35 | +if (!function_exists('parse')) { |
|
36 | 36 | function parse($src, $ph, $left = '[+', $right = '+]') |
37 | 37 | { |
38 | 38 | foreach ($ph as $k => $v) { |
39 | - $k = $left . $k . $right; |
|
39 | + $k = $left.$k.$right; |
|
40 | 40 | $src = str_replace($k, $v, $src); |
41 | 41 | } |
42 | 42 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | } |
45 | 45 | } |
46 | 46 | |
47 | -if( ! function_exists('ph')) { |
|
47 | +if (!function_exists('ph')) { |
|
48 | 48 | function ph() |
49 | 49 | { |
50 | 50 | global $_lang, $moduleName, $moduleVersion, $modx_textdir, $modx_release_date; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | $ph['textdir'] = $modx_textdir ? ' id="rtl"' : ''; |
60 | 60 | $ph['help_link'] = $installmode == 0 ? $_lang['help_link_new'] : $_lang['help_link_upd']; |
61 | 61 | $ph['version'] = $moduleVersion; |
62 | - $ph['release_date'] = ($modx_textdir ? '‏' : '') . $modx_release_date; |
|
62 | + $ph['release_date'] = ($modx_textdir ? '‏' : '').$modx_release_date; |
|
63 | 63 | $ph['footer1'] = $_lang['modx_footer1']; |
64 | 64 | $ph['footer2'] = $_lang['modx_footer2']; |
65 | 65 | $ph['current_year'] = date('Y'); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | } |
69 | 69 | } |
70 | 70 | |
71 | -if( ! function_exists('get_installmode')) { |
|
71 | +if (!function_exists('get_installmode')) { |
|
72 | 72 | function get_installmode() |
73 | 73 | { |
74 | 74 | global $base_path, $database_server, $database_user, $database_password, $dbase, $table_prefix; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | } |
128 | 128 | } |
129 | 129 | |
130 | -if( ! function_exists('getLangs')) { |
|
130 | +if (!function_exists('getLangs')) { |
|
131 | 131 | /** |
132 | 132 | * @param $install_language |
133 | 133 | * @return string |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | } |
142 | 142 | |
143 | 143 | $langs = array(); |
144 | - if ($handle = opendir("../" . MGR_DIR . "/includes/lang")) { |
|
144 | + if ($handle = opendir("../".MGR_DIR."/includes/lang")) { |
|
145 | 145 | while (false !== ($file = readdir($handle))) { |
146 | 146 | if (strpos($file, '.inc.') !== false) { |
147 | 147 | $langs[] = $file; |
@@ -4,141 +4,141 @@ |
||
4 | 4 | // SNUFFKIN/ Alex 2004 |
5 | 5 | |
6 | 6 | class SqlParser { |
7 | - public $host; |
|
8 | - public $dbname; |
|
9 | - public $prefix; |
|
10 | - public $user; |
|
11 | - public $password; |
|
12 | - public $mysqlErrors; |
|
13 | - public $conn; |
|
14 | - public $installFailed; |
|
15 | - public $sitename; |
|
16 | - public $adminname; |
|
17 | - public $adminemail; |
|
18 | - public $adminpass; |
|
19 | - public $managerlanguage; |
|
20 | - public $mode; |
|
21 | - public $fileManagerPath; |
|
22 | - public $imgPath; |
|
23 | - public $imgUrl; |
|
24 | - public $dbMODx; |
|
25 | - public $dbVersion; |
|
7 | + public $host; |
|
8 | + public $dbname; |
|
9 | + public $prefix; |
|
10 | + public $user; |
|
11 | + public $password; |
|
12 | + public $mysqlErrors; |
|
13 | + public $conn; |
|
14 | + public $installFailed; |
|
15 | + public $sitename; |
|
16 | + public $adminname; |
|
17 | + public $adminemail; |
|
18 | + public $adminpass; |
|
19 | + public $managerlanguage; |
|
20 | + public $mode; |
|
21 | + public $fileManagerPath; |
|
22 | + public $imgPath; |
|
23 | + public $imgUrl; |
|
24 | + public $dbMODx; |
|
25 | + public $dbVersion; |
|
26 | 26 | public $connection_charset; |
27 | 27 | public $connection_method; |
28 | 28 | public $ignoreDuplicateErrors; |
29 | 29 | public $autoTemplateLogic; |
30 | 30 | |
31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
32 | - $this->host = $host; |
|
33 | - $this->dbname = $db; |
|
34 | - $this->prefix = $prefix; |
|
35 | - $this->user = $user; |
|
36 | - $this->password = $password; |
|
37 | - $this->adminpass = $adminpass; |
|
38 | - $this->adminname = $adminname; |
|
39 | - $this->adminemail = $adminemail; |
|
40 | - $this->connection_charset = $connection_charset; |
|
41 | - $this->connection_method = $connection_method; |
|
42 | - $this->ignoreDuplicateErrors = false; |
|
43 | - $this->managerlanguage = $managerlanguage; |
|
31 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
32 | + $this->host = $host; |
|
33 | + $this->dbname = $db; |
|
34 | + $this->prefix = $prefix; |
|
35 | + $this->user = $user; |
|
36 | + $this->password = $password; |
|
37 | + $this->adminpass = $adminpass; |
|
38 | + $this->adminname = $adminname; |
|
39 | + $this->adminemail = $adminemail; |
|
40 | + $this->connection_charset = $connection_charset; |
|
41 | + $this->connection_method = $connection_method; |
|
42 | + $this->ignoreDuplicateErrors = false; |
|
43 | + $this->managerlanguage = $managerlanguage; |
|
44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
45 | - } |
|
45 | + } |
|
46 | 46 | |
47 | - public function connect() { |
|
48 | - $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
49 | - mysqli_select_db($this->conn, $this->dbname); |
|
50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
47 | + public function connect() { |
|
48 | + $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
|
49 | + mysqli_select_db($this->conn, $this->dbname); |
|
50 | + if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
51 | 51 | |
52 | - $this->dbVersion = 3.23; // assume version 3.23 |
|
53 | - if(function_exists("mysqli_get_server_info")) { |
|
54 | - $ver = mysqli_get_server_info($this->conn); |
|
55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
56 | - $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
57 | - } |
|
52 | + $this->dbVersion = 3.23; // assume version 3.23 |
|
53 | + if(function_exists("mysqli_get_server_info")) { |
|
54 | + $ver = mysqli_get_server_info($this->conn); |
|
55 | + $this->dbMODx = version_compare($ver,"4.0.2"); |
|
56 | + $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
|
57 | + } |
|
58 | 58 | |
59 | 59 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
60 | - } |
|
60 | + } |
|
61 | 61 | |
62 | 62 | public function process($filename) { |
63 | - global $custom_placeholders; |
|
64 | - |
|
65 | - // check to make sure file exists |
|
66 | - if (!file_exists($filename)) { |
|
67 | - $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
68 | - $this->installFailed = true ; |
|
69 | - return false; |
|
70 | - } |
|
71 | - |
|
72 | - $fh = fopen($filename, 'r'); |
|
73 | - $idata = ''; |
|
74 | - |
|
75 | - while (!feof($fh)) { |
|
76 | - $idata .= fread($fh, 1024); |
|
77 | - } |
|
78 | - |
|
79 | - fclose($fh); |
|
80 | - $idata = str_replace("\r", '', $idata); |
|
81 | - |
|
82 | - // check if in upgrade mode |
|
83 | - if ($this->mode === 'upd') { |
|
84 | - // remove non-upgradeable parts |
|
85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
87 | - if($s && $e) { |
|
88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
63 | + global $custom_placeholders; |
|
64 | + |
|
65 | + // check to make sure file exists |
|
66 | + if (!file_exists($filename)) { |
|
67 | + $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
|
68 | + $this->installFailed = true ; |
|
69 | + return false; |
|
70 | + } |
|
71 | + |
|
72 | + $fh = fopen($filename, 'r'); |
|
73 | + $idata = ''; |
|
74 | + |
|
75 | + while (!feof($fh)) { |
|
76 | + $idata .= fread($fh, 1024); |
|
77 | + } |
|
78 | + |
|
79 | + fclose($fh); |
|
80 | + $idata = str_replace("\r", '', $idata); |
|
81 | + |
|
82 | + // check if in upgrade mode |
|
83 | + if ($this->mode === 'upd') { |
|
84 | + // remove non-upgradeable parts |
|
85 | + $s = strpos($idata,'non-upgrade-able[['); |
|
86 | + $e = strpos($idata,']]non-upgrade-able') + 17; |
|
87 | + if($s && $e) { |
|
88 | + $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
89 | 89 | } |
90 | - } |
|
91 | - |
|
92 | - // replace {} tags |
|
93 | - $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
94 | - $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
95 | - $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
96 | - $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
97 | - $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
98 | - $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
99 | - $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
100 | - $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
101 | - $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
102 | - /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
103 | - |
|
104 | - // Replace custom placeholders |
|
105 | - foreach($custom_placeholders as $key=>$val) { |
|
106 | - if (strpos($idata, '{'.$key.'}') !== false) { |
|
107 | - $idata = str_replace('{'.$key.'}', $val, $idata); |
|
108 | - } |
|
109 | - } |
|
110 | - |
|
111 | - $sql_array = explode("\n\n", $idata); |
|
112 | - |
|
113 | - $num = 0; |
|
114 | - foreach($sql_array as $sql_entry) { |
|
115 | - $sql_do = trim($sql_entry, "\r\n; "); |
|
116 | - |
|
117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
118 | - |
|
119 | - // strip out comments and \n for mysql 3.x |
|
120 | - if ($this->dbVersion <4.0) { |
|
121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
122 | - $sql_do = str_replace('\r', "", $sql_do); |
|
123 | - $sql_do = str_replace('\n', "", $sql_do); |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - $num = $num + 1; |
|
128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
129 | - if(mysqli_error($this->conn)) { |
|
130 | - // Ignore duplicate and drop errors - Raymond |
|
131 | - if ($this->ignoreDuplicateErrors){ |
|
132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
133 | - } |
|
134 | - // End Ignore duplicate |
|
135 | - $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
136 | - $this->installFailed = true; |
|
137 | - } |
|
138 | - } |
|
139 | - } |
|
90 | + } |
|
91 | + |
|
92 | + // replace {} tags |
|
93 | + $idata = str_replace('{PREFIX}', $this->prefix, $idata); |
|
94 | + $idata = str_replace('{ADMIN}', $this->adminname, $idata); |
|
95 | + $idata = str_replace('{ADMINEMAIL}', $this->adminemail, $idata); |
|
96 | + $idata = str_replace('{ADMINPASS}', $this->adminpass, $idata); |
|
97 | + $idata = str_replace('{IMAGEPATH}', $this->imgPath, $idata); |
|
98 | + $idata = str_replace('{IMAGEURL}', $this->imgUrl, $idata); |
|
99 | + $idata = str_replace('{FILEMANAGERPATH}', $this->fileManagerPath, $idata); |
|
100 | + $idata = str_replace('{MANAGERLANGUAGE}', $this->managerlanguage, $idata); |
|
101 | + $idata = str_replace('{AUTOTEMPLATELOGIC}', $this->autoTemplateLogic, $idata); |
|
102 | + /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
|
103 | + |
|
104 | + // Replace custom placeholders |
|
105 | + foreach($custom_placeholders as $key=>$val) { |
|
106 | + if (strpos($idata, '{'.$key.'}') !== false) { |
|
107 | + $idata = str_replace('{'.$key.'}', $val, $idata); |
|
108 | + } |
|
109 | + } |
|
110 | + |
|
111 | + $sql_array = explode("\n\n", $idata); |
|
112 | + |
|
113 | + $num = 0; |
|
114 | + foreach($sql_array as $sql_entry) { |
|
115 | + $sql_do = trim($sql_entry, "\r\n; "); |
|
116 | + |
|
117 | + if (preg_match('/^\#/', $sql_do)) continue; |
|
118 | + |
|
119 | + // strip out comments and \n for mysql 3.x |
|
120 | + if ($this->dbVersion <4.0) { |
|
121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
122 | + $sql_do = str_replace('\r', "", $sql_do); |
|
123 | + $sql_do = str_replace('\n', "", $sql_do); |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + $num = $num + 1; |
|
128 | + if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
129 | + if(mysqli_error($this->conn)) { |
|
130 | + // Ignore duplicate and drop errors - Raymond |
|
131 | + if ($this->ignoreDuplicateErrors){ |
|
132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
133 | + } |
|
134 | + // End Ignore duplicate |
|
135 | + $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
|
136 | + $this->installFailed = true; |
|
137 | + } |
|
138 | + } |
|
139 | + } |
|
140 | 140 | |
141 | 141 | public function close() { |
142 | - mysqli_close($this->conn); |
|
143 | - } |
|
142 | + mysqli_close($this->conn); |
|
143 | + } |
|
144 | 144 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | // MySQL Dump Parser |
4 | 4 | // SNUFFKIN/ Alex 2004 |
5 | 5 | |
6 | -class SqlParser { |
|
6 | +class SqlParser{ |
|
7 | 7 | public $host; |
8 | 8 | public $dbname; |
9 | 9 | public $prefix; |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | public $ignoreDuplicateErrors; |
29 | 29 | public $autoTemplateLogic; |
30 | 30 | |
31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
31 | + public function __construct($host, $user, $password, $db, $prefix = 'modx_', $adminname, $adminemail, $adminpass, $connection_charset = 'utf8', $managerlanguage = 'english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent'){ |
|
32 | 32 | $this->host = $host; |
33 | 33 | $this->dbname = $db; |
34 | 34 | $this->prefix = $prefix; |
@@ -44,28 +44,28 @@ discard block |
||
44 | 44 | $this->autoTemplateLogic = $auto_template_logic; |
45 | 45 | } |
46 | 46 | |
47 | - public function connect() { |
|
47 | + public function connect(){ |
|
48 | 48 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
49 | 49 | mysqli_select_db($this->conn, $this->dbname); |
50 | 50 | if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
51 | 51 | |
52 | 52 | $this->dbVersion = 3.23; // assume version 3.23 |
53 | - if(function_exists("mysqli_get_server_info")) { |
|
53 | + if (function_exists("mysqli_get_server_info")) { |
|
54 | 54 | $ver = mysqli_get_server_info($this->conn); |
55 | - $this->dbMODx = version_compare($ver,"4.0.2"); |
|
55 | + $this->dbMODx = version_compare($ver, "4.0.2"); |
|
56 | 56 | $this->dbVersion = (float) $ver; // Typecasting (float) instead of floatval() [PHP < 4.2] |
57 | 57 | } |
58 | 58 | |
59 | - mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
|
59 | + mysqli_query($this->conn, "{$this->connection_method} {$this->connection_charset}"); |
|
60 | 60 | } |
61 | 61 | |
62 | - public function process($filename) { |
|
62 | + public function process($filename){ |
|
63 | 63 | global $custom_placeholders; |
64 | 64 | |
65 | 65 | // check to make sure file exists |
66 | 66 | if (!file_exists($filename)) { |
67 | 67 | $this->mysqlErrors[] = array("error" => "File '$filename' not found"); |
68 | - $this->installFailed = true ; |
|
68 | + $this->installFailed = true; |
|
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | |
@@ -82,10 +82,10 @@ discard block |
||
82 | 82 | // check if in upgrade mode |
83 | 83 | if ($this->mode === 'upd') { |
84 | 84 | // remove non-upgradeable parts |
85 | - $s = strpos($idata,'non-upgrade-able[['); |
|
86 | - $e = strpos($idata,']]non-upgrade-able') + 17; |
|
87 | - if($s && $e) { |
|
88 | - $idata = str_replace(substr($idata, $s,$e-$s),' Removed non upgradeable items', $idata); |
|
85 | + $s = strpos($idata, 'non-upgrade-able[['); |
|
86 | + $e = strpos($idata, ']]non-upgrade-able') + 17; |
|
87 | + if ($s && $e) { |
|
88 | + $idata = str_replace(substr($idata, $s, $e - $s), ' Removed non upgradeable items', $idata); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | /*$idata = str_replace('{VERSION}', $modx_version, $idata);*/ |
103 | 103 | |
104 | 104 | // Replace custom placeholders |
105 | - foreach($custom_placeholders as $key=>$val) { |
|
105 | + foreach ($custom_placeholders as $key=>$val) { |
|
106 | 106 | if (strpos($idata, '{'.$key.'}') !== false) { |
107 | 107 | $idata = str_replace('{'.$key.'}', $val, $idata); |
108 | 108 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | $sql_array = explode("\n\n", $idata); |
112 | 112 | |
113 | 113 | $num = 0; |
114 | - foreach($sql_array as $sql_entry) { |
|
114 | + foreach ($sql_array as $sql_entry) { |
|
115 | 115 | $sql_do = trim($sql_entry, "\r\n; "); |
116 | 116 | |
117 | 117 | if (preg_match('/^\#/', $sql_do)) continue; |
118 | 118 | |
119 | 119 | // strip out comments and \n for mysql 3.x |
120 | - if ($this->dbVersion <4.0) { |
|
121 | - $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~","",$sql_do); |
|
120 | + if ($this->dbVersion < 4.0) { |
|
121 | + $sql_do = preg_replace("~COMMENT.*[^']?'.*[^']?'~", "", $sql_do); |
|
122 | 122 | $sql_do = str_replace('\r', "", $sql_do); |
123 | 123 | $sql_do = str_replace('\n', "", $sql_do); |
124 | 124 | } |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | |
127 | 127 | $num = $num + 1; |
128 | 128 | if ($sql_do) mysqli_query($this->conn, $sql_do); |
129 | - if(mysqli_error($this->conn)) { |
|
129 | + if (mysqli_error($this->conn)) { |
|
130 | 130 | // Ignore duplicate and drop errors - Raymond |
131 | - if ($this->ignoreDuplicateErrors){ |
|
132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
131 | + if ($this->ignoreDuplicateErrors) { |
|
132 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 || mysqli_errno($this->conn) == 1091) continue; |
|
133 | 133 | } |
134 | 134 | // End Ignore duplicate |
135 | 135 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | - public function close() { |
|
141 | + public function close(){ |
|
142 | 142 | mysqli_close($this->conn); |
143 | 143 | } |
144 | 144 | } |
@@ -3,7 +3,8 @@ discard block |
||
3 | 3 | // MySQL Dump Parser |
4 | 4 | // SNUFFKIN/ Alex 2004 |
5 | 5 | |
6 | -class SqlParser { |
|
6 | +class SqlParser |
|
7 | +{ |
|
7 | 8 | public $host; |
8 | 9 | public $dbname; |
9 | 10 | public $prefix; |
@@ -28,7 +29,8 @@ discard block |
||
28 | 29 | public $ignoreDuplicateErrors; |
29 | 30 | public $autoTemplateLogic; |
30 | 31 | |
31 | - public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') { |
|
32 | + public function __construct($host, $user, $password, $db, $prefix='modx_', $adminname, $adminemail, $adminpass, $connection_charset= 'utf8', $managerlanguage='english', $connection_method = 'SET CHARACTER SET', $auto_template_logic = 'parent') |
|
33 | + { |
|
32 | 34 | $this->host = $host; |
33 | 35 | $this->dbname = $db; |
34 | 36 | $this->prefix = $prefix; |
@@ -44,10 +46,13 @@ discard block |
||
44 | 46 | $this->autoTemplateLogic = $auto_template_logic; |
45 | 47 | } |
46 | 48 | |
47 | - public function connect() { |
|
49 | + public function connect() |
|
50 | + { |
|
48 | 51 | $this->conn = mysqli_connect($this->host, $this->user, $this->password); |
49 | 52 | mysqli_select_db($this->conn, $this->dbname); |
50 | - if (function_exists('mysqli_set_charset')) mysqli_set_charset($this->conn, $this->connection_charset); |
|
53 | + if (function_exists('mysqli_set_charset')) { |
|
54 | + mysqli_set_charset($this->conn, $this->connection_charset); |
|
55 | + } |
|
51 | 56 | |
52 | 57 | $this->dbVersion = 3.23; // assume version 3.23 |
53 | 58 | if(function_exists("mysqli_get_server_info")) { |
@@ -59,7 +64,8 @@ discard block |
||
59 | 64 | mysqli_query($this->conn,"{$this->connection_method} {$this->connection_charset}"); |
60 | 65 | } |
61 | 66 | |
62 | - public function process($filename) { |
|
67 | + public function process($filename) |
|
68 | + { |
|
63 | 69 | global $custom_placeholders; |
64 | 70 | |
65 | 71 | // check to make sure file exists |
@@ -114,7 +120,9 @@ discard block |
||
114 | 120 | foreach($sql_array as $sql_entry) { |
115 | 121 | $sql_do = trim($sql_entry, "\r\n; "); |
116 | 122 | |
117 | - if (preg_match('/^\#/', $sql_do)) continue; |
|
123 | + if (preg_match('/^\#/', $sql_do)) { |
|
124 | + continue; |
|
125 | + } |
|
118 | 126 | |
119 | 127 | // strip out comments and \n for mysql 3.x |
120 | 128 | if ($this->dbVersion <4.0) { |
@@ -125,11 +133,15 @@ discard block |
||
125 | 133 | |
126 | 134 | |
127 | 135 | $num = $num + 1; |
128 | - if ($sql_do) mysqli_query($this->conn, $sql_do); |
|
136 | + if ($sql_do) { |
|
137 | + mysqli_query($this->conn, $sql_do); |
|
138 | + } |
|
129 | 139 | if(mysqli_error($this->conn)) { |
130 | 140 | // Ignore duplicate and drop errors - Raymond |
131 | - if ($this->ignoreDuplicateErrors){ |
|
132 | - if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) continue; |
|
141 | + if ($this->ignoreDuplicateErrors) { |
|
142 | + if (mysqli_errno($this->conn) == 1060 || mysqli_errno($this->conn) == 1061 || mysqli_errno($this->conn) == 1062 ||mysqli_errno($this->conn) == 1091) { |
|
143 | + continue; |
|
144 | + } |
|
133 | 145 | } |
134 | 146 | // End Ignore duplicate |
135 | 147 | $this->mysqlErrors[] = array("error" => mysqli_error($this->conn), "sql" => $sql_do); |
@@ -138,7 +150,8 @@ discard block |
||
138 | 150 | } |
139 | 151 | } |
140 | 152 | |
141 | - public function close() { |
|
153 | + public function close() |
|
154 | + { |
|
142 | 155 | mysqli_close($this->conn); |
143 | 156 | } |
144 | 157 | } |
@@ -5,7 +5,9 @@ |
||
5 | 5 | * Time: 10:00 |
6 | 6 | */ |
7 | 7 | |
8 | -if (isset($this->filter) && is_object($this->filter)) return true; |
|
8 | +if (isset($this->filter) && is_object($this->filter)) { |
|
9 | + return true; |
|
10 | +} |
|
9 | 11 | |
10 | 12 | include_once(MODX_MANAGER_PATH.'includes/extenders/modifiers.class.inc.php'); |
11 | 13 | $this->filter = new MODIFIERS; |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | -$installMode = isset($_POST['installmode']) ? (int)$_POST['installmode'] : 0; |
|
2 | +$installMode = isset($_POST['installmode']) ? (int) $_POST['installmode'] : 0; |
|
3 | 3 | |
4 | 4 | // Determine upgradeability |
5 | -$upgradeable= 0; |
|
5 | +$upgradeable = 0; |
|
6 | 6 | if ($installMode === 0) { |
7 | - $database_name= ''; |
|
8 | - $database_server= 'localhost'; |
|
7 | + $database_name = ''; |
|
8 | + $database_server = 'localhost'; |
|
9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
10 | 10 | } else { |
11 | 11 | $database_name = ''; |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | if ($dbase) { |
18 | 18 | $database_name = trim($dbase, '`'); |
19 | 19 | if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
20 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
21 | + elseif (!mysqli_select_db($conn, trim($dbase, '`'))) |
|
22 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode'] == 'new') ? 0 : 2; |
|
23 | 23 | else |
24 | 24 | $upgradeable = 1; |
25 | 25 | } |
26 | - else $upgradable= 2; |
|
26 | + else $upgradable = 2; |
|
27 | 27 | } |
28 | 28 | } |
29 | 29 | |
@@ -49,28 +49,28 @@ discard block |
||
49 | 49 | $database_connection_method = 'SET CHARACTER SET'; |
50 | 50 | } |
51 | 51 | |
52 | -$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name']: $database_name; |
|
53 | -$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix']: $table_prefix; |
|
52 | +$ph['database_name'] = isset($_POST['database_name']) ? $_POST['database_name'] : $database_name; |
|
53 | +$ph['tableprefix'] = isset($_POST['tableprefix']) ? $_POST['tableprefix'] : $table_prefix; |
|
54 | 54 | $ph['selected_set_character_set'] = isset($database_connection_method) && $database_connection_method == 'SET CHARACTER SET' ? 'selected' : ''; |
55 | 55 | $ph['selected_set_names'] = isset($database_connection_method) && $database_connection_method == 'SET NAMES' ? 'selected' : ''; |
56 | 56 | $ph['show#connection_method'] = (($installMode == 0) || ($installMode == 2)) ? 'block' : 'none'; |
57 | -$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation']: $database_collation; |
|
58 | -$ph['show#AUH'] = ($installMode == 0) ? 'block':'none'; |
|
59 | -$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin']:'admin'; |
|
60 | -$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail']:""; |
|
61 | -$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword']:""; |
|
62 | -$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm']:""; |
|
57 | +$ph['database_collation'] = isset($_POST['database_collation']) ? $_POST['database_collation'] : $database_collation; |
|
58 | +$ph['show#AUH'] = ($installMode == 0) ? 'block' : 'none'; |
|
59 | +$ph['cmsadmin'] = isset($_POST['cmsadmin']) ? $_POST['cmsadmin'] : 'admin'; |
|
60 | +$ph['cmsadminemail'] = isset($_POST['cmsadminemail']) ? $_POST['cmsadminemail'] : ""; |
|
61 | +$ph['cmspassword'] = isset($_POST['cmspassword']) ? $_POST['cmspassword'] : ""; |
|
62 | +$ph['cmspasswordconfirm'] = isset($_POST['cmspasswordconfirm']) ? $_POST['cmspasswordconfirm'] : ""; |
|
63 | 63 | $ph['managerLangs'] = getLangs($install_language); |
64 | 64 | $ph['install_language'] = $install_language; |
65 | 65 | $ph['installMode'] = $installMode; |
66 | -$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked':""; |
|
66 | +$ph['checkedChkagree'] = isset($_POST['chkagree']) ? 'checked' : ""; |
|
67 | 67 | $ph['database_connection_method'] = isset($database_connection_method) ? $database_connection_method : ''; |
68 | -$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost']: $database_server; |
|
69 | -$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname']: ''; |
|
70 | -$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword']: ""; |
|
68 | +$ph['databasehost'] = isset($_POST['databasehost']) ? $_POST['databasehost'] : $database_server; |
|
69 | +$ph['databaseloginname'] = isset($_SESSION['databaseloginname']) ? $_SESSION['databaseloginname'] : ''; |
|
70 | +$ph['databaseloginpassword'] = isset($_SESSION['databaseloginpassword']) ? $_SESSION['databaseloginpassword'] : ""; |
|
71 | 71 | $ph['MGR_DIR'] = MGR_DIR; |
72 | 72 | |
73 | 73 | $content = file_get_contents('./actions/tpl_connection.html'); |
74 | -$content = parse($content, $_lang, '[%','%]'); |
|
74 | +$content = parse($content, $_lang, '[%', '%]'); |
|
75 | 75 | $content = parse($content, $ph); |
76 | 76 | echo $content; |
@@ -9,21 +9,24 @@ |
||
9 | 9 | $table_prefix = base_convert(rand(10, 20), 10, 36).substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'), rand(0, 33), 3).'_'; |
10 | 10 | } else { |
11 | 11 | $database_name = ''; |
12 | - if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) $upgradeable = 0; |
|
13 | - else { |
|
12 | + if (!is_file($base_path.MGR_DIR.'/includes/config.inc.php')) { |
|
13 | + $upgradeable = 0; |
|
14 | + } else { |
|
14 | 15 | // Include the file so we can test its validity |
15 | 16 | include($base_path.MGR_DIR.'/includes/config.inc.php'); |
16 | 17 | // We need to have all connection settings - but prefix may be empty so we have to ignore it |
17 | 18 | if ($dbase) { |
18 | 19 | $database_name = trim($dbase, '`'); |
19 | - if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) |
|
20 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
21 | - elseif (! mysqli_select_db($conn, trim($dbase, '`'))) |
|
22 | - $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
23 | - else |
|
24 | - $upgradeable = 1; |
|
20 | + if (!$conn = mysqli_connect($database_server, $database_user, $database_password)) { |
|
21 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
22 | + } elseif (! mysqli_select_db($conn, trim($dbase, '`'))) { |
|
23 | + $upgradeable = (isset($_POST['installmode']) && $_POST['installmode']=='new') ? 0 : 2; |
|
24 | + } else { |
|
25 | + $upgradeable = 1; |
|
26 | + } |
|
27 | + } else { |
|
28 | + $upgradable= 2; |
|
25 | 29 | } |
26 | - else $upgradable= 2; |
|
27 | 30 | } |
28 | 31 | } |
29 | 32 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | $modx->getSettings(); |
6 | 6 | $modx->invokeEvent('OnWebPageInit'); |
7 | 7 | |
8 | -$vword = new VeriWord(148,60); |
|
8 | +$vword = new VeriWord(148, 60); |
|
9 | 9 | $vword->output_image(); |
10 | 10 | $vword->destroy_image(); |
11 | 11 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | ## see sample.php for test and usage |
42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
43 | 43 | #### |
44 | -class VeriWord { |
|
44 | +class VeriWord{ |
|
45 | 45 | |
46 | 46 | /* path to font directory*/ |
47 | 47 | public $dir_font = "ttf/"; |
@@ -51,44 +51,44 @@ discard block |
||
51 | 51 | public $im_width = 0; |
52 | 52 | public $im_height = 0; |
53 | 53 | |
54 | - public function __construct($w=200, $h=80) { |
|
54 | + public function __construct($w = 200, $h = 80){ |
|
55 | 55 | /* create session to set word for verification */ |
56 | 56 | $this->set_veriword(); |
57 | - $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
|
57 | + $this->dir_font = dirname(__FILE__).'/'.$this->dir_font; |
|
58 | 58 | $this->im_width = $w; |
59 | 59 | $this->im_height = $h; |
60 | 60 | } |
61 | 61 | |
62 | - public function set_veriword() { |
|
62 | + public function set_veriword(){ |
|
63 | 63 | /* create session variable for verification, |
64 | 64 | you may change the session variable name */ |
65 | 65 | $this->word = $this->pick_word(); |
66 | 66 | $_SESSION['veriword'] = $this->word; |
67 | 67 | } |
68 | 68 | |
69 | - public function output_image() { |
|
69 | + public function output_image(){ |
|
70 | 70 | /* output the image as jpeg */ |
71 | 71 | $this->draw_image(); |
72 | 72 | header("Content-type: image/jpeg"); |
73 | 73 | imagejpeg($this->im); |
74 | 74 | } |
75 | 75 | |
76 | - public function pick_word() { |
|
76 | + public function pick_word(){ |
|
77 | 77 | global $modx; |
78 | 78 | // set default words |
79 | - $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
79 | + $words = "MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
|
80 | 80 | $words = $modx->config['captcha_words'] ? $modx->config['captcha_words'] : $words; |
81 | 81 | $arr_words = array_filter(array_map('trim', explode(',', $words))); |
82 | 82 | |
83 | 83 | /* pick one randomly for text verification */ |
84 | - return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
|
84 | + return (string) $arr_words[array_rand($arr_words)].rand(10, 999); |
|
85 | 85 | } |
86 | 86 | |
87 | - public function draw_text() { |
|
87 | + public function draw_text(){ |
|
88 | 88 | $dir = dir($this->dir_font); |
89 | 89 | $fontstmp = array(); |
90 | 90 | while (false !== ($file = $dir->read())) { |
91 | - if(substr($file, -4) == '.ttf') { |
|
91 | + if (substr($file, -4) == '.ttf') { |
|
92 | 92 | $fontstmp[] = $this->dir_font.$file; |
93 | 93 | } |
94 | 94 | } |
@@ -96,35 +96,35 @@ discard block |
||
96 | 96 | $text_font = (string) $fontstmp[array_rand($fontstmp)]; |
97 | 97 | |
98 | 98 | /* angle for text inclination */ |
99 | - $text_angle = rand(-9,9); |
|
99 | + $text_angle = rand(-9, 9); |
|
100 | 100 | /* initial text size */ |
101 | 101 | $text_size = 30; |
102 | 102 | /* calculate text width and height */ |
103 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
104 | - $text_width = $box[2]-$box[0]; //text width |
|
105 | - $text_height= $box[5]-$box[3]; //text height |
|
103 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
104 | + $text_width = $box[2] - $box[0]; //text width |
|
105 | + $text_height = $box[5] - $box[3]; //text height |
|
106 | 106 | |
107 | 107 | /* adjust text size */ |
108 | - $text_size = round((20 * $this->im_width)/$text_width); |
|
108 | + $text_size = round((20 * $this->im_width) / $text_width); |
|
109 | 109 | |
110 | 110 | /* recalculate text width and height */ |
111 | - $box = imagettfbbox ( $text_size, $text_angle, $text_font, $this->word); |
|
112 | - $text_width = $box[2]-$box[0]; //text width |
|
113 | - $text_height= $box[5]-$box[3]; //text height |
|
111 | + $box = imagettfbbox($text_size, $text_angle, $text_font, $this->word); |
|
112 | + $text_width = $box[2] - $box[0]; //text width |
|
113 | + $text_height = $box[5] - $box[3]; //text height |
|
114 | 114 | |
115 | 115 | /* calculate center position of text */ |
116 | - $text_x = ($this->im_width - $text_width)/2; |
|
117 | - $text_y = ($this->im_height - $text_height)/2; |
|
116 | + $text_x = ($this->im_width - $text_width) / 2; |
|
117 | + $text_y = ($this->im_height - $text_height) / 2; |
|
118 | 118 | |
119 | 119 | /* create canvas for text drawing */ |
120 | - $im_text = imagecreate ($this->im_width, $this->im_height); |
|
121 | - $bg_color = imagecolorallocate ($im_text, 255, 255, 255); |
|
120 | + $im_text = imagecreate($this->im_width, $this->im_height); |
|
121 | + $bg_color = imagecolorallocate($im_text, 255, 255, 255); |
|
122 | 122 | |
123 | 123 | /* pick color for text */ |
124 | - $text_color = imagecolorallocate ($im_text, 0, 51, 153); |
|
124 | + $text_color = imagecolorallocate($im_text, 0, 51, 153); |
|
125 | 125 | |
126 | 126 | /* draw text into canvas */ |
127 | - imagettftext ( $im_text, |
|
127 | + imagettftext($im_text, |
|
128 | 128 | $text_size, |
129 | 129 | $text_angle, |
130 | 130 | $text_x, |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | } |
140 | 140 | |
141 | 141 | |
142 | - public function draw_image() { |
|
142 | + public function draw_image(){ |
|
143 | 143 | |
144 | 144 | /* pick one background image randomly from image directory */ |
145 | - $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
|
145 | + $img_file = $this->dir_noise."noise".rand(1, 4).".jpg"; |
|
146 | 146 | |
147 | 147 | /* create "noise" background image from your image stock*/ |
148 | - $noise_img = @imagecreatefromjpeg ($img_file); |
|
148 | + $noise_img = @imagecreatefromjpeg($img_file); |
|
149 | 149 | $noise_width = imagesx($noise_img); |
150 | 150 | $noise_height = imagesy($noise_img); |
151 | 151 | |
152 | 152 | /* resize the background image to fit the size of image output */ |
153 | - $this->im = imagecreatetruecolor($this->im_width,$this->im_height); |
|
154 | - imagecopyresampled ($this->im, |
|
153 | + $this->im = imagecreatetruecolor($this->im_width, $this->im_height); |
|
154 | + imagecopyresampled($this->im, |
|
155 | 155 | $noise_img, |
156 | 156 | 0, 0, 0, 0, |
157 | 157 | $this->im_width, |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | $noise_height); |
161 | 161 | |
162 | 162 | /* put text image into background image */ |
163 | - imagecopymerge ( $this->im, |
|
163 | + imagecopymerge($this->im, |
|
164 | 164 | $this->draw_text(), |
165 | 165 | 0, 0, 0, 0, |
166 | 166 | $this->im_width, |
167 | 167 | $this->im_height, |
168 | - 70 ); |
|
168 | + 70); |
|
169 | 169 | |
170 | 170 | return $this->im; |
171 | 171 | } |
172 | 172 | |
173 | - public function destroy_image() { |
|
173 | + public function destroy_image(){ |
|
174 | 174 | |
175 | 175 | imagedestroy($this->im); |
176 | 176 |
@@ -41,7 +41,8 @@ discard block |
||
41 | 41 | ## see sample.php for test and usage |
42 | 42 | ## sample URL: http://www.program-ruti.org/veriword/ |
43 | 43 | #### |
44 | -class VeriWord { |
|
44 | +class VeriWord |
|
45 | +{ |
|
45 | 46 | |
46 | 47 | /* path to font directory*/ |
47 | 48 | public $dir_font = "ttf/"; |
@@ -51,7 +52,8 @@ discard block |
||
51 | 52 | public $im_width = 0; |
52 | 53 | public $im_height = 0; |
53 | 54 | |
54 | - public function __construct($w=200, $h=80) { |
|
55 | + public function __construct($w=200, $h=80) |
|
56 | + { |
|
55 | 57 | /* create session to set word for verification */ |
56 | 58 | $this->set_veriword(); |
57 | 59 | $this->dir_font = dirname(__FILE__) . '/' . $this->dir_font; |
@@ -59,21 +61,24 @@ discard block |
||
59 | 61 | $this->im_height = $h; |
60 | 62 | } |
61 | 63 | |
62 | - public function set_veriword() { |
|
64 | + public function set_veriword() |
|
65 | + { |
|
63 | 66 | /* create session variable for verification, |
64 | 67 | you may change the session variable name */ |
65 | 68 | $this->word = $this->pick_word(); |
66 | 69 | $_SESSION['veriword'] = $this->word; |
67 | 70 | } |
68 | 71 | |
69 | - public function output_image() { |
|
72 | + public function output_image() |
|
73 | + { |
|
70 | 74 | /* output the image as jpeg */ |
71 | 75 | $this->draw_image(); |
72 | 76 | header("Content-type: image/jpeg"); |
73 | 77 | imagejpeg($this->im); |
74 | 78 | } |
75 | 79 | |
76 | - public function pick_word() { |
|
80 | + public function pick_word() |
|
81 | + { |
|
77 | 82 | global $modx; |
78 | 83 | // set default words |
79 | 84 | $words="MODX,Access,Better,BitCode,Chunk,Cache,Desc,Design,Excell,Enjoy,URLs,TechView,Gerald,Griff,Humphrey,Holiday,Intel,Integration,Joystick,Join(),Oscope,Genetic,Light,Likeness,Marit,Maaike,Niche,Netherlands,Ordinance,Oscillo,Parser,Phusion,Query,Question,Regalia,Righteous,Snippet,Sentinel,Template,Thespian,Unity,Enterprise,Verily,Veri,Website,WideWeb,Yap,Yellow,Zebra,Zygote"; |
@@ -84,7 +89,8 @@ discard block |
||
84 | 89 | return (string) $arr_words[array_rand($arr_words)].rand(10,999); |
85 | 90 | } |
86 | 91 | |
87 | - public function draw_text() { |
|
92 | + public function draw_text() |
|
93 | + { |
|
88 | 94 | $dir = dir($this->dir_font); |
89 | 95 | $fontstmp = array(); |
90 | 96 | while (false !== ($file = $dir->read())) { |
@@ -139,7 +145,8 @@ discard block |
||
139 | 145 | } |
140 | 146 | |
141 | 147 | |
142 | - public function draw_image() { |
|
148 | + public function draw_image() |
|
149 | + { |
|
143 | 150 | |
144 | 151 | /* pick one background image randomly from image directory */ |
145 | 152 | $img_file = $this->dir_noise."noise".rand(1,4).".jpg"; |
@@ -170,7 +177,8 @@ discard block |
||
170 | 177 | return $this->im; |
171 | 178 | } |
172 | 179 | |
173 | - public function destroy_image() { |
|
180 | + public function destroy_image() |
|
181 | + { |
|
174 | 182 | |
175 | 183 | imagedestroy($this->im); |
176 | 184 |