Ejemplo n.º 1
0
 function sanitize_twitter_handle($value)
 {
     if (strpos($value, '/') === false) {
         $handle = ltrim($value, '@');
     } else {
         $url_parts = explode('/', $value);
         $handle = array_pop($url_parts);
     }
     $handle = sustr::preg_filter('a-zA-Z0-9_', $handle);
     $handle = trim($handle);
     if ($handle) {
         $handle = "@{$handle}";
     }
     return $handle;
 }
 function admin_page_contents()
 {
     echo "\n<p>";
     _e('The Content Links section of Deeplink Juggernaut lets you automatically link a certain word or phrase in your post/page content to a URL you specify.', 'seo-ultimate');
     echo "</p>\n";
     $links = $this->get_setting('links', array());
     $num_links = count($links);
     if ($this->is_action('update')) {
         $links = array();
         $guid = stripslashes($_POST['_link_guid']);
         for ($i = 0; $i <= $num_links; $i++) {
             $anchor = stripslashes($_POST["link_{$i}_anchor"]);
             $to = stripslashes($_POST["link_{$i}_to"]);
             if (sustr::startswith($to, 'obj_')) {
                 $to = sustr::ltrim_str($to, 'obj_');
                 $to = explode('/', $to);
                 if (count($to) == 2) {
                     $to_type = $to[0];
                     $to_id = $to[1];
                 } else {
                     $to_type = $to[0];
                     $to_id = null;
                 }
             } else {
                 $to_type = 'url';
                 $to_id = $to;
             }
             $title = stripslashes($_POST["link_{$i}_title"]);
             $dampen_sitewide_lpa = sustr::preg_filter('0-9', strval($_POST["link_{$i}_dampen_sitewide_lpa"]));
             $dampen_sitewide_lpa = $dampen_sitewide_lpa === '' ? false : intval($dampen_sitewide_lpa);
             $sitewide_lpa = isset($_POST["link_{$i}_sitewide_lpa"]) ? sustr::preg_filter('0-9', strval($_POST["link_{$i}_sitewide_lpa"])) : '';
             $sitewide_lpa = $sitewide_lpa === '' ? false : intval($sitewide_lpa);
             $target = empty($_POST["link_{$i}_target"]) ? 'self' : 'blank';
             $nofollow = isset($_POST["link_{$i}_nofollow"]) ? intval($_POST["link_{$i}_nofollow"]) == 1 : false;
             $delete = isset($_POST["link_{$i}_delete"]) ? intval($_POST["link_{$i}_delete"]) == 1 : false;
             if (!$delete && (strlen($anchor) || $to_id)) {
                 $links[] = compact('anchor', 'to_type', 'to_id', 'title', 'dampen_sitewide_lpa', 'sitewide_lpa', 'nofollow', 'target');
             }
         }
         $this->update_setting('links', $links);
         $num_links = count($links);
     }
     $this->legacy_sitewide_lpa_in_use = false;
     foreach ($links as $link) {
         if (isset($link['sitewide_lpa']) && $link['sitewide_lpa']) {
             $this->legacy_sitewide_lpa_in_use = true;
             break;
         }
     }
     if ($this->legacy_sitewide_lpa_in_use) {
         $this->print_message('warning', __('<strong>Functionality Change Notice:</strong> The &#8220;Site Cap&#8221; feature (which allowed you set a per-link sitewide quantity limit) has been replaced with a more efficient &#8220;Dampener&#8221; feature that lets you reduce autolinking frequency by a percentage. Although the Site Cap feature has been replaced, we retained the &#8220;Site Cap&#8221; column for you in the table below, since it looks like you&#8217;ve used the Site Cap feature in the past. We retained the column to help you remember which links used the old feature, so that you know to which links to apply the new &#8220;Dampener&#8221; feature. Once you&#8217;re done migrating the Site Cap values to Dampener percentages, just clear the &#8220;Site Cap&#8221; boxes to make those boxes (and this message) go away.', 'seo-ultimate'));
     }
     $guid = substr(md5(time()), 0, 10);
     if ($num_links > 0) {
         $this->admin_subheader(__('Edit Existing Links', 'seo-ultimate'));
         $this->content_links_form($guid, 0, $links);
     }
     $this->admin_subheader(__('Add a New Link', 'seo-ultimate'));
     $this->content_links_form($guid, $num_links, array(array()), false);
 }
Ejemplo n.º 3
0
 function htmlsafe_preg_replace($search, $replace, $subject, $limit, &$count, $exclude_tags = false)
 {
     if (!$exclude_tags || !is_array($exclude_tags)) {
         $exclude_tags = array('a', 'pre', 'code', 'kbd');
     }
     if (count($exclude_tags) > 1) {
         $exclude_tags = sustr::preg_filter('a-z0-9|', implode('|', $exclude_tags));
     } else {
         $exclude_tags = array_shift($exclude_tags);
     }
     $search = str_replace('/', '\\/', $search);
     //Based off of regex from
     //http://stackoverflow.com/questions/3013164/regex-to-replace-a-string-in-html-but-not-within-a-link-or-heading
     $search_regex = "/\\b({$search})\\b(?!(?:(?!<\\/?(?:{$exclude_tags}).*?>).)*<\\/(?:{$exclude_tags}).*?>)(?![^<>]*>)/imsU";
     return preg_replace($search_regex, $replace, $subject, $limit, $count);
 }
