public static function dispatch() { $id = get_http_var('id'); $action = get_http_var('action'); $sql = <<<EOT SELECT m.id,m.journo_id, j.ref, j.prettyname, j.oneliner, m.url, m.submitted, m.reason FROM missing_articles m LEFT JOIN journo j ON m.journo_id=j.id WHERE m.id=?; EOT; $row = db_getRow($sql, $id); $w = new MissingArticleWidget($row); // perform whatever action has been requested $w->perform($action); // is request ajax? $ajax = get_http_var('ajax') ? true : false; if ($ajax) { $w->emit_core(); } else { // not an ajax request, so output a full page admPageHeader("Missing Article", "MissingArticleWidget::emit_head_js"); print "<h2>Missing article</h2>\n"; $w->emit_full(); admPageFooter(); } }
function display() { $action = get_http_var("action"); if ($action == 'edit') { $id = get_http_var('id'); $entry = db_getRow("SELECT * FROM journo_awards WHERE journo_id=? AND id=?", $this->journo['id'], $id); ?> <h2>Edit award</h2> <?php $this->showForm($entry); ?> <a class="remove" href="<?php echo $this->pagePath; ?> ?ref=<?php echo $this->journo['ref']; ?> &remove_id=<?php echo h($entry['id']); ?> ">Remove this award</a> <?php } if ($action == 'new') { ?> <h2>Add award</h2> <?php $this->showForm(null); } }
public static function fetch_one($id) { $sql = <<<EOT SELECT o.id, o.journo_id, o.url, o.title, o.pubdate, o.publication, o.status, j.ref AS journo_ref, j.prettyname as journo_prettyname FROM journo_other_articles o JOIN journo j ON o.journo_id=j.id WHERE o.id=? EOT; return db_getRow($sql, $id); }
function display() { $action = get_http_var("action"); if ($action == 'edit') { $edu_id = get_http_var('id'); $edu = db_getRow("SELECT * FROM journo_education WHERE journo_id=? AND id=?", $this->journo['id'], $edu_id); if ($edu['kind'] == 's') { ?> <h2>Edit education (school)</h2> <?php $this->showSchoolForm($edu); ?> <a class="remove" href="<?php echo $this->pagePath; ?> ?ref=<?php echo $this->journo['ref']; ?> &remove_id=<?php echo h($edu['id']); ?> ">Remove this school</a> <?php } else { ?> <h2>Edit education (university)</h2> <?php $this->showUniForm($edu); ?> <a class="remove" href="<?php echo $this->pagePath; ?> ?ref=<?php echo $this->journo['ref']; ?> &remove_id=<?php echo h($edu['id']); ?> ">Remove this university</a> <?php } } if ($action == 'new_school') { ?> <h2>Add education (school)</h2> <?php $this->showSchoolForm(null); } if ($action == 'new_uni') { ?> <h2>Add education (university)</h2> <?php $this->showUniForm(null); } }
function display() { ?> <h2>Contact Information</h2><?php $email = db_getRow("SELECT * FROM journo_email WHERE journo_id=? AND approved=true AND srctype='' LIMIT 1", $this->journo['id']); $phone = db_getRow("SELECT * FROM journo_phone WHERE journo_id=? LIMIT 1", $this->journo['id']); $address = db_getRow("SELECT * FROM journo_address WHERE journo_id=? LIMIT 1", $this->journo['id']); $twitter_id = journo_fetchTwitterID($this->journo['id']); $contact = array('email' => $email, 'phone' => $phone, 'address' => $address, 'twitter' => $twitter_id); $this->showForm($contact); }
function __construct() { $ref = get_http_var('ref'); $this->journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref); $r = array('reason_web' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email' => "Edit Journalisted profile for {$this->journo['prettyname']}", 'reason_email_subject' => "Edit {$this->journo['prettyname']} on Journalisted"); if (get_http_var('ajax')) { $this->P = person_if_signed_on(); } else { // if not ajax, it's ok to redirect to login screen $this->P = person_signon($r); } }
function cache_emit($cacheid, $genfunc = null, $maxage = null) { $sql = <<<EOT SELECT EXTRACT(EPOCH FROM NOW()-gentime) as elapsed, content \tFROM htmlcache \tWHERE name=? EOT; $valid = false; $content = ''; $row = db_getRow($sql, $cacheid); if ($row) { if ($maxage === null || $row['elapsed'] < $maxage) { $valid = true; } } if ($valid) { printf("<!-- cache: '%s' fetched from cache -->\n", $cacheid); print $row['content']; printf("<!-- cache: end '%s' -->\n", $cacheid); } else { /* if we got this far the cache entry is missing or expired, so * we want to rebuild it (if we can) */ if ($genfunc) { /* very first thing - update the gentime to prevent other requests * trying to regenerate the cache! * There is still a small window between the SELECT and here where * another request could sneak in, but it's probably not a big risk * in practice. * TODO: look again at getting the SELECT to lock the row! */ db_do("UPDATE htmlcache SET gentime=NOW() WHERE name=?", $cacheid); db_commit(); printf("<!-- cache: '%s' regenerated -->\n", $cacheid); ob_start(); cache_gen_annotated($cacheid, $genfunc); $content = ob_get_contents(); ob_flush(); printf("<!-- cache: end '%s' -->\n", $cacheid); db_do("DELETE FROM htmlcache WHERE name=?", $cacheid); db_do("INSERT INTO htmlcache (name,content) VALUES(?,?)", $cacheid, $content); db_commit(); } else { printf("<!-- cache: '%s' not found. uhoh. -->\n", $cacheid); } } }
function display() { $action = get_http_var("action"); if ($action == 'edit') { $emp_id = get_http_var('id'); $emp = db_getRow("SELECT * FROM journo_employment WHERE journo_id=? AND id=?", $this->journo['id'], $emp_id); $emp['current'] = $emp['current'] == 't' ? TRUE : FALSE; if ($emp['kind'] == 'e') { ?> <h2>Edit employment</h2> <?php $this->showEmploymentForm($emp); } if ($emp['kind'] == 'f') { ?> <h2>Edit freelance experience</h2> <?php $this->showFreelanceForm($emp); } ?> <a class="remove" href="<?php echo $this->pagePath; ?> ?ref=<?php echo $this->journo['ref']; ?> &remove_id=<?php echo h($emp['id']); ?> ">Remove this experience</a> <?php } if ($action == 'new_employment') { ?> <h2>Add employment</h2> <?php $this->showEmploymentForm(null); } if ($action == 'new_freelance') { ?> <h2>Add freelance experience</h2> <?php $this->showFreelanceForm(null); } }
function view() { $P = person_if_signed_on(); if (is_null($P)) { // only for logged-in users header("Location: /"); return; } /* they might have multiple profiles, thus option to specify one here */ $ref = strtolower(get_http_var('ref')); $journo = NULL; if ($ref) { $journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref); if (!$journo) { header("HTTP/1.0 404 Not Found"); return; } } if (is_null($journo)) { // no journo given - if person is logged on, see if they are associated with a journo (or journos) $editables = db_getAll("SELECT j.* FROM ( journo j INNER JOIN person_permission p ON p.journo_id=j.id) WHERE p.person_id=? AND p.permission='edit'", $P->id()); if (sizeof($editables) == 0) { header("Location: /"); return; } elseif (sizeof($editables) > 1) { /* let user pick which one... */ tmpl_pickjourno($editables); return; } else { // sizeof($editables) == 1 $journo = $editables[0]; // just one journo. } } // is this person allowed to edit this journo? if (!db_getOne("SELECT id FROM person_permission WHERE person_id=? AND journo_id=? AND permission='edit'", $P->id(), $journo['id'])) { // nope $journo = null; } if (!is_null($journo)) { header("Location: /{$journo['ref']}"); } else { header("Location: /f**k"); } }
function __construct() { $this->pageName = "photo"; $this->pageTitle = "Photo"; $this->pagePath = "/profile_photo"; $this->pageParams = array('head_extra_fn' => array(&$this, 'extra_head')); $this->uploadError = NULL; parent::__construct(); // fetch the current photo, if any $sql = <<<EOT SELECT p.id, p.image_id, p.is_thumbnail, i.width, i.height, i.filename, i.created FROM (journo_photo p INNER JOIN image i ON i.id=p.image_id ) WHERE p.journo_id=? LIMIT 1 EOT; $this->photo = db_getRow($sql, $this->journo['id']); if (!is_null($this->photo)) { $this->photo['is_thumbnail'] = $this->photo['is_thumbnail'] == 't' ? TRUE : FALSE; } }
function OLD_api_getJourno_invoke($params) { $j = $params['journo']; if (is_null($j)) { api_error("missing required parameter: 'journo'"); return; } $jfield = is_numeric($j) ? 'id' : 'ref'; $sql = "SELECT id,ref,prettyname,firstname,lastname,oneliner FROM journo WHERE status='a' AND {$jfield}=?"; $r = db_getRow($sql, $j); if (is_null($r)) { api_error("No matching journalist found"); return; } $journo = array(); foreach (array('id', 'ref', 'prettyname', 'firstname', 'lastname', 'oneliner') as $field) { $journo[$field] = $r[$field]; } $output = array('results' => $journo); api_output($output); }
function publication_collect($pub_id) { $p = db_getRow("SELECT * FROM organisation WHERE id=?", $pub_id); if (0) { /* recent articles */ $arts = db_getAll("SELECT id,title,pubdate,permalink FROM article WHERE srcorg=? ORDER BY pubdate DESC LIMIT 10", $pub_id); foreach ($arts as &$a) { article_augment($a); } unset($a); $p['recent_articles'] = $arts; } /* principles */ if ($p['sop_url']) { $p['principles'] = array('name' => $p['sop_name'], 'url' => $p['sop_url']); } else { $p['principles'] = null; } unset($p['sop_url']); unset($p['sop_name']); /* recent journos */ $sql = <<<EOT SELECT DISTINCT j.ref, j.prettyname, j.lastname FROM ( ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id ) INNER JOIN article a ON a.id=attr.article_id) WHERE a.srcorg=? AND a.status='a' AND a.pubdate > NOW() - INTERVAL '1 week' ORDER BY j.lastname; EOT; $journos = db_getAll($sql, $pub_id); $p['recent_journos'] = $journos; /* address (vcard adr fields) */ $foo = db_getOne("SELECT adr FROM pub_adr WHERE pub_id=?", $pub_id); $p['adr'] = $foo ? vcard_parse_adr($foo) : NULL; /* telephone (assume type='voice' for now) */ $p['tel'] = db_getOne("SELECT phone FROM pub_phone WHERE pub_id=?", $pub_id); return $p; }
function view() { if (!admCheckAccess()) { exit; } // should return error code? $j = get_http_var('j'); $j = strtolower($j); $journo = db_getRow("SELECT id,ref,prettyname,oneliner,status FROM journo WHERE ref=?", $j); if (is_null($journo)) { // TODO: 404 return; } $sql = <<<EOT SELECT p.id,p.email,p.name,perm.permission FROM person p INNER JOIN person_permission perm ON perm.person_id=p.id WHERE perm.permission='edit' AND perm.journo_id=? EOT; $users = db_getAll($sql, $journo['id']); $journo['arts'] = journo_collectArticles($journo, 5); $journo['num_arts'] = db_getOne("SELECT COUNT(*) FROM journo_attr WHERE journo_id=?", $journo['id']); $journo['linked_users'] = $users; template($journo); }
function DoRemoveAlert($P, $journo_ref) { $journo = db_getRow("SELECT id,prettyname FROM journo WHERE ref=?", $journo_ref); if (!$journo) { err("bad journalist ref"); } $url = "/{$journo_ref}"; $journo_id = $journo['id']; db_query("DELETE FROM alert WHERE journo_id=? AND person_id=?", $journo_id, $P->id); db_commit(); print "<p class=\"infomessage\"><a href=\"{$url}\">{$journo['prettyname']}</a> was removed from your list.</p>\n"; }
function handleSubmit() { $admired = $this->entriesFromHTTPVars(); // add ids of journos in the database foreach ($admired as &$a) { $a['admired_id'] = null; if ($a['admired_ref']) { $foo = db_getRow("SELECT id,prettyname FROM journo WHERE ref=?", $a['admired_ref']); if ($foo) { $a['admired_id'] = $foo['id']; $a['admired_name'] = $foo['prettyname']; } } } unset($a); db_do("DELETE FROM journo_admired WHERE journo_id=?", $this->journo['id']); foreach ($admired as &$a) { db_do("INSERT INTO journo_admired (journo_id,admired_name,admired_id) VALUES (?,?,?)", $this->journo['id'], $a['admired_name'], $a['admired_id']); // $id = db_getOne( "SELECT lastval()" ); } db_commit(); eventlog_Add("modify-admired", $this->journo['id']); }
function handle_pingback($method, $params, $extra) { list($sourceURI, $targetURI) = $params; // fetch the source URI to verify that the source does indeed link to the target $html = file_get_contents($sourceURI); if ($html === FALSE) { CRAPLOG("0x10\n"); return 0x10; // "The source URI does not exist." } // cheesy conversion to utf-8 $html = mb_convert_encoding($html, 'UTF-8', mb_detect_encoding($html, 'UTF-8, ISO-8859-1, windows-1252', true)); $html = html_entity_decode($html, ENT_COMPAT, 'UTF-8'); if (strpos($html, $targetURI) === FALSE) { CRAPLOG("0x11\n"); return 0x11; // "The source URI does not contain a link to the target URI, and so cannot be used as a source." } // check URL, try and extract journo ref $bits = crack_url($targetURI); $path = $bits['path']; $m = array(); $ref = null; if (preg_match("%([a-zA-Z0-9]+-[-a-zA-Z0-9]+)/?%", $path, $m)) { $ref = $m[1]; } if ($ref === null) { CRAPLOG("0x21\n"); return 0x21; // "The specified target URI cannot be used as a target." } // valid journo? $journo = db_getRow("SELECT * FROM journo WHERE ref=? AND status='a'", $ref); if ($journo === null) { CRAPLOG("0x21 (invalid journo)\n"); return 0x21; // "The specified target URI cannot be used as a target." } // try and extract title to use as description $desc = $sourceURI; $m = array(); if (preg_match('!<title>(.*?)</title>!i', $html, $m)) { $desc = $m[1]; $desc = preg_replace('/\\s+/', ' ', $desc); } // already got this pingback? if (db_getOne("SELECT id FROM journo_weblink WHERE journo_id=? AND url=? AND approved=true", $journo['id'], $sourceURI)) { CRAPLOG("0x30\n"); return 0x30; // "The pingback has already been registered." } // OK. time to add it! $sql = <<<EOT INSERT INTO journo_weblink (journo_id, url, description, approved, kind, rank) VALUES ( ?,?,?,true,'pingback',500) EOT; db_do($sql, $journo['id'], $sourceURI, $desc); db_commit(); CRAPLOG("added.\n"); return "Ping registered - thanks"; }
function journo_fetchTwitterID($journo_id) { $twitter_id = NULL; $l = db_getRow("SELECT * FROM journo_weblink WHERE journo_id=? AND kind='twitter' LIMIT 1", $journo_id); if (!is_null($l)) { $matches = array(); if (preg_match('%.*twitter.com/([^/?]+)$%i', $l['url'], $matches)) { $twitter_id = $matches[1]; } } return $twitter_id; }
<?php require_once '../conf/general'; require_once '../phplib/page.php'; require_once '../phplib/journo.php'; require_once '../phplib/misc.php'; require_once '../phplib/eventlog.php'; require_once '../phplib/recaptchalib.php'; require_once '../../phplib/db.php'; require_once '../../phplib/utility.php'; $ref = strtolower(get_http_var('journo')); $_journo = db_getRow("SELECT * FROM journo WHERE ref=?", $ref); $data = journo_collectData($_journo); $_keys = parse_ini_file(OPTION_JL_FSROOT . '/conf/recaptcha.ini'); page_header("Email {$_journo['prettyname']}'s profile to a friend"); ?> <div class="main"> <?php $params = formFetch(); if ($params['action'] == 'go') { $errs = formCheck($params); if ($errs) { formEmit($params, $errs); } else { // cool - all ready to go. do_it($params); } } else { formEmit($params); } ?>
public static function fetch_one($id) { $sql = <<<EOT SELECT l.*, j.ref AS journo_ref, j.prettyname as journo_prettyname FROM journo_weblink l JOIN journo j ON l.journo_id=j.id WHERE l.id=? EOT; return db_getRow($sql, $id); }
static function from_db($art_id) { $art = db_getRow("SELECT * FROM article WHERE id=?", $art_id); $date_fields = array('pubdate', 'lastscraped', 'firstseen', 'lastseen'); foreach ($date_fields as $f) { $art[$f] = new DrongoDateTime($art[$f]); } // $foo = db_getAll("SELECT j.ref FROM (journo_attr attr INNER JOIN journo j ON j.id=attr.journo_id) WHERE attr.article_id=?", $art_id); $authors = array(); foreach ($foo as $row) { $authors[] = $row['ref']; } $art['authors'] = join(',', $authors); return new ArticleModelForm($art); }
function __construct($journo, $blank = FALSE) { $this->journo = $journo; if (!$blank) { $this->url = get_http_var('url', ''); if ($this->url) { $this->url = clean_url($this->url); } // so we can detect if url is changed $this->prev_url = get_http_var('prev_url', ''); } if ($blank || !$this->url && !$this->prev_url) { $this->state = 'initial'; return; } $msg = is_sane_article_url($this->url); if (!is_null($msg)) { $this->errs['url'] = $msg; $this->state = 'bad_url'; return; } // article already in DB? $art_id = article_find($this->url); if (is_null($art_id)) { // nope - try and scrape it list($ret, $txt) = scrape_ScrapeURL($this->url, $this->journo['ref']); if ($ret != 0) { $this->errs['error_message'] = "Journa<i>listed</i> had problems reading this article"; $this->state = 'scrape_failed'; $this->_register_error(); return; } $arts = scrape_ParseOutput($txt); if (sizeof($arts) < 1) { $this->errs['error_message'] = "Journa<i>listed</i> had problems reading this article"; $this->state = 'scrape_failed'; $this->_register_error(); return; } $art_id = $arts[0]; } // if we get this far, $art_id will be set // fetch some basic details about the article $art = db_getRow("SELECT id,title,permalink,pubdate,srcorg FROM article WHERE id=?", $art_id); $sql = <<<EOT SELECT j.id,j.prettyname,j.ref FROM (journo j INNER JOIN journo_attr attr ON attr.journo_id=j.id) WHERE attr.article_id=? EOT; $journos = db_getAll($sql, $art_id); $art['journos'] = $journos; $this->article = $art; // attributed to the expected journo? $got_expected_journo = FALSE; foreach ($journos as $j) { if ($j['id'] == $this->journo['id']) { $got_expected_journo = TRUE; break; } } if ($got_expected_journo) { // all is well. $this->state = 'done'; return; } else { // $this->errs['error_message'] = "Journa<i>listed</i> had trouble reading the byline"; $this->state = 'journo_mismatch'; $this->_register_error(); return; } }
function journo_create($fullname) { $fullname = trim($fullname); $fullname = preg_replace('/\\s+/', ' ', $fullname); // collapse spaces // TODO: should deal with name titles/suffixes ("Dr." etc) but not a big deal $ref = toRef($fullname); // special case to deal with one-word names if (strpos($ref, '-') === FALSE) { $ref .= "-1"; } // make sure ref is unique $i = 1; while (db_getOne("SELECT id FROM journo WHERE ref=?", $ref)) { $ref = toRef($fullname) . "-" . $i++; } // work out firstname and lastname $parts = explode(' ', $fullname); $firstname = array_shift($parts); if (is_null($firstname)) { $firstname = ''; } $lastname = array_pop($parts); if (is_null($lastname)) { $lastname = ''; } $sql = <<<EOT INSERT INTO journo (ref,prettyname,firstname,lastname,status,firstname_metaphone,lastname_metaphone,created) VALUES (?,?,?,?,?,?,?,NOW()) EOT; db_do($sql, $ref, $fullname, $firstname, $lastname, 'i', substr(metaphone($firstname), 0, 4), substr(metaphone($lastname), 0, 4)); db_commit(); return db_getRow("SELECT * FROM journo WHERE ref=?", $ref); }
function SetBios($email_ids, $val) { $cnt = 0; foreach ($email_ids as $email_id) { $row = db_getRow("SELECT journo_id,approved FROM journo_email WHERE id=?", $email_id); if ($row['approved'] != $val) { db_do("UPDATE journo_email SET approved=? WHERE id=?", $val, $email_id); db_do("DELETE FROM htmlcache WHERE name=?", 'j' . $row['journo_id']); $cnt += 1; } } db_commit(); printf("<p><strong>%s %d email address(es)</strong></p>\n", $val == 't' ? 'approved' : 'unapproved', $cnt); }
function ConfirmRemoveEmail($journo_id, $email_id) { $l = db_getRow("SELECT * FROM journo_email WHERE id=?", $email_id); $journo = db_getRow("SELECT * FROM journo WHERE id=?", $journo_id); ?> <form method="post" action="/adm/journo"> <p>Are you sure you want to remove <code><?php echo $l['email']; ?> </code> from <?php echo $journo['prettyname']; ?> ?<br /> <input type="hidden" name="email_id" value="<?php echo $email_id; ?> " /> <input type="hidden" name="journo_id" value="<?php echo $journo_id; ?> " /> <input type="hidden" name="action" value="remove_email_confirmed" /> <input type="submit" name="submit" value="Yes!" /> <a href="?journo_id=<?php echo $journo_id; ?> ">No, I've changed my mind</a> </form> <?php }
function account_page() { $r = array('reason_web' => "Log in", 'reason_email' => "Log in to Journalisted", 'reason_email_subject' => 'Log in to Journalisted'); $P = person_signon($r); $passwordbox = new PasswordBox(); // linked to a journo for editing (or claim pending)? $sql = <<<EOT SELECT j.*, perm.permission FROM journo j INNER JOIN person_permission perm ON perm.journo_id=j.id WHERE perm.permission in ('edit','claimed') AND perm.person_id=? LIMIT 1 EOT; $journo = db_getRow($sql, $P->id()); // signed up for newsletters? $newsletter = db_getOne("SELECT person_id FROM person_receives_newsletter WHERE person_id=?", $P->id()) ? TRUE : FALSE; // how many alerts set up? $alert_cnt = db_getOne("SELECT count(*) FROM alert WHERE person_id=?", $P->id()); // what bits of profile have been filled in? $photo_cnt = 0; $edu_cnt = 0; $emp_cnt = 0; $book_cnt = 0; $award_cnt = 0; $admired_cnt = 0; if (!is_null($journo)) { $photo_cnt = db_getOne("SELECT count(*) FROM journo_photo WHERE journo_id=?", $journo['id']); $edu_cnt = db_getOne("SELECT count(*) FROM journo_education WHERE journo_id=?", $journo['id']); $emp_cnt = db_getOne("SELECT count(*) FROM journo_employment WHERE journo_id=?", $journo['id']); $book_cnt = db_getOne("SELECT count(*) FROM journo_books WHERE journo_id=?", $journo['id']); $award_cnt = db_getOne("SELECT count(*) FROM journo_awards WHERE journo_id=?", $journo['id']); $admired_cnt = db_getOne("SELECT count(*) FROM journo_admired WHERE journo_id=?", $journo['id']); $weblink_cnt = db_getOne("SELECT count(*) FROM journo_weblink WHERE kind<>'pingback' AND journo_id=?", $journo['id']); // collect contact details from all around $sql = <<<EOT SELECT ( SELECT count(*) FROM journo_address WHERE journo_id=? ) + ( SELECT count(*) FROM journo_phone WHERE journo_id=? ) + ( SELECT count(*) FROM journo_email WHERE approved=true AND journo_id=? ) + ( SELECT count(*) FROM journo_weblink WHERE kind='twitter' AND journo_id=? ) + ( SELECT count(*) FROM journo_address WHERE journo_id=? ); EOT; $contact_cnt = db_getOne($sql, $journo['id'], $journo['id'], $journo['id'], $journo['id'], $journo['id']); // combined article count (ugh) $sql = <<<EOT SELECT ( SELECT COUNT(*) FROM (article a INNER JOIN journo_attr attr ON attr.journo_id=a.id) WHERE a.status='a' AND attr.journo_id=? ) + ( SELECT COUNT(*) FROM journo_other_articles WHERE status='a' AND journo_id=? ) EOT; $article_cnt = db_getOne($sql, $journo['id'], $journo['id']); } $name_or_email = $P->name_or_blank() ? $P->name : $P->email; $title = "Your account"; page_header($title); if (!is_null($journo) && $journo['permission'] == 'edit' && $journo['status'] == 'i') { emit_inactive_note($journo); } ?> <div class="main account"> <h2>Welcome to journa<i>listed</i>, <?php echo $name_or_email; ?> </h2> <?php /* show a bunch of things user could/should do now... */ if (!is_null($journo) && $journo['permission'] == 'claimed') { emit_claim_pending($journo); } if (!is_null($journo) && $journo['permission'] == 'edit') { ?> Your public profile is at:<br/> <a class="public-profile-location" href="/<?php echo $journo['ref']; ?> "><?php echo OPTION_BASE_URL . '/' . $journo['ref']; ?> </a> <br/> <?php } ?> Things you can do now... <br/> <?php $n = 0; // track the number of items we're displaying if (!is_null($journo) && $journo['permission'] == 'edit') { if ($article_cnt < OPTION_JL_JOURNO_ACTIVATION_THRESHOLD) { emit_add_articles($journo); ++$n; } if ($photo_cnt == 0) { emit_add_photo($journo); ++$n; } if ($emp_cnt == 0) { emit_add_experience($journo); ++$n; } if ($edu_cnt == 0) { emit_add_education($journo); ++$n; } if ($weblink_cnt == 0) { emit_add_links($journo); ++$n; } if ($admired_cnt == 0) { emit_add_admired($journo); ++$n; } if ($contact_cnt == 0) { emit_add_contact_details($journo); ++$n; } } if ($alert_cnt == 0 && $n < 6 || $n < 2) { emit_add_alerts($alert_cnt); ++$n; } if (!$newsletter && $n < 6 || $n < 2) { emit_subscribe_to_newsletter($newsletter); ++$n; } ?> </div> <!-- end main --> <div class="sidebar"> <div class="box"> <div class="head"> <h3><?php echo $passwordbox->title(); ?> </h3> </div> <div class="body"> <?php $passwordbox->emit(); ?> <p>If you need to change your email address, please <?php echo SafeMailto(OPTION_TEAM_EMAIL, "let us know"); ?> </p> </div> <div class="foot"></div> </div> </div> <!-- end sidebar --> <?php page_footer(); }
require_once '../phplib/xap.php'; //require_once '../phplib/misc.php'; //require_once '../phplib/gatso.php'; //require_once '../phplib/cache.php'; require_once '../../phplib/db.php'; require_once '../../phplib/utility.php'; require_once '../../phplib/person.php'; /* get journo identifier (eg 'fred-bloggs') */ $paper_id = get_http_var('id', null); #page_header( $title, $pageparams ); page_header("Custom Papers"); $P = person_if_signed_on(true); /* Don't renew any login cookie. */ $paper = null; if ($paper_id) { $paper = db_getRow("SELECT * FROM custompaper WHERE id=?", $paper_id); } if ($paper) { emit_paper(&$paper); ?> <br /> <br /> <a href="/custompaper">back to custom newspaper index</a> <?php } else { emit_public_paper_list(); ?> <a href="/custompaper_edit">Edit your custom newspapers</a> <?php } page_footer();
if (!$id) { // it's new. $obj->journo_id = $journo_id; } else { // fetch from db $sql = <<<EOT SELECT e.*, l.id as src__id, l.url as src__url, l.title as src__title, l.pubdate as src__pubdate, l.publication as src__publication FROM (journo_awards e LEFT JOIN link l ON e.src=l.id ) WHERE e.id=? EOT; $row = db_getRow($sql, $id); $obj->fromDBRow($row); } /* print"<pre>\n"; print_r( $obj ); print"</pre>\n"; */ $form = $obj->buildForm(); ?> <h2><?php echo $id ? "Edit" : "Create New"; ?> award entry for <?php echo $journo['ref']; ?> </h2>
function FindByOutlet($outlet) { $order = get_http_var('order', 'lastname'); page_header(""); $org = db_getRow("SELECT id,prettyname FROM organisation WHERE shortname=?", $outlet); printf("<h2>Journalists who have written for %s</h2>", $org['prettyname']); print "<p>Ordered by "; if ($order == 'firstname') { print "first name (<a href=\"list?outlet={$outlet}\">order by last name</a>)"; } else { print "last name (<a href=\"list?outlet={$outlet}&order=firstname\">order by first name</a>)"; } print "</p>\n"; /* $sql = "SELECT j.ref, j.prettyname, j.oneliner, j.lastname, count(a.id) " . "FROM (( article a INNER JOIN journo_attr ja ON (a.status='a' AND a.id=ja.article_id) ) " . "INNER JOIN journo j ON (j.status='a' AND j.id=ja.journo_id) ) " . "WHERE a.srcorg=? " . "GROUP BY j.ref,j.prettyname,j.oneliner,j.lastname " . "ORDER BY count DESC"; */ $orderfields = $order == 'firstname' ? 'j.firstname,j.lastname' : 'j.lastname,j.firstname'; $sql = "SELECT DISTINCT j.ref, j.prettyname, j.oneliner, j.firstname, j.lastname " . "FROM (( article a INNER JOIN journo_attr ja ON (a.status='a' AND a.id=ja.article_id) ) " . "INNER JOIN journo j ON (j.status='a' AND j.id=ja.journo_id) ) " . "WHERE a.srcorg=? " . "ORDER BY {$orderfields}"; $q = db_query($sql, $org['id']); printf("<p>Found %d matches</p>", db_num_rows($q)); print "<ul>\n"; while ($j = db_fetch_array($q)) { printf("<li>%s</li>\n", FancyJournoLink($j)); } print "</ul>\n"; page_footer(); }
<strong>Do You really want to kill this post?</strong><br/> </p> <p> <a href="/adm/news" />No, I've changed my mind</a> <small><a href="/adm/news?action=reallydelete&id=<?php echo $id; ?> " />Yes, delete it!</a></small> </p> <?php newsPreview($post); break; case 'reallydelete': $id = get_http_var('id'); $post = db_getRow("SELECT * FROM news WHERE id=?", $id); newsDelete($post); newsList(); break; default: newsList(); break; } admPageFooter(); function newsList() { $posts = db_getAll("SELECT id,status,title,slug,posted,author,kind,date_from,date_to FROM news ORDER BY posted DESC"); ?> <h2>News Posts</h2> <a href="/adm/news?action=create">Create a new post</a> <ul>
function article_collect($article_id, $sim_orderby = 'score', $sim_showall = 'no') { $art = db_getRow('SELECT * FROM article WHERE id=?', $article_id); if (is_null($art)) { return null; } $art['article_id'] = $art['id']; $art['id36'] = article_id_to_id36($art['id']); $art['blog_links'] = db_getAll("SELECT * FROM article_bloglink WHERE article_id=? ORDER BY linkcreated DESC", $article_id); // journos $sql = <<<EOT SELECT j.prettyname, j.ref FROM ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id ) WHERE attr.article_id=? AND j.status='a'; EOT; $art['journos'] = db_getAll($sql, $article_id); $art['byline'] = article_markup_byline($art['byline'], $art['journos']); $orginfo = db_getRow("SELECT * FROM organisation WHERE id=?", $art['srcorg']); $art['srcorgname'] = $orginfo['prettyname']; $art['sop_name'] = $orginfo['sop_name']; $art['sop_url'] = $orginfo['sop_url']; $art['srcorg_url'] = $orginfo['home_url']; $permalink = $art['permalink']; $d = new datetime($art['pubdate']); $art['pretty_pubdate'] = pretty_date(strtotime($art['pubdate'])); $art['iso_pubdate'] = $d->format('c'); $art['buzz'] = BuzzFragment($art); /* similar articles */ if ($sim_orderby == 'date') { $ord = 'a.pubdate DESC, s.score DESC'; } else { // 'score' $ord = 's.score DESC, a.pubdate DESC'; } $sql = <<<EOT SELECT a.id,a.title, a.srcorg,a.byline,a.permalink,a.pubdate FROM article a INNER JOIN article_similar s ON s.other_id=a.id WHERE s.article_id=? and a.status='a' ORDER BY {$ord} EOT; /* only the first 10 by default */ if ($sim_showall != 'yes') { $sql .= " LIMIT 10"; } $sim_arts = db_getAll($sql, $article_id); foreach ($sim_arts as &$s) { article_augment($s); } unset($s); $art['sim_orderby'] = $sim_orderby; $art['sim_showall'] = $sim_showall; $art['sim_arts'] = $sim_arts; $tags = db_getAll('SELECT tag, freq FROM article_tag WHERE article_id=? ORDER BY freq DESC', $article_id); $sorted_tags = array(); foreach ($tags as $t) { $sorted_tags[$t['tag']] = intval($t['freq']); } ksort($sorted_tags); $art['tags'] = $sorted_tags; $art['comment_links'] = article_collect_commentlinks($article_id); return $art; }