Версия, подходяща за принтиране

Оригинлната версия може да видите тук

малко oop4 объркване
Публикувано от cnoko на: 03.06.2008 20:28
Здравейте малко се обърках та не ми се мисли хелп :)
CODE
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php    function http()
    {
       
global $db;
       
if ( !class_exists("open") )
        {
           
include root_path . 'inc/connect.php';
       
}
       
$this->fsock = new open;
       
if ( !$this->fsock->connect($this->uri) )
        {
           
$this->info['warnings'][] = lang('connection_timeout');
           
return false;
       
}
       
       
$this->uri = $this->fsock->url;
       
$mimetype = $this->fsock->content_type();
       
if (!$mimetype)
        {
           
$mimetype = 'text/html';
       
}
       
$this->uri                 = $this->fsock->real_uri();
       
$this->info['mimetype'] = $mimetype;
       
$this->info['active'] = 1;
       
$this->info['time'          ] = time();
       
$this->info['filesize'    ] = $this->fsock->size();
       
$this->info['active'      ] = 1;
       
$this->info['expenssion] = utf8_substr($this->uri,strrchr($this->uri, '.'),1);
       
$this->info['filename'    ] = ($this->info['filename']) ? $this->info['filename'] : urldecode(basename($this->uri));
       
$this->info['realfilename'] = utf8_strtolower(urldecode(basename($this->uri)));
       
$parse                      = @parse_url($this->uri);
       
$this->info['host'          ] = utf8_strtolower(urldecode($parse['host']));
       
$this->info['path'          ] = utf8_strtolower(urldecode($parse['path']));
       
$this->info['query'          ] = utf8_strtolower(urldecode($parse['query']));
       
$this->info['port'          ] = (int) $this->fsock->port;
       
$this->info['scahme'      ] = $parse['schame'];
       
$result = $db->sql_query("SELECT a.fileid
                        FROM attachments a,sites b,sites_querys c,sites_paths d
                        WHERE
                        a.site_id = b.site_id AND b.site_host='{
$db->sql_escape($this->info['host'])}'
                        AND b.site_schame='{
$db->sql_escape($this->info['scahme'])}' AND
                        b.port = '{
$this->info['port']}' AND
                        a.query_id = c.query_id AND
                        c.site_query = '{
$db->sql_escape($this->info['query'])}' AND
                        a.path_id = d.path_id AND
                        d.uri_path = '{
$db->sql_escape($this->info['path'])}' AND
                        a.real_filename = '{
$db->sql_escape($this->info['realfilename'])}' LIMIT 1
                       
");
       
$row = $db->sql_fetchrow($result);
       
if (@$row['fileid'])
        {
           
$this->info['warnings'][] = lang('tozi_fail_veche_go_imame');
           
return false;
       
}
       
$result = $db->sql_query ( "SELECT active,site_id FROM sites WHERE site_host = '{$this->info['host']}' AND site_schame='{$this->info['schame']}' LIMIT 1" );
       
if ( $row = $db->sql_fetchrow($result) )
        {
           
$this->info['site_id'] = $row['site_id'];
           
if ( !$row['active'] )
            {
               
$this->info['warnings'][] = lang('site_is_not_active');
               
return false;
           
}
       
else if ( config('sites_is_admin_odobrqvane') )
            {
               
$this->info['warnings'][] = lang('saita_shte_bude_odobren_ot_admina');
               
$this->info['active'] = 0;
           
}
        }
   
else
       
