Author Archive
Change sendmail’s outgoing ip
by admin on Apr.16, 2011, under Linux Happyness
Problem:
How to change sendmail’s outgoing ip?
Solution:
This is the ip that will be used to deliver messages, this ip might get blacklisted if one of your happy clients on a shared server decides to send a mass email.
Sendmail is always a bitch to config, but this time it wasn’t, just change your .m4 file adding:
CLIENT_OPTIONS(`Addr=123.456.789')dnl
rebuild the .cf file, restart sendmail and you’re done. In my case, I had a specific ip on the server that got “temporary” (permanently) blocked by gmail. Although new mail wasn’t being sent after the flood, google never unblocked my server, even after a week i still getting “limit rate exceeded” messages. Since I have many IPs on the server it was easier just to bind sendmail to another IP.
Source:
Server Ping PHP Script
by admin on Nov.15, 2008, under Coding
This Script will ping the servers on the $p array non stop, timeout is calculated * 5, so it you set _timeout to 2 the server timeout will be 10 seconds, that means that after 10 seconds of no reply it will take the server/service as down. It’s obviously recommended that you don’t run this script on the very same machine you want to test, since, if it gets down, you will never know (stupid). Apart from that, if you run this script on a machine with a crappy connection or/and port limited/firewalled you might expect problems.
Click here to see the .phps file with right padding or check this ugly text above (thanks to wordpress) :
<?php
// (c) z3n – R1V1@081114 – Port Check – Distribute under MIT License
define(‘is_debug’,0); // debug mode
define(‘w_sw’,1); // enable warning by email
define(‘_e’,'happy@didlidodli.com’); // warning email address
define(‘_timeout’,2); // fsockopen timeout in seconds
define(‘_max_timeout’,5); // max fsockopen timeout loops
define(‘_dt’,”Y-m-d \@ H:i:s”); // date/time format
$p=array( // Servers to Check – Server Name , IP/Hostname , Port
array(‘Server Name 1 WWW’,'1.2.3.4′,’80′),
array(‘Server Name 1 FTP’,'1.2.3.4′,’21′),
array(‘Server Name 1 ParaChat’,'1.2.3.4′,’7777′)
);
function f($x) { return number_format($x,0,’.',’,'); }
function a($t) { if ($t > 1000) { if ($t > 1000000) { if ($t > 1000000000) { if ($t > 1000000000000) { if ($t > 1000000000000000) { if ($t > 1000000000000000000) { if ($t > 1000000000000000000000) { $u=”o”;$t=$t/1000000000000000000000; } else { $u=”E”;$t=$t/1000000000000000000; } } else { $u=”P”;$t=$t/1000000000000000; } } else { $u=”T”;$t=$t/1000000000000; } } else { $u=”G”;$t=$t/1000000000; } } else { $u=”M”;$t=$t/1000000; } } else { $u=”K”;$t=$t/1000; } } else { $u=”"; } return round($t,3).$u; }
function p($i,$p,$t=5) {
$f=@fsockopen($i,$p,$e,$s,$t); // ip/hostname, port, error number, error description, timeout (sec)
@fclose($f);
if(!$f) {
if (is_debug) { echo “\n[ERROR] “.$e.”: “.$s.”\n”; }
return 0;
} else {
return 1;
}
}
echo “(c) z3n – R1V1@081114 – Ping by Port Check\n”;
for ($i=$b=$o=0,$k=count($p),$u=array_fill(0,$k,0);0 < 1;$i++) {
echo “\r[".date(_dt)."] L:”.a($i).” G:”.a($i-$b).” B:”.f($b).” T:”.a($o); // Loops , Good , Bad , Timeout
for ($j=0;$j<$k;$j++) {
if (!p($p[$j][1],$p[$j][2],_timeout)) {
$u[$j]++;$o++;
if ($u[$j] == _max_timeout) {
$m=”[".date(_dt).":".$i."@".$u[$j].”] “.$p[$j][0].”: (“.$p[$j][1].”:”.$p[$j][2].”) Down”;
if (w_sw) { mail(_e,$p[$j][0].” is Down”,$m,”From: “._e); }
echo “\n”.$m.”\n”;$b++;
}
} else {
if ($u[$j] >= _max_timeout) {
$m=”[".date(_dt).":".$i."@".$u[$j].”] “.$p[$j][0].”: (“.$p[$j][1].”:”.$p[$j][2].”) Online”;
if (w_sw) { mail(_e,$p[$j][0].” Back Online”,$m,”From: “._e); }
echo “\n”.$m.”\n”;$b–;
}
$u[$j]=0;
}
}
}
?>
document.onLoad and difference
by admin on Nov.05, 2008, under Coding
document.onLoad works faster, and apparently, if you put it on a separated .js file, it will refeer only to the .js file itself not the whole html page, while body onLoad will run only when the whole thing is loaded, which is better, for my case it’s the solution since other .js had to load first.
so,
issue:
document.onLoad causes an error (this can only be noticed online when things aren’t loaded instant)
solution:
body onLoad tag among with a little timer to display the div i want.
Javascript Argument Handling
by admin on Oct.31, 2008, under Coding
Problem:
yourhappyhtml.html?argument=xxx
Solution:
function d(){var x=window.location.search.split(‘?’);if(isset(x[1])){setTimeout(“z(“+x[1]+”)”,200);}}
Explanation:
this will call a function z that will show a specific hidden div depending on the parameter sent, due random crappyness on onload function i added a timer as a workaround, to call this in a bare way you should do ?number , and nothing else, x[0] is always null, isset() is:
function isset(v) { return ((v == undefined) || (v == “”)) ? false : true; }
to send more than one argument you will need to split the “=” as well inside the x[1], since javascript will take the whole query as a variable.
Disabling Firewall on Fedora (Lame)
by admin on Oct.23, 2008, under Linux Happyness
Problem:
fedora is firewalled and only accepts ssh connections
Solution:
system-config-firewall-tui
Javascript to Replace Accent Chars
by admin on Oct.18, 2008, under Coding
Problem:
convert accent html encoded chars, like ç , to their real values in javascript
Solution:
var _chr=[];var _etn=[];for(var x=0;x<95;x++){_chr[x]=(x+161);_etn[x]="&#"+(x+161)+";";} // replacing all chars could be slow you would like to restrict it to only the accent chars or the ones that you like
function chr(x){return String.fromCharCode(x);} function e2c(s){for(var x=0;x<95;x++){var m=s.indexOf(_etn[x]);while(m!=-1){s=s.replace(_etn[x],chr(_chr[x]));m=s.indexOf(_etn[x]);}}return s;}
you can test by:
alert(e2c(“¡¡¡¡¢çç㤥¿”));
to do the reverse just change the order of the replace vars
note that javascript is lame and don’t have array replace and it will only replace a single char on the string (even if there’s more) so lots of loops had to be added to it, this might be a drawback if you use this too many times into a same page or into very large texts.
Javascript eval(return)
by admin on Oct.17, 2008, under Coding, Tips & Hints
Problem:
javascript:eval(“return 666″)
Solution:
No solution; do a workaround you idiot.
Zend and Fedora Issue
by admin on Oct.17, 2008, under Linux Happyness
Problem:
Failed loading /usr/local/Zend/lib/Optimizer-3.3.3/php-5.1.x/ZendOptimizer.so: /usr/local/Zend/lib/Optimizer-3.3.3/php-5.1.x/ZendOptimizer.so: cannot restore segment prot after reloc: Permission denied
Fix:
setenforce 0 (and restart httpd) and disable SELINUX here: /etc/selinux/config SELINUX=disabled to have this set next time you boot the machine.
apache (13) permission deined error
by admin on Oct.13, 2008, under Linux Happyness
Error:
[XXX] [crit] [client XXX] (13)Permission denied: /path/to/user/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
Solution:
chmod 777 /home/userfolder
Running Multiple p2p Behind Router
by admin on Aug.03, 2008, under Tips & Hints
As a full time internet leecher i’ve developed a way to avoid p2ps to conflicting with each other, since some p2p networks, like torrents and emule (kademila) don’t have clients with port range features the best way to avoid them to conflicting is putting ‘em behind a router and configure to work with UPnP.
Doing this will make you fall into another problem, with so many p2ps running you must have a lot of upstream, since this is not my case, i had to avoid one p2p to leech the whole upstream that would make the other p2ps slower or even making ‘em to crash, since the upstream was used to much that other programs don’t even have bandwidth to keep their connections alive with the network, so i had to cap ‘em.
Using netlimiter i was able to cap emule and torrents at 5k/s/each with left some bandwidth free for PD. Since PD can’t be capped (if you cap it’s upstream you probably gonna get knocked out the network) i left it with some priority — other p2ps are full of leechers so it don’t worth having so much upstream for them.
Now the port scheme:
Torrent: 40000 , port range: 25000-25250 (you don’t need many ports on torrents on your home connection, if you open too many your ISP will probably kill the new ports making internet unable to work for other things)
Kad/Emule: 4662/4672 (UDP), port range: 25251-25500 (i don’t recall for sure, but the listening ports, 4662 and 4672, were supposed to be the default ports for this p2p network when it started)
PD: 27848 – this is the most sensitive of the p2ps, since not everyone has a japan-like connection you should watch this closely, pd tends to open lots and lots of ports, like 500 even 1000, when it couldn’t get any bandwidth or any good nodes, so if you don’t priorize it’s bandwidth , it’s mostly like that it either will die or it will flood with ports, so to have a long duration connection with pd you shouldn’t cap it at all.
Regular FTP/HTTP Downloaders: if you run one of those too and you are able to configure it’s port range, try to make a new range for it and don’t use many multiple connections or it will take the whole bandwidth – best choise if having a downloader that is able to cap itself, like flashget that way you can balance the bandwidth well. FTPs will be aways a problem if you have an overloaded or super-port-flooded connection since they require much more communications to start the download than a simple HTTP request.
An note about netlimiter: This program seems to be incompatible with some types of NICs you shouldn’t notice the incompatibility at all when you install and run it, but once you start getting tcpip.sys BSOD you will go nuts — so i recommend the old version , 1.3, which instead of crashing windows, it crash itself, so you just need to run a timer on the program and it will be restarted once it crashes. (To run old netlimiter without poping it up, use: netlimiter.exe /s)