Jump to content

Grayda

Members
  • Posts

    59
  • Joined

  • Last visited

Everything posted by Grayda

  1. 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..
  2. 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!
  3. 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
  4. 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..
  5. 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!
  6. 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
  7. 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
  8. 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?
  9. 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
  10. 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
  11. 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.
  12. 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.
  13. 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!
  14. 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!
  15. 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:
  16. Try this out: <?php if($_SERVER['HTTP_REFERER'] != "http://www.example.com/locator.php") { die("Go away"); } ?> And just change http://www.example.com to your domain). Call echo $_SERVER["HTTP_REFERER"]; to find out exactly what you need to put in there. Combine this with the define('AUTH_TOKEN',1); method suggested by sKunKbad and you're (almost) all set! And also, don't use die() in your final script. Output a pretty error message rather than a flat-out die() call. There's an article on phpfreaks about never using die in your scripts
  17. What sort of bandwidth do you want to control? Data usage or speed? Data usage is easy -- just call count() on the data you retrieve or inspect the HTTP headers for Content-Length: which will tell you how long the document is. Then you can just store that somewhere temporarily (in a database for example) and do some comparisons: <?php if($dataUsedSoFar >= $dataLimit) { return false; // or output a message if writing procedural code? } I don't know about limiting speed however. Maybe it's a question for your ISP who can limit those sorts of things? You might be able to do it in sockets, but I've never used sockets in PHP so I don't know. Anyone?
  18. I'm guessing this portfolio page is hosted elsewhere? If that's the case, you should be able to call fopen or some kind of cURL call to "download" the page on to your site (once a day / week / month, depending on how often the portfolio is updated) and re-work the HTML (using explode() or split() calls etc.) so it will display nicely in your page. I'm not well versed in fopen or cURL, but using file_get _contents might look like this: function downloadAndDisplay() { $data = file_get_contents("http://www.example.com/profile.php"); $links = explode("</div><div class='links'>", $data); $images = explode("</div><div class='image'>", $data); foreach($data as $arr) { echo $data, "<br />", $links; } } Make sure you have permission to fopen / file_get_contents / cURL external files. See http://au2.php.net/manual/en/wrappers.http.php for more info on this. But if the page is hosted locally, you could just include the file: include("portfolio/portfoliopage.php"); or convert the portfolio page to dynamic, so when the user adds a new portfolio piece, a table in the database is created. Then you can just 'SELECT link, image FROM tblPortfolio WHERE id='32'' and output it as you wish. Hope this helps? A good book on PHP + MySQL or some of the tutorials on this site should help you out if you're unsure about databases
  19. If you remove the Content-Type: headers and just let the raw excel data get echoed, are there any error messages in there? Perhaps it's the execution time of the script? Disabling the header changes will let you see if there are any messages.
  20. Yep. The general rule of thumb is, don't trust anything the user gives you. Ever. Even if your client is good as gold, escape it. Better to add it in than not, and face your site being hacked, dropped, used for spam etc.
  21. Doesn't deployment come under the banner of application design? Anyway, your best bet would be to look at something like NSIS, InstallShield or any of those installer programs. In the simplest case, you would download and install XAMPP onto your system, put your files in the htdocs folder, add your stuff to the database, disable and delete extensions you don't need, then run XAMPP through your installer-creating programs. Then you could install Apache and MySQL as services, create a desktop icon that points to localhost and you're right to go. Questions regarding how you can create these installer packages are definitely suited for another category (Other languages perhaps?)
  22. or: $SQ1 = array(1 => "What is your mother's maiden name?", 2 => "What is your mother's maiden name?"); $html = "<select><option>" . implode("</option><option>", $SQ1) . "</option></select>"; echo $html; is a little neater, might be faster and is a little easier to read
  23. Welcome! There are two types of iPhone applications. Web applications, which are run through Safari, and native apps (like the sort you buy through the App Store). If you're going for web apps, just create your a PHP script that does the updating, host it on your server then place a bookmark on their iPhone pointing to your script. If they want an "iPhone" feel to their applications, check out http://code.google.com/p/iui/ which is a great set of javascript and CSS files. You drop it in, make a few unordered lists (eg. <ul><li>Testing</li><li>Hello</li></ul>) and your site looks and behaves similar to an iPhone. I used it for the iPhone version of my website (http://iphone.solidinc.org) and it was dead simple to use! Also see Apple's documentation on making web apps http://developer.apple.com/safari/library/codinghowtos/Mobile/GraphicsMediaAndVisualEffects/index.html If you're looking at making a native iPhone application that has all the cool stuff like GPS that isn't run through Safari, it gets more complicated. You have to own a Mac with Mac OS X, download the iPhone SDK, develop it in Object-C, submit it to Apple for approval, get it in the store blah blah blah and it's more hassles than it's worth. So I say the web app is the way to go. It's just a standard HTML page that has CSS, Javascript, whatever else you need, and you simply host it on your own site and tell your client to go there in Safari. Easy! Hope that helps.
  24. I think (and correct me if I'm wrong here), sohdubom is asking if, when you unset() a class, the database records that that class created, are automatically deleted. And the answer is no. Using the room / house analogy: I have a house with three rooms. House is the parent, room is the child. I also have a friend nicknamed "Database". I tell Database I have a house with three rooms. They remember that (ie. Add a row to the specified table). Then one day I demolish a room (ie. Unset a room). It ceases to exist when I knock down the walls but Database doesn't know I've demolished a room unless I call them up and tell them. So nothing gets deleted from the database unless I write a function that does that. PHP and MySQL (for example) don't know about each other until you tell them about each other. You can, however, get PHP to automatically do some database stuff when you unset() an object. See this semi-psuedo-class: <?php class room extends house { public $roomID; function __construct($newRoomID) { // ... set up MySQL stuff here mysql_query("INSERT INTO `house` ('" . $newRoomID . "')"); $this->roomID = $newRoomID; } function __destruct() { // .. set up your MySQL information here mysql_query("DELETE FROM `house` WHERE room = '" . $this->roomID . "'"); } // .. More functions here (eg. furnish(), lightsOn() etc.) } So when you create a new room, you call $bathroom = new room("bathroom"); and a new room is created in the database. When you unset($bathroom); , your room is destroyed. So in short, no, if you unset a room, you have to manually delete it from the database. You can sort of automate this by creating a class function called __destruct(), which is a function called by PHP when an object is destroyed, so you can do cleanup work and write stuff to disk etc. Hope this helps?
  25. Even though this topic is marked as solved, I have some helpful advice when dealing with all that "garbage" a page throws out. If you're getting that page full of garbage, it means that your browser isn't correctly identifying the output as an image, so to fix that, you simply put at the top of your script, before any output occurs: header ("Content-Type: image/gif"); Replace image/gif with your content type (eg. image/jpg image/png) so your browser knows that it's GIF / PNG / whatever data, and should render it as such. Not sure if that'll help you now, but for anyone else reading this, it's a handy thing to know. Of course, if you're debugging the script, comment out the line so you can see error messages, or you'll get "This picture cannot be displayed due to errors" message..
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.