function main($num) { if ($num < 0) { $s = 1; $num = -$num; } else { $s = 0; } $zs = floor($num); $bzs = decbin($zs); $xs = $num - $zs; $res = (double) ($bzs . '.' . tenToBinary($xs, 1)); $teme = ws($res); $e = decbin($teme + 127); if ($teme == 0) { $e = '0' . $e; } $temm = $res / pow(10, $teme); $m = end(explode(".", $temm)); $lenm = strlen($m); if ($lenm < 23) { $m .= addzero(23 - $lenm); } return $s . ' ' . $e . ' ' . $m . ' '; }
} $t = localtime(time() + $days * 24 * 60 * 60, true); $months = array('января', 'февраля', 'марта', 'апреля', 'мая', 'июня', 'июля', 'августа', 'сентября', 'октября', 'ноября', 'декабря'); $anymonth = implode('|', $months); $banners = array(); for ($i = 0, $n = count($result); $i < $n; ++$i) { if ($result[$i]['StatusArchive'] == 'No') { $ad = $result[$i]['Text']; $new_ad = preg_replace('/до (\\d{2})\\.(\\d{2})/u', 'до ' . addzero($t['tm_mday']) . ' ' . $months[$t['tm_mon']], $ad); if ($new_ad != $ad) { if (mb_strlen($new_ad) > 75) { $new_ad = preg_replace('/до (\\d{2})\\.(\\d{2})/u', 'до ' . addzero($t['tm_mday']) . '.' . addzero($t['tm_mon'] + 1), $ad); } } else { $new_ad = preg_replace("/до (\\d{1,2}) ({$anymonth})/u", 'до ' . addzero($t['tm_mday']) . ' ' . $months[$t['tm_mon']], $ad); if (mb_strlen($new_ad) > 75) { $new_ad = preg_replace("/до (\\d{2}) ({$anymonth})/u", 'до ' . addzero($t['tm_mday']) . '.' . addzero($t['tm_mon'] + 1), $ad); } } if ($new_ad != $ad) { $result[$i]['Text'] = $new_ad; $banners[] = $result[$i]; } } else { } } if (count($banners) > 0) { print_r($client->call('CreateOrUpdateBanners', array('params' => $banners))); print $client->getError(); } }
} function addzero($value) { if ($value <= -1000) { return 0; } else { return $value; } } $nodeid = addzero($_POST["nodeid"]); //$rack = quotation($_POST["rack"]); $dateinstalled = quotation($_POST["dateinstalled"]); $supportphone = quotation($_POST["supportphone"]); $comment = quotation($_POST["comment"]); $lastmodifieddate = quotation($_POST["lastmodifieddate"]); $displaycategory = quotation($_POST["displaycategory"]); $latitude = addzero($_POST["latitude"]); $longitude = addzero($_POST["longitude"]); session_start(); require "db_initialize.php"; $query = "UPDATE public.assets\nSET\ndateinstalled={$dateinstalled},\nsupportphone={$supportphone},\ncomment={$comment},\nlastmodifieddate={$lastmodifieddate},\ndisplaycategory={$displaycategory},\nlatitude={$latitude},\nlongitude={$longitude}\nWHERE assets.nodeid={$nodeid};"; $result = pg_query($query) or die('Query failed: ' . pg_last_error()); pg_free_result($result); pg_close($dbconn); echo "Successfully updated!"; echo "<br>\n"; echo "\n<br>\n"; echo "\n<button onclick=closeWin()>Close</button>\n"; echo "\n<script>\nfunction closeWin() {\n window.close();\n}\n</script>\n"; pg_free_result($result); pg_close($dbconn);