function template_has_absolute_path($template) { $begins_with_directory_separator = is_equal($template[0], DIRECTORY_SEPARATOR); $begins_with_windows_drive_letter = is_equal(substr($template, 1, 2), ':\\'); $begins_with_network_drive = is_equal(substr($template, 0, 2), '\\\\'); return $begins_with_directory_separator or $begins_with_windows_drive_letter or $begins_with_network_drive; }
function array_duples($array) { $drop = array(); $copy = $array; foreach ($array as $key => $values) { foreach ($copy as $ckey => $cvalues) { if ($ckey == $key) { continue; } if (in_array($key, $drop)) { break; } if (is_equal($values, $cvalues)) { echo "################"; echo "{$key} and {$ckey} are equal, {$ckey} will be deleted\n"; foreach ($cvalues as $field => $value) { if (!is_numeric($field)) { echo str_pad($field, 32, ' ', STR_PAD_RIGHT) . ":" . str_pad($value, 64, ' ', STR_PAD_LEFT) . '|' . $values[$field] . "\n"; } } array_push($drop, $ckey); } } } return $drop; }
function time_distance_in_words($from_timestamp, $to_timestamp, $include_seconds = false) { $distance_in_minutes = round(abs($to_timestamp - $from_timestamp) / 60); $distance_in_seconds = round(abs($to_timestamp - $from_timestamp)); if (in_range(0, 1, $distance_in_minutes)) { if ($include_seconds) { if (in_range(0, 4, $distance_in_seconds)) { return 'less than 5 seconds'; } if (in_range(5, 9, $distance_in_seconds)) { return 'less than 10 seconds'; } if (in_range(10, 19, $distance_in_seconds)) { return 'less than 20 seconds'; } if (in_range(20, 39, $distance_in_seconds)) { return 'half a minute'; } if (in_range(40, 59, $distance_in_seconds)) { return 'less than a minute'; } return '1 minute'; } else { return is_equal($distance_in_minutes, 0) ? 'less than a minute' : '1 minute'; } } if (in_range(2, 44, $distance_in_minutes)) { return "{$distance_in_minutes} minutes"; } if (in_range(45, 89, $distance_in_minutes)) { return 'about 1 hour'; } if (in_range(90, 1439, $distance_in_minutes)) { return 'about ' . round($distance_in_minutes / 60.0) . ' hours'; } if (in_range(1440, 2879, $distance_in_minutes)) { return '1 day'; } if (in_range(2880, 43199, $distance_in_minutes)) { return round($distance_in_minutes / 1440) . ' days'; } if (in_range(43200, 86399, $distance_in_minutes)) { return 'about 1 month'; } if (in_range(86400, 525959, $distance_in_minutes)) { return round($distance_in_minutes / 43200) . ' months'; } if (in_range(525960, 1051919, $distance_in_minutes)) { return 'about 1 year'; } return 'over ' . round($distance_in_minutes / 525960) . ' years'; }
function convert_optional_parts_to_regex($pattern) { $optional_parts_pattern = '/\\[([^\\]\\[]*)\\]/'; $replacement = '(\\1)?'; while (true) { $regex_pattern = preg_replace($optional_parts_pattern, $replacement, $pattern); if (!is_equal($regex_pattern, $pattern)) { $pattern = $regex_pattern; } else { break; } } return $pattern; }
function form_validate($form_data, $form_fields) { $form = array(); foreach ($form_fields as $field => $field_info) { $value = form_array_value($field, $form_data); if (!is_equal(false, $value)) { $value = trim($value); $value = form_field_apply_before_filters($value, $field_info); $is_invalid_field = form_validate_field($value, $field_info); $value = form_field_apply_after_filters($value, $field_info); $form['names'][$field] = $field_info['name']; $form['xss-safe'][$field] = htmlentities($value, ENT_QUOTES); if ($is_invalid_field) { $form['errors'][$field] = $is_invalid_field; } else { $form['valid'][$field] = $value; } } } return $form; }
function route_match($routes, $request) { foreach ($routes as $route) { $method_matches = (is_equal($request['method'], $route['method']) or is_equal('', $route['method'])); foreach ($route['paths'] as $path) { if ($path_matches = path_match($path, $request['path'], $matches)) { break; } } if (isset($route['conds']['action']) and isset($request['form']['action'])) { $action_matches = is_equal($route['conds']['action'], valid_action($request['form']['action'])); } elseif (isset($route['conds']['action']) and !isset($request['form']['action'])) { $action_matches = false; } else { $action_matches = true; } if ($method_matches and $path_matches and $action_matches) { //$rpath_matches['0'] should be equal to 'foo' for '/foo/bar' and $rpath_matches['1'] should be 'bar' $route['path_matches'] = $matches; return $route; } } return false; }
/** * Set the target encoding to the output data. * * @param string $charset * @return XMLParser */ public function setTargetEncoding($charset = '') : self { if (empty($charset)) { $this->targetEncoding = self::UTF8; return $this; } if (is_equal($charset, self::ISO88591)) { $this->targetEncoding = self::WINDOWS1252; return $this; } if (!empty($charset)) { $this->targetEncoding = $charset; } return $this; }
<?php //input array $clg1 = array(12, 11, 5, 2, 7, 5, 11); $clg2 = array(5, 11, 5, 7, 11, 2, 11); if (is_equal($clg1, $clg2)) { if (is_negative_value($clg1) && is_negative_value($clg2)) { if (check_array($clg1, $clg2)) { echo "Equal"; } else { echo "Unequal"; } } else { echo "Invalid"; } } else { echo "Unequal"; } //if array are equal in length function is_equal($array1, $array2) { $len1 = count($array1); $len2 = count($array2); if ($len1 == $len2) { return 1; } else { return 0; } } //checking if array has any negative value function is_negative_value($array1)
function gappsconf($req) { /* The following DNS recrods are added: MX 10 ASPMX.L.GOOGLE.COM MX 20 ALT1.ASPMX.L.GOOGLE.COM MX 20 ALT2.ASPMX.L.GOOGLE.COM MX 30 ASPMX2.GOOGLEMAIL.COM MX 30 ASPMX3.GOOGLEMAIL.COM MX 30 ASPMX4.GOOGLEMAIL.COM MX 30 ASPMX5.GOOGLEMAIL.COM calendar CNAME ghs.google.com docs CNAME ghs.google.com mail CNAME ghs.google.com sites CNAME ghs.google.com */ $domain = $req['form']['domain']; $rid = $_SESSION['rid']; $global_salt = $_SESSION['global_salt']; $user_salt = sha1($rid); $key = generate_key($user_salt, $global_salt); $password = symmetric_decrypt($_COOKIE['data'], $key); $auth_params = "auth-userid={$rid}&auth-password={$password}"; $get_orderid_url = "https://test.httpapi.com/api/domains/orderid.json?{$auth_params}&domain-name={$domain}"; $result = file_get_contents($get_orderid_url); if (is_equal(false, $result)) { return array('template' => 'error', 'error_msg' => 'Could not fetch Order ID. Go back and try again.'); } $orderid = $result; $activate_url = "https://test.httpapi.com/api/dns/activate.json?{$auth_params}"; $add_cname_url = "https://test.httpapi.com/api/dns/manage/add-cname-record.json?{$auth_params}&domain-name={$domain}"; $add_mx_url = "https://test.httpapi.com/api/dns/manage/add-mx-record.json?{$auth_params}&domain-name={$domain}"; $requests[] = array("{$activate_url}&order-id={$orderid}", 'Activating DNS'); $requests[] = array("{$add_cname_url}&value=ghs.google.com&host=mail", "Adding CNAME for mail.{$domain}"); $requests[] = array("{$add_cname_url}&value=ghs.google.com&host=calendar", "Adding CNAME for calendar.{$domain}"); $requests[] = array("{$add_cname_url}&value=ghs.google.com&host=docs", "Adding CNAME for docs.{$domain}"); $requests[] = array("{$add_cname_url}&value=ghs.google.com&host=sites", "Adding CNAME for sites.{$domain}"); $requests[] = array("{$add_mx_url}&value=ASPMX.L.GOOGLE.COM&priority=10", "Adding MX: ASPMX.L.GOOGLE.COM"); $requests[] = array("{$add_mx_url}&value=ALT1.ASPMX.L.GOOGLE.COM&priority=20", "Adding MX: ALT1.ASPMX.L.GOOGLE.COM"); $requests[] = array("{$add_mx_url}&value=ALT2.ASPMX.L.GOOGLE.COM&priority=20", "Adding MX: ALT2.ASPMX.L.GOOGLE.COM"); $requests[] = array("{$add_mx_url}&value=ASPMX2.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX2.GOOGLEMAIL.COM"); $requests[] = array("{$add_mx_url}&value=ASPMX3.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX3.GOOGLEMAIL.COM"); $requests[] = array("{$add_mx_url}&value=ASPMX4.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX4.GOOGLEMAIL.COM"); $requests[] = array("{$add_mx_url}&value=ASPMX5.GOOGLEMAIL.COM&priority=30", "Adding MX: ASPMX5.GOOGLEMAIL.COM"); $results = array(); foreach ($requests as $request) { $result = file_get_contents($request[0]); if (is_equal(false, $result)) { return array('template' => 'error', 'error_msg' => "Error while adding {$request[1]}. Go back and try again."); } $results[] = array($request[1], json_decode($result, true)); } return array('results' => $results); }
function _apache_specific_is_rewrite_engine_on($rewrite_engine) { return is_equal('on', strtolower($rewrite_engine)); }
function validate_required($field_value, $is_required) { return $is_required ? !is_equal('', trim($field_value)) : true; }
function uri_path($path_to_index_dot_php) { $base_path = dirname($path_to_index_dot_php); $base_path_equals_directory_separator = (is_equal(strlen($base_path), 1) and is_equal(DIRECTORY_SEPARATOR, $base_path)); return $base_path_equals_directory_separator ? '' : $base_path; }
<div data-role="page" data-theme="b"> <div data-role="header"> <h1>OboxApps β</h1> <?php if (isset($_SESSION['authenticated']) and is_equal($_SESSION['authenticated'], true)) { ?> <a href="<?php echo absolute_uri('/logout'); ?> " data-icon="gear" class="ui-btn-right" data-theme="e" data-ajax="false">Logout</a> <?php } else { ?> <a href="<?php echo absolute_uri('#login'); ?> " data-icon="gear" class="ui-btn-right" data-rel="dialog" data-transition="slidedown">Login</a> <?php } ?> </div> <div data-role="content"> <ul data-role="listview" data-inset="true"> <li data-icon="info" data-theme="d"><a href="#getting-started">Getting Started</a></li> </ul> <ul data-role="listview" data-inset="true"> <li data-role="list-divider">Apps</li> <li><a href="<?php
function glue_response($req, $response) { $template_vars = is_array($response) ? array_merge($req, $response) : array_merge($req, array('content' => $response)); $headers = array_merge(array('content-type' => 'text/html'), response_headers($response)); if (isset($template_vars['template'])) { list($handler, $template) = template_resolver($template_vars['template']); unset($template_vars['template']); //TODO: feels liks a ugly hack to assume func from template but works well for handler-less (template-only) routes if (!isset($template_vars['handler'])) { $template_vars['handler'] = $handler; } if (!isset($template_vars['func'])) { $template_vars['func'] = $template; } if (template_file_exists(handler_template($handler, $template))) { if (isset($template_vars['layout'])) { $layout = $template_vars['layout']; unset($template_vars['layout']); if (is_equal(false, $layout)) { return response_(response_status_code($template_vars), $headers, template_render(handler_template($handler, $template), $template_vars)); } else { list($layout_handler, $layout_template) = template_resolver($layout); return response_(response_status_code($template_vars), $headers, template_compose(handler_template($handler, $template), $template_vars, handler_template($layout_handler, $layout_template), $template_vars)); } } else { return response_(response_status_code($template_vars), $headers, template_compose(handler_template($handler, $template), $template_vars, handler_layout($handler), $template_vars)); } } } return _200_plain(print_r($response, true)); }
<!DOCTYPE html> <html> <head> <title>php</title> </head> <body> <?php function is_equal($value1, $value2) { $output = "{$value1} == {$value2}: "; if ($value2 == $value1) { $output .= "true<br>"; } else { $output .= "false<br>"; } return $output; } echo is_equal(0, "4"); echo is_equal(0, "vc"); echo is_equal(0, true); echo is_equal(0, false); echo is_equal(0, 0); ?> <body> </html>
return $output; } echo is_equal(0, false); echo is_equal(4, true); echo is_equal(0, null); echo is_equal(0, "0"); echo is_equal(0, ""); echo is_equal(0, "a"); echo is_equal("1", "01"); echo is_equal("", null); echo is_equal(3, "3 dogs"); echo is_equal(100, "le2"); echo is_equal(100, 100.0); echo is_equal("abc", true); echo is_equal("123", " 123"); echo is_equal("123", "+0123"); ?> <br> <?php function is_exat($value1, $value2) { $output = "{$value1} === {$value2}: "; if ($value1 === $value2) { $output .= "true <br/>"; } else { $output .= "false <br />"; } return $output; } echo is_exat(0, false);
function valid_body_($body) { return is_equal(false, $body) ? NULL : $body; }
function str_singularize($str) { if (is_equal('s', substr($str, -1))) { return substr($str, 0, -1); } }
function get_all_mno_has_thesamebrand($mybrand_indb) { $c = 0; for ($i = 0; $i < count($mybrand_indb); $i++) { // echo "string"; $usrs = select('fs_member_brand_selected', 4, array('bn', $mybrand_indb[$i][2])); // select_w_2($tableName,$tablen,$where,$oparators){ // $tuser+=count($usrs); // $mnos=arrange_usr($usrs,$tuser,$i); // print_r($usrs); for ($j = 0; $j < count($usrs); $j++) { // print_r($usrs); // echo "<br>"; if (!is_equal($usrs[$j][1], $_SESSION['mno'])) { $mnos[$c] = $usrs[$j][1]; $c++; } } // print_r($mnos); } // echo "<hr> before remove!<br>"; // print_r($mnos); // $mnos_r=remove_duplicate($mnos); // echo "<hr> after remove!<br>"; // print_r($mnos_r); // echo "string"; // echo "<br>"; // echo $usrs[0][0][0]; return remove_duplicate($mnos); }
function exit_with() { $params = func_get_args(); if (is_equal(3, count($params))) { $response = response_($params[0], $params[1], $params[2]); } elseif (is_equal(1, count($params))) { $response = $params[0]; } else { $response = ''; } $response = valid_response($response); $response = prepare_external_response($response); flush_http_status($response['status_code']); flush_headers($response['headers']); echo $response['body']; exit; }
function handler_match_($handler, $req, &$matches = NULL) { $method_matched = (is_equal($req['method'], $handler['method']) or is_equal('*', $handler['method'])); foreach ($handler['paths'] as $path) { if ($path_matched = path_match($path, $req['path'], $matches)) { break; } } $action_cond_failed = (isset($handler['conds']['action']) and (!isset($req['form']['action']) or !is_equal($handler['conds']['action'], strtolower(str_underscorize($req['form']['action']))))); $query_cond_failed = (isset($handler['conds']['query']) and is_equal(true, $handler['conds']['query']) and empty($req['query'])); if ($method_matched and $path_matched and !$action_cond_failed and !$query_cond_failed) { return $handler; } }