$xls = PHPExcel_IOFactory::load("test.xlsx");
$xls->setActiveSheetIndex(0);
$sheet = $xls->getActiveSheet();
for($counter = 0; $counter < 10; $counter++)
{
$currentCellDate = date('d.m.Y', strtotime('+'.($counter).' day'));
echo $currentCellDate."\n";
$xls->getActiveSheet()->setCellValueByColumnAndRow(0, $counter + 1, $currentCellDate);
}
$objWriter = PHPExcel_IOFactory::createWriter($xls, 'Excel2007');
$objWriter->save("test.xlsx")
function getFileSize($url)
{
$cURLsession = curl_init();
curl_setopt($cURLsession, CURLOPT_URL, $url);
curl_setopt($cURLsession, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($cURLsession, CURLOPT_HEADER, TRUE);
curl_setopt($cURLsession, CURLOPT_NOBODY, TRUE);
$data = curl_exec($cURLsession);
if(($curlResult = curl_exec($cURLsession)) === false)
{
echo "Ошибка при получении данных: ".curl_error($cURLsession).". С ".$url;
}
$responseType = curl_getinfo($cURLsession, CURLINFO_CONTENT_TYPE);
$fileSize = curl_getinfo($cURLsession, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($cURLsession);
return $fileSize;
}
function getEpscapeData($content)
{
$regExpDateWrapper =
"#".
"(?=<div class=\"epdate\">)(?:.*?)(\d{1,2}\s.*?)(?:</span>|</small></h5>)(?:</div>)".
"(?:(?:<div class=\"episode\">)(.*?)(?:</div></div></div>))+".
"#si";
$regExpMovieWrapper =
"#".
"(?:<div class=\"episode\">)(?:.*?)".
"(?:<a href=\")(.*?)\"(?:.*?)".
"(?:<div class=\"shrutitle\"><a(?:.*?)>)(.*?)(?:</a>)".
"(?:.*?)(?:class=\"shtitle\">)(.*?)</div>".
"(?:.*?)(?:class=\"eptitle\"><b>)(.*?)(?:</b>\s{0,})(.*?)".
"(?:</div></div></div>)".
"#si";
preg_match_all($regExpDateWrapper, $content, $dateMatches, PREG_SET_ORDER);
foreach($dateMatches as $currentDate)
{
echo iconv("UTF-8", "CP1251", $currentDate[1])."\n";
preg_match_all($regExpMovieWrapper, $currentDate[0], $movieMatches, PREG_SET_ORDER);
foreach($movieMatches as $currentMovie)
{
$movieInfo =
"Link: ".$currentMovie[1]."\n".
"Название сериала: ".$currentMovie[2]."\n".
"Оригинальное название: ".$currentMovie[3]."\n".
"Название эпизода: ".$currentMovie[4]." ".$currentMovie[5]."\n\n";
echo iconv("UTF-8", "CP1251", $movieInfo);
}
echo "*********************************\n";
}
}
var pageIndex=1;
$.ajax
({
url: 'путь к php файлу',
data: {pageIndex: pageIndex},
type: 'get',
success: function(answer)
{
// Добавляем результат на страницу
console.log(answer);
pageIndex += 3;
},
error: function(error)
{
console.log('Ошибка');
console.log(error);
}
});
$answer = "";
$url = "http://epscape.com/calendar/next/";
$pageIndex = $_REQUEST['pageIndex'];
for($counter = 0; $counter < 3; $counter++)
{
$answer .= getEpscapeData($url.($counter + 1));
}
echo $answer;
function getEpscapeData($url)
{
........
return recievedData;
}
<?php
require_once "e:\\MyWork\\web\\Script\\PHP\\PHP_SocketIO_Client\\socket.io.php";
// Create a socket.io connection and send a simple message
$socketio = new SocketIO();
echo iconv("UTF-8", "CP866", "exit для выхода\n");
while(true)
{
$input = fgets(STDIN);
if(trim($input) == "exit")
{
break;
}
if ($socketio->send("127.0.0.1", 8081, iconv("CP866", "UTF-8", trim($input))))
{
echo iconv("UTF-8", "CP866", "Сообщение отправлено. Можете продолжать:\n");
} else
{
echo iconv("UTF-8", "CP866", "Какой-то сбой :(\n");
}
}
exit("Jobe done");
?>
$sourceContent = '<div style="margin-top: -18px;">
<nobr>
<b>18 / 25</b>
</nobr>
</div>';
$regExpWrapper = "#(?:<nobr>(?:.*)(?:<b>))(.*?)/(.*?)(?:</b>)#s";
preg_match($regExpWrapper, $sourceContent, $matches);
echo iconv("UTF-8", "CP866", $matches[1]." из ".$matches[2]);
$regExpWrapper = "#(?:\"wa-progress\")(?:.*?)(?:</div>(?:.*?)>(.*?)/(.*?)</div>)#s";
$cURL = curl_init();
curl_setopt ($cURL, CURLOPT_URL,'www.goldcs.ru');
curl_setopt ($cURL, CURLOPT_RETURNTRANSFER,1);
curl_setopt ($cURL, CURLOPT_SSL_VERIFYPEER, 0);
$cURLResult = curl_exec($cURL);
curl_close($cURL);
preg_match($regExpWrapper, $cURLResult, $matches);
echo iconv("UTF-8", "CP866", $matches[1]." из ".$matches[2]);
var ipaddress = '127.0.0.1';
var port = 9000;
function testWebSocketServerAndNotification()
{
var WebSocketServer = require('ws').Server;
var path = require('path');
var notifier = require('node-notifier');
var message = 'Hello from Node.js';
var path2Image = 'e:\\MyWork\\NodeWorkBench\\TestApp\\image\\infoBalloon.png';
var wss = new WebSocketServer({host:ipaddress, port:port});
wss.broadcast = function(data)
{
for (var i in this.clients)
{
this.clients[i].send(data);
}
};
wss.on('connection', function(ws)
{
ws.on('message', function(message)
{
wss.broadcast(message);
notifier.notify
({
title: 'My notification',
message: `Message: '${message}'`,
sound: true,
time: 5000,
wait: true,
icon: path.join(__dirname, 'image', 'notificationIcon.png'),
contentImage: path2Image,
});
});
});
console.log('Слушаем адрес ' + ipaddress + ' на порте: ' + port + ' ...');
}
<?php
require_once "e:\\MyWork\\web\\Script\\PHP\\PHP_SocketIO_Client\\socket.io.php";
$socketio = new SocketIO();
echo iconv("UTF-8", "CP866", "exit для выхода\n");
while(true)
{
$input = fgets(STDIN);
if(trim($input) == "exit")
{
break;
}
if ($socketio->send("127.0.0.1", 9000, iconv("CP866", "UTF-8", trim($input))))
{
echo iconv("UTF-8", "CP866", "Сообщение отправлено. Можете продолжать:\n");
} else
{
echo iconv("UTF-8", "CP866", "Какой-то сбой :(\n");
}
}
exit("Jobe done");
?>
testStr = 'http://name.ru/name?date=01%2F15%2F2016&count-people=45';
regExpWrapper = new RegExp('(?:date=)(.*?)&(?:.*)=(.*)$');
result = regExpWrapper.exec(decodeURIComponent(testStr));
console.log(result[2] + '. ' + result[1]);
$string = 'text: texttext;text;var=abc';//'text: texttext;text;var=abc;text';
$regExpWrapper = "/(?:var=)(.*?)(?:;|$)/";
preg_match($regExpWrapper, $string, $matches);
print_r($matches);