Esempio n. 1
0
 public static function get_authors($arr = array())
 {
     global $config_q;
     if (isset($arr["current_page"])) {
         $limit_start = ($arr["current_page"] - 1) * $config_q["quotes_on_page"];
         $limit = "LIMIT " . ($arr["current_page"] - 1) * $config_q["quotes_on_page"] . "," . $config_q["quotes_on_page"];
     }
     if (isset($arr["char"])) {
         $s_where = "WHERE author_lastname_" . $config_q["locale"] . " LIKE '" . $arr["char"] . "%' ";
     }
     if (strlen($s_where) > 0) {
         $s_where .= "\n\t\t\t\tAND\n\t\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.id = " . $config_q["db"]["prefix"] . "quotes.author_id\n\t\t\t\tAND\n\t\t\t\t\tactive = 1\n\t\t\t\tAND\n\t\t\t\t\tlang = '" . $config_q["locale"] . "' ";
     } else {
         $s_where .= "\n\t\t\t\tWHERE\n\t\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.id = " . $config_q["db"]["prefix"] . "quotes.author_id\n\t\t\t\tAND\n\t\t\t\t\tactive = 1\n\t\t\t\tAND\n\t\t\t\t\tlang = '" . $config_q["locale"] . "' ";
     }
     $a_out = array();
     $q = "\n\t\t\tSELECT\n\t\t\t\tDISTINCT\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.id as author_id,\n\t\t\t\tauthor_name_freeform_" . $config_q["locale"] . ",\n\t\t\t\tauthor_firstname_" . $config_q["locale"] . ",\n\t\t\t\tauthor_midname_" . $config_q["locale"] . ",\n\t\t\t\tauthor_lastname_" . $config_q["locale"] . ",\n\t\t\t\tauthor_born_death_circa,\n\t\t\t\tauthor_born,\n\t\t\t\tauthor_death,\n\t\t\t\tauthor_profession_" . $config_q["locale"] . ",\n\t\t\t\tauthor_wiki_url_" . $config_q["locale"] . ",\n\t\t\t\turl_friendly_author_name_" . $config_q["locale"] . "\n\t\t\tFROM\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes\n\t\t\t{$s_where}\n\t\t\torder by\n\t\t\t\tauthor_lastname_" . $config_q["locale"] . " asc\n\t\t\t{$limit};\n\t\t";
     $r = q($q);
     $a_out = array();
     while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) {
         $row = author::parse_author_born_death($row);
         $row = author::parse_author_name($row);
         $row = author::parse_url_friendly_author_name($row);
         $a_out[] = $row;
     }
     return $a_out;
 }
