function arcmaj3_wint() { $main_console = new FluidActive('Arcmaj3 statistics web console'); $db = new FractureDB('futuqiur_arcmaj3'); #$main_console->DBTextEntry($db, 'am_urls', 'location', 0); #$main_console->DBRowEntry($db, 'am_urls', 1); #$main_console->DBTableEntry($db, 'am_urls'); #$main_console->DBRowEntry($db, 'am_urls', 1); #$main_console->getQueryCount($db); $allProjects = $db->getTable('am_projects'); $main_console->append('<small>'); $main_console->append('<big><b>Overall</b></big><br>'); $total = $db->countTable('am_urls'); $total = $total[0]; $total = $total['COUNT(*)']; #print_r($total); $crawled = $db->countRows('am_urls', ' WHERE barrel != \'0\''); $crawled = $crawled[0]; $crawled = $crawled['COUNT(*)']; #print_r($crawled); $remaining = $total - $crawled; if ($total == 0) { $pcCr = 0; $pcRm = 0; } else { $pcCr = round($crawled / $total * 100, 2); $pcRm = round($remaining / $total * 100, 2); } $main_console->append('Total URLs: ' . $total . '<br>'); $main_console->append('Remaining URLs: ' . $remaining . ' (' . $pcRm . '%)<br>'); $main_console->append('Crawled URLs: ' . $crawled . ' <b>(' . $pcCr . '%)</b><br>'); foreach ($allProjects as $index => $data) { $main_console->append('<br><br><big><b>Project: ' . $data['urlPattern'] . ' (ID ' . $data['id'] . ')</b></big><br>'); $total = $db->countTable('am_urls', 'project', $data['id']); $total = $total[0]; $total = $total['COUNT(*)']; #print_r($total); $crawled = $db->countTable('am_urls', 'project', $data['id'], ' AND barrel != \'0\''); $crawled = $crawled[0]; $crawled = $crawled['COUNT(*)']; #print_r($crawled); $remaining = $total - $crawled; if ($total == 0) { $pcCr = 0; $pcRm = 0; } else { $pcCr = round($crawled / $total * 100, 2); $pcRm = round($remaining / $total * 100, 2); } $main_console->append('Total URLs: ' . $total . '<br>'); $main_console->append('Remaining URLs: ' . $remaining . ' (' . $pcRm . '%)<br>'); $main_console->append('Crawled URLs: ' . $crawled . ' <b>(' . $pcCr . '%)</b><br>'); } $main_console->append('</small>'); $main_console->close(); $db->close(); }
function DBSimpleSubmissionHandler() { $authorizationKey = $_REQUEST['authorizationKey']; $dbName = $_REQUEST['db']; $dataTargetTable = $_REQUEST['dataTargetTable']; $dataTargetField = $_REQUEST['dataTargetField']; $dataTargetRowId = $_REQUEST['dataTargetRowId']; $dataValue = $_REQUEST['dataValue']; global $generalAuthKey; //echo $authorizationKey; if ($authorizationKey == $generalAuthKey) { //echo 'true'; $db = new FractureDB($dbName); $db->setField($dataTargetTable, $dataTargetField, $dataValue, $dataTargetRowId); $db->close(); } }
function insertCoal($file = null, $csump = null) { $db = new FractureDB('futuqiur_ember'); global $l; $l->a("Started insertCoal<br>"); $status = 0; $id = null; if (is_null($file)) { $coal = coalFromUpload(); $details = $coal['details']; } else { $coal = coalFromFile($file, $csump); $details = $coal['details']; } $status = status_add($status, $coal['status']); global $coalCompressionType; $details['compression'] = $coalCompressionType; global $coalVersion; $details['coalVersion'] = $coalVersion; $detailsCsum = Csum_import($details['csum']); if ($detailsCsum->len == 0) { $details['blocks'] = ''; } $compressed = serialize($details); $c = new Csum($compressed); $chunkInfo = insertChunk($compressed, $c); $status = status_add($status, $chunkInfo['status']); if (check($status, true)) { $chunkId = $chunkInfo['id']; $id = $db->addRow('strings', 'chunk, md5', '\'' . $chunkId . '\', UNHEX(\'' . $detailsCsum->md5 . '\')'); //sleep(6); if (!checkCoal($id)) { $status = 45; } } unlink($file); $db->close(); return array('id' => $id, 'csum' => $details['csum'], 'filename' => $details['filename'], 'status' => $status); }
function arcmaj3_barrel_expire($barrelId) { echo 'Expiring barrel ' . $barrelId . '...<br>' . "\n"; $db = new FractureDB('futuqiur_arcmaj3'); $db->updateColumn('am_urls', 'barrel', '0', 'barrel', $barrelId); $db->setField('am_barrels', 'status', '2', $barrelId); echo 'Expired barrel ' . $barrelId . '.<br>' . "\n"; $db->close(); }
function DBSimpleSubmissionHandler() { $authorizationKey = $_REQUEST['authorizationKey']; $dbName = $_REQUEST['db']; $dataTargetTable = $_REQUEST['dataTargetTable']; $dataTargetField = $_REQUEST['dataTargetField']; $dataTargetRowId = $_REQUEST['dataTargetRowId']; $dataValue = $_REQUEST['dataValue']; $db = new FractureDB($dbName); $db->setField($dataTargetTable, $dataTargetField, $dataValue, $dataTargetRowId); $db->close(); }
function store($data, $csumb) { $csum = new Csum($data); if (!$csum->matches($csumb)) { return null; } $status = 0; //Why I'm not doing this type of deduplication: It could lead to inaccurate metadata about the coal. //Ya know, screw that. Coal *shouldn't support* file uploads — that should be handled by higher level software. I'm putting this back in for now, and just remember that the Coal file-level metadata is only an ugly, non-archival-quality, incomplete hack for while Ember doesn't exist yet to take care of that. $db = new FractureDB('futuqiur_ember'); $potentialDuplicates = $db->getColumnsUH('strings', 'id', 'md5', $csum->md5); foreach ($potentialDuplicates as $potential) { //echo 'duplicate testing'; $potentialRecord = retrieveCoal($potential['id']); if (!is_null($potentialRecord)) { $potentialData = $potentialRecord['data']; $potentialCsum = Csum_import($potentialRecord['csum']); if ($potentialData === $data && matches($csum, $potentialCsum)) { $duplicateId = $potential['id']; return array('id' => $duplicateId, 'csum' => $potentialRecord['csum'], 'status' => $status); } } } $db->close(); //echo 'gotten here'; $filename = 'coal_temp/' . uniqid() . '.cstf'; file_put_contents($filename, $data); return insertCoal($filename, $csum); }