本文整理汇总了PHP中db_fetch_result函数的典型用法代码示例。如果您正苦于以下问题:PHP db_fetch_result函数的具体用法?PHP db_fetch_result怎么用?PHP db_fetch_result使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_fetch_result函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getInfo
function getInfo()
{
//retrieve Data from the DB
$id = db_escape_string($_REQUEST['id']);
$result = db_query("SELECT title, link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) != 0) {
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...');
$article_link = db_fetch_result($result, 0, 'link');
}
$consumer_key = $this->host->get($this, "pocket_consumer_key");
$pocket_access_token = $this->host->get($this, "pocket_access_token");
//Call Pocket API
if (function_exists('curl_init')) {
$postfields = array('consumer_key' => $consumer_key, 'access_token' => $pocket_access_token, 'url' => $article_link, 'title' => $title);
$cURL = curl_init();
curl_setopt($cURL, CURLOPT_URL, 'https://getpocket.com/v3/add');
curl_setopt($cURL, CURLOPT_HEADER, 1);
curl_setopt($cURL, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded;charset=UTF-8'));
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
curl_setopt($cURL, CURLOPT_TIMEOUT, 5);
curl_setopt($cURL, CURLOPT_POST, 4);
curl_setopt($cURL, CURLOPT_POSTFIELDS, http_build_query($postfields));
$apicall = curl_exec($cURL);
curl_close($cURL);
//Store error code in $status
$status = preg_match('/^X-Error: .*$/m', $apicall, $matches) ? $matches[0] : 1;
} else {
$status = 'For the plugin to work you need to <strong>enable PHP extension CURL</strong>!';
}
//Return information on article and status
print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "status" => $status));
}
示例2: shareArticle
function shareArticle()
{
$param = db_escape_string($_REQUEST['param']);
$result = db_query($this->link, "SELECT uuid, ref_id FROM ttrss_user_entries WHERE int_id = '{$param}'\n\t\t\tAND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) == 0) {
print "Article not found.";
} else {
$uuid = db_fetch_result($result, 0, "uuid");
$ref_id = db_fetch_result($result, 0, "ref_id");
if (!$uuid) {
$uuid = db_escape_string(sha1(uniqid(rand(), true)));
db_query($this->link, "UPDATE ttrss_user_entries SET uuid = '{$uuid}' WHERE int_id = '{$param}'\n\t\t\t\t\tAND owner_uid = " . $_SESSION['uid']);
}
print __("You can share this article by the following unique URL:");
$url_path = get_self_url_prefix();
$url_path .= "/public.php?op=share&key={$uuid}";
print "<div class=\"tagCloudContainer\">";
print "<a id='pub_opml_url' href='{$url_path}' target='_blank'>{$url_path}</a>";
print "</div>";
/* if (!label_find_id($this->link, __('Shared'), $_SESSION["uid"]))
label_create($this->link, __('Shared'), $_SESSION["uid"]);
label_add_article($this->link, $ref_id, __('Shared'), $_SESSION['uid']); */
}
print "<div align='center'>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('shareArticleDlg').hide()\">" . __('Close this window') . "</button>";
print "</div>";
}
示例3: find_user_by_login
function find_user_by_login($login)
{
$login = db_escape_string($login);
$result = db_query($this->link, "SELECT id FROM ttrss_users WHERE\n\t\t\tlogin = '{$login}'");
if (db_num_rows($result) > 0) {
return db_fetch_result($result, 0, "id");
} else {
return false;
}
}
示例4: getInfo
function getInfo()
{
$id = db_escape_string($_REQUEST['id']);
$result = db_query($this->link, "SELECT title, link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) != 0) {
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...');
$article_link = db_fetch_result($result, 0, 'link');
}
print json_encode(array("title" => $title, "link" => $article_link, "id" => $id));
}
示例5: getUrl
function getUrl()
{
$id = db_escape_string($_REQUEST['id']);
$result = db_query("SELECT link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
$url = "";
if (db_num_rows($result) != 0) {
$url = db_fetch_result($result, 0, "link");
}
print json_encode(array("url" => $url, "id" => $id));
}
示例6: getShaarli
function getShaarli()
{
$id = db_escape_string($_REQUEST['id']);
$result = $this->dbh->query("SELECT title, link\n FROM ttrss_entries, ttrss_user_entries\n WHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) != 0) {
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...');
$article_link = db_fetch_result($result, 0, 'link');
}
$shaarli_url = $this->host->get($this, "shaarli");
print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "shaarli_url" => $shaarli_url));
}
示例7: digestgetcontents
function digestgetcontents()
{
$article_id = db_escape_string($_REQUEST['article_id']);
$result = db_query($this->link, "SELECT content,title,link,marked,published\n\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\tWHERE id = '{$article_id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
$content = sanitize($this->link, db_fetch_result($result, 0, "content"));
$title = strip_tags(db_fetch_result($result, 0, "title"));
$article_url = htmlspecialchars(db_fetch_result($result, 0, "link"));
$marked = sql_bool_to_bool(db_fetch_result($result, 0, "marked"));
$published = sql_bool_to_bool(db_fetch_result($result, 0, "published"));
print json_encode(array("article" => array("id" => $article_id, "url" => $article_url, "tags" => get_article_tags($this->link, $article_id), "marked" => $marked, "published" => $published, "title" => $title, "content" => $content)));
}
示例8: get_login_by_ssl_certificate
function get_login_by_ssl_certificate()
{
$cert_serial = db_escape_string(get_ssl_certificate_id());
if ($cert_serial) {
$result = db_query("SELECT login FROM ttrss_user_prefs, ttrss_users\n\t\t\t\tWHERE pref_name = 'SSL_CERT_SERIAL' AND value = '{$cert_serial}' AND\n\t\t\t\towner_uid = ttrss_users.id");
if (db_num_rows($result) != 0) {
return db_escape_string(db_fetch_result($result, 0, "login"));
}
}
return "";
}
示例9: redirect
function redirect()
{
$id = db_escape_string($_REQUEST['id']);
$result = db_query($this->link, "SELECT link FROM ttrss_entries, ttrss_user_entries\r\n\t\t\t\t\t\tWHERE id = '{$id}' AND id = ref_id AND owner_uid = '" . $_SESSION['uid'] . "'\r\n\t\t\t\t\t\tLIMIT 1");
if (db_num_rows($result) == 1) {
$article_url = db_fetch_result($result, 0, 'link');
$article_url = str_replace("\n", "", $article_url);
header("Location: {$article_url}");
return;
} else {
print_error(__("Article not found."));
}
}
示例10: import_article
function import_article($link, $data)
{
print "<p>Article: <b>" . $data["title"] . "</b> (" . $data["feed_title"] . ")<br>";
$owner_uid = $_SESSION["uid"];
db_query($link, "BEGIN");
$result = db_query($link, "SELECT id FROM ttrss_feeds WHERE feed_url = '" . db_escape_string($data["feed_url"]) . "' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) == 0) {
return false;
}
$feed_id = db_fetch_result($result, 0, "id");
$result = db_query($link, "SELECT id FROM ttrss_entries WHERE\n\t\t\tguid = '" . $data["guid"] . "'");
if (db_num_rows($result) == 0) {
print "Adding base entry...<br>";
$entry_title = db_escape_string($data["title"]);
$entry_guid = db_escape_string($data["guid"]);
$entry_link = db_escape_string($data["link"]);
$updated = db_escape_string($data["updated"]);
$date_entered = db_escape_string($data["date_entered"]);
$entry_content = db_escape_string($data["content"]);
$content_hash = "SHA1:" . sha1(strip_tags($entry_content));
$entry_comments = db_escape_string($data["comments"]);
$result = db_query($link, "INSERT INTO ttrss_entries \n\t\t\t\t\t(title,\n\t\t\t\t\tguid,\n\t\t\t\t\tlink,\n\t\t\t\t\tupdated,\n\t\t\t\t\tcontent,\n\t\t\t\t\tcontent_hash,\n\t\t\t\t\tno_orig_date,\n\t\t\t\t\tdate_entered,\n\t\t\t\t\tcomments)\n\t\t\t\tVALUES\n\t\t\t\t\t('{$entry_title}', \n\t\t\t\t\t'{$entry_guid}', \n\t\t\t\t\t'{$entry_link}',\n\t\t\t\t\t'{$updated}', \n\t\t\t\t\t'{$entry_content}', \n\t\t\t\t\t'{$content_hash}',\n\t\t\t\t\tfalse, \n\t\t\t\t\t'{$date_entered}', \n\t\t\t\t\t'{$entry_comments}')");
}
$result = db_query($link, "SELECT id FROM ttrss_entries WHERE\n\t\t\tguid = '" . $data["guid"] . "'");
if (db_num_rows($result) == 0) {
return false;
}
$entry_id = db_fetch_result($result, 0, "id");
print "Found base ID: {$entry_id}<br>";
$result = db_query($link, "SELECT int_id FROM ttrss_user_entries WHERE\n\t\t\tref_id = '{$entry_id}' AND owner_uid = '{$owner_uid}'");
if (db_num_rows($result) == 0) {
print "User table entry not found, creating...<br>";
$unread = sql_bool_to_string(db_escape_string($data["unread"]));
$marked = sql_bool_to_string(db_escape_string($data["marked"]));
$last_read = db_escape_string($data["last_read"]);
if (!$last_read) {
$last_read_qpart = 'NULL';
} else {
$last_read_qpart = "'{$last_read}'";
}
$result = db_query($link, "INSERT INTO ttrss_user_entries \n\t\t\t\t\t(ref_id, owner_uid, feed_id, unread, marked, last_read) \n\t\t\t\tVALUES ('{$entry_id}', '{$owner_uid}', '{$feed_id}', {$unread}, {$marked},\n\t\t\t\t\t{$last_read_qpart})");
} else {
print "User table entry already exists, nothing to do.<br>";
}
db_query($link, "COMMIT");
}
示例11: edit
function edit()
{
$param = db_escape_string($_REQUEST['param']);
$result = db_query("SELECT note FROM ttrss_user_entries WHERE\n\t\t\tref_id = '{$param}' AND owner_uid = " . $_SESSION['uid']);
$note = db_fetch_result($result, 0, "note");
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$param}\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pluginhandler\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"setNote\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"plugin\" value=\"note\">";
print "<table width='100%'><tr><td>";
print "<textarea dojoType=\"dijit.form.SimpleTextarea\"\n\t\t\tstyle='font-size : 12px; width : 100%; height: 100px;'\n\t\t\tplaceHolder='body#ttrssMain { font-size : 14px; };'\n\t\t\tname='note'>{$note}</textarea>";
print "</td></tr></table>";
print "<div class='dlgButtons'>";
print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"dijit.byId('editNoteDlg').execute()\">" . __('Save') . "</button> ";
print "<button dojoType=\"dijit.form.Button\"\n\t\t\tonclick=\"dijit.byId('editNoteDlg').hide()\">" . __('Cancel') . "</button>";
print "</div>";
}
示例12: getQr
function getQr()
{
$id = db_escape_string($_REQUEST['id']);
$article_link = '';
$result = db_query("SELECT title, link\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) != 0) {
$article_link = db_fetch_result($result, 0, 'link');
}
$pngPath = dirname(__FILE__) . '/cache/' . $id . '.png';
if (!file_exists($pngPath)) {
require_once dirname(__FILE__) . '/phpqrcode/qrlib.php';
QRcode::png($article_link, $pngPath);
}
echo '<div><img src="plugins/qrcodegen/cache/' . $id . '.png" style="display: block; margin: 0 auto;"></div>';
echo "<div style='text-align : center'>";
print "<button dojoType=\"dijit.form.Button\" onclick=\"dijit.byId('qrCodeArticleDlg').hide()\">" . __('Close this dialog') . "</button>";
print "</div>";
}
示例13: getInfo
function getInfo()
{
$id = db_escape_string($_REQUEST['id']);
$result = db_query("SELECT title, link\r\n\t\t\t\tFROM ttrss_entries, ttrss_user_entries\r\n\t\t\t\tWHERE id = '{$id}' AND ref_id = id AND owner_uid = " . $_SESSION['uid']);
if (db_num_rows($result) != 0) {
$title = truncate_string(strip_tags(db_fetch_result($result, 0, 'title')), 100, '...');
$article_link = db_fetch_result($result, 0, 'link');
}
$yourls_url = $this->host->get($this, "Yourls_URL");
$yourls_api = $this->host->get($this, "Yourls_API");
curl_setopt($curl_yourls, CURLOPT_URL, "{$yourls_url}/yourls-api.php?signature={$yourls_api}&action=shorturl&format=simple&url=" . urlencode($article_link) . "&title=" . urlencode($title));
curl_setopt($curl_yourls, CURLOPT_RETURNTRANSFER, true);
if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
curl_setopt($curl_yourls, CURLOPT_FOLLOWLOCATION, true);
}
$short_url = curl_exec($curl_yourls);
curl_setopt($this->curl_yourls, CURLOPT_URL, "{$yourls_url}/yourls-api.php?signature={$yourls_api}&action=shorturl&format=simple&url=" . urlencode($article_link) . "&title=" . urlencode($title));
$short_url = curl_exec($this->curl_yourls);
print json_encode(array("title" => $title, "link" => $article_link, "id" => $id, "yourlsurl" => $yourls_url, "yourlsapi" => $yourls_api, "shorturl" => $short_url));
}
示例14: edit
function edit()
{
$id = db_escape_string($_REQUEST["id"]);
$result = db_query($this->link, "SELECT * FROM ttrss_linked_instances WHERE\n\t\t\tid = '{$id}'");
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"id\" value=\"{$id}\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-instances\">";
print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"editSave\">";
print "<div class=\"dlgSec\">" . __("Instance") . "</div>";
print "<div class=\"dlgSecCont\">";
/* URL */
$access_url = htmlspecialchars(db_fetch_result($result, 0, "access_url"));
print __("URL:") . " ";
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Instance URL") . "\"\n\t\t\tregExp='^(http|https)://.*'\n\t\t\tstyle=\"font-size : 16px; width: 20em\" name=\"access_url\"\n\t\t\tvalue=\"{$access_url}\">";
print "<hr/>";
$access_key = htmlspecialchars(db_fetch_result($result, 0, "access_key"));
/* Access key */
print __("Access key:") . " ";
print "<input dojoType=\"dijit.form.ValidationTextBox\" required=\"1\"\n\t\t\tplaceHolder=\"" . __("Access key") . "\" regExp='\\w{40}'\n\t\t\tstyle=\"width: 20em\" name=\"access_key\" id=\"instance_edit_key\"\n\t\t\tvalue=\"{$access_key}\">";
print "<p class='insensitive'>" . __("Use one access key for both linked instances.");
print "</div>";
print "<div class=\"dlgButtons\">\n\t\t\t<div style='float : left'>\n\t\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').regenKey()\">" . __('Generate new key') . "</button>\n\t\t\t</div>\n\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').execute()\">" . __('Save') . "</button>\n\t\t\t<button dojoType=\"dijit.form.Button\"\n\t\t\t\tonclick=\"return dijit.byId('instanceEditDlg').hide()\"\">" . __('Cancel') . "</button></div>";
}
示例15: hook_article_filter
function hook_article_filter($article)
{
$wpm = 180;
// arbitrary value, based on adult averages
$word_count = str_word_count($article["content"]);
$minutes = round($word_count / $wpm);
$minimum_time_bucket = 5;
// minutes
$time_label = $this->minutes_to_time_label($minutes, $minimum_time_bucket);
_debug("estimated reading time: {$minutes} min ({$time_label}), based on {$word_count} words at {$wpm} WPM");
$owner_uid = $article["owner_uid"];
if (!label_find_id($time_label, $owner_uid)) {
label_create($time_label);
}
$guid = $article["guid"];
$result = db_query("SELECT id FROM ttrss_entries WHERE guid = '{$guid}'");
if (db_num_rows($result) != 0) {
$ref_id = db_fetch_result($result, 0, "id");
label_add_article($ref_id, $time_label, $owner_uid);
}
return $article;
}