|
8 | 8 | $table_name = 'scripts';
|
9 | 9 | $rec = SQLSelectOne("SELECT * FROM $table_name WHERE ID='$id'");
|
10 | 10 |
|
11 |
| -if(defined('SETTINGS_CODEEDITOR_TURNONSETTINGS')) { |
12 |
| - $out['SETTINGS_CODEEDITOR_TURNONSETTINGS'] = SETTINGS_CODEEDITOR_TURNONSETTINGS; |
13 |
| - $out['SETTINGS_CODEEDITOR_UPTOLINE'] = SETTINGS_CODEEDITOR_UPTOLINE; |
14 |
| - $out['SETTINGS_CODEEDITOR_SHOWERROR'] = SETTINGS_CODEEDITOR_SHOWERROR; |
| 11 | +if (defined('SETTINGS_CODEEDITOR_TURNONSETTINGS')) { |
| 12 | + $out['SETTINGS_CODEEDITOR_TURNONSETTINGS'] = SETTINGS_CODEEDITOR_TURNONSETTINGS; |
| 13 | + $out['SETTINGS_CODEEDITOR_UPTOLINE'] = SETTINGS_CODEEDITOR_UPTOLINE; |
| 14 | + $out['SETTINGS_CODEEDITOR_SHOWERROR'] = SETTINGS_CODEEDITOR_SHOWERROR; |
15 | 15 | }
|
16 | 16 | if ($this->mode == 'update') {
|
17 | 17 |
|
|
43 | 43 |
|
44 | 44 | //echo $code;exit;
|
45 | 45 |
|
46 |
| - $old_code=$rec['CODE']; |
| 46 | + $old_code = $rec['CODE']; |
47 | 47 | $rec['CODE'] = $code;
|
48 |
| - |
| 48 | + |
49 | 49 | if ($rec['CODE'] != '') {
|
50 | 50 | //echo $content;
|
51 |
| - |
| 51 | + |
52 | 52 | $errors = php_syntax_error($rec['CODE']);
|
53 | 53 |
|
54 | 54 | if ($errors) {
|
55 |
| - $out['ERR_LINE'] = preg_replace('/[^0-9]/', '', substr(stristr($errors, 'php on line '), 0, 18))-2; |
| 55 | + $out['ERR_LINE'] = preg_replace('/[^0-9]/', '', substr(stristr($errors, 'php on line '), 0, 18)) - 2; |
56 | 56 | $out['ERR_CODE'] = 1;
|
57 |
| - $errorStr = explode('Parse error: ', htmlspecialchars(strip_tags(nl2br($errors)))); |
58 |
| - $errorStr = explode('Errors parsing', $errorStr[1]); |
59 |
| - $errorStr = explode(' in ', $errorStr[0]); |
| 57 | + $errorStr = explode('Parse error: ', htmlspecialchars(strip_tags(nl2br($errors)))); |
| 58 | + $errorStr = explode('Errors parsing', $errorStr[1]); |
| 59 | + $errorStr = explode(' in ', $errorStr[0]); |
60 | 60 | if ($errorStr[0]) {
|
61 | 61 | $out['ERRORS'] = $errorStr[0];
|
62 |
| - $out['ERR_FULL'] = $errorStr[0].' '.$errorStr[1]; |
| 62 | + $out['ERR_FULL'] = $errorStr[0] . ' ' . $errorStr[1]; |
63 | 63 | } else {
|
64 | 64 | $out['ERRORS'] = $errors;
|
65 | 65 | $out['ERR_FULL'] = nl2br($errors);
|
66 | 66 | }
|
67 |
| - $out['ERR_OLD_CODE'] = $old_code; |
| 67 | + $out['ERR_OLD_CODE'] = $old_code; |
68 | 68 | $ok = 0;
|
69 | 69 | }
|
70 | 70 | }
|
71 | 71 |
|
72 | 72 | global $run_periodically;
|
73 | 73 | global $run_days;
|
74 | 74 | global $run_minutes;
|
75 |
| - global $run_hours; |
76 |
| - |
| 75 | + global $run_hours; |
| 76 | + |
77 | 77 | if ($run_periodically && isset($run_days)) {
|
78 | 78 | $rec['RUN_PERIODICALLY'] = (int)$run_periodically;
|
79 | 79 | $rec['RUN_DAYS'] = @implode(',', $run_days);
|
|
85 | 85 | $rec['RUN_PERIODICALLY'] = 0;
|
86 | 86 | $rec['RUN_DAYS'] = false;
|
87 | 87 | $rec['RUN_TIME'] = false;
|
88 |
| - } |
89 |
| - |
| 88 | + } |
| 89 | + |
90 | 90 | //$rec['EXECUTED']='0000-00-00 00:00:00';
|
91 | 91 | unset($rec['EXECUTED']);
|
92 | 92 |
|
93 | 93 | global $auto_link;
|
94 |
| - $rec['AUTO_LINK']=(int)$auto_link; |
| 94 | + $rec['AUTO_LINK'] = (int)$auto_link; |
95 | 95 |
|
96 | 96 | //UPDATING RECORD
|
97 | 97 | if ($ok) {
|
98 | 98 | $linked_object = '';
|
99 | 99 | $linked_property = '';
|
100 | 100 |
|
101 |
| - if (!isset($_REQUEST['auto_link']) || $_REQUEST['auto_link']==1) { |
102 |
| - if (preg_match('/^if(.+?){/is', $rec['CODE'], $m)) { |
103 |
| - $conditions = trim($m[1], '()'); |
104 |
| - if (preg_match('/getglobal\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) { |
105 |
| - $linked_object=$m2[1]; |
106 |
| - $linked_property=$m2[2]; |
107 |
| - } elseif (preg_match('/gg\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) { |
108 |
| - $linked_object=$m2[1]; |
109 |
| - $linked_property=$m2[2]; |
110 |
| - } elseif (preg_match('/timeis/is', $conditions) || |
111 |
| - preg_match('/timebefore/is', $conditions) || |
112 |
| - preg_match('/timeafter/is', $conditions) || |
113 |
| - preg_match('/timebetween/is', $conditions)) { |
114 |
| - $linked_object='ClockChime'; |
115 |
| - $linked_property='time'; |
116 |
| - } |
| 101 | + if (preg_match('/^if(.+?){/is', $rec['CODE'], $m)) { |
| 102 | + $conditions = trim($m[1], '()'); |
| 103 | + if (preg_match('/getglobal\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) { |
| 104 | + $linked_object = $m2[1]; |
| 105 | + $linked_property = $m2[2]; |
| 106 | + } elseif (preg_match('/gg\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) { |
| 107 | + $linked_object = $m2[1]; |
| 108 | + $linked_property = $m2[2]; |
| 109 | + } elseif (preg_match('/timeis/is', $conditions) || |
| 110 | + preg_match('/timebefore/is', $conditions) || |
| 111 | + preg_match('/timeafter/is', $conditions) || |
| 112 | + preg_match('/timebetween/is', $conditions)) { |
| 113 | + $linked_object = 'ClockChime'; |
| 114 | + $linked_property = 'time'; |
117 | 115 | }
|
| 116 | + } |
118 | 117 |
|
119 |
| - if ($linked_object!='' && $linked_property!='') { |
120 |
| - $rec['AUTO_LINK_AVAILABLE']=1; |
121 |
| - $rec['AUTO_LINK']=1; |
122 |
| - } else { |
123 |
| - $rec['AUTO_LINK_AVAILABLE']=0; |
124 |
| - } |
| 118 | + if ($linked_object != '' && $linked_property != '') { |
| 119 | + $rec['AUTO_LINK_AVAILABLE'] = 1; |
125 | 120 | } else {
|
126 |
| - $rec['AUTO_LINK']=0; |
| 121 | + $rec['AUTO_LINK_AVAILABLE'] = 0; |
127 | 122 | }
|
128 | 123 |
|
| 124 | + $rec['AUTO_LINK'] = gr('auto_link', 'int'); |
129 | 125 | $rec['LINKED_OBJECT'] = $linked_object;
|
130 | 126 | $rec['LINKED_PROPERTY'] = $linked_property;
|
131 |
| - if ($linked_object != '' && $linked_property != '') { |
| 127 | + |
| 128 | + if ($rec['AUTO_LINK'] && $rec['LINKED_OBJECT'] != '' && $rec['LINKED_PROPERTY'] != '') { |
132 | 129 | addLinkedProperty($linked_object, $linked_property, $this->name);
|
| 130 | + } else { |
| 131 | + $rec['AUTO_LINK'] = 0; |
| 132 | + removeLinkedPropertyIfNotUsed('scripts', $rec['LINKED_OBJECT'], $rec['LINKED_PROPERTY'], $this->name); |
133 | 133 | }
|
134 | 134 |
|
135 |
| - $rec['UPDATED']=date('Y-m-d H:i:s'); |
| 135 | + $rec['UPDATED'] = date('Y-m-d H:i:s'); |
136 | 136 |
|
137 | 137 | if ($rec['ID']) {
|
138 | 138 | SQLUpdate($table_name, $rec); // update
|
|
144 | 144 |
|
145 | 145 | global $edit_run;
|
146 | 146 | if ($edit_run) {
|
147 |
| - echo '<div style="margin: 30px 0px;border: 1px solid #dddddd;padding: 10px;border-left: 10px solid #4d96d3;resize: vertical;height: 400px;min-height: 100px;overflow: auto;"> |
148 |
| - <h3 style="margin: 0px;border-bottom: 1px solid #dddddd;padding-bottom: 5px;margin-bottom: 10px;">'.LANG_NEWDASH_RESULT.':</h3> |
| 147 | + echo '<div style="margin: 30px 0px;border: 1px solid #dddddd;padding: 10px;border-left: 10px solid #4d96d3;resize: vertical;height: 400px;min-height: 100px;overflow: auto;"> |
| 148 | + <h3 style="margin: 0px;border-bottom: 1px solid #dddddd;padding-bottom: 5px;margin-bottom: 10px;">' . LANG_NEWDASH_RESULT . ':</h3> |
149 | 149 | <pre>';
|
150 |
| - $this->runScript($rec['ID']); |
151 |
| - echo '</pre></div>'; |
152 |
| - |
153 |
| - $rec['EDIT_RUN'] = $edit_run; |
| 150 | + $this->runScript($rec['ID']); |
| 151 | + echo '</pre></div>'; |
| 152 | + |
| 153 | + $rec['EDIT_RUN'] = $edit_run; |
154 | 154 | }
|
155 | 155 |
|
156 | 156 |
|
|
206 | 206 | }
|
207 | 207 |
|
208 | 208 | $run_days = array();
|
209 |
| -if ($rec['RUN_DAYS']!=='') { |
| 209 | +if ($rec['RUN_DAYS'] !== '') { |
210 | 210 | $run_days = explode(',', $rec['RUN_DAYS']);
|
211 | 211 | }
|
212 | 212 |
|
|
0 commit comments