PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи

Страниц (1): [1]

> Найдено сообщений: 4
CRAZySTR Отправлено: 29 Августа, 2014 - 21:13:21 • Тема: Повторяется изображение • Форум: HTTP и PHP

Ответов: 0
Просмотров: 968
Столкнулся с проблемой. Повторяются изображения в каждом посте хотя в некоторых нет изображений. Помогите исправить.
PHP:
скопировать код в буфер обмена
  1. $message = "";
  2. $htmls = "";
  3. $msg = json_decode(file_get_contents("http://api.vk.com/method/wall.get?domain=raknet_official&count=100&v=5.24"), true);
  4. $html = (array)$msg;
  5. $api = $html["response"]["items"];
  6.  
  7. for($i = 0; $i < count($api); $i++) {
  8.         if (isset($api[$i]["attachments"])) {
  9.                 if (is_array($api[$i]["attachments"])) {
  10.                         foreach ($api[$i]["attachments"] as $attachment) {
  11.                                 if ($attachment["type"] == "photo") $htmls .= "<img src=\"{$attachment["photo"]["photo_604"]}\">";
  12.                                 /*else if ($attachment["type"] == "link") {
  13.                                         $htmls .= " <a href='".str_replace("&", "&", $attachment["link"]["url"])."'>Ссылка</a>";
  14.                                         if(isset($_REQUEST["nolinks"])) continue;
  15.                                 }
  16.                                 else if ($attachment["type"] == "doc") {
  17.                                         if($attachment["doc"]["ext"]=="gif")
  18.                                                 $htmls .= " <img src='".str_replace("&", "&", $attachment["doc"]["url"])."'/>";
  19.                                 }
  20.                                 else if ($attachment["type"] == "video") {
  21.                                         $video = $attachment["video"];
  22.                                         $description .= htmlspecialchars("<iframe src='http://vk.com/video{$video["owner_id"]}_{$video["id"]}&hash=4723bf39ce361e10&hd=1' width='607' height='360' frameborder='0'></iframe>");
  23.                                 }*/
  24.                         }
  25.                 }
  26.         }
  27.         $text = preg_replace("/(^|[\n ])([\w]*?)((ht)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" target=\"_blank\">$3</a>", $api[$i]["text"]);
  28.         $text = str_replace("\n","<br />",$text);
  29.         $text = str_replace("[","<a href=\"http://vk.com/",$text);
  30.         $text = str_replace("|","\" target=\"_blank\">",$text);
  31.         $text = str_replace("]","</a>",$text);
  32.         $result = explode(" ", $text);
  33.         $date = user::times( $api[$i]["date"] );
  34.         $message .= "<div class=\"media\">
  35.                        <div class=\"media-body\">
  36.                            {$text}
  37.                                                                                                                 {$htmls}
  38.                            <div class=\"clearfix\"></div>
  39.                            <div class=\"attrs\">Дата публикации: {$date}</div>
  40.                            <div class=\"block attrs\">Like: {$api[$i]["likes"]["count"]}</div>
  41.                            <div class=\"block attrs\">Repost: {$api[$i]["reposts"]["count"]}</div>
  42.                                                         <div class=\"list-options\">
  43.                                                                 <a href=\"http://vk.com/wall{$api[$i]["from_id"]}_{$api[$i]["id"]}\" target=\"_blank\" class=\"btn btn-sm\">Показать полностью</a>
  44.                                                         </div>
  45.                        </div>
  46.                    </div>";
  47. }

исправил
CRAZySTR Отправлено: 27 Августа, 2014 - 07:44:50 • Тема: Поиск и замена • Форум: Хранение данных, их вывод и обработка

Ответов: 0
Просмотров: 846
нужна помощь, не могу понять что и как
к примеру имеется текст

Спойлер (Отобразить)


в этом тексте есть id и имя участника

текст поделил данным примером
PHP:
скопировать код в буфер обмена
  1. $text = str_replace("|"," ",$text);
  2.         $text = str_replace("[","",$text);
  3.         $text = str_replace("]","",$text);
  4. $result = explode(" ", $text);

а в тексте что выше таких участников много. Как считать и выводить результат ?