Esempio n. 2
0
require_once $config_q["basepath"] . '/classes/twitter.php';
require_once $config_q["basepath"] . '/classes/twitter_quote.php';
$datetime_today = date("Y-m-d") . " 00:00:00";
$q = "\n\tSELECT\n\t\t" . $config_q["db"]["prefix"] . "quotes.id as quote_id,\n\t\t" . $config_q["db"]["prefix"] . "quotes.quote,\n\t\t" . $config_q["db"]["prefix"] . "quotes.rank,\n\t\t" . $config_q["db"]["prefix"] . "quotes.tag,\n\t\t" . $config_q["db"]["prefix"] . "quotes.author_id,\n\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_name_freeform_" . $config_q["locale"] . ",\n\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_firstname_" . $config_q["locale"] . ",\n\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_midname_" . $config_q["locale"] . ",\n\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_lastname_" . $config_q["locale"] . ",\n\t\t" . $config_q["db"]["prefix"] . "quote_authors.url_friendly_author_name_" . $config_q["locale"] . "\n\tFROM\n\t\t" . $config_q["db"]["prefix"] . "quotes,\n\t\t" . $config_q["db"]["prefix"] . "quote_authors\n\tWHERE\n\t\t" . $config_q["db"]["prefix"] . "quotes.id\n\tNOT IN\n\t(\n\t\tSELECT \n\t\t\tquote_id\n\t\tFROM\n\t\t\t" . $config_q["db"]["prefix"] . "twitter_log\n\t)\n\tAND\n\t\trank > 0\n\tAND\n\t\t" . $config_q["db"]["prefix"] . "quotes.author_id = " . $config_q["db"]["prefix"] . "quote_authors.id\n\tAND\n\t\t" . $config_q["db"]["prefix"] . "quotes.lang = '" . $config_q["locale"] . "'\n\tORDER BY\n\t\t" . $config_q["db"]["prefix"] . "quotes.created_time\n\tASC\n\tLIMIT 1\n\t";
echo $q;
$r = q($q);
$i = 0;
$a_out = array();
$row = mysqli_fetch_array($r, MYSQL_ASSOC);
$row["quote"] = str_replace(array(" -", "[-]", "  "), array(" —", "[—]", "  "), $row["quote"]);
if (strpos($row["quote"], '"') !== false) {
    $row["quote"] = preg_replace("/\"(.*)\"/imsU", "“\\1”", $row["quote"]);
} else {
    $row["quote"] = "“" . $row["quote"] . "”";
}
$row = author::parse_author_name($row);
$a_out[] = $row;
$a_out = quote::parse_author_photos($a_out);
$row = $a_out[0];
$first_tag = explode(",", $row["tag"]);
$first_tag = str_replace("_", " ", trim($first_tag[0]));
$facebook_attachment = array('name' => $row["author_name_wo_brackets"] . ' ' . _('quotations'), 'href' => $config_q["baseurl"] . '/' . _("quotes") . '/' . _("authors") . '/' . $row["url_friendly_author_name_" . $config_q["locale"]], 'caption' => str_replace("http://", "", $config_q["baseurl"]), 'description' => $row["author_name_wo_brackets"] . ' ' . _('quotations'), 'properties' => array(_('Tag') => array('text' => $first_tag, 'href' => $config_q["baseurl"] . '/' . _("quotes") . '/' . _("tags") . '/' . $first_tag), _('Rating') => $row["rank"]));
if (strlen($row["author_img"]["nice_name"]) > 0) {
    $facebook_attachment['media'] = array(array('type' => 'image', 'src' => $config_q["baseurl"] . '/cache/images/' . str_replace(".jpg", "_90px.jpg", $row["author_img"]["nice_name"]), 'href' => $config_q["baseurl"] . '/' . _("quotes") . '/' . _("authors") . '/' . $row["url_friendly_author_name_" . $config_q["locale"]]));
}
facebook_wrapper::publish_to_wall($row["quote"], $facebook_attachment, array(array('text' => _('Go to quotation'), 'href' => $config_q["baseurl"] . "/" . $row["quote_id"])), $config_q["facebook"]["wall_id"]);
$ct = new twitter_quote($config_q["twitter"]["username"], $config_q["twitter"]["password"]);
$url = str_replace("http://", "", $config_q["baseurl"]) . "/" . $row["quote_id"];
if ($ct->set_status($row["quote"] . " " . $row["author_name_wo_brackets"], $url) != true) {
    die("Twitter is unavailable at this time");
}
Esempio n. 3
0
 public static function get_from_waitinglist()
 {
     global $user, $config_q, $table_prefix;
     $q = "\n\t\t\tSELECT\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.id AS waiting_quote_id,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_id AS author_id,\n\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_name_freeform_et AS author_name_freeform_et,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_lastname_et AS author_lastname_et,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_midname_et AS author_midname_et,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.author_firstname_et AS author_firstname_et,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors.url_friendly_author_name_" . $config_q["locale"] . ",\n\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_name AS waiting_author_name,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_profession_et AS waiting_author_profession_et,\n\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_born AS waiting_author_born,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_death AS waiting_author_death,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.quote AS quote,\n\t\t\t\t" . $config_q["db"]["prefix"] . "categories.name_" . $config_q["locale"] . " as category,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.tag AS tag,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.source_title AS waiting_source_title,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.source_year_start AS waiting_source_year_start,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.created_by AS waiting_created_by,\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.date_inserted AS waiting_date_inserted,\n\t\t\t\t" . USERS_TABLE . ".username AS username\n\t\t\tFROM\n\t\t\t(\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval,\n\t\t\t\t" . USERS_TABLE . ",\n\t\t\t\t" . $config_q["db"]["prefix"] . "categories\n\t\t\t)\n\t\t\tLEFT JOIN\n\t\t\t\t" . $config_q["db"]["prefix"] . "quote_authors\n\t\t\tON\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_id = " . $config_q["db"]["prefix"] . "_quote_authors.id\n\t\t\tWHERE\n\t\t\t\t" . USERS_TABLE . ".user_id = " . $config_q["db"]["prefix"] . "quotes_waiting_approval.created_by\n\t\t\t\tAND\n\t\t\t\t" . $config_q["db"]["prefix"] . "quotes_waiting_approval.author_id != 0\n\t\t\t\tAND\n\t\t\t\tstatus = 0\n\t\t\t\tAND\n\t\t\t\t" . $config_q["db"]["prefix"] . "categories.id = " . $config_q["db"]["prefix"] . "quotes_waiting_approval.category\n\t\t\tORDER BY \n\t\t\t\tdate_inserted\n\t\t\tASC\n\t\t;";
     $r = q($q);
     $a_out = array();
     while ($row = mysqli_fetch_array($r, MYSQL_ASSOC)) {
         $row = quote::parse_tags($row);
         $row = author::parse_author_name($row);
         $row = author::parse_author_born_death($row);
         $row = author::parse_author_profession($row);
         $row = author::parse_url_friendly_author_name($row);
         $a_out[] = $row;
     }
     //$a_out = $this->get_author_img_data2($a_out);
     $a_out = quote::parse_author_photos($a_out);
     return $a_out;
 }