Beispiel #1
0
 function get_direct_link($key, $prli_link_id = false)
 {
     global $frm_siteurl;
     $target_url = esc_url($frm_siteurl . '/index.php?plugin=formidable&controller=forms&frm_action=preview&form=' . $key);
     if ($prli_link_id && class_exists('PrliLink')) {
         $prli = prli_get_pretty_link_url($prli_link_id);
         if ($prli) {
             $target_url = $prli;
         }
     }
     return $target_url;
 }
Beispiel #2
0
/**
 * Gets the full Pretty Link URL from a link id
 *
 * @return bool (false if failure) | string containing the pretty link url
 */
function prli_xmlrpc_get_pretty_link_url($args)
{
    $username = $args[0];
    $password = $args[1];
    if (!get_option('enable_xmlrpc')) {
        return new IXR_Error(401, __('Sorry, XML-RPC Not enabled for this website', 'pretty-link'));
    }
    if (!user_pass_ok($username, $password)) {
        return new IXR_Error(401, __('Sorry, Login failed', 'pretty-link'));
    }
    // make sure user is an admin
    $userdata = get_userdatabylogin($username);
    if (!isset($userdata->user_level) or (int) $userdata->user_level < 8) {
        return new IXR_Error(401, __('Sorry, you must be an administrator to access this resource', 'pretty-link'));
    }
    if (!isset($args[2])) {
        return new IXR_Error(401, __('Sorry, you must provide an id to lookup', 'pretty-link'));
    }
    $id = $args[2];
    if ($url = prli_get_pretty_link_url($id)) {
        return $url;
    } else {
        return new IXR_Error(401, __('There was an error fetching your Pretty Link URL', 'pretty-link'));
    }
}
Beispiel #3
0
 public function get_target_to_pretty_urls($urls = array(), $create_pretty_links = false)
 {
     global $wpdb, $prli_blogurl;
     if (empty($urls)) {
         return false;
     }
     $decoded_urls = array_map(create_function('$url', 'return html_entity_decode(urldecode($url));'), $urls);
     if (count($decoded_urls) > 1) {
         $where = "IN (" . implode(',', array_map(create_function('$url', 'return "\\"{$url}\\"";'), $decoded_urls)) . ")";
     } else {
         $where = "= '" . html_entity_decode(urldecode($decoded_urls[0])) . "'";
     }
     $query = "SELECT li.url AS target_url, " . "CONCAT(%s, li.slug) AS pretty_url " . "FROM {$this->table_name} AS li " . "WHERE li.url {$where}";
     $query = $wpdb->prepare($query, $prli_blogurl . PrliUtils::get_permalink_pre_slug_uri());
     $results = (array) $wpdb->get_results($query);
     $prli_lookup = array();
     foreach ($results as $url_hash) {
         if (isset($prli_lookup[$url_hash->target_url])) {
             $prli_lookup[$url_hash->target_url][] = $url_hash->pretty_url;
         } else {
             $prli_lookup[$url_hash->target_url] = array($url_hash->pretty_url);
         }
     }
     if ($create_pretty_links) {
         foreach ($decoded_urls as $url) {
             if (!isset($prli_lookup[$url])) {
                 if ($id = prli_create_pretty_link($url)) {
                     $prli_lookup[$url] = array(prli_get_pretty_link_url($id));
                 }
             }
         }
     }
     return $prli_lookup;
 }