Grayda
Members-
Posts
59 -
Joined
-
Last visited
Profile Information
-
Gender
Not Telling
Grayda's Achievements
Member (2/5)
0
Reputation
-
Creating an alert system for rapidly changing data?
Grayda replied to Grayda's topic in Application Design
Actually, it made some sense to me in a way. Having various options for alerting is a good idea (e.g. user can pick to be alerted on Kp = 7, or if some value goes over a threshold. I'm still nutting out some other stuff, so I'll give proper thought to it when I get a moment. And I did think of a "live" service where people would pay a subscription fee that would allow me, or a team of people, to hit a button when an aurora is detected on a webcam and / or "the gauges" look promising, but that's a bit out there, and probably something I'd look at if things took off.. -
Creating an alert system for rapidly changing data?
Grayda replied to Grayda's topic in Application Design
Thanks for the reply. Some super useful info in there, especially about Kp not being an event in itself, but a symptom of an event. I might try Option B and see how it goes for a while. I'm running two separate "channels", a master API, and a beta API that I try out changes before migrating, so there's no harm in me adding in two options and spending a while evaluating both. Cheers! -
I'm writing a PHP-based API around some data that is updated as frequently as once a minute, or as infrequently as once every 15 minutes. I'd like to have a cron job push alerts to end users when certain criteria is met (e.g. data goes above a certain threshold), but because my data changes so rapidly and is prone to wild fluctuations, I'm not entirely sure how to approach this. For reference, users can include, for example, people who have downloaded my Pebble smartwatch app, or my upcoming mobile phone app. The data that I'm most interested in (which, if you're interested, is from the ACE spacecraft, and is used to help people view the northern or southern lights) changes every fifteen minutes, and the Kp index it provides is used as a (arguably) good indicator of how likely you are to see an aurora. Values under 5 are usually of no interest to most, anything above 5 (up to 9) are worth getting an alert about. These values can fluctuate, so if a Kp 5 storm is expected, it can hit 6, then dip to 4, then back to 5 and so forth. This is due to the particles ejected from the sun not being a nice, even "wave". I've personally witnessed nights where Kp goes up, then sits low for a while, so you head home, only to find that 10 minutes later it picked up again. Aaanyway, back to my story, I'd like to find a way to alert users about these values when they're of interest, but without bombarding them with notifications, or missing too many events. Here's the various options I've considered: Send an alert every 15 minutes (too often, too annoying, not 'smart') Send an alert every 15 minutes, but only if the value has increased, then "reset" the check after a period of time (better, but what if it hits 7, then dips to 4 for 45 minutes, then hits 6.99? You'd miss out on an alert!) Find a way to check if the user has dismissed the notification and don't re-send it to them for an hour (not feasible, as Pebble's UX doesn't really allow for that, not to mention iOS doesn't have a way to notify your app when an alert has been dismissed) Some kind of data check, where if a value has remained high for longer than 30 minutes, it's alert-worthy and one gets sent out (but you'd miss out on stuff if the value is high for 29 minutes)And riding on the back of that, if the value remains stable, prime the alert. If it increases after it's primed, send the message. I'm more than happy to do some reading and learning. I just didn't exactly know what to search for, as I'm not dealing with something like storage space (where you can send an email if it hits < 20%, and it's unlikely that the storage will fluctuate between 20% and 21%, causing repeated messages) or rare events like CPU usage that you can alert if it stays high for longer than x many minutes
-
Morning all! I work at school that is "Accessibility" mad. They turn on Sticky Keys, Filter Keys or Toggle Keys and press the buttons to make noise and distract the teacher. I'd like to rain on their parade by disabling it. Nobody in the school uses those three options. What I'd like to know is, can I disable these functions via Group Policy? I'd like to avoid a startup script if possible and either keep it purely registry based or use a Software Restriction policy to stop them. I've tried deleting the registry key that holds the value but it still keeps toggling. I've also tried using Process Monitor to find out what it's doing and where it's doing it, but can't find much useful information.. I'd like to avoid blocking ALL accessibility functions, as we have a few students and staff who need to use the high-contrast functions of the accessibility settings. I've had a look on Google, but none of the solutions there work. Instead, they recommend installing software to all machines which isn't very practival..
-
Make Any Webpage Look Like It Was Made By A 13 Year-Old In 1996
Grayda replied to Lamez's topic in Miscellaneous
It doesn't quite work if your site already looks like a Geocities site :P I loved the "Campaign against frames" image that was plastered along the top of my site, http://www.solidinc.org. Back in 1996, Frames were hot stuff! People could steal content from multiple sites without having to bother with downloading it to their site then re-uploading it! lulzy find! -
A simplistic way to go about this would be: <select> <?php for($i = 0; $i <= count($choice) - 1; $i++) { echo "<option"; if($_POST["myChoice"] == $choice[$i]) { echo " selected='selected'"; } echo ">" . $_POST["myChoice"] . "</option>"; } ?> </select> Keep in mind that this is very simplistic, untested (I'm at work :B) and is probably not secure (unsanitized $_POST data just asking for an XSS Attack) but you get the idea. You create part of your HTML tag then add an if() statement. If the data in $_POST is equal to the choice being outputted, add the "selected='selected'" property to the tag. If the data doesn't match, it finishes off the HTML tag and carries on. With some tweakage, you can use this to take information directly from a database and automatically select options based on row data. But be careful. If you don't sanitize user input, you leave yourself wide open to an XSS attack or much worse. Hope this helps
-
Be patient. Not everyone here visits on a daily basis, nor do they get paid for their help. In response to your question, you can do something like this: <form action="test.php" method="post"> <input type="submit" value="One" name="choice[]" /> <input type="submit" value="Two" name="choice[]" /> <input type="submit" value="Three" name="choice[]" /> </form> <?php if($_POST["choice"][0] == "One") { echo "One clicked"; } elseif($_POST["choice"][0] == "Two") { echo "Two clicked"; } elseif($_POST["choice"][0] == "Three") { echo "Three clicked"; } elseif(empty($_POST)) { } else { echo "Uh oh, hacking attempt! lol"; } ?> By adding [] to the end of an input's name, you turn it in to an array (akin to $blah[] = "Hello"; $blah[] = "World"; ) so you can add 100 buttons, all with the same name and echo out $_POST["blah"][0] to find out which one was clicked. If you do the same with checkboxes or listboxes with multiple="multiple", you can find out exactly which boxes were ticked. For example: <?php for($i = 0; $i <= 100; $i++) { echo "Was $i clicked?: " . $_POST["blah"][$i] . "<br />"; } ?> Hope that helps! And remember that your answer might take a few days or even a few weeks to be answered. It's whoever stops by and knows the answer. If you're looking for immediate answers, try a company that does telephone support for PHP
-
Could you do a simple search / replace to accomplish this? <?php $dia = array("á", "Á", "ä", "é", "í", "ó", "ö", "ő", "ú", "ü"); $non = array("a", "A", "a", "e", "i", "o", "o", "o", "u", "u"); $searchTerm = str_replace($dia, $non, $searchTerm); // pass $searchTerm off to your search function ?> Is this what you're after?
-
Need a script that I don't know the name of... HELP
Grayda replied to frkmilla's topic in Third Party Scripts
If you want to do this on content on your page, why not try using output buffering? It lets you catch a page before it's sent to the browser and do whatever you wish to it. Check out http://au2.php.net/manual/en/ref.outcontrol.php for information about that. But for now, here's a modification to my script that includes OB: <?php ob_start(); include("../url/url.php"); include("url.php"); include("url/url.php"); // .... more content here .... $mytext = ob_get_contents(); $mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext); $mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext); echo $mytext; ob_end_clean(); ?> So what this does, is turn on output buffering (ie. withholds the page from the browser) then tinkers with it using str_replace. Then when that's done, it outputs the text and turns off the buffer. But if it were my script, I'd convert my pages into OOP (there are some great OOP tutorials on this site, check 'em out) and write a function to do this for me, and also add in some lines so I could do search / replace via a database. That way I wouldn't have to include the above code on every page, I could just call: $myclass-.startReplace(); // ... content ... $myclass->replaceText() $myclass->endReplace(); and have it read the search and replace values from a database. And before you ask, I can't / won't write up the full script here. Not only do I not have the time, but it'd be too long and require a lot of explanation. So instead I can point you to plenty of PHP tutorials because the results are a lot more exciting when you learn it yourself -
You could also bundle up something like [link=http://www.apachefriends.org]xampplite[/link] in to an installer and add some code to your application so that they do the work at home, bring the app in, run it again and click "Send to server" to sync. You could do a few checks to see if your server is available and if it's not, stop the sync from happening
-
Need a script that I don't know the name of... HELP
Grayda replied to frkmilla's topic in Third Party Scripts
I think I get it. You want certain words to be, say, red. And you want other words to be made in to a link? I think this should help: <?php $mytext = "Buffalo with an aqualung"; $mytext = str_replace("Buffalo", "<a href='buffalo.php'>Buffalo</a>", $mytext); $mytext = str_replace("aqualung", "<b>aqualung</b>", $mytext); echo $mytext So when you run the script, Buffalo will be replaced with a link to buffalo.php and aqualung will be made bold. That, of course, is the simple way to do it. You can get complex with regexes and whatnot, but if you're only doing a few things at a time, this is ideal. -
help displaying partial results with "more" link
Grayda replied to DarkJamie's topic in PHP Coding Help
Why not try this?: SELECT LEFT(title, 160) FROM myTable WHERE title = "SomeTitle" That will get the first 160 characters from the 'title' column in 'myTable'. If you want the last 160, change left to right. You could even combine them so you can get 80 characters from the left and 80 from the right. -
As part of my website, I'm building a list of countries and trying to add extra information about their currency and "official" language with the intent of 1) releasing it for others to use and 2) create an approximation script so that people can pick their location and have their language and currency (among other things) set for them automatically. I've found several importable CSV files for countries but no CSV / SQL / text files / whatever for lanugages or currencies. All the data I've found that I could "search and replace" are a big mess and would require a lot of messing around to get somewhere. Can anyone point me in the right direction? Thanks!
-
HTTP_REFERRER seems to not work all the time on IE, and even if it does, programs like Norton can prevent this information being sent (in case it's used in some kind of Session ID attack or something). The next best way is to set a $_SESSION on the previous page. So for example if you know that only requests from gotolocator.php should be allowed, then you can put at the bottom of gotolocator.php: <?php session_start(); $_SESSION['theLastPage] = $_SERVER['PHP_SELF']; ?> Then on locator.php: <?php if($_SESSION["theLastPage"] != "gotolocator.php") { die("Go away"); } else { unset($_SESSION["theLastPage"]) } That last line of code is very important. If you don't unset() $_SESSION["theLastPage"] then I could go to "somerandompage.php" then straight back to locator.php if there is no code to overwrite or unset "theLastPage" which would still be locator.php. Dunno how serious it could be, but it pays to be extra sure!
-
You're welcome! And I need to add a correction to my last post. In my explanation of the database side of things, it should read: instead of: