<commit_before><?php
/* Web based feature publisher */
include("../config/settings.inc.php");
include("$rootpath/include/database.inc.php");
include("$rootpath/include/facebook.php");

$facebook = new Facebook(Array(
  'appId' => '148705700931',
  'secret' => $fb_feature_secret,
  'cookie' => true,
));
$me = null;
$uid = $facebook->getUser();
if ($uid){    
	$me = $facebook->api('/me');
}
if ($me){
  $logouturl = $facebook->getLogoutUrl();
}else {
  $loginurl = $facebook->getLoginUrl(Array(
    'scope' => 'publish_stream,offline_access,manage_pages'
  ));
}


$story = isset($_REQUEST["story"]) ? $_REQUEST["story"] : null;
$title = isset($_REQUEST["title"]) ? $_REQUEST["title"] : null;
$caption = isset($_REQUEST["caption"]) ? $_REQUEST["caption"] : null;
$tags = isset($_REQUEST["tags"]) ? $_REQUEST["tags"] : null;
$voting = (isset($_REQUEST["voting"]) && $_REQUEST["voting"] == "yes") ?
          true : false;

$mesosite = iemdb("mesosite", TRUE, TRUE);
pg_prepare($mesosite, "INJECTOR", "INSERT into feature 
  (title, story, caption, voting, tags, fbid) VALUES 
  ($1   , $2   , $3   , $4     , $5  , $6)");



$rooturl = "http://mesonet.agron.iastate.edu";
$permalink = sprintf('%s/onsite/features/cat.php?day=%s', $rooturl, date("Y-m-d") );
$thumbnail = sprintf('%s/onsite/features/%s_s.png', $rooturl, 
             date("Y/m/ymd") );

$attachment = Array(
 'name' => 'IEM Feature',
 'href' => $permalink,
 'caption' => 'caption',
 'description' => 'Feature Image',
 'media' => array(array('type' => 'image',
    'src' => $thumbnail,
    'href' => $permalink)),
);
$action_links = array(
  array('text' => 'Permalink',
        'href' => $permalink));

if ( isset($_REQUEST["facebook"]) && $_REQUEST["facebook"] == "yes"){
  $fbid = $facebook->api(Array("method"=>'stream.publish', 
       "message" => $_REQUEST["story"],
       "attachment" => $attachment,
       "action_links" => $action_links,
    //   "target_id" => null,
       "uid" => 157789644737));
  $story_fbid = explode("_", $fbid);
  $story_fbid = str_replace('"', '', $story_fbid[1]);
}
if ($story != null && $title != null &&
    isset($_REQUEST['iemdb']) && $_REQUEST['iemdb'] == 'yes'){
  pg_query($mesosite, "DELETE from feature WHERE date(valid) = 'TODAY'");
  pg_execute($mesosite, "INJECTOR", Array($title, $story, $caption,
             $voting, $tags, $story_fbid) );
}

include("$rootpath/include/header.php");
if ($me){ 
	echo "<a href=\"$logouturl\">Logout</a>";<commit_msg>add reassuring name to page<commit_after><?php
/* Web based feature publisher */
include("../config/settings.inc.php");
include("$rootpath/include/database.inc.php");
include("$rootpath/include/facebook.php");

$facebook = new Facebook(Array(
  'appId' => '148705700931',
  'secret' => $fb_feature_secret,
  'cookie' => true,
));
$me = null;
$uid = $facebook->getUser();
if ($uid){    
	$me = $facebook->api('/me');
}
if ($me){
  $logouturl = $facebook->getLogoutUrl();
}else {
  $loginurl = $facebook->getLoginUrl(Array(
    'scope' => 'publish_stream,offline_access,manage_pages'
  ));
}


$story = isset($_REQUEST["story"]) ? $_REQUEST["story"] : null;
$title = isset($_REQUEST["title"]) ? $_REQUEST["title"] : null;
$caption = isset($_REQUEST["caption"]) ? $_REQUEST["caption"] : null;
$tags = isset($_REQUEST["tags"]) ? $_REQUEST["tags"] : null;
$voting = (isset($_REQUEST["voting"]) && $_REQUEST["voting"] == "yes") ?
          true : false;

$mesosite = iemdb("mesosite", TRUE, TRUE);
pg_prepare($mesosite, "INJECTOR", "INSERT into feature 
  (title, story, caption, voting, tags, fbid) VALUES 
  ($1   , $2   , $3   , $4     , $5  , $6)");



$rooturl = "http://mesonet.agron.iastate.edu";
$permalink = sprintf('%s/onsite/features/cat.php?day=%s', $rooturl, date("Y-m-d") );
$thumbnail = sprintf('%s/onsite/features/%s_s.png', $rooturl, 
             date("Y/m/ymd") );

$attachment = Array(
 'name' => 'IEM Feature',
 'href' => $permalink,
 'caption' => 'caption',
 'description' => 'Feature Image',
 'media' => array(array('type' => 'image',
    'src' => $thumbnail,
    'href' => $permalink)),
);
$action_links = array(
  array('text' => 'Permalink',
        'href' => $permalink));

if ( isset($_REQUEST["facebook"]) && $_REQUEST["facebook"] == "yes"){
  $fbid = $facebook->api(Array("method"=>'stream.publish', 
       "message" => $_REQUEST["story"],
       "attachment" => $attachment,
       "action_links" => $action_links,
    //   "target_id" => null,
       "uid" => 157789644737));
  $story_fbid = explode("_", $fbid);
  $story_fbid = str_replace('"', '', $story_fbid[1]);
}
if ($story != null && $title != null &&
    isset($_REQUEST['iemdb']) && $_REQUEST['iemdb'] == 'yes'){
  pg_query($mesosite, "DELETE from feature WHERE date(valid) = 'TODAY'");
  pg_execute($mesosite, "INJECTOR", Array($title, $story, $caption,
             $voting, $tags, $story_fbid) );
}

include("$rootpath/include/header.php");
if ($me){ 
	echo "Hello, ". $me["name"] ."!<a href=\"$logouturl\">Logout</a>";
{'fraction_non_alphanumeric': 0.23528229857343783, 'fraction_numerical': 0.012457303596544103, 'mean_word_length': 4.47032967032967, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1153380', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1777, 'n_words': 333}