Subversion Repositories oidplus

Rev

Rev 1109 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1109 Rev 1130
Line 254... Line 254...
254
	file_put_contents($output_dir.'/releases.ser.gz', gzencode(serialize($out)));
254
	file_put_contents($output_dir.'/releases.ser.gz', gzencode(serialize($out)));
255
}
255
}
256
 
256
 
257
# ------------------------------------------------------------------------------------------
257
# ------------------------------------------------------------------------------------------
258
 
258
 
-
 
259
/**
-
 
260
 * @param string $dir_old
-
 
261
 * @param string $dir_new
-
 
262
 * @param string|null $basepath_old
-
 
263
 * @param string|null $basepath_new
-
 
264
 * @return void
-
 
265
 */
259
function getDirContents_del($dir_old, $dir_new, $basepath_old=null, $basepath_new=null) {
266
function getDirContents_del(string $dir_old, string $dir_new, string $basepath_old=null, string $basepath_new=null) {
260
	global $outscript;
267
	global $outscript;
261
 
268
 
262
	if (is_null($basepath_old)) $basepath_old = $dir_old;
269
	if (is_null($basepath_old)) $basepath_old = $dir_old;
263
	$basepath_old = my_realpath($basepath_old) . DIRECTORY_SEPARATOR;
270
	$basepath_old = my_realpath($basepath_old) . DIRECTORY_SEPARATOR;
264
	if ($basepath_old == '/') {
271
	if ($basepath_old == '/') {
Line 303... Line 310...
303
			$outscript .= "\n";
310
			$outscript .= "\n";
304
		}
311
		}
305
	}
312
	}
306
}
313
}
307
 
314
 
-
 
315
/**
-
 
316
 * @param string $dir_old
-
 
317
 * @param string $dir_new
-
 
318
 * @param string|null $basepath_old
-
 
319
 * @param string|null $basepath_new
-
 
320
 * @return void
-
 
321
 * @throws Exception
-
 
322
 */
308
function getDirContents_diff($dir_old, $dir_new, $basepath_old=null, $basepath_new=null) {
323
function getDirContents_diff(string $dir_old, string $dir_new, string $basepath_old=null, string $basepath_new=null) {
309
	global $outscript;
324
	global $outscript;
310
 
325
 
311
	if (is_null($basepath_old)) $basepath_old = $dir_old;
326
	if (is_null($basepath_old)) $basepath_old = $dir_old;
312
	$basepath_old = my_realpath($basepath_old) . DIRECTORY_SEPARATOR;
327
	$basepath_old = my_realpath($basepath_old) . DIRECTORY_SEPARATOR;
313
	if ($basepath_old == '/') {
328
	if ($basepath_old == '/') {
Line 407... Line 422...
407
			getDirContents_diff($path_old, $path_new, $basepath_old, $basepath_new);
422
			getDirContents_diff($path_old, $path_new, $basepath_old, $basepath_new);
408
		}
423
		}
409
	}
424
	}
410
}
425
}
411
 
426
 
-
 
427
/**
-
 
428
 * @param string $dir_old
-
 
429
 * @param string $dir_new
-
 
430
 * @param string|null $basepath_old
-
 
431
 * @param string|null $basepath_new
-
 
432
 * @return void
-
 
433
 * @throws Exception
-
 
434
 */
412
function getDirContents_add($dir_old, $dir_new, $basepath_old=null, $basepath_new=null) {
435
function getDirContents_add(string $dir_old, string $dir_new, string $basepath_old=null, string $basepath_new=null) {
413
	global $outscript;
436
	global $outscript;
414
 
437
 
415
	if (is_null($basepath_new)) $basepath_new = $dir_new;
438
	if (is_null($basepath_new)) $basepath_new = $dir_new;
416
	$basepath_new = my_realpath($basepath_new) . DIRECTORY_SEPARATOR;
439
	$basepath_new = my_realpath($basepath_new) . DIRECTORY_SEPARATOR;
417
	if ($basepath_new == '/') {
440
	if ($basepath_new == '/') {
Line 486... Line 509...
486
			getDirContents_add($path_old, $path_new, $basepath_old, $basepath_new);
509
			getDirContents_add($path_old, $path_new, $basepath_old, $basepath_new);
487
		}
510
		}
488
	}
511
	}
489
}
512
}
490
 
513
 
-
 
514
/**
-
 
515
 * @param string $dir_old
-
 
516
 * @param string $dir_new
-
 
517
 * @return void
-
 
518
 * @throws Exception
-
 
519
 */
