public static function fetch($id) { initdb(); // Fetch the user's home page and look for profile information there $user = ORM::for_table('users')->where_id_is($id)->find_one(); echo "Looking for representative h-card for " . $user->url . "\n"; $client = new HTTP(); $data = $client->get($user->url); $parsed = Mf2\parse($data['body'], $user->url); $representative = Mf2\HCard\representative($parsed, $user->url); if ($representative) { echo "Found it!\n"; print_r($representative); if (array_key_exists('name', $representative['properties'])) { $user->name = $representative['properties']['name'][0]; } if (array_key_exists('photo', $representative['properties'])) { $user->photo = $representative['properties']['photo'][0]; } $user->save(); } else { echo "Couldn't find one\n"; } }
<?php require_once 'phplib/populator.php'; initdb(); session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Tution Book :::::::: Zakir</title> <link rel = "stylesheet" type = "text/css" href = "ExpreStyle.css" /> </head> <body> <center> <table width="780" border="0"> <tr> <td><img src="imgs/banner.jpg" height="100" width="780" /></td> </tr> <tr> <td> <table width="780" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"><a href="start.php">Home</a></td> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"><a href="login.php">Login</a></td> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"><a href="join.php">Join Us</a></td> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"><a href="logout.php">Log Out</a></td> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"><a href="about.php">About Us</a></td> <td width="70" class="MOut" onmouseover="this.className='MOver'" onmouseout="this.className='MOut'"> </td> </tr>
#!/usr/bin/php -q <?php //////////////////////////////////////////////////////////////////////////// // $Id$ // // Description: statistics cleanup // //////////////////////////////////////////////////////////////////////////// include "cleanup-functions.php"; include "cleanup-config.php"; // ************* PRELIMINARY TASKS, DATA INIT ************* set_time_limit(0); // get for which revision we generate stats if ($argv[1] == "") { $rev = "HEAD"; } else { $rev = $argv[1]; } // open database connection $dbh = initdb($sql_host, $sql_user, $sql_pass, $sql_db); debug(10, "cleanup statistics"); $res = @mysql_query("DELETE FROM essential WHERE rev='{$rev}' AND " . "sdate < DATE_SUB(NOW(),INTERVAL '60' DAY)", $dbh); if (!$res) { send_err("SQL error: delete by sdate for {$rev} branch."); die; } $deleted = @mysql_affected_rows($dbh); debug(10, "deleted {$deleted} records for {$rev} branch"); closedb($dbh); // send_ok("Deleted $deleted records for $rev branch.");
} /* figure out which site we're displaying */ $sitedata = null; $sitehost = implode('.', array_slice(explode('.', $_SERVER['HTTP_HOST']), -2)); foreach ($aliases as $host => $alias) { if ($sitehost == $host) { $sitedata = $sites[$alias]; } } if (is_null($sitedata)) { /* we weren't able to find the site */ // header('Location: http://www.somuchdoge.com', 302); exit; } /* bring up the database */ $dbs = initdb($sitedata); /* gather up the meme image & text for our display */ try { $s1 = $dbs['datadb']->query('SELECT * FROM data ORDER BY RANDOM() LIMIT 1'); } catch (Exception $e) { die('Site is experiencing problems. Please try again later. (err=query_db1)'); } $memedata = $s1->fetch(); if (!$memedata) { die('Site is experiencing problems. Please try again later. (err=query_db2)'); } $memeword = explode('||', $memedata['exp']); $memeword = $memeword[array_rand($memeword)]; $memeimg = "{$sitedata['imgs']}/{$memedata['filename']}"; $memeroot = "{$sitedata['root']}"; /* process our request */
public static function send($id, $client = false, $http = false) { initdb(); $webmention = ORM::for_table('webmentions')->where('id', $id)->find_one(); if (!$webmention) { echo 'Webmention ' . $id . ' was not found' . "\n"; return; } if (!$client) { $client = new MentionClient(); } if (!$http) { $http = new HTTP(); } self::$http = $http; // Discover the webmention or pingback endpoint $endpoint = $client->discoverWebmentionEndpoint($webmention->target); if (!$endpoint) { // If no webmention endpoint found, try to send a pingback $pingbackEndpoint = $client->discoverPingbackEndpoint($webmention->target); // If no pingback endpoint was found, we can't do anything else if (!$pingbackEndpoint) { return self::updateStatus($webmention, null, 'not_supported'); } $webmention->pingback_endpoint = $pingbackEndpoint; $webmention->save(); $success = $client->sendPingbackToEndpoint($pingbackEndpoint, $webmention->source, $webmention->target); return self::updateStatus($webmention, null, $success ? 'accepted' : 'error'); } // There is a webmention endpoint, send the webmention now $webmention->webmention_endpoint = $endpoint; $webmention->save(); $params = []; if ($webmention->code) { $params['code'] = $webmention->code; if ($webmention->realm) { $params['realm'] = $webmention->realm; } } if ($webmention->vouch) { $params['vouch'] = $webmention->vouch; } $response = $client->sendWebmentionToEndpoint($endpoint, $webmention->source, $webmention->target, $params); if (in_array($response['code'], [200, 201, 202])) { $status = 'accepted'; $webmention->complete = $response['code'] == 200 ? 1 : 0; // Check if the endpoint returned a status URL if (array_key_exists('Location', $response['headers'])) { $webmention->webmention_status_url = \Mf2\resolveUrl($endpoint, $response['headers']['Location']); // TODO: queue a job to poll the endpoint for updates and deliver to the callback URL } else { // No status URL was returned, so we can't follow up with this later. Mark as complete. $webmention->complete = 1; } } else { $webmention->complete = 1; $status = 'error'; } $webmention->save(); $result = self::updateStatus($webmention, $response['code'], $status, $response['body']); $pdo = ORM::get_db(); $pdo = null; return $result; }