Oct 28
This simple script makes good things!
1) leave first img tag
2) remove all another img tags
3) cut text by length
So you get simple text short text with one image on it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| function cut_text($x) {
$alli = catch_that_image($x);
if ($alli) {
$x= substr($x, 0, $alli[2]+$alli[3]).
substr(strip_only($x, '<img>'), $alli[2]);
}
if(strlen($x) > 700) {
$x = substr($x, 0, 700);
$y = strrpos($x, '>');
$x = substr($x, 0, $y). '>...';
}
return $x;
}
function catch_that_image($x) {
$first_img = '';
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $x, $matches);
@$first_img = $matches [1][0];
$imglen = strlen($matches [0][0]);
if (strlen($matches [1][0]) AND $imglen){
$imgpos = stripos($x, $matches [0][0]);
$tx = substr($x, 0, $imgpos).substr($x, $imgpos+$imglen); //Vsio krome<img>
}else{
$tx = false;
}
return array($tx,$matches [0][0], $imgpos, $imglen );
}
function strip_only($str, $tags) {
if(!is_array($tags)) {
$tags = (strpos($str, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags));
if(end($tags) == '') array_pop($tags);
}
foreach($tags as $tag) $str = preg_replace('#</?'.$tag.'[^>]*>#is', '', $str);
return $str;
}
echo cut_text('<div class="content" style="min-height: 202px;">
<img width="200" height="200" alt="Post Pic" src="http://www.wprecipes.com/wp-content/uploads/2009/02/php2.jpg"/>
<div class="pic fl">
<img width="200" height="200" alt="Post Pic" src="http://www.wprecipes.com/wp-content/uploads/2009/02/php2.jpg"/>
</div>
<div class="post-title">
</div>
<img width="200" height="200" alt="Post Pic" src="http://www.wprecipes.com/wp-content/uploads/2009/02/php2.jpg"/>
<div class="post-excerpt">'); |
Apr 02
please open header php in template
and replace title
<title>
<?php if (is_category()) { echo strip_tags(category_description()); }
else{
wp_title(‘«’, true, ‘right’); ?> <?php bloginfo(‘name’);
}
?></title>
Jul 25
Linkator is the avtomatizirovannya system of exchange by Refs.s. Participants place for itself on a site the catalogue of Refs.s, where the sites of other participants are presented, or pay placing of reference the creator of catalogue without placing of catalogue for itself.
Jul 25
(pay per click)(angl.) to pay for pressure. It is the system of advertising in the internet, which places advertising on sites, suitable under this theme, and payment goes for pressure an user on a banner(text or graphic). Thus turns out that an advertiser buys itself clients in the internet after fully priemlimuyu sum.
Jun 07
Banner Banner – it more frequent than all an animation graphic picture placed with the purpose of advertising on some site. Sometimes it is compared to the outdoor advertising.
Jun 07
At development of multilingual sites for html-pages most more comfortable and predpochtitel’ney to use the code of Utf-8, providing support all or almost all existent languages and encoding ascii-characters (Roman alphabet, numbers and special characters) by one byte, and national alphabets — a few. Thus, the code of Utf-8 has variable physical length of every character. In this connection sometimes there are problems at programming of multilanguage sites.
For example, in a programming of PHP of function of strlen and substr language give out improper results, if there are characters of national alphabet in a line (as intended for work with an onebyte code). Certainly, in PHP there are such functions as mb_strlen and mb_susbtr, specially intended for work with multibyte lines. But, by default support of Multibyte String Functions in PHP is turned off,that automatically limits the choice of khostinga for the designed site. In addition, during connecting of the module of mb_string the set of the supported languages is specified. And that is why there is probability, that the language required you can not appear in the list of supported.
However, there is other, more comfortable and flexible decision of problem. Taking advantage of functions of PCRE, correctly perceiving the code of Utf-8, it is possible to write the functions of utf8_strlen and utf8_substr:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
| function utf8_strlen($s)
{
return preg_match_all('/./u', $s, $tmp);
}
</code>
<code>
function utf8_substr($s, $offset, $len = 'all')
{
if ($offset<0) $offset = utf8_strlen($s) + $offset;
if ($len!='all')
{
if ($len<0) $len = utf8_strlen($s) - $offset + $len;
$xlen = utf8_strlen($s) - $offset;
$len = ($len>$xlen) ? $xlen : $len;
preg_match('/^.{' . $offset . '}(.{0,'.$len.'})/us', $s, $tmp);
}
else
{
preg_match('/^.{' . $offset . '}(.*)/us', $s, $tmp);
}
return (isset($tmp[1])) ? $tmp[1] : false;
} |
Continuing the theme of work with lines in the code of Utf-8, will consider a few functions, workings without set in PHP of expansion of Multibyte String Functions, namely utf8_strpos and utf8_substr_count:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| function utf8_strpos($haystack, $needle, $offset = 0)
{
# get substring (if isset offset param)
$offset = ($offset<0) ? 0 : $offset;
if ($offset>0)
{
preg_match('/^.{' . $offset . '}(.*)/us', $haystack, $dummy);
$haystack = (isset($dummy[1])) ? $dummy[1] : '';
}
# get relative pos
$p = strpos($haystack, $needle);
if ($haystack=='' or $p===false) return false;
$r = $offset;
$i = 0;
# calc real pos
while($i<$p)
{
if (ord($haystack[$i])<128)
{
# ascii symbol
$i = $i + 1;
}
else
{
# non-ascii symbol with variable length
# (handling first byte)
$bvalue = decbin(ord($haystack[$i]));
$i = $i + strlen(preg_replace('/^(1+)(.+)$/', '\1', $bvalue));
}
$r++;
}
return $r;
}
function utf8_substr_count($h, $n)
{
# preparing $n for using in reg. ex.
$n = preg_quote($n, '/');
# select all matches
preg_match_all('/' . $n . '/u', $h, $dummy);
return count($dummy[0]);
} |
Feb 11
There are many Ranking Factors for SEO, but Search Engines owners do not liked to people know about them.
This table is explain what is the distribution of Ranking Factors
Mini SEO Textbook
|
Keywords
|
|
|
Keywords in <title>
|
+3
|
|
Keywords in URL
|
+3
|
|
Density of a keyword in the text of the document
|
+3
|
|
Keywords in references(links) of pages
|
+3
|
|
Keywords in headings (<H1>, <H2>, etc. tags)
|
+3
|
|
Keywords in the beginning of the document
|
+2
|
|
Keywords in <alt> tag
|
+2
|
|
Keywords in meta tags
|
+1
|
|
Optimization under low-frequency inquiries
|
+1
|
|
Synonyms
|
+1
|
|
Keywords with a typing error
|
0
|
|
Dissolution of a keyword in the text
|
-2
|
|
The greater(big) density of keywords on page
|
-3
|
|
outer and inner links
|
|
|
Keywords in references(links)
|
+3
|
|
References(Links) to your site from popular pages
|
+3
|
|
References(Links) from pages of similar subjects
|
+3
|
|
References(Links) from domains of the second level in a zone .ru (if at you Russian site)
|
+3
|
|
It is a lot of references(links) to your site
|
+3
|
|
The text around of the reference(link)
|
+2
|
|
Age of references(links) of referring sites (the is more senior that, the better)
|
+2
|
|
References(Links) from popular catalogues
|
+2
|
|
The it is less on a referring page of external references(links) the better
|
+1
|
|
Tag <title = “> with a keyword in the reference(link)
|
+1
|
|
References(Links) with bad link category sites and from doubtful sites
|
0
|
|
Spam of references(links) in the comment
|
-1
|
|
The latent references(links)
|
-3
|
|
Meta tags
|
|
|
<Description> metatag
|
+1
|
|
<Keywords> metatag
|
+1
|
|
<Language> metatag
|
+1
|
|
<Refresh> metatag
|
-1
|
|
The maintenance(contents)
|
|
|
The unique maintenance(contents)
|
+3
|
|
Frequent changes (updating of pages, addition new)
|
+3
|
|
Formatting of keywords tags (<strong> <i>)
|
+2
|
|
Bad design and dirty html a code
|
-2
|
|
Plagiarism
|
-3
|
|
The invisible text
|
-3
|
|
Doorways
|
-3
|
|
Duplicates of pages
|
-3
|
|
Structure of pages and its(her) maintenance(contents)
|
|
|
JavaScript (do not go too far and clean(remove) in files)
|
0
|
|
Images in the text
|
0
|
|
Podcast and video
|
0
|
|
Navigation from pictures
|
-1
|
|
Frames (Frames)
|
-2
|
|
Flash
|
-2
|
|
Domains, URL
|
|
|
Keywords in URL
|
+3
|
|
Availability of a site (a good hosting, fast loading of page)
|
+3
|
|
Sitemap
|
+2
|
|
It is a lot of pages
|
+2
|
|
The the site, the is more senior better
|
+2
|
|
One subjects of a site (it is not necessary to do auto a site and in the same place to write about brooms)
|
+2
|
|
The domain of the second level (site.us)
|
+1
|
|
Dear zones (.us it is better than .info or .org)
|
+1
|
|
Hyphens in URL (instead of blanks between keywords)
|
+1
|
|
Length URL
|
0
|
|
IP the address
|
0
|
|
Google Adsense on pages
|
0
|
|
Inaccessibility of a site, bad hosting
|
-1
|
|
Dynamic URL
|
-1
|
|
Sessions (Session ID)
|
-2
|
|
Redirects (301 and 302)
|
-3
|
|
Jan 16
JavaScript allowing to do this by this easy steps:
1
2
3
4
5
| <script type=”text/javascript”>
document.getElementById("z").innerHTML = "bla bnla";
</script>
<diz id=”z”> Text goes here</div> |