<?php require_once dirname(__FILE__) . '/../../init.php'; $total = array(); foreach (file(dirname(__FILE__) . '/stat') as $row) { $userId = extractId($row, "/User:\\s+\\d+/i"); $oldStatus = extractId($row, "/Old:\\s+\\d+/"); $newStatus = extractId($row, '/status_id=\'?\\d+\'?/i'); //var_dump($userId,$oldStatus,$newStatus); if ($newStatus == 11) { $total[$userId] = 11; } elseif ($oldStatus == 10 && !isset($total[$userId])) { $total[$userId] = 10; } } $fp = fopen(dirname(__FILE__) . '/patch.sql', 'w'); foreach ($total as $k => $v) { if ($v == 10) { fputs($fp, "update panelie_user set status_id=10 where user_id={$k};\n"); } } fclose($fp); function extractId($row, $pattern) { preg_match($pattern, $row, $firstStep); preg_match('/\\d+/', $firstStep[0], $secondStep); return $secondStep[0]; }
function isSupportedWonderHowto($id) { $ret = true; // Any videos not from these services are unsupported if (!preg_match("@videojug|youtube|howcast|5min@", $id)) { $ret = false; } else { // If it's a supported service extract which service and the video id, then check if it exists $url_re = '@value&61;"(http://[^"]+)"@'; if (preg_match($url_re, $id, $url)) { $url = $url[1]; $url = htmlspecialchars_decode($url); } else { // No match. Ignore. error("oops, couldn't find a url for {$id}\n"); return $ret; } $service_re = '@http://www.(videojug|youtube|howcast|5min).com/@'; if (preg_match($service_re, $url, $service)) { $service = $service[1]; } else { // No match. Ignore. error("oops, couldn't find a service for url: {$url}\n"); return $ret; } $id = extractId($url, $service); // If we can extract an id, see if it's a valid video, otherwise return true $ret = strlen($id) ? isSupportedVideo($service, $id) : $ret; } return $ret; }