本文整理汇总了PHP中pts_strings::keep_in_string方法的典型用法代码示例。如果您正苦于以下问题:PHP pts_strings::keep_in_string方法的具体用法?PHP pts_strings::keep_in_string怎么用?PHP pts_strings::keep_in_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pts_strings
的用法示例。
在下文中一共展示了pts_strings::keep_in_string方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean_save_name_string
public function clean_save_name_string($input)
{
$input = strtolower($input);
$input = pts_strings::remove_redundant(pts_strings::keep_in_string(str_replace(' ', '-', trim($input)), pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH), '-');
if (strlen($input) > 126) {
$input = substr($input, 0, 126);
}
return $input;
}
示例2: clean_save_name
public static function clean_save_name($input, $is_new_save = true)
{
$input = pts_client::swap_variables($input, array('pts_client', 'user_run_save_variables'));
$input = pts_strings::remove_redundant(pts_strings::keep_in_string(str_replace(' ', '-', trim($input)), pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH), '-');
if ($is_new_save) {
$input = strtolower($input);
}
if (strlen($input) > 126) {
$input = substr($input, 0, 126);
}
return $input;
}
示例3: sw_os_version
public static function sw_os_version()
{
// Returns OS version
if (phodevi::is_macosx()) {
$os = phodevi_osx_parser::read_osx_system_profiler('SPSoftwareDataType', 'SystemVersion');
$start_pos = strpos($os, '.');
$end_pos = strrpos($os, '.');
$start_pos = strrpos(substr($os, 0, $start_pos), ' ');
$end_pos = strpos($os, ' ', $end_pos);
$os_version = substr($os, $start_pos + 1, $end_pos - $start_pos);
} else {
if (phodevi::is_linux()) {
$os_version = phodevi_linux_parser::read_lsb('Release');
if ($os_version == null && is_readable('/etc/os-release')) {
$os_release = parse_ini_file('/etc/os-release');
if (isset($os_release['VERSION_ID']) && !empty($os_release['VERSION_ID'])) {
$os_version = $os_release['VERSION_ID'];
} else {
if (isset($os_release['VERSION']) && !empty($os_release['VERSION'])) {
$os_version = $os_release['VERSION'];
}
}
$os_version = pts_strings::keep_in_string($os_version, pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE);
}
} else {
$os_version = php_uname('r');
}
}
return $os_version;
}
示例4: pci_devices
public static function pci_devices()
{
$pci_devices = array();
if (phodevi::is_linux() && isset(phodevi::$vfs->lspci)) {
$lspci = phodevi::$vfs->lspci;
$lspci = explode("\n\n", $lspci);
foreach ($lspci as $o => &$lspci_section) {
$lspci_section = explode("\n", $lspci_section);
$formatted_section = array();
foreach ($lspci_section as $i => &$line) {
$line = explode(':', $line);
if (count($line) == 2 && in_array($line[0], array('Class', 'Vendor', 'Device', 'Driver', 'Rev', 'Module'))) {
$line[1] = trim($line[1]);
if (($c = strrpos($line[1], ' [')) !== false) {
$id = substr($line[1], $c + 2);
$id = '0x' . substr($id, 0, strpos($id, ']'));
switch ($line[0]) {
case 'Vendor':
$formatted_section['VendorID'] = $id;
break;
case 'Device':
$formatted_section['DeviceID'] = $id;
break;
}
$line[1] = substr($line[1], 0, $c);
}
if ($line[0] == 'Class') {
switch ($line[1]) {
case 'Ethernet controller':
case 'Network controller':
$line[1] = 'Network';
break;
case 'VGA compatible controller':
$line[1] = 'GPU';
break;
case 'Audio device':
case 'Multimedia audio controller':
$line[1] = 'Audio';
break;
// case 'RAM memory':
// case 'Host bridge':
// $line[1] = 'Chipset';
// break;
// case 'RAM memory':
// case 'Host bridge':
// $line[1] = 'Chipset';
// break;
default:
$line[1] = null;
break;
}
} else {
if ($line[0] == 'Device' || $line[0] == 'Vendor') {
$line[1] = pts_strings::trim_search_query(pts_strings::strip_string($line[1]));
$line[1] = pts_strings::keep_in_string($line[1], pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_SPACE | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COLON | pts_strings::CHAR_COMMA);
}
}
$formatted_section[$line[0]] = $line[1];
}
}
if (count($formatted_section) > 0 && $formatted_section['Class'] != null) {
array_push($pci_devices, $formatted_section);
}
}
}
return $pci_devices;
}
示例5: render_page_process
public static function render_page_process($PATH)
{
echo phoromatic_webui_header_logged_in();
$main = null;
if (!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['system_title']) && !empty($_POST['system_title']) && isset($_POST['system_description']) && isset($_POST['system_state'])) {
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET Title = :title, Description = :description, State = :state, CurrentTask = \'Awaiting Task\', BlockPowerOffs = :block_power_offs WHERE AccountID = :account_id AND SystemID = :system_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$stmt->bindValue(':title', $_POST['system_title']);
$stmt->bindValue(':description', $_POST['system_description']);
$stmt->bindValue(':state', $_POST['system_state']);
$stmt->bindValue(':block_power_offs', $_POST['block_power_offs']);
$stmt->execute();
}
if (!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['maintenance_mode'])) {
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET MaintenanceMode = :maintenance_mode WHERE AccountID = :account_id AND SystemID = :system_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$stmt->bindValue(':maintenance_mode', $_POST['maintenance_mode']);
$stmt->execute();
}
if (!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['tick_thread_reboot'])) {
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET TickThreadEvent = :event WHERE AccountID = :account_id AND SystemID = :system_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$stmt->bindValue(':event', time() . ':reboot');
$stmt->execute();
}
if (!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['tick_thread_halt'])) {
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET TickThreadEvent = :event WHERE AccountID = :account_id AND SystemID = :system_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$stmt->bindValue(':event', time() . ':halt-testing');
$stmt->execute();
}
if (!PHOROMATIC_USER_IS_VIEWER && !empty($PATH[0]) && isset($_POST['system_var_names']) && isset($_POST['system_var_values'])) {
$vars = array();
foreach ($_POST['system_var_names'] as $i => $name) {
if (isset($_POST['system_var_values'][$i])) {
$name = pts_strings::keep_in_string(strtoupper($name), pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_UNDERSCORE);
$val = pts_strings::keep_in_string($_POST['system_var_values'][$i], pts_strings::CHAR_LETTER | pts_strings::CHAR_NUMERIC | pts_strings::CHAR_DASH | pts_strings::CHAR_UNDERSCORE | pts_strings::CHAR_COMMA | pts_strings::CHAR_SLASH | pts_strings::CHAR_SPACE | pts_strings::CHAR_DECIMAL | pts_strings::CHAR_PLUS | pts_strings::CHAR_EQUAL);
if ($name != null) {
$vars[$name] = $val;
}
}
}
$var_string = null;
foreach ($vars as $name => $val) {
$var_string .= $name . '=' . $val . ';';
}
$stmt = phoromatic_server::$db->prepare('UPDATE phoromatic_systems SET SystemVariables = :system_variables WHERE AccountID = :account_id AND SystemID = :system_id');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$stmt->bindValue(':system_variables', $var_string);
$stmt->execute();
}
if (!empty($PATH[0])) {
$stmt = phoromatic_server::$db->prepare('SELECT * FROM phoromatic_systems WHERE AccountID = :account_id AND SystemID = :system_id ORDER BY LastCommunication DESC');
$stmt->bindValue(':account_id', $_SESSION['AccountID']);
$stmt->bindValue(':system_id', $PATH[0]);
$result = $stmt->execute();
if (!empty($result)) {
$row = $result->fetchArray();
if (!PHOROMATIC_USER_IS_VIEWER && isset($PATH[1]) && $PATH[1] == 'edit') {
$main = '<h1>' . $row['Title'] . '</h1>';
$main .= '<form name="system_form" id="system_form" action="?systems/' . $PATH[0] . '" method="post" onsubmit="return phoromatic_system_edit(this);">
<p><div style="width: 200px; font-weight: bold; float: left;">System Title:</div> <input type="text" style="width: 400px;" name="system_title" value="' . $row['Title'] . '" /></p>
<p><div style="width: 200px; font-weight: bold; float: left;">System Description:</div> <textarea style="width: 400px;" name="system_description">' . $row['Description'] . '</textarea></p>
<p><div style="width: 200px; font-weight: bold; float: left;">System State:</div><select name="system_state" style="width: 200px;"><option value="-1">Disabled</option><option value="1" selected="selected">Enabled</option></select></p>
<p><div style="width: 200px; font-weight: bold; float: left;">Allow Phoromatic To Power Off System When Testing Complete:</div><select name="block_power_offs" style="width: 200px;"><option value="0">Permitted</option><option value="1">Block Power-Off Signaling For This System</option></select> <sup>Assuming the power-off setting is enabled from the account settings page.</sup></p>
<p><div style="width: 200px; font-weight: bold; float: left;"> </div> <input type="submit" value="Submit" /></p></form>';
} else {
$main = '<h1>' . $row['Title'] . '</h1><p><em>' . ($row['Description'] != null ? $row['Description'] : 'No system description.') . '</em></p>';
if (phoromatic_server::system_check_if_down($_SESSION['AccountID'], $row['SystemID'], $row['LastCommunication'], $row['CurrentTask'])) {
$main .= '<h3 style="text-align: center; color: red;">This system appears to be offline or inactive and there are pending tests scheduled to be run on this system that have yet to be completed. This system has not communicated with the Phoromatic Server in ' . pts_strings::format_time(time() - strtotime($row['LastCommunication']), 'SECONDS', true, 60) . '.</h3>';
}
if (!PHOROMATIC_USER_IS_VIEWER) {
$main .= '<p><a href="?systems/' . $PATH[0] . '/edit">Edit Task & Enable/Disable System</a></p>';
}
}
switch ($row['State']) {
case -1:
$state = 'Disabled';
break;
case 0:
$state = 'Connected; Awaiting Approval';
break;
case 1:
$state = 'Active';
break;
}
$main .= '<hr />';
$info_table = array('Status:' => $row['CurrentTask'], 'Last Communication:' => phoromatic_user_friendly_timedate($row['LastCommunication']), 'Estimated Time Left For Task: ' => phoromatic_compute_estimated_time_remaining_string($row['EstimatedTimeForTask'], $row['LastCommunication']), 'State:' => $state, 'Phoronix Test Suite Client:' => $row['ClientVersion'], 'Initial Creation:' => phoromatic_user_friendly_timedate($row['CreatedOn']), 'System ID:' => $row['SystemID'], 'Last IP:' => $row['LastIP'], 'MAC Address:' => $row['NetworkMAC'], 'Wake-On-LAN Information:' => empty($row['NetworkWakeOnLAN']) ? 'N/A' : $row['NetworkWakeOnLAN'], 'Power-Off Sequence Permitted: ' => $row['BlockPowerOffs'] == 1 ? 'Blocked' : 'Permitted');
$main .= '<h2>System State</h2>' . pts_webui::r2d_array_to_table($info_table, 'auto');
if (!PHOROMATIC_USER_IS_VIEWER) {
if ($row['MaintenanceMode'] == 1) {
$mm_str = 'Disable Maintenance Mode';
$mm_val = 0;
$mm_onclick = 'return true;';
} else {
//.........这里部分代码省略.........
示例6: memory_string
public static function memory_string()
{
$mem_string = null;
$mem_prefix = null;
$mem_size = false;
$mem_speed = false;
$mem_type = false;
$mem_manufacturer = false;
$mem_part = false;
if (phodevi::is_macosx()) {
$mem_size = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Size', true, array('Empty'));
$mem_speed = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Speed');
$mem_type = phodevi_osx_parser::read_osx_system_profiler('SPMemoryDataType', 'Type');
} else {
if (phodevi::is_solaris()) {
$mem_size = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,InstalledSize');
$mem_speed = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,Speed');
$mem_type = phodevi_solaris_parser::read_sun_ddu_dmi_info('MemoryDevice*,MemoryDeviceType');
if (is_array($mem_speed) && count($mem_speed) > 0) {
$mem_speed = array_shift($mem_speed);
}
$mem_speed = str_replace('MHZ', 'MHz', $mem_speed);
} else {
if (phodevi::is_windows()) {
$mem_size = phodevi_windows_parser::read_cpuz('DIMM #', 'Size', true);
foreach ($mem_size as $key => &$individual_size) {
$individual_size = pts_arrays::first_element(explode(' ', $individual_size));
if (!is_numeric($individual_size)) {
unset($mem_size[$key]);
}
}
$mem_type = phodevi_windows_parser::read_cpuz('Memory Type', null);
$mem_speed = intval(phodevi_windows_parser::read_cpuz('Memory Frequency', null)) . 'MHz';
} else {
if (phodevi::is_linux()) {
$mem_size = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Size', false, array('Not Installed', 'No Module Installed', 'Undefined'));
$mem_speed = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Speed', true, array('Unknown', 'Undefined'));
$mem_type = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Type', true, array('Unknown', 'Other', 'Flash', 'Undefined'));
$mem_manufacturer = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Manufacturer', true, array('Unknown', 'Undefined'));
$mem_part = phodevi_linux_parser::read_dmidecode('memory', 'Memory Device', 'Part Number', true, array('Unknown', 'Undefined'));
}
}
}
}
if (is_array($mem_type)) {
$mem_type = array_pop($mem_type);
}
if ($mem_size != false && (!is_array($mem_size) || count($mem_size) != 0)) {
for ($i = 0; $i < count($mem_size); $i++) {
switch (substr($mem_size[$i], -1)) {
case 'K':
// looks like sometimes Solaris now reports flash chip as memory. its string ends with K
unset($mem_size[$i]);
unset($mem_speed[$i]);
unset($mem_type[$i]);
break;
case 'M':
// report megabytes as MB, just not M, as on Solaris
$mem_size[$i] .= 'B';
break;
case 'B':
if (strtolower(substr($mem_size[$i], -2, 1)) == 'k') {
// some hardware on Linux via dmidecode reports flash chips
unset($mem_size[$i]);
//unset($mem_speed[$i]);
//unset($mem_type[$i]);
}
break;
}
}
foreach ($mem_size as $i => $mem_stick) {
if (!is_numeric(substr($mem_stick, 0, 3)) && stripos($mem_stick, 'GB') == false) {
// If the memory size isn't at least three digits (basically 128MB+), chances are something is wrong, i.e. reporting flash chip from dmidecode, so get rid of it.
unset($mem_size[$i]);
}
}
$mem_count = count($mem_size);
if (!empty($mem_type)) {
if (($cut = strpos($mem_type, ' ')) > 0) {
$mem_type = substr($mem_type, 0, $cut);
}
if (!in_array($mem_type, array('Other')) && (pts_strings::keep_in_string($mem_type, pts_strings::CHAR_NUMERIC | pts_strings::CHAR_LETTER) == $mem_type || phodevi::is_windows())) {
$mem_prefix = $mem_type;
}
} else {
$mem_prefix = null;
}
if (!empty($mem_speed)) {
if (($cut = strpos($mem_speed, ' (')) > 0) {
$mem_speed = substr($mem_speed, 0, $cut);
}
if (!empty($mem_prefix)) {
$mem_prefix .= '-';
}
$mem_prefix .= str_replace(' ', null, $mem_speed);
}
// TODO: Allow a combination of both functions below, so like 2 x 2GB + 3 x 1GB DDR2-800
if ($mem_count > 1 && count(array_unique($mem_size)) > 1) {
$mem_string = implode(' + ', $mem_size) . ' ' . $mem_prefix;
} else {
//.........这里部分代码省略.........
示例7: hdd_scheduler
public static function hdd_scheduler()
{
$scheduler = null;
$device = self::proc_mount_options();
$device = basename($device['device']);
if (is_readable('/sys/block/' . ($d = pts_strings::keep_in_string($device, pts_strings::CHAR_LETTER)) . '/queue/scheduler')) {
$scheduler = '/sys/block/' . $d . '/queue/scheduler';
} else {
if (is_link($device = '/dev/disk/by-uuid/' . $device)) {
// Go from the disk UUID to the device
$device = pts_strings::keep_in_string(basename(readlink($device)), pts_strings::CHAR_LETTER);
if (is_readable('/sys/block/' . $device . '/queue/scheduler')) {
$scheduler = '/sys/block/' . $device . '/queue/scheduler';
}
} else {
if (is_readable('/sys/block/sda/queue/scheduler')) {
$scheduler = '/sys/block/sda/queue/scheduler';
}
}
}
if ($scheduler) {
$scheduler = pts_file_io::file_get_contents($scheduler);
if (($s = strpos($scheduler, '[')) !== false && ($e = strpos($scheduler, ']', $s)) !== false) {
$scheduler = strtoupper(substr($scheduler, $s + 1, $e - $s - 1));
}
}
return $scheduler;
}