当前位置: 首页>>代码示例>>PHP>>正文


PHP yourls__函数代码示例

本文整理汇总了PHP中yourls__函数的典型用法代码示例。如果您正苦于以下问题:PHP yourls__函数的具体用法?PHP yourls__怎么用?PHP yourls__使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了yourls__函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: yourls_set_DB_driver

/**
 * Pick the right DB class and return an instance
 *
 * @since 1.7
 * @param string $extension Optional: user defined choice
 * @return class $ydb DB class instance
 */
function yourls_set_DB_driver()
{
    // Auto-pick the driver. Priority: user defined, then PDO, then mysqli, then mysql
    if (defined('YOURLS_DB_DRIVER')) {
        $driver = strtolower(YOURLS_DB_DRIVER);
        // accept 'MySQL', 'mySQL', etc
    } elseif (extension_loaded('pdo_mysql')) {
        $driver = 'pdo';
    } elseif (extension_loaded('mysqli')) {
        $driver = 'mysqli';
    } elseif (extension_loaded('mysql')) {
        $driver = 'mysql';
    } else {
        $driver = '';
    }
    // Set the new driver
    if (in_array($driver, array('mysql', 'mysqli', 'pdo'))) {
        require_once YOURLS_INC . '/ezSQL/ez_sql_core.php';
        require_once YOURLS_INC . '/ezSQL/ez_sql_core_yourls.php';
        require_once YOURLS_INC . '/ezSQL/ez_sql_' . $driver . '.php';
        require_once YOURLS_INC . '/ezSQL/ez_sql_' . $driver . '_yourls.php';
    }
    $class = 'ezSQL_' . $driver . '_yourls';
    global $ydb;
    if (!class_exists($class, false)) {
        $ydb = new stdClass();
        yourls_die(yourls__('YOURLS requires the mysql, mysqli or pdo_mysql PHP extension. No extension found. Check your server config, or contact your host.'), yourls__('Fatal error'), 503);
    }
    yourls_do_action('set_DB_driver', $driver);
    $ydb = new $class(YOURLS_DB_USER, YOURLS_DB_PASS, YOURLS_DB_NAME, YOURLS_DB_HOST);
    yourls_debug_log("DB driver: {$driver}");
}
开发者ID:mimischi,项目名称:gu-urlshorter,代码行数:39,代码来源:class-mysql.php

示例2: getFunctions

 public function getFunctions()
 {
     return array(new \Twig_SimpleFunction('yourls__', function ($text, $domain = '') {
         if (!$domain) {
             $domain = $this->_options['namespace'];
         }
         return yourls__($text, $domain);
     }));
 }
开发者ID:laemmi,项目名称:laemmi-yourls-default-tools,代码行数:9,代码来源:Extension.php

示例3: yourls_is_valid_user

/**
 * Check for valid user via login form or stored cookie. Returns true or an error message
 *
 */
