create table new_post like post;
$limit = 10000;
$count = 0;
$lastId = 1; // последний id можно менять ручками ( если скрипт зависнит)
$endId = 70170509; // максимальный ид в таблице, докуда копируем
$sqlTemplate = "insert into new_post ( select id, user_id, text)
from post where id > :lastId: and id < {$endId} order by id ASC limit {$limit})";
$sql = str_replace(':lastId:', $lastId, $sqlTemplate);
while ($res = $connection->createCommand($sql)->execute()) {
$lastId = $connection->createCommand('SELECT id FROM new_post ORDER BY id DESC limit 1')->queryScalar(); // получаем ласт запись в новой таблице
$count += $limit;
file_put_contents($file,
"processed " . number_format($count, 0, '.', ' ') . " rows\nlast id " . $lastId . "\n\n", FILE_APPEND);
$sql = str_replace(':lastId:', $lastId, $sqlTemplate);
}
file_put_contents($file, "--done---\n\n", FILE_APPEND);
<?php
define('VK_ID', ID_пользователя_в_виде_числа);
function decode($str){
$vals = explode("#", explode("?extra=", $str)[1]);
$tstr = vk_o($vals[0]);
$ops = vk_o($vals[1]);
$ops_arr = explode(chr(9), $ops);
$len = sizeof($ops_arr);
for($i = $len - 1; $i >= 0; $i--){
$args_arr = explode(chr(11), $ops_arr[$i]);
$op_ind = array_shift($args_arr);
switch($op_ind){
case "v": $tstr = vk_v($tstr); break;
case "r": $tstr = vk_r($tstr, $args_arr[0]); break;
case "x": $tstr = vk_x($tstr, $args_arr[0]); break;
case "s": $tstr = vk_s($tstr, $args_arr[0]); break;
case "i": $tstr = vk_i($tstr, $args_arr[0]); break;
}
}
return $tstr;
}
$vk_str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN0PQRSTUVWXYZO123456789+/=";
function vk_o($str){
global $vk_str;
$len = strlen($str);
$result = "";
for($s = 0, $index2 = 0; $s < $len; $s++){
$sym_index = strpos($vk_str, $str[$s]);
if($sym_index !== false){
$i = (($index2 % 4) !== 0) ? ( ($i<<6) + $sym_index) : $sym_index;
if(($index2%4) != 0){
$index2++;
$shift = -2 * $index2 & 6;
$result .= chr(0xFF & ($i >> $shift));
} else {
$index2++;
}
}
}
return $result;
}
function vk_s($str, $start){
$len = strlen($str);
if($len > 0){
$cur = abs($start);
$shuffle_pos = array();
for($i = $len - 1; $i >= 0; $i--){
$cur = (($len * ($i + 1)) ^ $cur + $i) % $len;
$shuffle_pos[$i] = $cur;
}
for($i = 1; $i < $len; $i++){
$offset = $shuffle_pos[$len - $i - 1];
$prev = $str[$i];
$str[$i] = $str[$offset];
$str[$offset] = $prev;
}
}
return $str;
}
function vk_i($str, $i){
return vk_s($str, $i ^ (int) VK_ID);
}
function vk_v($str){
return strrev($str);
}
function vk_r($str, $i){
global $vk_str;
$vk_str2 = $vk_str . $vk_str;
$vk_str2_len = strlen($vk_str2);
$len = strlen($str);
$result = "";
for($s = 0; $s < $len; $s++){
$index = strpos($vk_str2, $str[$s]);
if($index !== false){
$offset = ($index - $i);
if($offset < 0){
$offset += $vk_str2_len;
}
$result .= $vk_str2[$offset];
} else {
$result .= $str[$s];
}
}
return $result;
}
function vk_x($str, $i){
$xor_val = ord($i[0]);
$str_len = strlen($str);
$result = "";
for($i = 0; $i < $str_len; $i++){
$result .= chr(ord($str[$i]) ^ $xor_val);
}
return $result;
}
echo decode($argv[1]);
?>
Все ли в порядке с SSD?Да.
Сделал smart ssd диска на сервере, подскажите, долго будет работать?Ну долгую работу предсказать трудно - мало ли что может случится, сегодня он работает, а завтра его кто нибудь уронит вместе с сервером на бетонный пол, и он уже работать не будет.
Как парсить тексты песен с сайта Вконтакте vk.com без использования api на php не используя phantomjs и подобное?
**
!www
mysqldump -uname -ppass db | ssh -C user@host 'cat > /path/db.sql'
mysqldump -uname -ppass db | gzip -c | ssh login@host 'cat > /path/db.gz'
mysqldump -uname -ppass db | gzip -c | ncftpput -u login -p pass -c host /db.gz
<# :
@echo off
copy/b "%~f0" "%temp%\%~n0.ps1" >nul
powershell -Version 2 -ExecutionPolicy bypass -noprofile "%temp%\%~n0.ps1" "%cd% " "%~1"
del "%temp%\%~n0.ps1"
pause
exit /b
#>
param([string]$cwd='.', [string]$dll)
function main {
"Chrome 'developer mode extensions' warning disabler v1.0.10.20170114`n"
$pathsDone = @{}
if ($dll -and (gi -literal $dll)) {
doPatch "DRAG'n'DROPPED" ((gi -literal $dll).directoryName + '\')
exit
}
doPatch CURRENT ((gi -literal $cwd).fullName + '\')
('HKLM', 'HKCU') | %{ $hive = $_
('', '\Wow6432Node') | %{
$key = "${hive}:\SOFTWARE$_\Google\Update\Clients"
gci -ea silentlycontinue $key -r | gp | ?{ $_.CommandLine } | %{
$path = $_.CommandLine -replace '"(.+?\\\d+\.\d+\.\d+\.\d+\\).+', '$1'
doPatch REGISTRY $path
}
}
}
}
function doPatch([string]$pathLabel, [string]$path) {
if ($pathsDone[$path.toLower()]) { return }
$dll = $path + "chrome.dll"
if (!(test-path -literal $dll)) {
return
}
"======================="
"$pathLabel PATH $((gi -literal $dll).DirectoryName)"
"`tREADING Chrome.dll..."
$bytes = [IO.File]::ReadAllBytes($dll)
# process PE headers
$BC = [BitConverter]
$coff = $BC::ToUInt32($bytes,0x3C) + 4
$is64 = $BC::ToUInt16($bytes,$coff) -eq 0x8664
$opthdr = $coff+20
$codesize = $BC::ToUInt32($bytes,$opthdr+4)
$imagebase32 = $BC::ToUInt32($bytes,$opthdr+28)
# patch the flag in data section
$data = $BC::ToString($bytes,$codesize)
$flag = "ExtensionDeveloperModeWarning"
$stroffs = $data.IndexOf($BC::ToString($flag[1..99]))/3 - 1
if ($stroffs -lt 0) {
write-host -f red "`t$flag not found"
return
}
$stroffs += $codesize
if ($bytes[$stroffs] -eq 0) {
write-host -f darkgreen "`tALREADY PATCHED"
return
}
$exe = join-path (split-path $path) chrome.exe
$EA = $ErrorActionPreference
$ErrorActionPreference = 'silentlyContinue'
while ((get-process chrome -module | ?{ $_.FileName -eq $exe })) {
forEach ($timeout in 15..0) {
write-host -n -b yellow -f black `
"`rChrome is running and will be terminated in $timeout sec. "
write-host -n -b yellow -f darkyellow "Press ENTER to do it now. "
if ([console]::KeyAvailable) {
$key = $Host.UI.RawUI.ReadKey("AllowCtrlC,IncludeKeyDown,NoEcho")
if ($key.virtualKeyCode -eq 13) { break }
if ($key.virtualKeyCode -eq 27) { write-host; exit }
}
sleep 1
}
write-host
get-process chrome | ?{
$_.MainWindowHandle.toInt64() -and ($_ | gps -file).FileName -eq $exe
} | %{
"`tTrying to exit gracefully..."
if ($_.CloseMainWindow()) {
sleep 1
}
}
$killLabelShown = 0
get-process chrome | ?{
($_ | gps -file | select -expand FileName) -eq $exe
} | %{
if (!$killLabelShown++) {
"`tTerminating background chrome processes..."
}
stop-process $_ -force
}
sleep -milliseconds 200
}
$ErrorActionPreference = $EA
$bytes[$stroffs] = 0
"`tPATCHED $flag flag"
# patch the channel restriction code for stable/beta
$code = $BC::ToString($bytes,0,$codesize)
$rxChannel = '83-F8-(?:03-7D|02-7F)'
# old code: cmp eax,3; jge ...
# new code: cmp eax,2; jg ...
$chanpos = 0
try {
if ($is64) {
$pos = 0
$rx = [regex]"$rxChannel-.{1,100}-48-8D"
do {
$m = $rx.match($code,$pos)
if (!$m.success) { break }
$chanpos = $m.index/3 + 2
$pos = $m.index + $m.length + 1
$offs = $BC::ToUInt32($bytes,$pos/3+1)
$diff = $pos/3+5+$offs - $stroffs
} until ($diff -ge 0 -and $diff -le 4096 -and $diff % 256 -eq 0)
if (!$m.success) {
$rx = [regex]"84-C0.{18,48}($rxChannel)-.{30,60}84-C0"
$m = $rx.matches($code)
if ($m.count -ne 1) { throw }
$chanpos = $m[0].groups[1].index/3 + 2
}
} else {
$flagOffs = [uint32]$stroffs + [uint32]$imagebase32
$flagOffsStr = $BC::ToString($BC::GetBytes($flagOffs))
$variants = "(?<channel>$rxChannel-.{1,100})-68-(?<flag>`$1-.{6}`$2)",
"68-(?<flag>`$1-.{6}`$2).{300,500}E8.{12,32}(?<channel>$rxChannel)",
"E8.{12,32}(?<channel>$rxChannel).{300,500}68-(?<flag>`$1-.{6}`$2)"
forEach ($variant in $variants) {
$pattern = $flagOffsStr -replace '^(..)-.{6}(..)', $variant
"`tLooking for $($pattern -replace '\?<.+?>', '')..."
$minDiff = 65536
foreach ($m in [regex]::matches($code, $pattern)) {
$maybeFlagOffs = $BC::toUInt32($bytes, $m.groups['flag'].index/3)
$diff = [Math]::abs($maybeFlagOffs - $flagOffs)
if ($diff % 256 -eq 0 -and $diff -lt $minDiff) {
$minDiff = $diff
$chanpos = $m.groups['channel'].index/3 + 2
}
}
}
if (!$chanpos) { throw }
}
} catch {
write-host -f red "`tUnable to find the channel code, try updating me"
write-host -f red "`thttp://stackoverflow.com/a/30361260"
return
}
$bytes[$chanpos] = 9
"`tPATCHED Chrome release channel restriction"
"`tWriting to a temporary dll..."
[IO.File]::WriteAllBytes("$dll.new",$bytes)
"`tBacking up the original dll..."
move -literal $dll "$dll.bak" -force
"`tRenaming the temporary dll as the original dll..."
move -literal "$dll.new" $dll -force
$pathsDone[$path.toLower()] = $true
write-host -f green "`tDONE.`n"
[GC]::Collect()
}
main