Ejemplo n.º 4
0
 function log_hit($hit)
 {
     if ($hit['status_code'] == 404) {
         if ($this->get_setting('restrict_logging', true)) {
             if (!($this->get_setting('log_spiders', true) && suweb::is_search_engine_ua($hit['user_agent'])) && !($this->get_setting('log_errors_with_referers', true) && strlen($hit['referer']))) {
                 return $hit;
             }
         }
         $exceptions = suarr::explode_lines($this->get_setting('exceptions', ''));
         foreach ($exceptions as $exception) {
             if (preg_match(sustr::wildcards_to_regex($exception), $hit['url'])) {
                 return $hit;
             }
         }
         $l = $this->get_setting('log', array());
         $max_log_size = absint(sustr::preg_filter('0-9', strval($this->get_setting('max_log_size', 100))));
         while (count($l) > $max_log_size) {
             array_pop($l);
         }
         $u = $hit['url'];
         if (!isset($l[$u])) {
             $l[$u] = array();
             $l[$u]['hit_count'] = 0;
             $l[$u]['is_new'] = isset($hit['is_new']) ? $hit['is_new'] : true;
             $l[$u]['referers'] = array();
             $l[$u]['user_agents'] = array();
             $l[$u]['last_hit_time'] = 0;
         }
         $l[$u]['hit_count']++;
         if (!$l[$u]['is_new'] && $hit['is_new']) {
             $l[$u]['is_new'] = true;
         }
         if ($hit['time'] > $l[$u]['last_hit_time']) {
             $l[$u]['last_hit_time'] = $hit['time'];
         }
         if (strlen($hit['referer']) && !in_array($hit['referer'], $l[$u]['referers'])) {
             $l[$u]['referers'][] = $hit['referer'];
         }
         if (strlen($hit['user_agent']) && !in_array($hit['user_agent'], $l[$u]['user_agents'])) {
             $l[$u]['user_agents'][] = $hit['user_agent'];
         }
         $this->update_setting('log', $l);
     }
     return $hit;
 }
Ejemplo n.º 5
0
 function do_installation()
 {
     if (!isset($_POST['version'])) {
         return false;
     }
     $nv = sustr::preg_filter('0-9a-zA-Z .', $_POST['version']);
     if (!strlen($nv)) {
         return false;
     }
     //Don't allow downgrading to anything below the minimum limit
     if (version_compare(SU_DOWNGRADE_LIMIT, $nv, '>')) {
         return;
     }
     switch (version_compare($nv, SU_VERSION)) {
         case -1:
             //Downgrade
             $title = __('Downgrade to SEO Ultimate %s', 'seo-ultimate');
             if (!$this->current_user_can_downgrade()) {
                 wp_die(__('You do not have sufficient permissions to downgrade plugins on this site.', 'seo-ultimate'));
                 return;
             }
             break;
         case 0:
             //Reinstall
             $title = __('Reinstall SEO Ultimate %s', 'seo-ultimate');
             if (!$this->current_user_can_reinstall()) {
                 wp_die(__('You do not have sufficient permissions to reinstall plugins on this site.', 'seo-ultimate'));
                 return;
             }
             break;
         case 1:
             //Upgrade
             $title = __('Upgrade to SEO Ultimate %s', 'seo-ultimate');
             if (!$this->current_user_can_upgrade()) {
                 wp_die(__('You do not have sufficient permissions to upgrade plugins on this site.', 'seo-ultimate'));
                 return;
             }
             break;
         default:
             return;
     }
     $title = sprintf($title, $nv);
     $nonce = 'su-install-plugin';
     $plugin = 'seo-ultimate/seo-ultimate.php';
     $url = 'update.php?action=upgrade-plugin&plugin=' . $plugin;
     include_once $this->plugin->plugin_dir_path . 'plugin/class.su-installer.php';
     $upgrader = new SU_Installer(new SU_Installer_Skin(compact('title', 'nonce', 'url', 'plugin')));
     $upgrader->upgrade($plugin, SU_VERSION, $nv);
     return true;
 }
Ejemplo n.º 6
0
 /**
  * Sorts an array of arrays by using a given array key to locate string values in the second-level arrays and sorting the first-level array accordingly.
  * Reverse length sorting is used. (Longest strings are first, shortest strings last.)
  * 
  * @param array $arr Passed by reference
  * @param string $valuekey The array key used to access the string values by which the arrays in $arr are to be sorted
  */
 static function vklrsort(&$arr, $valuekey)
 {
     $valuekey = sustr::preg_filter('A-Za-z0-9 ', $valuekey);
     uasort($arr, create_function('$a,$b', 'return strlen($b["' . $valuekey . '"]) - strlen($a["' . $valuekey . '"]);'));
 }
 function filter_alias_dir($alias_dir)
 {
     return trim(sustr::preg_filter('a-zA-Z0-9_/', $alias_dir), '/');
 }
Ejemplo n.º 8
0
 function filter_canonical_url_scheme($scheme)
 {
     return sustr::preg_filter('a-z', $scheme);
 }