function yourls_is_valid_user()
{
    // Allow plugins to short-circuit the whole function
    $pre = yourls_apply_filter('shunt_is_valid_user', null);
    if (null !== $pre) {
        return $pre;
    }
    // $unfiltered_valid : are credentials valid? Boolean value. It's "unfiltered" to allow plugins to eventually filter it.
    $unfiltered_valid = false;
    // Logout request
    if (isset($_GET['action']) && $_GET['action'] == 'logout') {
        yourls_do_action('logout');
        yourls_store_cookie(null);
        return yourls__('Logged out successfully');
    }
    // Check cookies or login request. Login form has precedence.
    yourls_do_action('pre_login');
    // Determine auth method and check credentials
    if (yourls_is_API() && isset($_REQUEST['timestamp']) && !empty($_REQUEST['timestamp']) && isset($_REQUEST['signature']) && !empty($_REQUEST['signature'])) {
        yourls_do_action('pre_login_signature_timestamp');
        $unfiltered_valid = yourls_check_signature_timestamp();
    } elseif (yourls_is_API() && !isset($_REQUEST['timestamp']) && isset($_REQUEST['signature']) && !empty($_REQUEST['signature'])) {
        yourls_do_action('pre_login_signature');
        $unfiltered_valid = yourls_check_signature();
    } elseif (isset($_REQUEST['username']) && isset($_REQUEST['password']) && !empty($_REQUEST['username']) && !empty($_REQUEST['password'])) {
        yourls_do_action('pre_login_username_password');
        $unfiltered_valid = yourls_check_username_password();
    } elseif (!yourls_is_API() && isset($_COOKIE[yourls_cookie_name()])) {
        yourls_do_action('pre_login_cookie');
        $unfiltered_valid = yourls_check_auth_cookie();
    }
    // Regardless of validity, allow plugins to filter the boolean and have final word
    $valid = yourls_apply_filter('is_valid_user', $unfiltered_valid);
    // Login for the win!
    if ($valid) {
        yourls_do_action('login');
        // (Re)store encrypted cookie if needed
        if (!yourls_is_API()) {
            yourls_store_cookie(YOURLS_USER);
            // Login form : redirect to requested URL to avoid re-submitting the login form on page reload
            if (isset($_REQUEST['username']) && isset($_REQUEST['password']) && isset($_SERVER['REQUEST_URI'])) {
                $url = $_SERVER['REQUEST_URI'];
                yourls_redirect($url);
            }
        }
        // Login successful
        return true;
    }
    // Login failed
    yourls_do_action('login_failed');
    if (isset($_REQUEST['username']) || isset($_REQUEST['password'])) {
        return yourls__('Invalid username or password');
    } else {
        return yourls__('Please log in');
    }
}
开发者ID:Steadroy,项目名称:YOURLS,代码行数:60,代码来源:functions-auth.php

示例4: display_error

function display_error($message, $action)
{
    echo '<div class="content error">';
    echo '<p class="message">' . $message . '</p>';
    if (!empty($action)) {
        echo $action;
    } else {
        echo '<p class="action"><a href="javascript:history.go(-1)" class="button">' . yourls__('&larr; Go back and try again', 'isq_translation') . '</a></p>';
    }
    echo '</div>';
    include 'footer.php';
    die;
}
开发者ID:blacksector,项目名称:infinity-squared,代码行数:13,代码来源:result.php

示例5: yourls_check_password_hash

/**
 * Check a REQUEST password sent in plain text against stored password which can be a salted hash
 *
 */
function yourls_check_password_hash($stored, $plaintext)
{
    if (substr($stored, 0, 4) == 'md5:' and strlen($stored) == 42) {
        // Stored password is a salted hash: "md5:<$r = rand(10000,99999)>:<md5($r.'thepassword')>"
        // And 42. Of course. http://www.google.com/search?q=the+answer+to+life+the+universe+and+everything
        list($temp, $salt, $md5) = explode(':', $stored);
        return $stored == 'md5:' . $salt . ':' . md5($salt . $plaintext);
    } else {
        // Password was sent in clear
        $message = '';
        $message .= yourls__('<strong>Notice</strong>: your password is stored as clear text in your <tt>config.php</tt>');
        $message .= yourls__('Did you know you can easily improve the security of your YOURLS install by <strong>encrypting</strong> your password?');
        $message .= yourls__('See <a href="http://yourls.org/userpassword">UsernamePassword</a> for details');
        yourls_add_notice($message, 'notice');
        return $stored == $plaintext;
    }
}
开发者ID:GasmoN,项目名称:yourls,代码行数:21,代码来源:functions-auth.php

示例6: RegExp

            ur = l.split(new RegExp(ups))[1],
            ups = ups.split(/\\:/),
            p = '?up=' + enc(ups[0]+':') + '&us=' + enc(ups[1]) + '&ur='+enc(ur) + '&t=' + enc(d.title) + '&s=' + s2 + '&share=tumblr',
            u = f + p;
        try {
            throw ('ozhismygod');
        } catch (z) {
            a = function () {
                if (!w.open(u,'Share','width=450,height=450,left=430','_blank')) l = u;
            };
            if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0);
            else a();
        }
        void(0);
TUMBLR;
yourls_bookmarklet_link(yourls_make_bookmarklet($js_code), yourls__('YOURLS &amp; Tumblr'));
?>
        
		<?php 
yourls_do_action('social_bookmarklet_buttons_after');
?>
		
		</p>

	<h2><?php 
yourls_e('Prefix-n-Shorten');
?>
</h2>
		
		<p><?php 
