javaweasel
Forum Replies Created
-
Forum: Plugins
In reply to: [Randomize] Widget and shortcode just returning single itemOK…I had a major and embarrassing realization. This plugin is *supposed* to return a single, random item from a collection. In that case, it is working perfectly fine as-is.
So, to return an entire list of randomized items as we needed, I had to rewrite the code to work for our case.
For reference, here’s what I changed to make it work in our case:
The result set in get_randomize returns only a single row because $wpdb->get_row() and ‘LIMIT 1’ only returns a single row by design. I removed the ‘LIMIT 1’ from the SELECT statement and changed the $wpdb->get_row() to $wpdb->get_results() and enumerated the resulting array to create a single string of a randomized list.
function get_randomize($category='', $random=false) { global $wpdb; $table_name = $wpdb->prefix . 'randomize'; $sql = 'SELECT randomize_id, text FROM '. $table_name." WHERE visible='yes' "; $sql .= ($category!='') ? " AND category = '$category'" : '' ; if($random) //Remove the LIMIT 1 from the SELECT statement to return an entire list //$sql .= ' ORDER BY RAND() LIMIT 1 '; $sql .= ' ORDER BY RAND() '; else //s$sql .= ' ORDER BY timestamp, randomize_id LIMIT 1 '; $sql .= ' ORDER BY timestamp, randomize_id '; //Remove this action, since it returns only a single row. //$row = $wpdb->get_row($sql); //New stuff to enable returning an entire list separated with <br /> tags $strResult = ""; $arrResult = $wpdb->get_results($sql); foreach ($arrResult as $row) { $strResult .= $row->text . '<br />'; // update the timestamp of the row we just selected (used by rotator, not by random) if(!$random AND intval($row->randomize_id)) { $sql = 'UPDATE '.$table_name.' SET timestamp = Now() WHERE randomize_id = '.intval($row->randomize_id); $wpdb->query($sql); } } // now we can safely render shortcodes without self recursion (unless there is only one item containing [randomize] shortcode - don't do that, it's just silly!) $snippet = do_shortcode($strResult); return $snippet; }
Forum: Plugins
In reply to: [Randomize] Widget and shortcode just returning single itemMore info: I opened up a MySQL CLI and ran the
—
SELECT randomize_id, text FROM randomize WHERE visible=’yes’ AND category = ‘the_list’ ORDER BY RAND()
—
statement, and it returned all the expected items.It looks like it is failing in the PHP side of things.
Forum: Plugins
In reply to: [Randomize] Widget and shortcode just returning single itemThe server is running ver. 7.3.
Forum: Plugins
In reply to: [Randomize] Widget and shortcode just returning single item…and this in the error log:
PHP Notice: Undefined variable: result in ***/wp-content/plugins/randomize/randomize.php on line 155It’s in the randomize_get_category_options function. I fixed the problem, but it still only returns a single item.
- This reply was modified 4 years, 8 months ago by javaweasel.
The NFW installations on the two sites appear to be functioning independently as expected. I installed NFW on a third sub-site using the .user.ini to point to that installation, and it too is behaving normally. Marking as resolved.
Aha! It seems that renaming the second-site php.ini to .user.ini did the trick. I tested both sites with bogus GETs and each installation seems to only be responding to attacks on the correct domains. Logging and LiveLog is also displaying as expected. If there are no further issues in 24 hours, I’ll come back and mark as resolved.
OK. I’ve created a second php.ini in the second-site directory. Still no changes in behaviour, but it’s early yet. I’ll report back in 24 hours to see if Apache picks up the new php.ini.
php.ini is only in the root directory.
running https://www.secondsite.com/test.php:
public_html/second-site/wp-content/plugins/ninjafirewall/lib/firewall.phprunning https://www.primarysite.com/secondsite/test.php
public_html/second-site/wp-content/plugins/ninjafirewall/lib/firewall.phpI put test.php in the root directory.
running https://www.primarysite.com/test.php
public_html/second-site/wp-content/plugins/ninjafirewall/lib/firewall.phpIt seems to point to the second installation in all cases.
OK…I went in and disabled all the .htaccess hardening put in place by the Sucuri plugin. The Live Log now works. But…
I have NFW installed on two websites. One is at the www root, but another is in a subdirectory (‘www/second-site’). The second site has its own domain name. The php.ini file is in ‘www’.
What I’m seeing is that Live Log works now on both sites, but shows traffic happening on both sites. However. “Firewall Log” only works on the ‘www/second-site’, but it logs everything, including what’s happening in the primary site in ‘www’.
I’m now assuming that two installations of NFW within a single diretory structure is not a good thing, or at least not very efficient, even if the sites are independent of each other?
No luck. I made the change from 503 -> 403, but no difference in the Live Log:
No traffic yet, please wait…
Error: cannot find your log file. Try to reload this page.
Error: cannot find your log file. Try to reload this page.
…etc.Thanks for the quick reply.
I deleted livelog.php.
It does get recreated when I look at Live Log
It remains at 0 bytes and I still get the “Error: cannot find your log file. Try to reload this page” message.
Permissions on the file: 644