{
           
$result = $db->sql_query("SELECT MAX(site_id) as next_id FROM sites LIMIT 1");
           
$row = $db->sql_fetchrow($result);
           
$next_id = $row['next_id']+1;
           
$this->info['site_id'] = $next_id;
           
$db->sql_query ("INSERT INTO sites(site_id,site_host,port,site_schame,active)
                            VALUES (
$next_id,'{$db->sql_escape($this->info['host'])}',{$this->info['port']},
                            '{
$this->info['schame']}',1);");
       
}
       
$result  =  $db->sql_query("SELECT query_id FROM sites_querys
                                    WHERE site_query = '{
$db->sql_escape($this->info['query'])}' LIMIT 1");
       
if ( $row = $db->sql_fetchrow($result) )
        {
           
$this->info['query_id'] = $row['query_id'];
       
}
   
else
       
{
           
$result = $db->sql_query("SELECT MAX(query_id) as next_id FROM sites_querys LIMIT 1");
           
$row = $db->sql_fetchrow($result);
           
$next = $row['next_id']+1;
           
$db->sql_query("INSERT INTO sites_querys(query_id,site_query) VALUES($next,'{$db->sql_escape($this->info['query'])}');");
           
$this->info['query_id'] = $next;
       
}

       
$result  =  $db->sql_query("SELECT path_id FROM sites_paths WHERE uri_path = '{$db->sql_escape($this->info['path'])}' LIMIT 1");
       
if ( $row = $db->sql_fetchrow($result) )
        {
           
$this->info['path_id'] = $row['path_id'];
       
}
   
else
       
{
           
$result = $db->sql_query("SELECT MAX(path_id) as next_id FROM sites_paths LIMIT 1");
           
$row = $db->sql_fetchrow($result);
           
$next = $row['next_id']+1;
           
$db->sql_query("INSERT INTO sites_paths(path_id,uri_path) VALUES($next,'{$db->sql_escape($this->info['path'])}');");
           
$this->info['path_id'] = $next;
       
}
       
if ( config('download_files'))
        {
           
$this->download();
       
}
       
$this->full_info();
   
}
   
function full_info()
    {
       
global $db;
       
$result = $db->sql_query("SELECT module_file,module_class,module_id FROM modules_attachments
                        WHERE module_active = 1 AND mimetype = '{
$this->info['mimetype']}' LIMIT 1");
       
if ($row = $db->sql_fetchrow($result))
        {
           
$this->info['module_id'] = $row['module_id'];
           
$class     = $row['module_class'];
           
$filename  = root_path . 'inc/modules/getid3/' . $row['module_file'];
           
if(!file_exists($filename))
            {
               
$this->info['warnings'][] = lang('module_file_not_exists');
               
return false;
           
}
           
if ( !class_exists($class) )
            {
               
include ($filename);
           
}
           
if ($getid3 = new $class($this->info,$this->fsock,$this->uri))
            {
               
$this->insert();
           
}
           
$this->fsock->close();
           
unset($getid3);
       
}
 
else if ($this->info['mimetype'] == 'text/html')
        {
           
if ( !class_exists("search_links") )
            {
               
include root_path ."inc/modules/getid3/getid3.indexing.php";
           
}
           
$getid3 = new search_links($this->uri,$this);
           
unset($getid3);
       
}
   
else
       
{
           
$this->inf['warnings'][] = lang('nqma_modul_za_tozi_fail');
           
return false;
       
}
    }
