@@ -26,10 +26,10 @@ |
||
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | - * HTML code to display this datepicker |
|
29 | + * HTML code to display this datepicker |
|
30 | 30 | * |
31 | 31 | * @return string |
32 | - */ |
|
32 | + */ |
|
33 | 33 | public function toHtml() |
34 | 34 | { |
35 | 35 | if ($this->_flagFrozen) { |
@@ -7,16 +7,16 @@ |
||
7 | 7 | */ |
8 | 8 | class HTML_QuickForm_Rule_Date extends HTML_QuickForm_Rule |
9 | 9 | { |
10 | - /** |
|
11 | - * Check a date |
|
12 | - * @see HTML_QuickForm_Rule |
|
13 | - * @param string $date example 2014-04-30 |
|
10 | + /** |
|
11 | + * Check a date |
|
12 | + * @see HTML_QuickForm_Rule |
|
13 | + * @param string $date example 2014-04-30 |
|
14 | 14 | * @param array $options |
15 | 15 | * |
16 | - * @return boolean True if date is valid |
|
17 | - */ |
|
18 | - public function validate($date, $options) |
|
19 | - { |
|
16 | + * @return boolean True if date is valid |
|
17 | + */ |
|
18 | + public function validate($date, $options) |
|
19 | + { |
|
20 | 20 | return api_is_valid_date($date, 'Y-m-d'); |
21 | - } |
|
21 | + } |
|
22 | 22 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | */ |
7 | 7 | class HTML_QuickForm_Rule_UsernameAvailable extends HTML_QuickForm_Rule |
8 | 8 | { |
9 | - /** |
|
10 | - * Function to check if a username is available |
|
11 | - * @see HTML_QuickForm_Rule |
|
12 | - * @param string $username Wanted username |
|
13 | - * @param string $current_username |
|
14 | - * @return boolean True if username is available |
|
15 | - */ |
|
16 | - function validate($username, $current_username = null) { |
|
17 | - $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
9 | + /** |
|
10 | + * Function to check if a username is available |
|
11 | + * @see HTML_QuickForm_Rule |
|
12 | + * @param string $username Wanted username |
|
13 | + * @param string $current_username |
|
14 | + * @return boolean True if username is available |
|
15 | + */ |
|
16 | + function validate($username, $current_username = null) { |
|
17 | + $user_table = Database::get_main_table(TABLE_MAIN_USER); |
|
18 | 18 | $username = Database::escape_string($username); |
19 | 19 | $current_username = Database::escape_string($current_username); |
20 | 20 | |
21 | - $sql = "SELECT * FROM $user_table WHERE username = '$username'"; |
|
22 | - if (!is_null($current_username)) { |
|
23 | - $sql .= " AND username != '$current_username'"; |
|
24 | - } |
|
25 | - $res = Database::query($sql); |
|
26 | - $number = Database::num_rows($res); |
|
27 | - return $number == 0; |
|
28 | - } |
|
21 | + $sql = "SELECT * FROM $user_table WHERE username = '$username'"; |
|
22 | + if (!is_null($current_username)) { |
|
23 | + $sql .= " AND username != '$current_username'"; |
|
24 | + } |
|
25 | + $res = Database::query($sql); |
|
26 | + $number = Database::num_rows($res); |
|
27 | + return $number == 0; |
|
28 | + } |
|
29 | 29 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * @return boolean True if the 2 given dates match the operator |
13 | 13 | */ |
14 | 14 | function validate($values, $operator = null) { |
15 | - $datetime1 = api_strtotime($values[0]); |
|
15 | + $datetime1 = api_strtotime($values[0]); |
|
16 | 16 | $datetime2 = api_strtotime($values[1]); |
17 | 17 | |
18 | 18 | if (strpos($operator, 'allow_empty') !== false) { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | return true; |
22 | 22 | } |
23 | 23 | } |
24 | - $result = parent::validate(array($datetime1, $datetime2), $operator); |
|
24 | + $result = parent::validate(array($datetime1, $datetime2), $operator); |
|
25 | 25 | return $result; |
26 | 26 | } |
27 | 27 | } |
@@ -27,10 +27,10 @@ |
||
27 | 27 | */ |
28 | 28 | function validate($value, $options = null) |
29 | 29 | { |
30 | - if(is_array($value)) |
|
31 | - { |
|
32 | - $value = implode(null,$value); |
|
33 | - } |
|
30 | + if(is_array($value)) |
|
31 | + { |
|
32 | + $value = implode(null,$value); |
|
33 | + } |
|
34 | 34 | if ((string)$value == '') { |
35 | 35 | return false; |
36 | 36 | } |
@@ -9,18 +9,18 @@ |
||
9 | 9 | class HTML_QuickForm_Rule_FileName extends HTML_QuickForm_Rule |
10 | 10 | { |
11 | 11 | |
12 | - /** |
|
13 | - * @param $value array Uploaded file info (from $_FILES) |
|
14 | - * @param null $options |
|
15 | - * @return bool |
|
16 | - */ |
|
17 | - public function validate($value, $options = null) |
|
18 | - { |
|
19 | - if ((isset($elementValue['error']) && $elementValue['error'] == 0) || |
|
20 | - (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) { |
|
21 | - return is_uploaded_file($elementValue['tmp_name']); |
|
22 | - } else { |
|
23 | - return false; |
|
24 | - } |
|
25 | - } |
|
12 | + /** |
|
13 | + * @param $value array Uploaded file info (from $_FILES) |
|
14 | + * @param null $options |
|
15 | + * @return bool |
|
16 | + */ |
|
17 | + public function validate($value, $options = null) |
|
18 | + { |
|
19 | + if ((isset($elementValue['error']) && $elementValue['error'] == 0) || |
|
20 | + (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) { |
|
21 | + return is_uploaded_file($elementValue['tmp_name']); |
|
22 | + } else { |
|
23 | + return false; |
|
24 | + } |
|
25 | + } |
|
26 | 26 | } |
@@ -7,22 +7,22 @@ |
||
7 | 7 | */ |
8 | 8 | class HTML_QuickForm_Rule_MaxFileSize extends HTML_QuickForm_Rule |
9 | 9 | { |
10 | - /** |
|
11 | - * @param $value array Uploaded file info (from $_FILES) |
|
12 | - * @param null $options |
|
13 | - * @return bool |
|
14 | - */ |
|
15 | - public function validate($elementValue, $maxSize) |
|
16 | - { |
|
17 | - if (!empty($elementValue['error']) && |
|
18 | - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | - ) { |
|
20 | - return false; |
|
21 | - } |
|
22 | - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | - return true; |
|
24 | - } |
|
10 | + /** |
|
11 | + * @param $value array Uploaded file info (from $_FILES) |
|
12 | + * @param null $options |
|
13 | + * @return bool |
|
14 | + */ |
|
15 | + public function validate($elementValue, $maxSize) |
|
16 | + { |
|
17 | + if (!empty($elementValue['error']) && |
|
18 | + (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error']) |
|
19 | + ) { |
|
20 | + return false; |
|
21 | + } |
|
22 | + if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { |
|
23 | + return true; |
|
24 | + } |
|
25 | 25 | |
26 | - return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | - } |
|
26 | + return ($maxSize >= @filesize($elementValue['tmp_name'])); |
|
27 | + } |
|
28 | 28 | } |
@@ -6,24 +6,24 @@ |
||
6 | 6 | */ |
7 | 7 | class HTML_QuickForm_Compare_Fields extends HTML_QuickForm_Rule_Compare |
8 | 8 | { |
9 | - /** |
|
10 | - * Function to check an array of fields |
|
11 | - * @param array of field names |
|
9 | + /** |
|
10 | + * Function to check an array of fields |
|
11 | + * @param array of field names |
|
12 | 12 | * @param string operator ==, >=, etc |
13 | 13 | * @param string the value to compare |
14 | - * @return boolean True if date is valid |
|
15 | - */ |
|
16 | - function validate($values, $operator_and_max_value) { |
|
14 | + * @return boolean True if date is valid |
|
15 | + */ |
|
16 | + function validate($values, $operator_and_max_value) { |
|
17 | 17 | if (is_array($values) && !empty($values) && !empty($operator_and_max_value)) { |
18 | - $final_value = 0; |
|
19 | - foreach ($values as $value) { |
|
20 | - $final_value += $value; |
|
21 | - } |
|
22 | - $params = explode('@', $operator_and_max_value); |
|
23 | - $operator = $params[0]; |
|
24 | - $max_value = $params[1]; |
|
25 | - return parent::validate(array($final_value, $max_value), $operator); |
|
18 | + $final_value = 0; |
|
19 | + foreach ($values as $value) { |
|
20 | + $final_value += $value; |
|
21 | + } |
|
22 | + $params = explode('@', $operator_and_max_value); |
|
23 | + $operator = $params[0]; |
|
24 | + $max_value = $params[1]; |
|
25 | + return parent::validate(array($final_value, $max_value), $operator); |
|
26 | 26 | } |
27 | 27 | return false; |
28 | - } |
|
28 | + } |
|
29 | 29 | } |
30 | 30 | \ No newline at end of file |
@@ -25,12 +25,12 @@ discard block |
||
25 | 25 | |
26 | 26 | function GetInt4d($data, $pos) |
27 | 27 | { |
28 | - $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); |
|
29 | - if ($value>=4294967294) |
|
30 | - { |
|
31 | - $value=-2; |
|
32 | - } |
|
33 | - return $value; |
|
28 | + $value = ord($data[$pos]) | (ord($data[$pos+1]) << 8) | (ord($data[$pos+2]) << 16) | (ord($data[$pos+3]) << 24); |
|
29 | + if ($value>=4294967294) |
|
30 | + { |
|
31 | + $value=-2; |
|
32 | + } |
|
33 | + return $value; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | |
@@ -45,30 +45,30 @@ discard block |
||
45 | 45 | |
46 | 46 | function read($sFileName){ |
47 | 47 | |
48 | - // check if file exist and is readable (Darko Miljanovic) |
|
49 | - if(!is_readable($sFileName)) { |
|
50 | - $this->error = 1; |
|
51 | - return false; |
|
52 | - } |
|
48 | + // check if file exist and is readable (Darko Miljanovic) |
|
49 | + if(!is_readable($sFileName)) { |
|
50 | + $this->error = 1; |
|
51 | + return false; |
|
52 | + } |
|
53 | 53 | |
54 | - $this->data = @file_get_contents($sFileName); |
|
55 | - if (!$this->data) { |
|
56 | - $this->error = 1; |
|
57 | - return false; |
|
58 | - } |
|
59 | - //echo IDENTIFIER_OLE; |
|
60 | - //echo 'start'; |
|
61 | - if (substr($this->data, 0, 8) != IDENTIFIER_OLE) { |
|
62 | - $this->error = 1; |
|
63 | - return false; |
|
64 | - } |
|
54 | + $this->data = @file_get_contents($sFileName); |
|
55 | + if (!$this->data) { |
|
56 | + $this->error = 1; |
|
57 | + return false; |
|
58 | + } |
|
59 | + //echo IDENTIFIER_OLE; |
|
60 | + //echo 'start'; |
|
61 | + if (substr($this->data, 0, 8) != IDENTIFIER_OLE) { |
|
62 | + $this->error = 1; |
|
63 | + return false; |
|
64 | + } |
|
65 | 65 | $this->numBigBlockDepotBlocks = GetInt4d($this->data, NUM_BIG_BLOCK_DEPOT_BLOCKS_POS); |
66 | 66 | $this->sbdStartBlock = GetInt4d($this->data, SMALL_BLOCK_DEPOT_BLOCK_POS); |
67 | 67 | $this->rootStartBlock = GetInt4d($this->data, ROOT_START_BLOCK_POS); |
68 | 68 | $this->extensionBlock = GetInt4d($this->data, EXTENSION_BLOCK_POS); |
69 | 69 | $this->numExtensionBlocks = GetInt4d($this->data, NUM_EXTENSION_BLOCK_POS); |
70 | 70 | |
71 | - /* |
|
71 | + /* |
|
72 | 72 | echo $this->numBigBlockDepotBlocks." "; |
73 | 73 | echo $this->sbdStartBlock." "; |
74 | 74 | echo $this->rootStartBlock." "; |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | //echo "sbdStartBlock = $this->sbdStartBlock\n"; |
79 | 79 | $bigBlockDepotBlocks = array(); |
80 | 80 | $pos = BIG_BLOCK_DEPOT_BLOCKS_POS; |
81 | - // echo "pos = $pos"; |
|
82 | - $bbdBlocks = $this->numBigBlockDepotBlocks; |
|
81 | + // echo "pos = $pos"; |
|
82 | + $bbdBlocks = $this->numBigBlockDepotBlocks; |
|
83 | 83 | |
84 | 84 | if ($this->numExtensionBlocks != 0) { |
85 | 85 | $bbdBlocks = (BIG_BLOCK_SIZE - BIG_BLOCK_DEPOT_BLOCKS_POS)/4; |
86 | 86 | } |
87 | 87 | |
88 | 88 | for ($i = 0; $i < $bbdBlocks; $i++) { |
89 | - $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos); |
|
90 | - $pos += 4; |
|
89 | + $bigBlockDepotBlocks[$i] = GetInt4d($this->data, $pos); |
|
90 | + $pos += 4; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - // var_dump($bigBlockDepotBlocks); |
|
109 | + // var_dump($bigBlockDepotBlocks); |
|
110 | 110 | |
111 | 111 | // readBigBlockDepot |
112 | 112 | $pos = 0; |
@@ -123,26 +123,26 @@ discard block |
||
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
126 | - //var_dump($this->bigBlockChain); |
|
126 | + //var_dump($this->bigBlockChain); |
|
127 | 127 | //echo '=====2'; |
128 | 128 | // readSmallBlockDepot(); |
129 | 129 | $pos = 0; |
130 | - $index = 0; |
|
131 | - $sbdBlock = $this->sbdStartBlock; |
|
132 | - $this->smallBlockChain = array(); |
|
130 | + $index = 0; |
|
131 | + $sbdBlock = $this->sbdStartBlock; |
|
132 | + $this->smallBlockChain = array(); |
|
133 | 133 | |
134 | - while ($sbdBlock != -2) { |
|
134 | + while ($sbdBlock != -2) { |
|
135 | 135 | |
136 | - $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE; |
|
136 | + $pos = ($sbdBlock + 1) * BIG_BLOCK_SIZE; |
|
137 | 137 | |
138 | - for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) { |
|
139 | - $this->smallBlockChain[$index] = GetInt4d($this->data, $pos); |
|
140 | - $pos += 4; |
|
141 | - $index++; |
|
142 | - } |
|
138 | + for ($j = 0; $j < BIG_BLOCK_SIZE / 4; $j++) { |
|
139 | + $this->smallBlockChain[$index] = GetInt4d($this->data, $pos); |
|
140 | + $pos += 4; |
|
141 | + $index++; |
|
142 | + } |
|
143 | 143 | |
144 | - $sbdBlock = $this->bigBlockChain[$sbdBlock]; |
|
145 | - } |
|
144 | + $sbdBlock = $this->bigBlockChain[$sbdBlock]; |
|
145 | + } |
|
146 | 146 | |
147 | 147 | |
148 | 148 | // readData(rootStartBlock) |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - function __readData($bl) { |
|
165 | + function __readData($bl) { |
|
166 | 166 | $block = $bl; |
167 | 167 | $pos = 0; |
168 | 168 | $data = ''; |
@@ -171,28 +171,28 @@ discard block |
||
171 | 171 | $pos = ($block + 1) * BIG_BLOCK_SIZE; |
172 | 172 | $data = $data.substr($this->data, $pos, BIG_BLOCK_SIZE); |
173 | 173 | //echo "pos = $pos data=$data\n"; |
174 | - $block = $this->bigBlockChain[$block]; |
|
174 | + $block = $this->bigBlockChain[$block]; |
|
175 | + } |
|
176 | + return $data; |
|
175 | 177 | } |
176 | - return $data; |
|
177 | - } |
|
178 | 178 | |
179 | 179 | function __readPropertySets(){ |
180 | 180 | $offset = 0; |
181 | 181 | //var_dump($this->entry); |
182 | 182 | while ($offset < strlen($this->entry)) { |
183 | - $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE); |
|
183 | + $d = substr($this->entry, $offset, PROPERTY_STORAGE_BLOCK_SIZE); |
|
184 | 184 | |
185 | - $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8); |
|
185 | + $nameSize = ord($d[SIZE_OF_NAME_POS]) | (ord($d[SIZE_OF_NAME_POS+1]) << 8); |
|
186 | 186 | |
187 | - $type = ord($d[TYPE_POS]); |
|
188 | - //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1; |
|
187 | + $type = ord($d[TYPE_POS]); |
|
188 | + //$maxBlock = strlen($d) / BIG_BLOCK_SIZE - 1; |
|
189 | 189 | |
190 | - $startBlock = GetInt4d($d, START_BLOCK_POS); |
|
191 | - $size = GetInt4d($d, SIZE_POS); |
|
190 | + $startBlock = GetInt4d($d, START_BLOCK_POS); |
|
191 | + $size = GetInt4d($d, SIZE_POS); |
|
192 | 192 | |
193 | 193 | $name = ''; |
194 | 194 | for ($i = 0; $i < $nameSize ; $i++) { |
195 | - $name .= $d[$i]; |
|
195 | + $name .= $d[$i]; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $name = str_replace("\x00", "", $name); |
@@ -221,50 +221,50 @@ discard block |
||
221 | 221 | |
222 | 222 | |
223 | 223 | function getWorkBook(){ |
224 | - if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){ |
|
224 | + if ($this->props[$this->wrkbook]['size'] < SMALL_BLOCK_THRESHOLD){ |
|
225 | 225 | // getSmallBlockStream(PropertyStorage ps) |
226 | 226 | |
227 | - $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']); |
|
227 | + $rootdata = $this->__readData($this->props[$this->rootentry]['startBlock']); |
|
228 | 228 | |
229 | - $streamData = ''; |
|
230 | - $block = $this->props[$this->wrkbook]['startBlock']; |
|
231 | - //$count = 0; |
|
232 | - $pos = 0; |
|
233 | - while ($block != -2) { |
|
234 | - $pos = $block * SMALL_BLOCK_SIZE; |
|
235 | - $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE); |
|
229 | + $streamData = ''; |
|
230 | + $block = $this->props[$this->wrkbook]['startBlock']; |
|
231 | + //$count = 0; |
|
232 | + $pos = 0; |
|
233 | + while ($block != -2) { |
|
234 | + $pos = $block * SMALL_BLOCK_SIZE; |
|
235 | + $streamData .= substr($rootdata, $pos, SMALL_BLOCK_SIZE); |
|
236 | 236 | |
237 | - $block = $this->smallBlockChain[$block]; |
|
238 | - } |
|
237 | + $block = $this->smallBlockChain[$block]; |
|
238 | + } |
|
239 | 239 | |
240 | - return $streamData; |
|
240 | + return $streamData; |
|
241 | 241 | |
242 | 242 | |
243 | - }else{ |
|
243 | + }else{ |
|
244 | 244 | |
245 | - $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE; |
|
246 | - if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) { |
|
247 | - $numBlocks++; |
|
248 | - } |
|
245 | + $numBlocks = $this->props[$this->wrkbook]['size'] / BIG_BLOCK_SIZE; |
|
246 | + if ($this->props[$this->wrkbook]['size'] % BIG_BLOCK_SIZE != 0) { |
|
247 | + $numBlocks++; |
|
248 | + } |
|
249 | 249 | |
250 | - if ($numBlocks == 0) return ''; |
|
250 | + if ($numBlocks == 0) return ''; |
|
251 | 251 | |
252 | - //echo "numBlocks = $numBlocks\n"; |
|
253 | - //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE]; |
|
254 | - //print_r($this->wrkbook); |
|
255 | - $streamData = ''; |
|
256 | - $block = $this->props[$this->wrkbook]['startBlock']; |
|
257 | - //$count = 0; |
|
258 | - $pos = 0; |
|
259 | - //echo "block = $block"; |
|
260 | - while ($block != -2) { |
|
261 | - $pos = ($block + 1) * BIG_BLOCK_SIZE; |
|
262 | - $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE); |
|
263 | - $block = $this->bigBlockChain[$block]; |
|
264 | - } |
|
265 | - //echo 'stream'.$streamData; |
|
266 | - return $streamData; |
|
267 | - } |
|
252 | + //echo "numBlocks = $numBlocks\n"; |
|
253 | + //byte[] streamData = new byte[numBlocks * BIG_BLOCK_SIZE]; |
|
254 | + //print_r($this->wrkbook); |
|
255 | + $streamData = ''; |
|
256 | + $block = $this->props[$this->wrkbook]['startBlock']; |
|
257 | + //$count = 0; |
|
258 | + $pos = 0; |
|
259 | + //echo "block = $block"; |
|
260 | + while ($block != -2) { |
|
261 | + $pos = ($block + 1) * BIG_BLOCK_SIZE; |
|
262 | + $streamData .= substr($this->data, $pos, BIG_BLOCK_SIZE); |
|
263 | + $block = $this->bigBlockChain[$block]; |
|
264 | + } |
|
265 | + //echo 'stream'.$streamData; |
|
266 | + return $streamData; |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | } |