本文整理汇总了PHP中yourls_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP yourls_get_option函数的具体用法?PHP yourls_get_option怎么用?PHP yourls_get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了yourls_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: abdulrauf_adminreCaptcha_addjs
function abdulrauf_adminreCaptcha_addjs()
{
$siteKey = yourls_get_option('abdulrauf_adminreCaptcha_pub_key');
?>
<script type="text/javascript">
//JQuery function to add div for reCaptcha widget and load js only on login screen
$(document).ready(function() {
var logindiv = document.getElementById('login');
if (logindiv != null) { //check if we are on login screen
//getting reCaptcha script by jquery only on login screen
$.getScript( "https://www.google.com/recaptcha/api.js?onload=loadCaptcha&render=explicit");
var form = logindiv.innerHTML;
var index = form.indexOf('<p style="text-align: right;">'); //finding tag before which reCaptcha widget should appear
document.getElementById('login').innerHTML = form.slice(0, index) + '<div id="captcha_container"></div>' + form.slice(index);
}
});
// JavaScript function to explicitly render the reCAPTCHA widget
var loadCaptcha = function() {
captchaContainer = grecaptcha.render('captcha_container', {
'sitekey' : '<?php
echo $siteKey;
?>
'
});
};
</script>
<?php
}
示例2: temp_instead_admin_page_update
function temp_instead_admin_page_update()
{
$mode = $_POST['temp_instead_mode'];
if ($mode) {
$mode = intval($mode);
if (yourls_get_option('temp_instead_mode') !== false) {
echo '<b>Redirect mode was updated successfully.</b>';
yourls_update_option('temp_instead_mode', $mode);
} else {
echo '<b>Redirect mode was stored successfully.</b>';
yourls_add_option('temp_instead_mode', $mode);
}
}
}
示例3: ozh_yourls_samplepage_do_page
function ozh_yourls_samplepage_do_page()
{
// Check if a form was submitted
if (isset($_POST['test_option'])) {
ozh_yourls_samplepage_update_option();
}
// Get value from database
$test_option = yourls_get_option('test_option');
echo <<<HTML
\t\t<h2>Sample Plugin Administration Page</h2>
\t\t<p>This plugin stores an integer in the option database</p>
\t\t<form method="post">
\t\t<p><label for="test_option">Enter an integer</label> <input type="text" id="test_option" name="test_option" value="{$test_option}" /></p>
\t\t<p><input type="submit" value="Update value" /></p>
\t\t</form>
HTML;
}
示例4: yourls_upgrade_to_15
/**
* Main func for upgrade from 1.4.3 to 1.5
*
*/
function yourls_upgrade_to_15()
{
// Create empty 'active_plugins' entry in the option if needed
if (yourls_get_option('active_plugins') === false) {
yourls_add_option('active_plugins', array());
}
echo "<p>Enabling the plugin API. Please wait...</p>";
// Alter URL table to store titles
global $ydb;
$table_url = YOURLS_DB_TABLE_URL;
$sql = "ALTER TABLE `{$table_url}` ADD `title` TEXT AFTER `url`;";
$ydb->query($sql);
echo "<p>Updating table structure. Please wait...</p>";
// Update .htaccess
yourls_create_htaccess();
echo "<p>Updating .htaccess file. Please wait...</p>";
}
示例5: yourls_new_core_version_notice
/**
* Display a notice if there is a newer version of YOURLS available
*
* @since 1.7
*/
function yourls_new_core_version_notice()
{
yourls_debug_log('Check for new version: ' . (yourls_maybe_check_core_version() ? 'yes' : 'no'));
$checks = yourls_get_option('core_version_checks');
if (isset($checks->last_result->latest) and version_compare($checks->last_result->latest, YOURLS_VERSION, '>')) {
$msg = yourls_s('<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $checks->last_result->latest);
yourls_add_notice($msg);
}
}
示例6: yourls_load_plugins
function yourls_load_plugins()
{
global $ydb;
$ydb->plugins = array();
$active_plugins = yourls_get_option('active_plugins');
// Don't load plugins when installing or updating
if (!$active_plugins or defined('YOURLS_INSTALLING') and YOURLS_INSTALLING or yourls_upgrade_is_needed()) {
return;
}
foreach ((array) $active_plugins as $key => $plugin) {
if (yourls_validate_plugin_file(YOURLS_PLUGINDIR . '/' . $plugin)) {
include_once YOURLS_PLUGINDIR . '/' . $plugin;
$ydb->plugins[] = $plugin;
unset($active_plugins[$key]);
}
}
// $active_plugins should be empty now, if not, a plugin could not be find: remove it
if (count($active_plugins)) {
$missing = '<strong>' . join('</strong>, <strong>', $active_plugins) . '</strong>';
yourls_update_option('active_plugins', $ydb->plugins);
$message = 'Could not find and deactivated ' . yourls_plural('plugin', count($active_plugins)) . ' ' . $missing;
yourls_add_notice($message);
}
}
示例7: yourls_add_option
/**
* Add an option to the DB
*
* Pretty much stolen from WordPress
*
* @since 1.4
* @param string $option Name of option to add. Expected to not be SQL-escaped.
* @param mixed $value Optional option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
* @return bool False if option was not added and true otherwise.
*/
function yourls_add_option($name, $value = '')
{
global $ydb;
$table = YOURLS_DB_TABLE_OPTIONS;
$name = trim($name);
if (empty($name)) {
return false;
}
// Use clone to break object refs -- see commit 09b989d375bac65e692277f61a84fede2fb04ae3
if (is_object($value)) {
$value = clone $value;
}
$name = yourls_escape($name);
// Make sure the option doesn't already exist
if (false !== yourls_get_option($name)) {
return false;
}
$_value = yourls_escape(yourls_maybe_serialize($value));
yourls_do_action('add_option', $name, $_value);
$ydb->query("INSERT INTO `{$table}` (`option_name`, `option_value`) VALUES ('{$name}', '{$_value}')");
$ydb->option[$name] = $value;
return true;
}
示例8: yourls_load_plugins
function yourls_load_plugins()
{
// Don't load plugins when installing or updating
if (yourls_is_installing() or yourls_is_upgrading()) {
return;
}
$active_plugins = yourls_get_option('active_plugins');
if (false === $active_plugins) {
return;
}
global $ydb;
$ydb->plugins = array();
foreach ((array) $active_plugins as $key => $plugin) {
if (yourls_validate_plugin_file(YOURLS_PLUGINDIR . '/' . $plugin)) {
include_once YOURLS_PLUGINDIR . '/' . $plugin;
$ydb->plugins[] = $plugin;
unset($active_plugins[$key]);
}
}
// $active_plugins should be empty now, if not, a plugin could not be find: remove it
if (count($active_plugins)) {
yourls_update_option('active_plugins', $ydb->plugins);
$message = yourls_n('Could not find and deactivated plugin :', 'Could not find and deactivated plugins :', count($active_plugins));
$missing = '<strong>' . join('</strong>, <strong>', $active_plugins) . '</strong>';
yourls_add_notice($message . ' ' . $missing);
}
}
示例9: yourls_update_option
* The following code is a shim that helps users store passwords securely in config.php
* by storing a password hash and removing the plaintext.
*
* TODO: Remove this once real user management is implemented
*/
// Did we just fail at encrypting passwords ?
if (isset($_GET['dismiss']) && $_GET['dismiss'] == 'hasherror') {
yourls_update_option('defer_hashing_error', time() + 86400 * 7);
// now + 1 week
} else {
// Encrypt passwords that are clear text
if (!defined('YOURLS_NO_HASH_PASSWORD') && yourls_has_cleartext_passwords()) {
$hash = yourls_hash_passwords_now(YOURLS_CONFIGFILE);
if ($hash === true) {
// Hashing succesful. Remove flag from DB if any.
if (yourls_get_option('defer_hashing_error')) {
yourls_delete_option('defer_hashing_error');
}
} else {
// It failed, display message for first time or if last time was a week ago
if (time() > yourls_get_option('defer_hashing_error') or !yourls_get_option('defer_hashing_error')) {
$message = yourls_s('Could not auto-encrypt passwords. Error was: "%s".', $hash);
$message .= ' ';
$message .= yourls_s('<a href="%s">Get help</a>.', 'http://yourls.org/userpassword');
$message .= '</p><p>';
$message .= yourls_s('<a href="%s">Click here</a> to dismiss this message for one week.', '?dismiss=hasherror');
yourls_add_notice($message);
}
}
}
}
示例10: gmo_domain_swap_add_menu
function gmo_domain_swap_add_menu()
{
echo '<li>';
echo 'Active domain: <select onchange="window.location.hostname = this.value;">';
$domain_swap_values = json_decode(yourls_get_option('domain_swap_values'));
foreach ($domain_swap_values->domains as $domain) {
$selected = $_SERVER["SERVER_NAME"] == $domain ? 'selected' : '';
echo '<option ' . $selected . ' value="' . $domain . '"/>//' . $domain . '/';
}
echo '</select>';
echo '</li>';
}
示例11: itfs_piwik_log_request
/**
* Sends the keyword and destination URL to Piwik
*
* @param bool $return The value to return. Defaults to false with doesn't enable the filter
* @param string $keyword The requested keyword
* @return bool
*/
function itfs_piwik_log_request($return, $keyword)
{
// Get current configuration from database
$piwik_config = yourls_get_option('piwik_config');
// Let's check if the user wants to log bots
if ($piwik_config[remove_bots]) {
if (itfs_piwik_is_bot()) {
return $return;
}
}
try {
// Need to use a file_exists check as require only produces a fatal compilation error
if (!file_exists(dirname(__FILE__) . '/libs/Piwik/PiwikTracker.php')) {
throw new Exception("Error can't load PiwikTracker.php");
} else {
// Piwik Tracking API init
require_once dirname(__FILE__) . '/libs/Piwik/PiwikTracker.php';
PiwikTracker::$URL = $piwik_config[piwik_url];
}
} catch (Exception $e) {
error_log("ITFS_PIWIK: " . $e->getMessage(), 0);
return $return;
}
// Use this to get the destination
$destination = yourls_get_keyword_longurl($keyword);
// Only log a request if we have a destination and the proper Piwik settings
if ($destination == false) {
error_log("ITFS_PIWIK: Missing parameters prevented me from logging the request with Piwik", 0);
error_log("ITFS_PIWIK: Parameters we have: " . $keyword . ', ' . $destination, 0);
return $return;
}
//Useful for hosts using one Piwik installation with multiple YOURLS installation
$domain_landed = $_SERVER['HTTP_HOST'];
$page_url = "http://" . $domain_landed . "/" . $keyword;
try {
$pt = new PiwikTracker($piwik_config[site_id]);
// This will be the entry page in Piwik
$pt->setUrl($page_url);
// This will fail silently if the token is not valid or if the user doesn't have admin rights
if (!empty($piwik_config[token])) {
$pt->setTokenAuth($piwik_config[token]);
}
// This shows up in the visitor logs and identify the source of the data
$pt->setCustomVariable(1, 'App', 'Piwik plugin for YOURLS', 'visit');
// Some useful variables
$pt->setCustomVariable(2, 'Domain landed', $domain_landed, 'page');
$pt->setCustomVariable(3, 'Keyword', $keyword, 'page');
// User defined custom variable
if (!empty($piwik_config[customvar_name]) && !empty($piwik_config[customvar_value])) {
$pt->setCustomVariable(4, $piwik_config[customvar_name], $piwik_config[customvar_value], $piwik_config[customvar_scope]);
}
// Track the visit in Piwik
$title = yourls_get_keyword_title($keyword);
@$pt->doTrackPageView($title);
// The destination URL will show up as an outlink
@$pt->doTrackAction($destination, 'link');
} catch (Exception $e) {
error_log("ITFS_PIWIK: Error when trying to log the request with Piwik. " . $e->getMessage(), 0);
return $return;
}
if ($piwik_config[disable_stats]) {
//error_log("ITFS_PIWIK: NOT logging locally", 0);
return;
} else {
//error_log("ITFS_PIWIK: Logging locally", 0);
return $return;
}
}
示例12: yourls_date_i18n
/**
* Return the date in localized format, based on timestamp.
*
* If the locale specifies the locale month and weekday, then the locale will
* take over the format for the date. If it isn't, then the date format string
* will be used instead.
*
* @since 1.6
*
* @param string $dateformatstring Format to display the date.
* @param bool|int $unixtimestamp Optional. Unix timestamp.
* @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
* @return string The date, translated if locale specifies it.
*/
function yourls_date_i18n($dateformatstring, $unixtimestamp = false, $gmt = false)
{
global $yourls_locale_formats;
if (!isset($yourls_locale_formats)) {
$yourls_locale_formats = new YOURLS_Locale_Formats();
}
$i = $unixtimestamp;
if (false === $i) {
if (!$gmt) {
$i = yourls_current_time('timestamp');
} else {
$i = time();
}
// we should not let date() interfere with our
// specially computed timestamp
$gmt = true;
}
// store original value for language with untypical grammars
// see http://core.trac.wordpress.org/ticket/9396
$req_format = $dateformatstring;
$datefunc = $gmt ? 'gmdate' : 'date';
if (!empty($yourls_locale_formats->month) && !empty($yourls_locale_formats->weekday)) {
$datemonth = $yourls_locale_formats->get_month($datefunc('m', $i));
$datemonth_abbrev = $yourls_locale_formats->get_month_abbrev($datemonth);
$dateweekday = $yourls_locale_formats->get_weekday($datefunc('w', $i));
$dateweekday_abbrev = $yourls_locale_formats->get_weekday_abbrev($dateweekday);
$datemeridiem = $yourls_locale_formats->get_meridiem($datefunc('a', $i));
$datemeridiem_capital = $yourls_locale_formats->get_meridiem($datefunc('A', $i));
$dateformatstring = ' ' . $dateformatstring;
$dateformatstring = preg_replace("/([^\\\\])D/", "\\1" . yourls_backslashit($dateweekday_abbrev), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\\])F/", "\\1" . yourls_backslashit($datemonth), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\\])l/", "\\1" . yourls_backslashit($dateweekday), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\\])M/", "\\1" . yourls_backslashit($datemonth_abbrev), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\\])a/", "\\1" . yourls_backslashit($datemeridiem), $dateformatstring);
$dateformatstring = preg_replace("/([^\\\\])A/", "\\1" . yourls_backslashit($datemeridiem_capital), $dateformatstring);
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
}
$timezone_formats = array('P', 'I', 'O', 'T', 'Z', 'e');
$timezone_formats_re = implode('|', $timezone_formats);
if (preg_match("/{$timezone_formats_re}/", $dateformatstring)) {
// TODO: implement a timezone option
$timezone_string = yourls_get_option('timezone_string');
if ($timezone_string) {
$timezone_object = timezone_open($timezone_string);
$date_object = date_create(null, $timezone_object);
foreach ($timezone_formats as $timezone_format) {
if (false !== strpos($dateformatstring, $timezone_format)) {
$formatted = date_format($date_object, $timezone_format);
$dateformatstring = ' ' . $dateformatstring;
$dateformatstring = preg_replace("/([^\\\\]){$timezone_format}/", "\\1" . yourls_backslashit($formatted), $dateformatstring);
$dateformatstring = substr($dateformatstring, 1, strlen($dateformatstring) - 1);
}
}
}
}
$j = @$datefunc($dateformatstring, $i);
// allow plugins to redo this entirely for languages with untypical grammars
$j = yourls_apply_filter('date_i18n', $j, $req_format, $i, $gmt);
return $j;
}
示例13: yourls_check_maintenance_mode
function yourls_check_maintenance_mode()
{
// TODO: all cases that always display the sites (is_admin but not is_ajax?)
if (1) {
return;
}
// first case: /user/maintenance.php file
if (file_exists(YOURLS_USERDIR . '/maintenance.php')) {
include YOURLS_USERDIR . '/maintenance.php';
die;
}
// second case: option in DB
if (yourls_get_option('maintenance_mode') !== false) {
require_once YOURLS_INC . '/functions-html.php';
$title = 'Service temporarily unavailable';
$message = 'Our service is currently undergoing scheduled maintenance.</p>
<p>Things should not last very long, thank you for your patience and please excuse the inconvenience';
yourls_die($message, $title, 503);
}
}
示例14: yourls_get_option
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
require_once "recaptchalib.php";
// Register API keys at https://www.google.com/recaptcha/admin
$siteKey = yourls_get_option('abdulrauf_adminreCaptcha_pub_key');
$secret = yourls_get_option('abdulrauf_adminreCaptcha_priv_key');
// reCAPTCHA supported 40+ languages listed here: https://developers.google.com/recaptcha/docs/language
$lang = "en";
// The response from reCAPTCHA
$resp = null;
// The error code from reCAPTCHA, if any
$error = null;
$reCaptcha = new ReCaptcha($secret);
// Was there a reCAPTCHA response?
if ($_POST["g-recaptcha-response"]) {
$resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]);
}
示例15: yourls_is_installed
function yourls_is_installed()
{
static $is_installed = false;
if ($is_installed === false) {
$check_14 = $check_13 = false;
global $ydb;
if (defined('YOURLS_DB_TABLE_NEXTDEC')) {
$check_13 = $ydb->get_var('SELECT `next_id` FROM ' . YOURLS_DB_TABLE_NEXTDEC);
}
$check_14 = yourls_get_option('version');
$is_installed = $check_13 || $check_14;
}
return $is_installed;
}