yourls_se("When viewing a page, you can also prefix its full URL: just head to your browser's address bar, add \"<span>%s</span>\" to the beginning of the current URL (right before its 'http://' part) and hit enter.", preg_replace('@https?://@', '', YOURLS_SITE) . '/');
开发者ID:Steadroy,项目名称:YOURLS,代码行数:31,代码来源:tools.php

示例7: yourls_plugin_admin_page

/**
 * Handle plugin administration page
 *
 */
function yourls_plugin_admin_page($plugin_page)
{
    global $ydb;
    // Check the plugin page is actually registered
    if (!isset($ydb->plugin_pages[$plugin_page])) {
        yourls_die(yourls__('This page does not exist. Maybe a plugin you thought was activated is inactive?'), yourls__('Invalid link'));
    }
    // Draw the page itself
    yourls_do_action('load-' . $plugin_page);
    yourls_html_head('plugin_page_' . $plugin_page, $ydb->plugin_pages[$plugin_page]['title']);
    yourls_html_logo();
    yourls_html_menu();
    call_user_func($ydb->plugin_pages[$plugin_page]['function']);
    yourls_html_footer();
    die;
}
开发者ID:GasmoN,项目名称:yourls,代码行数:20,代码来源:functions-plugins.php

示例8: yourls_l10n_calendar_strings

/**
 * Output translated strings used by the Javascript calendar
 *
 * @since 1.6
 */
function yourls_l10n_calendar_strings()
{
    echo "\n<script>\n";
    echo "var l10n_cal_month = " . json_encode(array_values(yourls_l10n_months())) . ";\n";
    echo "var l10n_cal_days = " . json_encode(array_values(yourls_l10n_weekday_initial())) . ";\n";
    echo "var l10n_cal_today = \"" . yourls_esc_js(yourls__('Today')) . "\";\n";
    echo "var l10n_cal_close = \"" . yourls_esc_js(yourls__('Close')) . "\";\n";
    echo "</script>\n";
    // Dummy returns, to initialize l10n strings used in the calendar
    yourls__('Today');
    yourls__('Close');
}
开发者ID:yourls,项目名称:yourls,代码行数:17,代码来源:functions-html.php

示例9: yourls_deprecated_function

/**
 * Marks a function as deprecated and informs when it has been used. Stolen from WP.
 *
 * There is a hook deprecated_function that will be called that can be used
 * to get the backtrace up to what file and function called the deprecated
 * function.
 *
 * The current behavior is to trigger a user error if YOURLS_DEBUG is true.
 *
 * This function is to be used in every function that is deprecated.
 *
 * @since 1.6
 * @uses yourls_do_action() Calls 'deprecated_function' and passes the function name, what to use instead,
 *   and the version the function was deprecated in.
 * @uses yourls_apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do
 *   trigger or false to not trigger error.
 *
 * @param string $function The function that was called
 * @param string $version The version of WordPress that deprecated the function
 * @param string $replacement Optional. The function that should have been called
 */