PHP:
скопировать код в буфер обмена
  1. $message = "";
  2. $msg = json_decode(file_get_contents("http://api.vk.com/method/wall.get?domain=vkdesigners&count=1"), false);
  3. for($i = 1; $i < 2; $i++) {
  4.         if(isset($msg->response[$i]->text)) $link = $msg->response[$i]->text;
  5.         if(isset($msg->response[$i]->from_id)) $wall = $msg->response[$i]->from_id;
  6.         if(isset($msg->response[$i]->id)) $wall1 = $msg->response[$i]->id;
  7.         if(isset($msg->response[$i]->date)) $wall2 = $msg->response[$i]->date;
  8.         if(isset($msg->response[$i]->reposts->count)) $repost = $msg->response[$i]->reposts->count;
  9.         if(isset($msg->response[$i]->likes->count)) $like = $msg->response[$i]->likes->count;
  10.        
  11. $text = preg_replace("/(^|[\n ])([\w]*?)((ht)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*)/is", "$1$2<a href=\"$3\" target=\"_blank\">$3</a>", $link);
  12.        
  13.         $text = str_replace("|"," ",$text);
  14.         $text = str_replace("[","",$text);
  15.         $text = str_replace("]","",$text);
  16.         $result = explode(" ", $text);
  17.  
  18.         $date = user::times( $wall2 );
  19.         $message .= "<div class=\"media\">
  20.                        <div class=\"media-body\">
  21.                            {$text}
  22.                            <div class=\"clearfix\"></div>
  23.                            <div class=\"attrs\">Дата публикации: {$date}</div>
  24.                            <div class=\"block attrs\">Like: {$like}</div>
  25.                            <div class=\"block attrs\">Repost: {$repost}</div>
  26.                                                         <div class=\"list-options\">
  27.                                                                 <a href=\"http://vk.com/wall{$wall}_{$wall1}\" target=\"_blank\" class=\"btn btn-sm\">Показать полностью</a>
  28.                                                         </div>
  29.                        </div>
  30.                    </div>";
  31. }

P.S сам сделал
CRAZySTR Отправлено: 25 Августа, 2014 - 14:47:57 • Тема: Parse error: syntax error, unexpected '[', expecting ')' in • Форум: Если скрипт не работает

Ответов: 2
Просмотров: 1113
Мелкий пишет:
Ошибки нет. Обновите PHP до актуальной версии, этот код требует минимум 5.4.

Спасибо, тыкнул бы спасибку но не позволяет кол-во сообщений )
CRAZySTR Отправлено: 25 Августа, 2014 - 14:27:45 • Тема: Parse error: syntax error, unexpected '[', expecting ')' in • Форум: Если скрипт не работает

Ответов: 2
Просмотров: 1113
Всем привет, нужна помощь в исправлении.
PHP:
скопировать код в буфер обмена
  1.         public function editsignature()
  2.         {
  3.                 $blogquery = $this->db->query("SELECT * FROM `posts` LIMIT 0, 5");
  4.                 $datestring = "%Y";
  5.                 $data = array(
  6.             'blog_title' => $this->config->item('site_title'),
  7.             'blog_heading' => $this->config->item('site_heading'),
  8.             'template_dir' => base_url().'templates/'.$this->config->item('template').'/ucp/',
  9.             'page_name' => 'Editing Signature',
  10.             'year' => mdate($datestring).' | Powered by FractalBB',
  11.             'userdata' => $this->user_model->getDetails(get_cookie('token')),
  12.             'username' => $this->user_model->userFromToken(get_cookie('token')), //Get username using v1.2 method
  13.             'signature' => $this->user_model->getDetails(get_cookie('token'))['signature'],//95 строка
  14.             'latest_posts' => $blogquery->result_array(),
  15.             'ucp_modules' => $this->modules->generateUCPLinks()
  16.             );
  17.  
  18.                 $this->parser->parse('../../templates/'.$this->config->item('template').'/ucp/header',$data); //Initiate the 'header' file with all the data above
  19.                 $this->parser->parse('../../templates/'.$this->config->item('template').'/ucp/sig',$data); //Initiate the 'sig' file with all the data above
  20.                 $this->parser->parse('../../templates/'.$this->config->item('template').'/ucp/footer',$data); //Initiate the 'footer' file with all the data above
  21.         }

Страниц (1): [1]
Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB