Subversion-Projekte lars-tiefland.ci

Revision

Revision 68 | Revision 2049 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 68 Revision 1257
Zeile 151... Zeile 151...
151
	 * @param	string	$data
151
	 * @param	string	$data
152
	 * @return	string
152
	 * @return	string
153
	 */
153
	 */
154
	function hex2bin($data)
154
	function hex2bin($data)
155
	{
155
	{
156
		if (in_array($type = gettype($data), array('array', 'double', 'object'), TRUE))
156
		if (in_array($type = gettype($data), array('array', 'double', 'object', 'resource'), TRUE))
157
		{
157
		{
158
			if ($type === 'object' && method_exists($data, '__toString'))
158
			if ($type === 'object' && method_exists($data, '__toString'))
159
			{
159
			{
160
				$data = (string) $data;
160
				$data = (string) $data;
161
			}
161
			}
Zeile 178... Zeile 178...
178
		}
178
		}
Zeile 179... Zeile 179...
179
 
179
 
180
		return pack('H*', $data);
180
		return pack('H*', $data);
181
	}
181
	}
182
}
-
 
183
 
-
 
184
// ------------------------------------------------------------------------
-
 
185
 
-
 
186
if (is_php('5.3'))
-
 
187
{
-
 
188
	return;
-
 
189
}
-
 
190
 
-
 
191
// ------------------------------------------------------------------------
-
 
192
 
-
 
193
if ( ! function_exists('array_replace'))
-
 
194
{
-
 
195
	/**
-
 
196
	 * array_replace()
-
 
197
	 *
-
 
198
	 * @link	http://php.net/array_replace
-
 
199
	 * @return	array
-
 
200
	 */
-
 
201
	function array_replace()
-
 
202
	{
-
 
203
		$arrays = func_get_args();
-
 
204
 
-
 
205
		if (($c = count($arrays)) === 0)
-
 
206
		{
-
 
207
			trigger_error('array_replace() expects at least 1 parameter, 0 given', E_USER_WARNING);
-
 
208
			return NULL;
-
 
209
		}
-
 
210
		elseif ($c === 1)
-
 
211
		{
-
 
212
			if ( ! is_array($arrays[0]))
-
 
213
			{
-
 
214
				trigger_error('array_replace(): Argument #1 is not an array', E_USER_WARNING);
-
 
215
				return NULL;
-
 
216
			}
-
 
217
 
-
 
218
			return $arrays[0];
-
 
219
		}
-
 
220
 
-
 
221
		$array = array_shift($arrays);
-
 
222
		$c--;
-
 
223
 
-
 
224
		for ($i = 0; $i < $c; $i++)
-
 
225
		{
-
 
226
			if ( ! is_array($arrays[$i]))
-
 
227
			{
-
 
228
				trigger_error('array_replace(): Argument #'.($i + 2).' is not an array', E_USER_WARNING);
-
 
229
				return NULL;
-
 
230
			}
-
 
231
			elseif (empty($arrays[$i]))
-
 
232
			{
-
 
233
				continue;
-
 
234
			}
-
 
235
 
-
 
236
			foreach (array_keys($arrays[$i]) as $key)
-
 
237
			{
-
 
238
				$array[$key] = $arrays[$i][$key];
-
 
239
			}
-
 
240
		}
-
 
241
 
-
 
242
		return $array;
-
 
243
	}
-
 
244
}
-
 
245
 
-
 
246
// ------------------------------------------------------------------------
-
 
247
 
-
 
248
if ( ! function_exists('array_replace_recursive'))
-
 
249
{
-
 
250
	/**
-
 
251
	 * array_replace_recursive()
-
 
252
	 *
-
 
253
	 * @link	http://php.net/array_replace_recursive
-
 
254
	 * @return	array
-
 
255
	 */
-
 
256
	function array_replace_recursive()
-
 
257
	{
-
 
258
		$arrays = func_get_args();
-
 
259
 
-
 
260
		if (($c = count($arrays)) === 0)
-
 
261
		{
-
 
262
			trigger_error('array_replace_recursive() expects at least 1 parameter, 0 given', E_USER_WARNING);
-
 
263
			return NULL;
-
 
264
		}
-
 
265
		elseif ($c === 1)
-
 
266
		{
-
 
267
			if ( ! is_array($arrays[0]))
-
 
268
			{
-
 
269
				trigger_error('array_replace_recursive(): Argument #1 is not an array', E_USER_WARNING);
-
 
270
				return NULL;
-
 
271
			}
-
 
272
 
-
 
273
			return $arrays[0];
-
 
274
		}
-
 
275
 
-
 
276
		$array = array_shift($arrays);
-
 
277
		$c--;
-
 
278
 
-
 
279
		for ($i = 0; $i < $c; $i++)
-
 
280
		{
-
 
281
			if ( ! is_array($arrays[$i]))
-
 
282
			{
-
 
283
				trigger_error('array_replace_recursive(): Argument #'.($i + 2).' is not an array', E_USER_WARNING);
-
 
284
				return NULL;
-
 
285
			}
-
 
286
			elseif (empty($arrays[$i]))
-
 
287
			{
-
 
288
				continue;
-
 
289
			}
-
 
290
 
-
 
291
			foreach (array_keys($arrays[$i]) as $key)
-
 
292
			{
-
 
293
				$array[$key] = (is_array($arrays[$i][$key]) && isset($array[$key]) && is_array($array[$key]))
-
 
294
					? array_replace_recursive($array[$key], $arrays[$i][$key])
-
 
295
					: $arrays[$i][$key];
-
 
296
			}
-
 
297
		}
-
 
298
 
-
 
299
		return $array;
-
 
300
	}
-
 
301
}
-
 
