Archive for the ‘Windows’ Category

Send email when medical results appear on

24/09/2015 Leave a comment

Bellow php script will check every 15 min if medical results appear on and send email with notification.

$url = ";;
$zlecenie = "xxxxxxxxx";
$pesel = "xxxxxxxxxxx";

$f = "lam24.ini";
$size = filesize($f);
$fH = fopen($f,"r");
$data = fread($fH,$size);
if(strpos($data,'true') !== false) {

$ckfile = tempnam("/tmp", "CURLCOOKIE");
$useragent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.2 (KHTML, like Gecko) Chrome/5.0.342.3 Safari/533.2';

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

$html = curl_exec($ch);


preg_match('~~', $html, $viewstate);
preg_match('~~', $html, $eventValidation);

$viewstate = $viewstate[1];
$eventValidation = $eventValidation[1];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $ckfile);
curl_setopt($ch, CURLOPT_COOKIEFILE, $ckfile);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);

$postfields = array();
$postfields['__EVENTTARGET'] = "";
$postfields['__EVENTARGUMENT'] = "";
$postfields['__VIEWSTATE'] = $viewstate;
$postfields['__EVENTVALIDATION'] = $eventValidation;
$postfields['Login$UserName'] = $zlecenie;
$postfields['Login$Password'] = $pesel;
$postfields['Login$loginButton'] = 'Pokaż wyniki';

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
$ret = curl_exec($ch);
if(strpos($ret,'Nie znaleziono wynik') !== true) {
$fp = fopen($f, 'w');
fwrite($fp, 'true');

$to = '';
$subject = 'Wyniki Lam24';
$message = 'Automatyczny skrypt, ktory sprawdza dostepnosc wynikow co 15 minut informuje za sa one juz dostepne:' . "\r\n" . '' . "\r\n" .
'Zlecenie: ' . $zlecenie . "\r\n" .
'Pesel: ' . $pesel;
$headers = 'From:' . "\r\n" .
'Reply-To:' . "\r\n" .
'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

*/15 * * * * /usr/bin/php /home/n4p1/lam24/lam24.php

Categories: Bash, PHP + MySQL

Change the created/modified time of files

03/02/2013 Leave a comment

You can manually change created/modified/last accessed time of files using power shell and bellow command:

Get-ChildItem * | foreach { $_.CreationTime = get-date "3/2/2013 1:00 pm"; $_.LastWriteTime
 = get-date "3/2/2013 1:00 pm"; $_.LastAccessTime = get-date "3/2/2013 1:00 pm" }

Where * is a wildcard for all files in current directory. You can simply change it to file name etc.

Categories: Windows

Import XML data to MySQL tables

01/08/2012 1 comment

According to mysql documentation there is possibility to load data to mysql table from xml files. Hoverer after trying to execute below command:

napi@debian:/home/napi$ mysql -u root -p
mysql> use test;
Database changed
mysql> LOAD XML LOCAL INFILE '/var/www/SIMC.xml' INTO TABLE simc;
ERROR 1148 (42000): The used command is not allowed with this MySQL version

as a output I get this weird error. To fix that just add one parameter: ‘–local-infile’ to mysql command:

napi@debian:/home/napi$ mysql -u root -p --local-infile
mysql> use test;
Database changed
mysql>  LOAD XML LOCAL INFILE '/var/www/SIMC.xml' INTO TABLE simc;
Query OK, 4115 rows affected, 1580 warnings (0.85 sec)
Records: 4115  Deleted: 0  Skipped: 0  Warnings: 1580
Categories: PHP + MySQL


08/11/2011 Leave a comment

Today I failed 70-640 exam…. Damn… I got 644/1000 points. 700 needed to pass.

Categories: Certification, Windows

How to parse lotto numbers from and put it to DB?

21/07/2011 Leave a comment

Answers is:

$hostname = "localhost";
$username = "lotto";
$password = "";

try {
$db = new PDO("mysql:host=$hostname;dbname=lotto", $username, $password);

$n = 1;
while ($n <= 126) {
$html = file_get_contents("$n");
preg_match_all("#(<td nowrap>(.*?)</td>)|(<td align=\"center\"  class=\"(.*?)\" title=\"(.*?)\">(.*?)</td>)#", $html, $match);

$match2 = array_mesh($match[2], $match[6]);

foreach ($match2 as $record){
if($i==7 or $i==0){
$time = strtotime($record);
$db->query("INSERT INTO losowania (id, data) VALUES ('', $time)");
$id = $db->lastInsertId();
else {
$db->query("INSERT INTO liczby (id, losowania_id, liczby) VALUES ('', $id, $record)");
$db = null; // close the database connection
catch(PDOException $e) {
echo $e->getMessage();

function array_mesh() {
// Combine multiple associative arrays and sum the values for any common keys
// The function can accept any number of arrays as arguments
// The values must be numeric or the summed value will be 0

// Get the number of arguments being passed
$numargs = func_num_args();

// Save the arguments to an array
$arg_list = func_get_args();

// Create an array to hold the combined data
$out = array();

// Loop through each of the arguments
for ($i = 0; $i < $numargs; $i++) {
$in = $arg_list[$i]; // This will be equal to each array passed as an argument

// Loop through each of the arrays passed as arguments
foreach($in as $key => $value) {
// If the same key exists in the $out array
if(array_key_exists($key, $out)) {
// Sum the values of the common key
$sum = $in[$key].$out[$key];
// Add the key => value pair to array $out
$out[$key] = $sum;
// Add to $out any key => value pairs in the $in array that did not have a match in $out
$out[$key] = $in[$key];

return $out;

Categories: PHP + MySQL, Programming

Log In to an Expired Windows XP

26/06/2011 Leave a comment

We need reset XP trial.

In Safe mode type:

rundll32.exe syssetup,SetupOobeBnk

This can be done 4 times.

Categories: Windows

Linux commands in Windows command-line

01/12/2010 2 comments

How often you are working on windows and linux (eg. via putty) at the same time? Would you like use wget, ls, grep, mkdir commands in windows cmd.exe? Would not it be nicer to have linux commands in windows?  If yes, you should install GnuWin inside your Windows OS.

There is o two ways to do that. You can install all packages or install only that what you need. There is a packages list available to manual install.

Categories: Windows