491
function getDirContents($dir_old, $dir_new) {
520
function getDirContents(string $dir_old, string $dir_new) {
492
	global $func_idx;
521
	global $func_idx;
493
	$func_idx = 0;
522
	$func_idx = 0;
494
	getDirContents_add($dir_old, $dir_new);
523
	getDirContents_add($dir_old, $dir_new);
495
	getDirContents_diff($dir_old, $dir_new);
524
	getDirContents_diff($dir_old, $dir_new);
496
	getDirContents_del($dir_old, $dir_new);
525
	getDirContents_del($dir_old, $dir_new);
497
}
526
}
498
 
527
 
-
 
528
/**
-
 
529
 * @param int $rev
-
 
530
 * @param string $dir
-
 
531
 * @return void
-
 
532
 */
499
function hotfix_dir($rev, $dir) {
533
function hotfix_dir(int $rev, string $dir) {
500
	if ($rev == 699) {
534
	if ($rev == 699) {
501
		// Fix syntax error that lead to a stalled update!
535
		// Fix syntax error that lead to a stalled update!
502
		$file = $dir.'/plugins/viathinksoft/adminPages/900_software_update/OIDplusPageAdminSoftwareUpdate.class.php';
536
		$file = $dir.'/plugins/viathinksoft/adminPages/900_software_update/OIDplusPageAdminSoftwareUpdate.class.php';
503
		$cont = file_get_contents($file);
537
		$cont = file_get_contents($file);
504
		$cont = str_replace("urlencode('oidplus:system_file_check',OIDplus::getEditionInfo()['downloadpage']))",
538
		$cont = str_replace("urlencode('oidplus:system_file_check',OIDplus::getEditionInfo()['downloadpage']))",
Line 535... Line 569...
535
		$cont = str_replace('echo "OK, password $password\n";', '', $cont);
569
		$cont = str_replace('echo "OK, password $password\n";', '', $cont);
536
		file_put_contents($file, $cont);
570
		file_put_contents($file, $cont);
537
	}
571
	}
538
}
572
}
539
 
573
 
-
 
574
/**
-
 
575
 * @param string $data
-
 
576
 * @param int $width
-
 
577
 * @return string
-
 
578
 */
540
function split_equal_length($data, $width=65) {
579
function split_equal_length(string $data, int $width=65): string {
541
	$res = '';
580
	$res = '';
542
	for ($i=0; $i<strlen($data); $i+=$width) {
581
	for ($i=0; $i<strlen($data); $i+=$width) {
543
		$res .= substr($data, $i, $width)."\n";
582
		$res .= substr($data, $i, $width)."\n";
544
	}
583
	}
545
	return $res;
584
	return $res;
546
}
585
}
547
 
586
 
-
 
587
/**
-
 
588
 * @param string $out_file
-
 
589
 * @param string $in_file
-
 
590
 * @param string $res
-
 
591
 * @param string $line_prefix
-
 
592
 * @param int $width
-
 
593
 * @return void
-
 
594
 * @throws Exception
-
 
595
 */
548
function special_save_file($out_file, $in_file, &$res, $line_prefix, $width=50) {
596
function special_save_file(string $out_file, string $in_file, string &$res, string $line_prefix, int $width=50) {
549
	$handle = @fopen($in_file, "rb");
597
	$handle = @fopen($in_file, "rb");
550
	if (!$handle) {
598
	if (!$handle) {
551
		throw new Exception("Cannot open file $in_file");
599
		throw new Exception("Cannot open file $in_file");
552
	}
600
	}
553
	$res .= $line_prefix."\$fp = fopen('$out_file', 'w');\n";
601
	$res .= $line_prefix."\$fp = fopen('$out_file', 'w');\n";
Line 561... Line 609...
561
 
609
 
562
	$res .= $line_prefix."fclose(\$fp);\n";
610
	$res .= $line_prefix."fclose(\$fp);\n";
563
	fclose($handle);
611
	fclose($handle);
564
}
612
}
565
 
613
 
-
 
614
/**
-
 
615
 * @param string $name
-
 
616
 * @return mixed|string
-
 
617
 */
566
function my_realpath($name) {
618
function my_realpath(string $name) {
567
	$ret = realpath($name);
619
	$ret = realpath($name);
568
	return ($ret === false) ? $name : $ret;
620
	return ($ret === false) ? $name : $ret;
569
}
621
}
570
 
622
 
-
 
623
/**
-
 
624
 * @param string $dir
-
 
625
 * @return array
-
 
626
 */
571
function my_scandir($dir) {
627
function my_scandir(string $dir): array {
572
	$ret = @scandir($dir);
628
	$ret = @scandir($dir);
573
	if ($ret === false) return array();
629
	if ($ret === false) return array();
574
	return $ret;
630
	return $ret;
575
}
631
}