Jump to content

requinix

Administrators
  • Posts

    15,066
  • Joined

  • Last visited

  • Days Won

    414

Everything posted by requinix

  1. And there it is. See, the "url" param, and thus the $url variable, and thus the $urls array, contains a string of all the URLs. That's no good. Your code needs an array of individual URLs, not all of them bunched together. 1. You copied and pasted that 'http://www.dallascowboys.com/rss/video', 'http://www.dallascowboys.com/rss/gallery', 'http://www.dallascowboys.com/rss/audio', 'http://espn.go.com/blog/feed?blog=nfceast', 'https://sports.yahoo.com/nfl/teams/dal/rss.xml',into the textarea. You, as a user, need to fix that so it becomes http://www.dallascowboys.com/rss/video http://www.dallascowboys.com/rss/gallery http://www.dallascowboys.com/rss/audio http://espn.go.com/blog/feed?blog=nfceast https://sports.yahoo.com/nfl/teams/dal/rss.xmlOne URL for each line. No extra apostrophes or commas or anything. Make sure your form has instructions to do that. 2. Now you know each line is a URL. Supposedly. IMO the best way to get the individual URLs out of it is to try to locate a valid URL on each line, which gives you some freedom about leaving blank lines and such: $url = $params->get('url'); // beginning of line, maybe whitespace, a "http://" or "https://" url, maybe more whitespace, then the end of the line if (preg_match_all('/^\s*(https?://\S+)\s*$/im', $url, $matches, PREG_PATTERN_ORDER)) { $urls = $matches[1]; } else { // did not find any urls $urls = array(); }3. Now that you have $urls set you don't need /********* Feeds *********/ $urls = array($url); /********* Feeds *********/
  2. Assuming you had $url = $params->get('url'); print_r($url); echo '<div id="wrapper" style="margin-top:1px;">'; echo '<ul id="ticker">';that means $url is actually the string 'http://www.dallascowboys.com/rss/video', 'http://www.dallascowboys.com/rss/gallery', 'http://www.dallascowboys.com/rss/audio', 'http://espn.go.com/blog/feed?blog=nfceast', 'https://sports.yahoo.com/nfl/teams/dal/rss.xml',which is no good. How is the "url" parameter being set? Can you make it an array of strings?
  3. Here's the thing: with /********* Feeds *********/ $urls = array($params->get('url')); /********* Feeds *********/$urls is guaranteed to be an array containing one single item. That contradicts the first output you gave. As for the second, there is no "$url" in the code you posted so I don't know where its value is coming from.
  4. Well, first step is figuring out the exact value of $urls... print_r($urls);
  5. "lol /b/'s attacking me but I have mad hacker skillz I can see them coming from 'localhost' lol watch me ddos them back wtf why is my computer so slow guys stop it's not funny anymore"
  6. ...What do you think "localhost" is? [edit] No, wait, this isn't going to work. localhost is always the computer who is trying to look up what "localhost" is. If I click a link to http://localhost/image1.jpg then localhost is my computer. If your server tries to download that image to itself then localhost is your server. What you're saying doesn't make sense. You cannot block localhost. Localhost is yourself. You are localhost. Are you trying to stop hotlinking in general? If so then forget all this "localhost" stuff.
  7. Huh. Linux typically handles Unicode filenames well. Are you absolutely sure the file is named correctly? Do you have shell access? SSH to the server, make sure your client is set to use UTF-8 encoding, and do an ls of the directory to see if the file is called Š.php.
  8. All the work happens in the bprs function. So that needs to change. You're using jQuery, right? Your second loop, which puts everything together using &s and =s, can be replaced with a call to $.param(), as long as the first loop creates an object that looks like { data: [ { name: "name 1", credits: 1 }, { name: "name 2", credits: 2 }, ... ] }So the first loop becomes like var rowCount = $('#accountsTable tr').length; var accountsCount = rowCount -1; var accountsData = []; for (var n = 1; n <= accountsCount; n++) { accountsData.push({ name: $('#accountName' + n).text(), credits: $('#credits' + n).text() }); }and the second loop goes away and becomes simply var data = $.param({ date: new Date(), data: accountsData });
  9. RewriteEngine on #force to https RewriteCond %{HTTPS} =off [OR] RewriteCond %{HTTP_HOST} !=www.example.com.au RewriteRule ^ https://www.example.com.au%{REQUEST_URI} [L,R=301] #Remove php from page RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ $1.php [L,QSA]
  10. Ah yes, the [L] flag. You may know that it means "last" as in "this is the last rule and stop processing anything else", but that's not quite accurate. It means to actually stop evaluating rules for this pass. If you rewrite to something else, Apache will probably send that new URL through its request processing procedure, which involves bringing up the .htaccess with its rules one more time. So what happens is 1. You rewrite /example to /example.php 2. mod_rewrite stops processing and "returns" to Apache 3. Apache gets the new URL (/example.php) and begins to handle that 4. Your .htaccess comes into play again and the "force to https" action kicks in 5. The user is then redirected to the HTTPS version of /example.php Pretty easy way to fix this: do external redirects before internal redirects. Switch the two rule bits around.
  11. Name your inputs either a) accountName[n] and credits[n] b) accounts[n][name] and data[n][credits] I'd suggest the second. Then your PHP looks like $contents = $mystring . "..."; $n = 1; $accounts = array(); foreach ($_POST["accounts"] as $account) { $accounts[] = "<strong>Account {$n}</strong><br>({$account['name']})<br>CREDITS<br>{$account['credits']}"; } $contents .= implode("<br>-<br>", $accounts);
  12. Looks like something is calling date_i18n() with a $unixtimestamp that isn't a number... Do you have any ideas where that may be? Look for a place that's showing bad date strings.
  13. Maybe it's me but that code seems quite confusing. You can make this really simple: 1. If page > 1 then show 2. For loop from 1 to current page - 1: show link for page 3. Show "link" for current page 4. For loop from current page + 1 to last page: show link for page 5. If page > link for last page 1, 3, and 5 are pretty obvious. For 2 and 4, it's possible for a loop to not even execute depending on what the current page is. Consider if the current page is 1 and the pages are 1-4: 1. Page is not > 1 then do not show 2. Loop from 1 to 0: show link (links: none) 3. Current page (links: 1) 4. Loop from 2 to 4: show link (links: 1, 2, 3, 4) 5. Page is > link (links: 1, 2, 3, 4, >>)
  14. No. Okay: 1. What would happen if I went to http://example.com.au? 2. What would happen if I went to https://example.com.au?
  15. Think it through. "If HTTPS is on or the host is not the www version then redirect" versus "If HTTPS is off or the host is not the www version then redirect".
  16. If you're getting a 404 then the PHP isn't executing in the first place. Try with just S.php and see if it works.
  17. Why? They're two completely different things: a contact form and a newsletter registration form. It doesn't make sense to combine them.
  18. You're overwriting $results['events'] every time. What you should do is start with "events" as an array and then add to it. $sql = mysql_query("SELECT * FROM schedules") or die(mysql_error()); $results = array('events' => array()); while($rs=mysql_fetch_array($sql)){ $results['events'][] = array( 'id' => (int)$rs['id'], 'start' => $rs['date_start'], 'end' => $rs['date_end'], 'title' => $rs['details'], 'free' => (bool)$rs['isfree'], 'userId' => (int)$rs['techID'], 'color' => render_color_code($rs['zip']) ); }And you're nesting your arrays wrong. array([]) will put an array inside another array. Use either the array() or [] syntax to get just the one array.
  19. Given that sample JSON data, what would the table look like? Because I'm not sure that anyone here has any idea what the difference between "freebusys" and "events" is.
  20. Top one doesn't have you jumping in and out of PHP mode. Bottom one keeps the HTML separate from the code. What do you think is better?
  21. "mysql:host=HOST;dbname=DB_NAME"PDO doesn't know that "HOST" and "DB_NAME" are PHP constants. You have to put the values in yourself. "mysql:host=" . HOST . ";dbname=" . DB_NAME
  22. Yeah, I don't like the idea of combining the input and output just to pass it all around either. Passing both separately wouldn't be that bad... Do you need the entire input object, either because you need to know a lot of it or because you don't know which parts are relevant? If you only needed a couple pieces of data, and you knew which pieces, then I'd deal with those separately. Like $this->view = ClassThatCreatesViewsFromOutputData::factory($input["field1"], $input["field2"], $output);The idea is to reduce the dependency on the structure of the input data - at least as far as the view generation goes. One way to think about that is "what would I do if the input method changed (eg, command-line program instead of an HTML form)" or "how could I make this easier to test automatically using unit testing" *. Decoupling the relevant input data (field1 and field2) from the actual input itself helps this part easier. Question: given that the hypothetical field1 and field2 are part of the input data, implying that they are potentially necessary when generating the output data, would you be able to get the necessary information from the output instead? Everything you've said so far is pretty abstract so I have no idea whether that's possible, or whether the question even makes sense, but that's the next place I would look. You've probably already considered and discarded this idea. Otherwise... I think you're stuck with passing the input and output data around with each other. $this->view = ClassThatCreatesViewsFromOutputData::factory($input, $output);It then means that the view is necessarily coupled to the structure of both the input and output data, but I can't think of any better options. * Unit testing. Something everybody should do but nobody ever actually does. There are two potential tests here: 1. Given particular input data, derive the correct output data 2. Given particular output data and required other data (eg, the input's field1 and field2), derive the correct view (and one could consider a third too: deriving the correct view from particular input data, which is equivalent to tests 1+2) Having the process broken down into the two steps makes it easier to locate bugs when something goes wrong, and means needing to write less code to test multiple varieties of input and output. Testing #1 is not a problem. Testing #2 removes the idea of "input data" from the equation entirely, which is why I would try to keep the entire $input away from the process of determining the view. But as I said, there may not be any better way to deal with it, and you may be forced to say that the "required other data" is potentially everything from the input.
  23. So the question is who computes the output data, who determines the template, and how do they share the necessary information with each other? In MVC terms you have the controller, view, and model. Looks like the code you posted comes from the controller? Then the view should be the appropriate template, according to the output, while the model is the part that computes the output data from the input. The model should not be aware of the view - that is, determine the template to use for displaying its data. And inside the view is too late to determine which view to use. Then it's up to the controller to decide. If determining the template is easy, like a few lines of code or something not too big and scary to put into a helper method, then I'd put it in the controller: this logic won't be used elsewhere (I guess?) so it should stay as "close" to the controller as possible. public function controller() { $model = new ClassThatComputesData(); $output = $model->compute($input); if ($output->property == "special value") { $this->view = "special_view.php"; } else if ($output->method() > MAGIC_VALUE) { $this->view = "magic_value_view.php"; } else { $this->view = "generic_view.php"; } }May seem weird but the whole point of a controller is to shuffle information between the various models and various views, so determining which view to serve some model is part of its job. Otherwise I'd go for a view factory. It's code somewhere specifically dedicated to figuring out which view is appropriate for given input data. The controller can simply use the view factory to get the appropriate view. public function controller() { $model = new ClassThatComputesData(); $output = $model->compute($input); $this->view = ClassThatCreatesViewsFromOutputData::factory($output); } public function factory(OutputModel $model) { // lots of work that will eventually { return "particular_view.php"; // } }
  24. So you're saying you tried making a bunch of requests, watching in the browser as each request gets sent, until you got one of them to insert 0 for a question? And the value of "n" in the browser (or the value of "answ" in the request data) is always 1 or -0.25? Do you have email set up? Try something as simple as if ($mark != 1 && $mark != -0.25) { mail("yourself@example.com", "mark={$mark}", var_dump($_REQUEST, true), "From: yoursendingaccount@example.com"); }Then you'll get an email every time $mark doesn't have the right value, and it will include all the form data that was sent. And you say it's a recent development? That must mean something has changed recently. Were there any changes to the site? Did your host upgrade PHP versions or change other configuration?
×
×
  • 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.