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.
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.
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
I always use mktime, it feels less like guesswork than strtotime.
Mktime(0, 0, 0, date('m', $timestamp)-1, 1, date('Y', $timestamp)) for the first of last month, +1 for next month, you can also set the day of month to 0 to get the last day of the previous month
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
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
if you're merging on the same background image from the source and destination then there wont be a quality issue unless the actor overlaps their position in another shot
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.
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
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.
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!
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.
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
to /etc/apparmor.d/lxc/lxc-default-with-mounting and /etc/apparmor.d/lxc/lxc-default
then reload apparmor
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.
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.
Manchester, UK here. I have a warm room containing 3 x Dell R610 with:
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
What was the recovery like after that volume?
I always use mktime, it feels less like guesswork than strtotime.
Mktime(0, 0, 0, date('m', $timestamp)-1, 1, date('Y', $timestamp)) for the first of last month, +1 for next month, you can also set the day of month to 0 to get the last day of the previous month
Your approach to settings doesn't seem to be well thought out in general (Caching/innefficient), but:
so you would do:
I would give some project euler questions to be solved using PHP.
http://projecteuler.net/
A quick one would be to use http://php.net/__get
You could store the result as
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
in this case just doing
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
Yes I do
if you're merging on the same background image from the source and destination then there wont be a quality issue unless the actor overlaps their position in another shot
The description doesn't make much sense, do you have an example for us?
Also, 4000 records isn't much, and if you write the script correctly, parsing 1 shouldn't be any harder than parsing 4000.
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.
I prefer
mktime(0,0,0,date('m'), 0);
Day zero is the last day of the previous month.
or
mktime(0,0,0,date('m')-1, 1)
First day of last month.
This way seems much more reliable and programattic
Just tested on my server and that code works fine. You mentioned "No PHP Errors" previously, but didn't mention any errors now. Are there any?
For some extra info, I would use a hidden field to submit the value instead, if that was the case.
That way it would also work correctly if return was pressed in any other input.
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
no worries, that's what i'm here for
I'd like to see the contract if you find a good one, too.
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.
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!
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.
just looked at the dupes for this entry and found other redditor attempts:
http://colourclock.codefocus.ca/ and http://pseudony.ms/colorclock.html
i think my code is a bit easier to read
Just recreated this in js: http://d62.net/demos/js/hex_clock.html
way ahead of you: http://d62.net/demos/js/hex_clock.html