You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
665 B
25 lines
665 B
<?php
|
|
|
|
namespace utils;
|
|
|
|
class sed {
|
|
|
|
public static function replace($file, $find, $replace) {
|
|
if (!file_exists($file)) {
|
|
return false;
|
|
}
|
|
$find = str_replace('"', "'", $find);
|
|
$two = getLeft($find, 2);
|
|
if ($two == '-$' || isStringFound($find, '=')) {
|
|
$find = getRight($find, strlen($find) - 2);
|
|
$ds = '';
|
|
} else {
|
|
$ds = '$';
|
|
}
|
|
$replace = str_replace('"', "'", $replace);
|
|
exec(\neato::get_bin . 'sed -i "s@' . $ds . $find . '@' . $replace . '@g" ' . safeCmd($file), $output, $exit_code);
|
|
checkForError($exit_code, "sed: {$file} Unable to find/replace: {$find}");
|
|
return $exit_code;
|
|
}
|
|
|
|
} |