?>
това отгое са основните функции
и това е др класс при който забива
CODE
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
set_time_limit
(0);
class search_links
{
var $data = '';
var $urls = array();
var $imgs = array();
var $sql_urls = array();
var $url;
   
function search_links ( $uri,&$getid3 )
    {
       
global $db;
       
if(defined("INDEXING"))
        {
           
return false;
       
}
       
define("INDEXING",true);
       
$this->url = $uri;
       
$this->parse_url = @parse_url( $this->url );
       
$getid3->fsock->connect( $uri );
       
       
$this->data = '';
       
       
while (!$getid3->fsock->eof())
        {
           
$this->data .= $getid3->fsock->read(1024);
       
}
       
$this->encoding = ($getid3->fsock->encoding()) ? $getid3->fsock->encoding : $this->meta_encoding();
       
       
$getid3->fsock->close();
       
unset($getid3->fsock);
       
$this->read_links();
       
$newurl = '\'' . $db->sql_escape(preg_replace("/(.[^\:])\/+/", "$1/", urldecode($this->url))) . '\'';
       
if (!in_array($newurl,$this->sql_urls))
        {
           
$this->sql_urls[] = $newurl;
       
}
       
$total = sizeof($this->sql_urls);
       
if ( $total )
        {
           
$ids = array();
           
$sql_where($total > 1) ? ' IN (' . implode(',', $this->sql_urls) . ')' : "={$this->sql_urls[0]}";
           
$db->sql_query("SELECT full_url,id FROM indexing WHERE full_url $sql_where LIMIT 1");
           
while ( $row = $db->sql_fetchrow($result))
            {
               
unset($row['full_url'],$this->sql_urls);
               
$ids[] = $row['id'];
           
}
           
if ($total = sizeof($ids) )
            {
               
$sql_where = ( $total > 1)  ? 'IN (' . implode(",", $ids) . ')' : "= {$ids[0]}";
               
$db->sql_query("UPDATE indexing SET indexed=indexed+1 WHERE id $sql_where");
           
}
           
if ( $total = sizeof($this->sql_urls) )
            {
               
$sql = $db->sql_query("SELECT MAX(id) as next_id FROM indexing LIMIT 1");
               
$row = $db->sql_fetchrow($result);
               
$next_id = $row['next_id'];
               
for  ( $i = 0; $i < $total; ++$i)
                {
                   
$next_id++;
                   
$full_url = $this->sql_urls[$i];
                   
$db->sql_query("INSERT INTO indexing(id,full_url,indexed) VALUES ($next_id,$full_url,1);");
               
}
            }
        }
       
unset($this->sql_urls);
       
for ($i = 0,$total = sizeof($this->urls); $i < $total; ++$i)
        {   
           
$getid3->uri = $this->urls[$i];
           
$getid3->http();
           
unset($getid3->info['warnings']);
       
}
       
unset($this->urls);
        /*
       
for ($i = 0,$total = sizeof($this->imgs); $i < $total; ++$i)
        {
           
$getid3->uri = $this->imgs['url'][$i];
           
$getid3->info['filename'] = utf8_recode($this->encoding, $this->imgs['alt'][$i]);
           
$getid3->http();
           
unset($getid3->info['warnings']);
       
}*/
       
unset($this->imgs);
   
}
   
   
function meta_encoding()
    {
       
if ( !preg_match("/\<meta .*?charset=[\"']{0,1}([a-z0-9\-]+)/i", $this->data, $m) )
        {
           
return 'ISO-8859-1';
       
}
       
       
return $m[1];
   
}
   
   
function read_links()
    {
   
global $db;
       
preg_match_all("/href=(\"(.+?)\"|'(.+?)'|(.+?[^\"'\\s,]))/si", $this->data, $match, PREG_SET_ORDER);
       
for ($i = 0, $total = sizeof($match);$i < $total; ++$i)
        {
           
$url = real_url($match[$i][2], $this->url);
           
if (!empty($url) && !in_array($url,$this->urls))
            {
               
$this->sql_urls[] = '\'' . $db->sql_escape(preg_replace("/(.[^:])\/+/","$1/",urldecode($url))) . '\'';
               
$this->urls[] = $url;
           
}
        }
       
$pattern = "/\<img (.*?)src=(?:\"(.*?)\"|'(.*?)'|(.*?[^\\s,]))(.*?)\>/si";
       
       
preg_match_all($pattern, $this->data, $match, PREG_SET_ORDER);
       
       
$pattern = '/(?:alt|title)=(?:"(.*?)"|\'(.*?)\'|(.*?[^\\s,]))/i';
       
       
for ($i = 0, $total = sizeof($match); $i < $total; ++$i)
        {
           
if ( !preg_match($pattern, $match[$i][1], $m) ||  !preg_match($pattern, $match[$i][3], $m) )
            {
               
continue;
           
}
           
$this->imgs['alt'][] = trim($m[1]);
           
$this->imgs['uri'][] = real_url($match[$i][2],$this->url);
       
}
       
unset($match,$m);
       
unset($this->data);
   
}
}
?>
Нещо ми забива значи как точно да ги свържа за да не забива за 4 линка от които само 1 от тях ще вади текст ( с бърз нет г/д съм)

Публикувано от cnoko на: 03.06.2008 21:59
модераторите или админите, ако искат да изтрият тази тема
Оправих се просто в момента съм с по слабия комп (256 ram) и съм натоварил сървъра цял ден му правя тестове с http конект, иначе работи (имах малки грешки с for циклите, но ги поправих) :)


IT-PLACE.NET