Skip to content

u/adbe

In this archive from Jan 2011 to Sep 2016

0
posts
28
comments
0
media
91
score

As a note, to enable direct NFS mounting within the container you need to enable/allow it on the host through editing the apparmor config.

I assume this is disabled by default because of privilege escalation or some other security issue, but for my purposes in a homelab I don't mind leaving my TV NFS shares slightly more exposed...

On the proxmox host add

mount fstype=nfs,

to /etc/apparmor.d/lxc/lxc-default-with-mounting and /etc/apparmor.d/lxc/lxc-default

then reload apparmor

service apparmor reload

This needs to be done on each node on the cluster to ensure you can easily move containers around and still have their software functional on the new node.

2 points

All of my VM storage is on NFS on my Synology, so I was considering replacing 1 or 2 of my R610s with some 32GB RAM/i5 NUCs (2 or them would replace 1 node, but i'm not really anywhere near capacity so would just swap a 64GB/2*Xeon for 1 32GB/1*i5) but the price is still putting me off.

Would be great for proxmox as something low power and low on the moving-parts scale just for maintaining quorum in a cluster.

3 points

Manchester, UK here. I have a warm room containing 3 x Dell R610 with:

  • 2x low power (40w) L5630 (2.13Ghz Quad Core, so 16 thread)
  • 4-6 SAS/SATA/SSD (varies)
  • 8 x 8GB RAM per server
  • Dual PSU (varies between the lower wattage and the higher)
  • iDrac6 ent.

The iDrac power usage doesn't tend to show any higher than 205w with plex in use plus 6 or 7 lower power VMs running.

With the full suite plugged in and switched on (3 x R610, 1 x HP ML310e G8v2, Watchguard x750e (pfsense), 24 port gigabit switch and Synology DS1513) and all plugged in to a ups to a "kill a watt", I don't see the total going much over 600w.

I got each of mine from eBay (£45-£120 - all with rails and bezel) and upgraded the RAM separately (96GB is around £100-130)

tl;dr R610 should be fine, you may even get 2 for that budget

2 points

Your approach to settings doesn't seem to be well thought out in general (Caching/innefficient), but:

function get_settings_array($field_name = ''){
    $arr =  $this->db->where('id', 1)->get('settings')->row_array();
    return (empty($field_name)) ? $arr : $arr[$field_name];
}

so you would do:

 $i = $this->settings_reader->get_settings_array('name');
1 points

A quick one would be to use http://php.net/__get

You could store the result as

class mysql_result {
private $res
public function __construct($data){
    $this->res = $data;
}
public function __get($key){
    return (isset($this->res[$key])) ? $this->res[$key] : (is_callable($this->{'get'.$key}()) ? $this->{'get'.$key} : false;
}
}

This would (untested, just written in the editor) return the array key for $this->keyname, or call the function named $this->getkeyname() if the key doesnt exist in the constructed array.

combined with __set you can update the values and then do a save() function for putting back in the db

1 points

in this case just doing

$str = str_replace('\'', '"', $str);
$str = str_replace('[[', '[', $str);
$str = str_replace(']]', ']', $str);

with the $str being the json, gives you a valid array of the google data, instead of that regex. it'd need pre-sanitising to ensure there arent any more " inside though

2 points

Chill, first of all, I only said "seems".

Secondly, strtotime does a lot of magic to interpret ambiguous dates (of which this is not one) - e.g. guessing which locale you're using if you give it a dd/mm/yyyy instead of mm/dd/yyyy.

thirdly, if you're using a word like "last" in there, you can't loop over it programmaticly.

Fourthly, according to user comments on php.net, strtotime will give you the current time on that date unless you explicitly supply a time. e.g. strtotime('midnight first day of last month'); is not the same result as strtotime('first day of last month'); if the script is not run at exactly midnight.

1 points

What leads you to believe it's a cache issue?

One thing to check is that you're not relying on <button value="x" name="submitButton">Submit</button> and expecting $_REQUEST['submitButton'] == x.

IE submits the html content of the <button> as the value, so in this case would submit $_REQUEST['submitButton'] == 'Submit'. Firefox doesn't do this.

If you are relying on that value and redirecting based on it, it is possible that is the reason for the 404.

otherwise, I'd need more detail. What page is it redirecting to? is symfony set up to give a 404 when incorrect parameters are passed to the script? etc

1 points

In addition to the issue that's now solved, you've missed a request variable being escaped in your code.

A user can submit HTML in $_REQUEST["media"] and have it get through to the email.

This could be used with the fact that the values of the other variables are not checked to spoof the format of the email.

By that I mean that $_REQUEST["fName"] could be sent as "Adam\r\nEmail: blah@blah.com\r\nPhone: etc." because the check you do only escapes html chars.

1 points

A lot of the suggestions here would not happen in the real world.

In general you won't have much control over client machines if you're a contractor for a contractor like this. Personally I've not been in this situation but I would just add checks in the init/config file of the script checking for PHP's safe mode (or other relevant options), if it was enabled, the script would throw an exception clearly stating the reason, and refusing to run any further.

Wording the exception message clearly placing blame on server configuration and ensuring that it DOES run once that setting is fixed should solve your problem.

It also sounds like you're quite inexperienced with PHP if you made many changes to the script in an attempt to fix it before realising the actual error, leaving the script in a poorer position than it started. Scripts like this end up as entries on dailywtf!

0 points

I downloaded the code with the intention of rewriting it to be cleaner, but it's too chaotic.

I would split classes into a separate folder, separate the html output and php code as much as possible, and avoid things like the hardcoded references to "http://fancey.ca/antischismogenesis/".

The system should auto detect which hostname it's running on and make the url available as a global variable. Maybe by implementing the registry pattern (here is one of the first results from google for that http://www.phppatterns.com/docs/design/the_registry - looks alright as an explanation)

Things like addrelation.php look like they should be a method to a relation class, the function chatline should probably be a method addLine to the chat handling class.

As others have mentioned, it would also benefit greatly from database abstraction, maybe with the default being SQLite, so it's instant to get it up and running for downloaders with some demo data (you could ship a demo db with the download)

I'm trying be constructive here, let me know if you want anymore feedback since I have a few more ideas for improvements.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.