302
 
-
 
303
// ------------------------------------------------------------------------
-
 
304
 
-
 
305
if ( ! function_exists('quoted_printable_encode'))
-
 
306
{
-
 
307
	/**
-
 
308
	 * quoted_printable_encode()
-
 
309
	 *
-
 
310
	 * @link	http://php.net/quoted_printable_encode
-
 
311
	 * @param	string	$str
-
 
312
	 * @return	string
-
 
313
	 */
-
 
314
	function quoted_printable_encode($str)
-
 
315
	{
-
 
316
		if (strlen($str) === 0)
-
 
317
		{
-
 
318
			return '';
-
 
319
		}
-
 
320
		elseif (in_array($type = gettype($str), array('array', 'object'), TRUE))
-
 
321
		{
-
 
322
			if ($type === 'object' && method_exists($str, '__toString'))
-
 
323
			{
-
 
324
				$str = (string) $str;
-
 
325
			}
-
 
326
			else
-
 
327
			{
-
 
328
				trigger_error('quoted_printable_encode() expects parameter 1 to be string, '.$type.' given', E_USER_WARNING);
-
 
329
				return NULL;
-
 
330
			}
-
 
331
		}
-
 
332
 
-
 
333
		if (function_exists('imap_8bit'))
-
 
334
		{
-
 
335
			return imap_8bit($str);
-
 
336
		}
-
 
337
 
-
 
338
		$i = $lp = 0;
-
 
339
		$output = '';
-
 
340
		$hex = '0123456789ABCDEF';
-
 
341
		$length = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'))
-
 
342
			? mb_strlen($str, '8bit')
-
 
343
			: strlen($str);
-
 
344
 
-
 
345
		while ($length--)
-
 
346
		{
-
 
347
			if ((($c = $str[$i++]) === "\015") && isset($str[$i]) && ($str[$i] === "\012") && $length > 0)
-
 
348
			{
-
 
349
				$output .= "\015".$str[$i++];
-
 
350
				$length--;
-
 
351
				$lp = 0;
-
 
352
				continue;
-
 
353
			}
-
 
354
 
-
 
355
			if (
-
 
356
				ctype_cntrl($c)
-
 
357
				OR (ord($c) === 0x7f)
-
 
358
				OR (ord($c) & 0x80)
-
 
359
				OR ($c === '=')
-
 
360
				OR ($c === ' ' && isset($str[$i]) && $str[$i] === "\015")
-
 
361
			)
-
 
362
			{
-
 
363
				if (
-
 
364
					(($lp += 3) > 75 && ord($c) <= 0x7f)
-
 
365
					OR (ord($c) > 0x7f && ord($c) <= 0xdf && ($lp + 3) > 75)
-
 
366
					OR (ord($c) > 0xdf && ord($c) <= 0xef && ($lp + 6) > 75)
-
 
367
					OR (ord($c) > 0xef && ord($c) <= 0xf4 && ($lp + 9) > 75)
-
 
368
				)
-
 
369
				{
-
 
370
					$output .= "=\015\012";
-
 
371
					$lp = 3;
-
 
372
				}
-
 
373
 
-
 
374
				$output .= '='.$hex[ord($c) >> 4].$hex[ord($c) & 0xf];
-
 
375
				continue;
-
 
376
			}
-
 
377
 
-
 
378
			if ((++$lp) > 75)
-
 
379
			{
-
 
380
				$output .= "=\015\012";
-
 
381
				$lp = 1;
-
 
382
			}
-
 
383
 
-
 
384
			$output .= $c;
-
 
385
		}
-
 
386
 
-
 
387
		return $output;
-
 
388
	}
-