function yourls_deprecated_function($function, $version, $replacement = null)
{
    yourls_do_action('deprecated_function', $function, $replacement, $version);
    // Allow plugin to filter the output error trigger
    if (YOURLS_DEBUG && yourls_apply_filters('deprecated_function_trigger_error', true)) {
        if (!is_null($replacement)) {
            trigger_error(sprintf(yourls__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement));
        } else {
            trigger_error(sprintf(yourls__('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version));
        }
    }
}
开发者ID:steenhulthin,项目名称:hult.in,代码行数:33,代码来源:functions.php

示例10: yourls_db_dead

/**
 * Die with a DB error message
 *
 * @TODO in version 1.8 : use a new localized string, specific to the problem (ie: "DB is dead")
 *
 * @since 1.7.1
 */
function yourls_db_dead()
{
    // Use any /user/db_error.php file
    if (file_exists(YOURLS_USERDIR . '/db_error.php')) {
        include_once YOURLS_USERDIR . '/db_error.php';
        die;
    }
    yourls_die(yourls__('Incorrect DB config, or could not connect to DB'), yourls__('Fatal error'), 503);
}
开发者ID:steenhulthin,项目名称:hult.in,代码行数:16,代码来源:class-mysql.php

示例11: mapLdapException

 /**
  * Map Ldap exceptions
  *
  * @param Exception $e
  * @return string
  */
 private function mapLdapException(Exception $e)
 {
     switch ($e->getCode()) {
         case Ldap::ERROR_COULD_CONNECT_TO_SERVER:
         case Ldap::ERROR_COULD_NOT_BIND_TO_SERVER:
             $msg = yourls__('No connection to LDAP-Server', self::APP_NAMESPACE);
             break;
         case Ldap::ERROR_NO_SEARCH_RESULT:
         case Ldap::ERROR_NO_USER_WITH_INFORMATION_FOUND:
         case Ldap::ERROR_NO_ENTRIES_FOUND:
         case Ldap::ERROR_USER_IS_NOT_IN_ALLOWED_GROUP:
         case Ldap::ERROR_AUTH_FAILED_WRONG_PASSWORD:
         default:
             $msg = yourls__('Invalid username or password', self::APP_NAMESPACE);
     }
     return $msg . (true === YOURLS_DEBUG ? ' (' . $e->getMessage() . ')' : '');
 }
开发者ID:laemmi,项目名称:laemmi-yourls-easy-ldap,代码行数:23,代码来源:Plugin.php

示例12: action_yourls_ajax_laemmi_edit_ldapgroup_save

 /**
  * Action: yourls_ajax_laemmi_edit_ldapgroup_save
  */
 public function action_yourls_ajax_laemmi_edit_ldapgroup_save()
 {
     $keyword = yourls_sanitize_string($this->getRequest('keyword'));
     $nonce = $this->getRequest('nonce');
     $id = yourls_string2htmlid($keyword);
     yourls_verify_nonce('laemmi_edit_ldapgroup_save_' . $id, $nonce, false, 'omg error');
     $this->action_insert_link(['', '', $keyword, '', '', '']);
     $return = [];
     $return['status'] = 'success';
     $return['message'] = yourls__('Link updated in database', self::APP_NAMESPACE);
     echo json_encode($return);
 }
开发者ID:laemmi,项目名称:laemmi-yourls-bind-user-to-entry,代码行数:15,代码来源:Plugin.php

示例13: yourls_site_url

?>
		<p>
			<img src="<?php 
yourls_site_url();
?>
/images/yourls-logo.png" alt="YOURLS" title="YOURLS" />
		</p>
		<?php 
// Print errors, warnings and success messages
foreach (array('error', 'warning', 'success') as $info) {
    if (count(${$info}) > 0) {
        echo "<ul class='{$info}'>";
        foreach (${$info} as $msg) {
            echo '<li>' . $msg . "</li>\n";
        }
        echo '</ul>';
    }
}
// Display install button or link to admin area if applicable
if (!yourls_is_installed() && !isset($_REQUEST['install'])) {
    echo '<p style="text-align: center;"><input type="submit" name="install" value="' . yourls__('Install YOURLS') . '" class="button" /></p>';
} else {
    if (count($error) == 0) {
        echo '<p style="text-align: center;">&raquo; <a href="' . yourls_admin_url() . '" title="' . yourls__('YOURLS Administration Page') . '">' . yourls__('YOURLS Administration Page') . '</a></p>';
    }
}
?>
	</form>
</div>
<?php 
yourls_html_footer();
开发者ID:steenhulthin,项目名称:hult.in,代码行数:31,代码来源:install.php

示例14: yourls_html_tfooter

    yourls_html_tfooter($params);
}
yourls_table_tbody_start();
// Main Query
$where = yourls_apply_filter('admin_list_where', $where);
$url_results = $ydb->get_results("SELECT * FROM `{$table_url}` WHERE 1=1 {$where} ORDER BY `{$sort_by}` {$sort_order} LIMIT {$offset}, {$perpage};");
$found_rows = false;
if ($url_results) {
    $found_rows = true;
    foreach ($url_results as $url_result) {
        $keyword = yourls_sanitize_string($url_result->keyword);
        $timestamp = strtotime($url_result->timestamp);
        $url = stripslashes($url_result->url);
        $ip = $url_result->ip;
        $title = $url_result->title ? $url_result->title : '';
        $clicks = $url_result->clicks;
        echo yourls_table_add_row($keyword, $url, $title, $ip, $clicks, $timestamp);
    }
}
$display = $found_rows ? 'display:none' : '';
echo '<tr id="nourl_found" style="' . $display . '"><td colspan="6">' . yourls__('No URL') . '</td></tr>';
yourls_table_tbody_end();
yourls_table_end();
yourls_do_action('admin_page_after_table');
if ($is_bookmark) {
    yourls_share_box($url, $return['shorturl'], $title, $text);
}
?>
	
<?php 
yourls_html_footer();
开发者ID:yourls,项目名称:yourls,代码行数:31,代码来源:index.php

示例15: yourls_create_sql_tables

/**
 * Create MySQL tables. Return array( 'success' => array of success strings, 'errors' => array of error strings )
 *
 * @since 1.3
 * @return array  An array like array( 'success' => array of success strings, 'errors' => array of error strings )
 */
function yourls_create_sql_tables()
{
    // Allow plugins (most likely a custom db.php layer in user dir) to short-circuit the whole function
    $pre = yourls_apply_filter('shunt_yourls_create_sql_tables', null);
    // your filter function should return an array of ( 'success' => $success_msg, 'error' => $error_msg ), see below
    if (null !== $pre) {
        return $pre;
    }
    global $ydb;
    $error_msg = array();
    $success_msg = array();
    // Create Table Query
    $create_tables = array();
    $create_tables[YOURLS_DB_TABLE_URL] = 'CREATE TABLE IF NOT EXISTS `' . YOURLS_DB_TABLE_URL . '` (' . '`keyword` varchar(200) BINARY NOT NULL,' . '`url` text BINARY NOT NULL,' . '`title` text CHARACTER SET utf8,' . '`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,' . '`ip` VARCHAR(41) NOT NULL,' . '`clicks` INT(10) UNSIGNED NOT NULL,' . ' PRIMARY KEY  (`keyword`),' . ' KEY `timestamp` (`timestamp`),' . ' KEY `ip` (`ip`)' . ');';
    $create_tables[YOURLS_DB_TABLE_OPTIONS] = 'CREATE TABLE IF NOT EXISTS `' . YOURLS_DB_TABLE_OPTIONS . '` (' . '`option_id` bigint(20) unsigned NOT NULL auto_increment,' . '`option_name` varchar(64) NOT NULL default "",' . '`option_value` longtext NOT NULL,' . 'PRIMARY KEY  (`option_id`,`option_name`),' . 'KEY `option_name` (`option_name`)' . ') AUTO_INCREMENT=1 ;';
    $create_tables[YOURLS_DB_TABLE_LOG] = 'CREATE TABLE IF NOT EXISTS `' . YOURLS_DB_TABLE_LOG . '` (' . '`click_id` int(11) NOT NULL auto_increment,' . '`click_time` datetime NOT NULL,' . '`shorturl` varchar(200) BINARY NOT NULL,' . '`referrer` varchar(200) NOT NULL,' . '`user_agent` varchar(255) NOT NULL,' . '`ip_address` varchar(41) NOT NULL,' . '`country_code` char(2) NOT NULL,' . 'PRIMARY KEY  (`click_id`),' . 'KEY `shorturl` (`shorturl`)' . ') AUTO_INCREMENT=1 ;';
    $create_table_count = 0;
    $ydb->show_errors = true;
    // Create tables
    foreach ($create_tables as $table_name => $table_query) {
        $ydb->query($table_query);
        $create_success = $ydb->query("SHOW TABLES LIKE '{$table_name}'");
        if ($create_success) {
            $create_table_count++;
            $success_msg[] = yourls_s("Table '%s' created.", $table_name);
        } else {
            $error_msg[] = yourls_s("Error creating table '%s'.", $table_name);
        }
    }
    // Initializes the option table
    if (!yourls_initialize_options()) {
        $error_msg[] = yourls__('Could not initialize options');
    }
    // Insert sample links
    if (!yourls_insert_sample_links()) {
        $error_msg[] = yourls__('Could not insert sample short URLs');
    }
    // Check results of operations
    if (sizeof($create_tables) == $create_table_count) {
        $success_msg[] = yourls__('YOURLS tables successfully created.');
    } else {
        $error_msg[] = yourls__('Error creating YOURLS tables.');
    }
    return array('success' => $success_msg, 'error' => $error_msg);
}
开发者ID:Steadroy,项目名称:YOURLS,代码行数:51,代码来源:functions-install.php


注:本文中的yourls__函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。