/** * {@inheritdoc} */ public function next() { if (!$this->post->type->hierarchical && $this->post->older) { return post_url($this->post->older, true); } return null; }
/** * 图片截取 */ function imageIntercept($param) { //图片目录 if (in_array($_SERVER['HTTP_HOST'], array("imglocal.boqii.com", "imglocal.boqiicdn.com"))) { $dirName = 'D:/Project/www/svnimg/Data/Vet/C'; $imgdir = 'http://imglocal.boqii.com'; $imgcdndir = "http://imglocal.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array('imgtest.boqii.com', 'imgtest.boqiicdn.com'))) { $dirName = '/webwww/img/Data/Vet/C'; $imgdir = 'http://imgtest.boqii.com'; $imgcdndir = "http://imgtest.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img1.boqii.com", "img1.boqiicdn.com"))) { $dirName = '/webwww1/img1/Data/Vet/C'; $imgdir = 'http://img1.boqii.com'; $imgcdndir = "http://img1.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img.boqii.com", "img.boqiicdn.com"))) { $dirName = '/webwww/img/Data/Vet/C'; $imgdir = 'http://img.boqii.com'; $imgcdndir = "http://img.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img.boqii.com", "img3.boqiicdn.com"))) { $dirName = '/webwww/img/Data/Vet/C'; $imgdir = 'http://img3.boqii.com'; $imgcdndir = "http://img3.boqiicdn.com/"; } $post_data = array('twidth' => $param['twidth'], 'theight' => $param['theight'], 'picurl' => $param['picurl'], 'tpicurl' => $param['tpicurl'], 'tpath' => str_replace($imgcdndir, '', $param['tpicurl']), 'type' => 1, 'subtype' => $param['type'], 'aucode' => 'boqii', 'method' => 'mbprase'); $url = $imgdir . "/Server/upload.php"; $result = post_url($url, $post_data); return $result; }
function handle_pubsubhubbub() { global $a, $db; logger('start'); // We'll push to each subscriber that has push > 0, // i.e. there has been an update (set in notifier.php). $r = q("SELECT * FROM `push_subscriber` WHERE `push` > 0"); foreach ($r as $rr) { $params = get_feed_for($a, '', $rr['nickname'], $rr['last_update'], 0, true); $hmac_sig = hash_hmac("sha1", $params, $rr['secret']); $headers = array("Content-type: application/atom+xml", sprintf("Link: <%s>;rel=hub," . "<%s>;rel=self", $a->get_baseurl() . '/pubsubhubbub', $rr['topic']), "X-Hub-Signature: sha1=" . $hmac_sig); logger('POST ' . print_r($headers, true) . "\n" . $params, LOGGER_DEBUG); post_url($rr['callback_url'], $params, $headers); $ret = $a->get_curl_code(); if ($ret >= 200 && $ret <= 299) { logger('successfully pushed to ' . $rr['callback_url']); // set last_update to "now", and reset push=0 $date_now = datetime_convert('UTC', 'UTC', 'now', 'Y-m-d H:i:s'); q("UPDATE `push_subscriber` SET `push` = 0, last_update = '%s' WHERE id = %d", dbesc($date_now), intval($rr['id'])); } else { logger('error when pushing to ' . $rr['callback_url'] . ' HTTP: ' . $ret); // we use the push variable also as a counter, if we failed we // increment this until some upper limit where we give up $new_push = intval($rr['push']) + 1; if ($new_push > 30) { // OK, let's give up $new_push = 0; } q("UPDATE `push_subscriber` SET `push` = %d WHERE id = %d", $new_push, intval($rr['id'])); } } logger('done'); }
/** * @brief Controller for /match. * * It takes keywords from your profile and queries the directory server for * matching keywords from other profiles. * * @param App &$a * @return void|string */ function match_content(&$a) { $o = ''; if (!local_user()) { return; } $a->page['aside'] .= findpeople_widget(); $a->page['aside'] .= follow_widget(); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory'))) { $x = post_url(get_server() . '/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $id = 0; foreach ($j->results as $jj) { $match_nurl = normalise_link($jj->url); $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl)); if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $photo_menu = array(array(t("View Profile"), zrl($jj->url))); $photo_menu[] = array(t("Connect/Follow"), $connlnk); $contact_details = get_contact_details_by_url($jj->url, local_user()); $entry = array('url' => zrl($jj->url), 'itemurl' => $contact_details['addr'] != "" ? $contact_details['addr'] : $jj->url, 'name' => $jj->name, 'details' => $contact_details['location'], 'tags' => $contact_details['keywords'], 'about' => $contact_details['about'], 'account_type' => $contact_details['community'] ? t('Forum') : '', 'thumb' => proxy_url($jj->photo, false, PROXY_SIZE_THUMB), 'inttxt' => ' ' . t('is interested in:'), 'conntxt' => t('Connect'), 'connlnk' => $connlnk, 'img_hover' => $jj->tags, 'photo_menu' => $photo_menu, 'id' => ++$id); $entries[] = $entry; } } $tpl = get_markup_template('viewcontact_template.tpl'); $o .= replace_macros($tpl, array('$title' => t('Profile Match'), '$contacts' => $entries, '$paginate' => paginate($a))); } else { info(t('No matches') . EOL); } } return $o; }
private function mainMessage() { $user = $this->userText(); $url = post_url($this->post->topic_id, $this->post->post_id); $title = $this->topic->topic_title; $command = $this->replyCommand(); $prefix = $this->prefix; return "{$prefix}: <{$url}|{$title}> by {$user} `{$command}`"; }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $a->page['aside'] .= follow_widget(); $a->page['aside'] .= findpeople_widget(); $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= replace_macros(get_markup_template("section_title.tpl"), array('$title' => t('Profile Match'))); $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory'))) { $x = post_url(get_server() . '/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $match_nurl = normalise_link($jj->url); $match = q("SELECT `nurl` FROM `contact` WHERE `uid` = '%d' AND nurl='%s' LIMIT 1", intval(local_user()), dbesc($match_nurl)); if (!count($match)) { $jj->photo = str_replace("http:///photo/", get_server() . "/photo/", $jj->photo); $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => proxy_url($jj->photo), '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
/** * 缩略图处理 * * @param path string 文件路径 * @param filename string 文件名 * @param uid int 用户ID(如果图片目录不需要用用户id三级扩展则传0) * @param subtype string 子模块类型 * */ function imagePrase($path, $filename, $uid, $subtype) { global $img_dir; //需要上传的文件 $post_data = array('id' => $uid, 'type' => 1, 'aucode' => "boqii", 'subtype' => $subtype, 'method' => 'prase', 'path' => $path, 'filename' => $filename); $url = $img_dir . "/Server/upload.php"; $result = post_url($url, $post_data); if ($result && strpos($result, '{') === false) { $json = array('status' => 'error', 'tip' => '处理失败!'); } else { $json = json_decode($result, true); } return json_encode($json); }
/** * 관리자 메인 페이지입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_admin_main_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $view['view']['latest_member'] = $this->Member_model->get_admin_list(7, '', '', '', 'mem_id', 'desc', '', ''); if (isset($view['view']['latest_member']['list']) && is_array($view['view']['latest_member']['list'])) { foreach ($view['view']['latest_member']['list'] as $key => $val) { $view['view']['latest_member']['list'][$key]['display_name'] = display_username(element('mem_userid', $val), element('mem_nickname', $val)); } } $view['view']['latest_point'] = $this->Point_model->get_admin_list(7, '', '', '', 'poi_id', 'desc', '', ''); if (isset($view['view']['latest_point']['list']) && is_array($view['view']['latest_point']['list'])) { foreach ($view['view']['latest_point']['list'] as $key => $val) { $view['view']['latest_point']['list'][$key]['display_name'] = display_username(element('mem_userid', $val), element('mem_nickname', $val)); } } $view['view']['latest_post'] = $this->Post_model->get_admin_list(7, '', '', '', 'post_id', 'desc', '', ''); if (isset($view['view']['latest_post']['list']) && is_array($view['view']['latest_post']['list'])) { foreach ($view['view']['latest_post']['list'] as $key => $val) { $brd_key = $this->board->item_id('brd_key', element('brd_id', $val)); $view['view']['latest_post']['list'][$key]['post_url'] = post_url($brd_key, element('post_id', $val)); $view['view']['latest_post']['list'][$key]['display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val)); } } $view['view']['latest_comment'] = $this->Comment_model->get_admin_list(7, '', '', '', 'cmt_id', 'desc', '', ''); if (isset($view['view']['latest_comment']['list']) && is_array($view['view']['latest_comment']['list'])) { foreach ($view['view']['latest_comment']['list'] as $key => $val) { $post = $this->Post_model->get_one(element('post_id', $val), 'brd_id'); $brd_key = $this->board->item_id('brd_key', element('brd_id', $post)); $view['view']['latest_comment']['list'][$key]['post_url'] = post_url($brd_key, element('post_id', $val)) . '#comment_' . element('cmt_id', $val); $view['view']['latest_comment']['list'][$key]['display_name'] = display_username(element('cmt_userid', $val), element('cmt_nickname', $val)); } } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 어드민 레이아웃을 정의합니다 */ $layoutconfig = array('layout' => 'layout', 'skin' => 'main'); $view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
function match_content(&$a) { $o = ''; if (!local_user()) { return; } $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd; $o .= '<h2>' . t('Profile Match') . '</h2>'; $r = q("SELECT `pub_keywords`, `prv_keywords` FROM `profile` WHERE `is-default` = 1 AND `uid` = %d LIMIT 1", intval(local_user())); if (!count($r)) { return; } if (!$r[0]['pub_keywords'] && !$r[0]['prv_keywords']) { notice(t('No keywords to match. Please add keywords to your default profile.') . EOL); return; } $params = array(); $tags = trim($r[0]['pub_keywords'] . ' ' . $r[0]['prv_keywords']); if ($tags) { $params['s'] = $tags; if ($a->pager['page'] != 1) { $params['p'] = $a->pager['page']; } if (strlen(get_config('system', 'directory_submit_url'))) { $x = post_url('http://dir.friendica.com/msearch', $params); } else { $x = post_url($a->get_baseurl() . '/msearch', $params); } $j = json_decode($x); if ($j->total) { $a->set_pager_total($j->total); $a->set_pager_itemspage($j->items_page); } if (count($j->results)) { $tpl = get_markup_template('match.tpl'); foreach ($j->results as $jj) { $connlnk = $a->get_baseurl() . '/follow/?url=' . $jj->url; $o .= replace_macros($tpl, array('$url' => zrl($jj->url), '$name' => $jj->name, '$photo' => $jj->photo, '$inttxt' => ' ' . t('is interested in:'), '$conntxt' => t('Connect'), '$connlnk' => $connlnk, '$tags' => $jj->tags)); } } else { info(t('No matches') . EOL); } } $o .= cleardiv(); $o .= paginate($a); return $o; }
/** * 图片截取 * @param $imgh 原始图片的高 * @param $imgw 原始图片的宽 * @param $nowh 截取之后图片的高 * @param $noww 截取之后图片的宽 * @param $ph 截图高度为ph * @param $picurl 图片地址picurl * @param $pw 截图宽度为pw * @param $px 截图X坐标为px * @param $py 截图Y坐标为py * @param $type 图片的类型 */ public function imageIntercept($param) { $post_data = array('imgh' => $param['imgh'], 'imgw' => $param['imgw'], 'nowh' => $param['nowh'], 'noww' => $param['noww'], 'ph' => $param['ph'], 'picurl' => $param['picurl'], 'pw' => $param['pw'], 'px' => $param['px'], 'py' => $param['py'], 'type' => 1, 'subtype' => $param['type'], 'aucode' => 'boqii', 'method' => 'imagickIntercept'); //服务器地址 if (in_array($_SERVER['HTTP_HOST'], array("mycmslocal.jason.com"))) { $url = "http://mycmslocal.jason.com/Addons/img/Server/upload.php"; } elseif (in_array($_SERVER['HTTP_HOST'], array('www.jinx888.com'))) { $url = "http://www.jinx888.com/Addons/img/Server/upload.php"; } $result = post_url($url, $post_data); if ($result && strpos($result, '{') === false) { $json = array('status' => 'error', 'tip' => '截图失败!'); } else { $json = json_decode($result, true); } return json_encode($json); }
function post_by_cat_links($posts, $cat, $website_url_array) { $item_counter = 0; $string = '<ul>'; foreach ($posts as $post) { if (strcasecmp(trim($post->category_name), $cat) == 0 && strcasecmp(trim($post->post_type), "primary_page") != 0 && in_array($post->post_slug, $website_url_array) != 1) { $url = post_url($post); $string .= '<li>'; $string .= '<h4>' . anchor($url, e($post->post_title)) . '</h4>'; $string .= '</li>'; $item_counter++; } } if ($item_counter < 1) { $string .= '<li>'; $string .= '<h4><a href="#">There are no ' . $cat . '</a></h4>'; $string .= '</li>'; } $string .= '</ul>'; return $string; }
/** * 图片截取 */ function watermark($param) { //图片目录 if (in_array($_SERVER['HTTP_HOST'], array("imglocal.boqii.com", "imglocal.boqiicdn.com"))) { $imgdir = 'http://imglocal.boqii.com'; $imgcdndir = "http://imglocal.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array('imgtest.boqii.com', 'imgtest.boqiicdn.com'))) { $imgdir = 'http://imgtest.boqii.com'; $imgcdndir = "http://imgtest.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img1.boqii.com", "img1.boqiicdn.com"))) { $imgdir = 'http://img1.boqii.com'; $imgcdndir = "http://img1.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img.boqii.com", "img.boqiicdn.com"))) { $imgdir = 'http://img.boqii.com'; $imgcdndir = "http://img.boqiicdn.com/"; } elseif (in_array($_SERVER['HTTP_HOST'], array("img3.boqii.com", "img3.boqiicdn.com"))) { $imgdir = 'http://img3.boqii.com'; $imgcdndir = "http://img3.boqiicdn.com/"; } $post_data = array('picurl' => $param['picurl'], 'type' => 1, 'subtype' => $param['type'], 'aucode' => 'boqii', 'method' => 'watermark'); $url = $imgdir . "/Server/upload.php"; $result = json_decode(post_url($url, $post_data), true); return $result; }
*/ function post_url($url, $post_data, $time = 30) { $time = $time <= 30 ? $time : 30; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); curl_setopt($ch, CURLOPT_TIMEOUT, $time); $output = curl_exec($ch); curl_close($ch); return $output; } $_FILE = $_FILES['upfile']["tmp_name"]; $post_data = array('id' => 755739, 'type' => 1, 'aucode' => "boqii", 'subtype' => 'weibo', 'upfile' => "@" . $_FILE); $url = "http://imga.boqii.com/Server/upload.php"; print_r(json_decode(post_url($url, $post_data), true)); ?> <html> <body> <form action="client.php" method="post" enctype="multipart/form-data"> <label for="file">Filename:</label> <input type="file" name="upfile" id="upfile" /> <br /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html>
/** * 목록을 가져오는 메소드입니다 */ public function index() { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_admin_board_fileupload_index'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); /** * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다. */ $param =& $this->querystring; $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1; $view['view']['sort'] = array('pfi_id' => $param->sort('pfi_id', 'asc'), 'pfi_filesize' => $param->sort('pfi_filesize', 'asc'), 'pfi_download' => $param->sort('pfi_download', 'asc'), 'pfi_datetime' => $param->sort('pfi_datetime', 'asc')); $findex = $this->input->get('findex') ? $this->input->get('findex') : $this->{$this->modelname}->primary_key; $forder = $this->input->get('forder', null, 'desc'); $sfield = $this->input->get('sfield', null, ''); $skeyword = $this->input->get('skeyword', null, ''); $per_page = admin_listnum(); $offset = ($page - 1) * $per_page; /** * 게시판 목록에 필요한 정보를 가져옵니다. */ $this->{$this->modelname}->allow_search_field = array('pfi_id', 'post.post_id', 'post.mem_id', 'pfi_originname', 'pfi_filename', 'pfi_datetime', 'pfi_ip'); // 검색이 가능한 필드 $this->{$this->modelname}->search_field_equal = array('pfi_id', 'post.post_id', 'post.mem_id'); // 검색중 like 가 아닌 = 검색을 하는 필드 $this->{$this->modelname}->allow_order_field = array('pfi_id', 'pfi_filesize', 'pfi_download', 'pfi_datetime'); // 정렬이 가능한 필드 $where = array(); if ($brdid = (int) $this->input->get('brd_id')) { $where['post.brd_id'] = $brdid; } $result = $this->{$this->modelname}->get_admin_list($per_page, $offset, $where, '', $findex, $forder, $sfield, $skeyword); $list_num = $result['total_rows'] - ($page - 1) * $per_page; if (element('list', $result)) { foreach (element('list', $result) as $key => $val) { $result['list'][$key]['post_display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val)); $brd_key = $this->board->item_id('brd_key', element('brd_id', $val)); $result['list'][$key]['posturl'] = post_url($brd_key, element('post_id', $val)); $result['list'][$key]['download_link'] = admin_url($this->pagedir . '/download/' . element('pfi_id', $val)); if (element('pfi_is_image', $val)) { $result['list'][$key]['origin_image_url'] = thumb_url('post', element('pfi_filename', $val)); $result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $val), '80'); } $result['list'][$key]['board'] = $board = $this->board->item_all(element('brd_id', $val)); if ($board) { $result['list'][$key]['baordurl'] = board_url(element('brd_key', $board)); } $result['list'][$key]['num'] = $list_num--; } } $view['view']['data'] = $result; $view['view']['boardlist'] = $this->Board_model->get_board_list(); /** * primary key 정보를 저장합니다 */ $view['view']['primary_key'] = $this->{$this->modelname}->primary_key; /** * 페이지네이션을 생성합니다 */ $config['base_url'] = admin_url($this->pagedir) . '?' . $param->replace('page'); $config['total_rows'] = $result['total_rows']; $config['per_page'] = $per_page; $this->pagination->initialize($config); $view['view']['paging'] = $this->pagination->create_links(); $view['view']['page'] = $page; /** * 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다 */ $search_option = array('pfi_originname' => '파일명', 'pfi_datetime' => '올린날짜', 'pfi_ip' => 'IP'); $view['view']['skeyword'] = $sfield && array_key_exists($sfield, $search_option) ? $skeyword : ''; $view['view']['search_option'] = search_option($search_option, $sfield); $view['view']['listall_url'] = admin_url($this->pagedir); $view['view']['list_delete_url'] = admin_url($this->pagedir . '/listdelete/?' . $param->output()); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 어드민 레이아웃을 정의합니다 */ $layoutconfig = array('layout' => 'layout', 'skin' => 'index'); $view['layout'] = $this->managelayout->admin($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); }
<ul selected="true"> <li class="group"><?php echo lang('archives'); ?> </li> <?php foreach ($posts as $post) { ?> <li> <a href="<?php echo post_url($post['url_title'], $post['date_posted']); ?> "><?php echo $post['title']; ?> </a> </li> <?php } ?> </ul>
<a class="" href="<?php echo base_url(post_url($post)); ?> "> <?php echo html_entity_decode(text_trunk($post->post_title)); ?> </a> </h2> <p> <?php echo html_entity_decode(text_trunk($post->post_content, 30)); ?> </p> <p> <a href="<?php echo base_url(post_url($post)); ?> ">read more</a> </p> </div> </div> <?php } ?> </div> </div> </div>
function ljpost_send(&$a, &$b) { if ($b['deleted'] || $b['private'] || $b['created'] !== $b['edited']) { return; } if (!strstr($b['postopts'], 'ljpost')) { return; } if ($b['parent'] != $b['id']) { return; } // LiveJournal post in the LJ user's timezone. // Hopefully the person's Friendica account // will be set to the same thing. $tz = 'UTC'; $x = q("select timezone from user where uid = %d limit 1", intval($b['uid'])); if ($x && strlen($x[0]['timezone'])) { $tz = $x[0]['timezone']; } $lj_username = xmlify(get_pconfig($b['uid'], 'ljpost', 'lj_username')); $lj_password = xmlify(get_pconfig($b['uid'], 'ljpost', 'lj_password')); $lj_journal = xmlify(get_pconfig($b['uid'], 'ljpost', 'lj_journal')); // if(! $lj_journal) // $lj_journal = $lj_username; $lj_blog = xmlify(get_pconfig($b['uid'], 'ljpost', 'lj_blog')); if (!strlen($lj_blog)) { $lj_blog = xmlify('http://www.livejournal.com/interface/xmlrpc'); } if ($lj_username && $lj_password && $lj_blog) { require_once 'include/bbcode.php'; require_once 'include/datetime.php'; $title = xmlify($b['title']); $post = bbcode($b['body']); $post = xmlify($post); $tags = ljpost_get_tags($b['tag']); $date = datetime_convert('UTC', $tz, $b['created'], 'Y-m-d H:i:s'); $year = intval(substr($date, 0, 4)); $mon = intval(substr($date, 5, 2)); $day = intval(substr($date, 8, 2)); $hour = intval(substr($date, 11, 2)); $min = intval(substr($date, 14, 2)); $xml = <<<EOT <?xml version="1.0" encoding="utf-8"?> <methodCall> <methodName>LJ.XMLRPC.postevent</methodName> <params> <param><value> <struct> <member><name>username</name><value><string>{$lj_username}</string></value></member> <member><name>password</name><value><string>{$lj_password}</string></value></member> <member><name>event</name><value><string>{$post}</string></value></member> <member><name>subject</name><value><string>{$title}</string></value></member> <member><name>lineendings</name><value><string>unix</string></value></member> <member><name>year</name><value><int>{$year}</int></value></member> <member><name>mon</name><value><int>{$mon}</int></value></member> <member><name>day</name><value><int>{$day}</int></value></member> <member><name>hour</name><value><int>{$hour}</int></value></member> <member><name>min</name><value><int>{$min}</int></value></member> \t\t<member><name>usejournal</name><value><string>{$lj_username}</string></value></member> \t\t<member> \t\t\t<name>props</name> \t\t\t<value> \t\t\t\t<struct> \t\t\t\t\t<member> \t\t\t\t\t\t<name>useragent</name> \t\t\t\t\t\t<value><string>Friendica</string></value> \t\t\t\t\t</member> \t\t\t\t\t<member> \t\t\t\t\t\t<name>taglist</name> \t\t\t\t\t\t<value><string>{$tags}</string></value> \t\t\t\t\t</member> \t\t\t\t</struct> \t\t\t</value> \t\t</member> </struct> </value></param> </params> </methodCall> EOT; logger('ljpost: data: ' . $xml, LOGGER_DATA); if ($lj_blog !== 'test') { $x = post_url($lj_blog, $xml, array("Content-Type: text/xml")); } logger('posted to livejournal: ' . $x ? $x : '', LOGGER_DEBUG); } }
"><?php if (is_array($post_list)) { $i = 0; $__LIST__ = $post_list; if (count($__LIST__) == 0) { echo ""; } else { foreach ($__LIST__ as $key => $val) { $mod = $i % 2; ++$i; ?> <div class="showitem J_item"><div class="showcont clearfix"><div class="showitemTitle clearfix"><h3 class="fl" sp="<?php echo $req["sp"]; ?> "><a href="<?php echo post_url($val['id'], $val['post_key']); ?> " target="_blank" <?php if ($val['tcolor']) { ?> style="color: <?php echo $val["tcolor"]; ?> ;"<?php } ?> ><?php echo $val["title"]; ?> <span> <?php echo $val["prices"];
function notifier_run($argv, $argc) { global $a, $db; if (is_null($a)) { $a = new App(); } if (is_null($db)) { @(include ".htconfig.php"); require_once "dba.php"; $db = new dba($db_host, $db_user, $db_pass, $db_data); unset($db_host, $db_user, $db_pass, $db_data); } require_once "session.php"; require_once "datetime.php"; require_once 'include/items.php'; require_once 'include/bbcode.php'; load_config('config'); load_config('system'); load_hooks(); if ($argc < 3) { return; } $a->set_baseurl(get_config('system', 'url')); logger('notifier: invoked: ' . print_r($argv, true)); $cmd = $argv[1]; switch ($cmd) { case 'mail': default: $item_id = intval($argv[2]); if (!$item_id) { return; } break; } $expire = false; $mail = false; $fsuggest = false; $top_level = false; $recipients = array(); $url_recipients = array(); $normal_mode = true; if ($cmd === 'mail') { $normal_mode = false; $mail = true; $message = q("SELECT * FROM `mail` WHERE `id` = %d LIMIT 1", intval($item_id)); if (!count($message)) { return; } $uid = $message[0]['uid']; $recipients[] = $message[0]['contact-id']; $item = $message[0]; } elseif ($cmd === 'expire') { $normal_mode = false; $expire = true; $items = q("SELECT * FROM `item` WHERE `uid` = %d AND `wall` = 1 \n\t\t\tAND `deleted` = 1 AND `changed` > UTC_TIMESTAMP() - INTERVAL 10 MINUTE", intval($item_id)); $uid = $item_id; $item_id = 0; if (!count($items)) { return; } } elseif ($cmd === 'suggest') { $normal_mode = false; $fsuggest = true; $suggest = q("SELECT * FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item_id)); if (!count($suggest)) { return; } $uid = $suggest[0]['uid']; $recipients[] = $suggest[0]['cid']; $item = $suggest[0]; } else { // find ancestors $r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($item_id)); if (!count($r) || !intval($r[0]['parent'])) { return; } $target_item = $r[0]; $parent_id = intval($r[0]['parent']); $uid = $r[0]['uid']; $updated = $r[0]['edited']; if (!$parent_id) { return; } $items = q("SELECT `item`.*, `sign`.`signed_text`,`sign`.`signature`,`sign`.`signer` \n\t\t\tFROM `item` LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id` WHERE `parent` = %d ORDER BY `id` ASC", intval($parent_id)); if (!count($items)) { return; } // avoid race condition with deleting entries if ($items[0]['deleted']) { foreach ($items as $item) { $item['deleted'] = 1; } } if (count($items) == 1 && $items[0]['id'] === $target_item['id'] && $items[0]['uri'] === $items[0]['parent-uri']) { logger('notifier: top level post'); $top_level = true; } } $r = q("SELECT `contact`.*, `user`.`pubkey` AS `upubkey`, `user`.`prvkey` AS `uprvkey`, \n\t\t`user`.`timezone`, `user`.`nickname`, `user`.`sprvkey`, `user`.`spubkey`, \n\t\t`user`.`page-flags`, `user`.`prvnets`\n\t\tFROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` \n\t\tWHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1", intval($uid)); if (!count($r)) { return; } $owner = $r[0]; $walltowall = $top_level && $owner['id'] != $items[0]['contact-id'] ? true : false; $hub = get_config('system', 'huburl'); // If this is a public conversation, notify the feed hub $public_message = true; // fill this in with a single salmon slap if applicable $slap = ''; if (!($mail || $fsuggest)) { require_once 'include/group.php'; $parent = $items[0]; // This is IMPORTANT!!!! // We will only send a "notify owner to relay" or followup message if the referenced post // originated on our system by virtue of having our hostname somewhere // in the URI, AND it was a comment (not top_level) AND the parent originated elsewhere. // if $parent['wall'] == 1 we will already have the parent message in our array // and we will relay the whole lot. // expire sends an entire group of expire messages and cannot be forwarded. // However the conversation owner will be a part of the conversation and will // be notified during this run. // Other DFRN conversation members will be alerted during polled updates. // Diaspora members currently are not notified of expirations, and other networks have // either limited or no ability to process deletions. We should at least fix Diaspora // by stringing togther an array of retractions and sending them onward. $localhost = $a->get_hostname(); if (strpos($localhost, ':')) { $localhost = substr($localhost, 0, strpos($localhost, ':')); } /** * * Be VERY CAREFUL if you make any changes to the following several lines. Seemingly innocuous changes * have been known to cause runaway conditions which affected several servers, along with * permissions issues. * */ $relay_to_owner = false; if (!$top_level && $parent['wall'] == 0 && !$expire && stristr($target_item['uri'], $localhost)) { $relay_to_owner = true; } if ($cmd === 'uplink' && intval($parent['forum_mode']) && !$top_level) { $relay_to_owner = true; } // until the 'origin' flag has been in use for several months // we will just use it as a fallback test // later we will be able to use it as the primary test of whether or not to relay. if (!$target_item['origin']) { $relay_to_owner = false; } if ($parent['origin']) { $relay_to_owner = false; } if ($relay_to_owner) { logger('notifier: followup', LOGGER_DEBUG); // local followup to remote post $followup = true; $public_message = false; // not public $conversant_str = dbesc($parent['contact-id']); } else { $followup = false; // don't send deletions onward for other people's stuff if ($target_item['deleted'] && !intval($target_item['wall'])) { logger('notifier: ignoring delete notification for non-wall item'); return; } if (strlen($parent['allow_cid']) || strlen($parent['allow_gid']) || strlen($parent['deny_cid']) || strlen($parent['deny_gid'])) { $public_message = false; // private recipients, not public } $allow_people = expand_acl($parent['allow_cid']); $allow_groups = expand_groups(expand_acl($parent['allow_gid'])); $deny_people = expand_acl($parent['deny_cid']); $deny_groups = expand_groups(expand_acl($parent['deny_gid'])); // if our parent is a forum, uplink to the origonal author causing // a delivery fork if (intval($parent['forum_mode']) && !$top_level && $cmd !== 'uplink') { proc_run('php', 'include/notifier', 'uplink', $item_id); } $conversants = array(); foreach ($items as $item) { $recipients[] = $item['contact-id']; $conversants[] = $item['contact-id']; // pull out additional tagged people to notify (if public message) if ($public_message && strlen($item['inform'])) { $people = explode(',', $item['inform']); foreach ($people as $person) { if (substr($person, 0, 4) === 'cid:') { $recipients[] = intval(substr($person, 4)); $conversants[] = intval(substr($person, 4)); } else { $url_recipients[] = substr($person, 4); } } } } logger('notifier: url_recipients' . print_r($url_recipients, true)); $conversants = array_unique($conversants); $recipients = array_unique(array_merge($recipients, $allow_people, $allow_groups)); $deny = array_unique(array_merge($deny_people, $deny_groups)); $recipients = array_diff($recipients, $deny); $conversant_str = dbesc(implode(', ', $conversants)); } $r = q("SELECT * FROM `contact` WHERE `id` IN ( {$conversant_str} ) AND `blocked` = 0 AND `pending` = 0"); if (count($r)) { $contacts = $r; } } $feed_template = get_markup_template('atom_feed.tpl'); $mail_template = get_markup_template('atom_mail.tpl'); $atom = ''; $slaps = array(); $hubxml = feed_hublinks(); $birthday = feed_birthday($owner['uid'], $owner['timezone']); if (strlen($birthday)) { $birthday = '<dfrn:birthday>' . xmlify($birthday) . '</dfrn:birthday>'; } $atom .= replace_macros($feed_template, array('$version' => xmlify(FRIENDICA_VERSION), '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname']), '$feed_title' => xmlify($owner['name']), '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00', ATOM_TIME)), '$hub' => $hubxml, '$salmon' => '', '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']), '$thumb' => xmlify($owner['thumb']), '$picdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['avatar-date'] . '+00:00', ATOM_TIME)), '$uridate' => xmlify(datetime_convert('UTC', 'UTC', $owner['uri-date'] . '+00:00', ATOM_TIME)), '$namdate' => xmlify(datetime_convert('UTC', 'UTC', $owner['name-date'] . '+00:00', ATOM_TIME)), '$birthday' => $birthday)); if ($mail) { $public_message = false; // mail is not public $body = fix_private_photos($item['body'], $owner['uid']); $atom .= replace_macros($mail_template, array('$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$thumb' => xmlify($owner['thumb']), '$item_id' => xmlify($item['uri']), '$subject' => xmlify($item['title']), '$created' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00', ATOM_TIME)), '$content' => xmlify($body), '$parent_id' => xmlify($item['parent-uri']))); } elseif ($fsuggest) { $public_message = false; // suggestions are not public $sugg_template = get_markup_template('atom_suggest.tpl'); $atom .= replace_macros($sugg_template, array('$name' => xmlify($item['name']), '$url' => xmlify($item['url']), '$photo' => xmlify($item['photo']), '$request' => xmlify($item['request']), '$note' => xmlify($item['note']))); // We don't need this any more q("DELETE FROM `fsuggest` WHERE `id` = %d LIMIT 1", intval($item['id'])); } else { if ($followup) { foreach ($items as $item) { // there is only one item if (!$item['parent']) { continue; } if ($item['id'] == $item_id) { logger('notifier: followup: item: ' . print_r($item, true), LOGGER_DATA); $slap = atom_entry($item, 'html', $owner, $owner, false); $atom .= atom_entry($item, 'text', $owner, $owner, false); } } } else { foreach ($items as $item) { if (!$item['parent']) { continue; } // private emails may be in included in public conversations. Filter them. if ($public_message && $item['private']) { continue; } $contact = get_item_contact($item, $contacts); if (!$contact) { continue; } if ($normal_mode) { // we only need the current item, but include the parent because without it // older sites without a corresponding dfrn_notify change may do the wrong thing. if ($item_id == $item['id'] || $item['id'] == $item['parent']) { $atom .= atom_entry($item, 'text', $contact, $owner, true); } } else { $atom .= atom_entry($item, 'text', $contact, $owner, true); } if ($top_level && $public_message && $item['author-link'] === $item['owner-link'] && !$expire) { $slaps[] = atom_entry($item, 'html', $contact, $owner, true); } } } } $atom .= '</feed>' . "\r\n"; logger('notifier: ' . $atom, LOGGER_DATA); logger('notifier: slaps: ' . print_r($slaps, true), LOGGER_DATA); // If this is a public message and pubmail is set on the parent, include all your email contacts $mail_disabled = function_exists('imap_open') && !get_config('system', 'imap_disabled') ? 0 : 1; if (!$mail_disabled) { if (!strlen($target_item['allow_cid']) && !strlen($target_item['allow_gid']) && !strlen($target_item['deny_cid']) && !strlen($target_item['deny_gid']) && intval($target_item['pubmail'])) { $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `network` = '%s'", intval($uid), dbesc(NETWORK_MAIL)); if (count($r)) { foreach ($r as $rr) { $recipients[] = $rr['id']; } } } } if ($followup) { $recip_str = $parent['contact-id']; } else { $recip_str = implode(', ', $recipients); } $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) AND `blocked` = 0 AND `pending` = 0 ", dbesc($recip_str)); require_once 'include/salmon.php'; $interval = get_config('system', 'delivery_interval') === false ? 2 : intval(get_config('system', 'delivery_interval')); // delivery loop if (count($r)) { foreach ($r as $contact) { if (!$mail && !$fsuggest && !$followup && !$contact['self']) { if ($contact['network'] === NETWORK_DIASPORA && $public_message) { continue; } q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", dbesc($cmd), intval($item_id), intval($contact['id'])); } } foreach ($r as $contact) { if ($contact['self']) { continue; } // potentially more than one recipient. Start a new process and space them out a bit. // we will deliver single recipient types of message and email receipients here. if (!$mail && !$fsuggest && !$followup) { proc_run('php', 'include/delivery.php', $cmd, $item_id, $contact['id']); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } continue; } $deliver_status = 0; logger("main delivery by notifier: followup={$followup} mail={$mail} fsuggest={$fsuggest}"); switch ($contact['network']) { case NETWORK_DFRN: // perform local delivery if we are on the same site $basepath = implode('/', array_slice(explode('/', $contact['url']), 0, 3)); if (link_compare($basepath, $a->get_baseurl())) { $nickname = basename($contact['url']); if ($contact['issued-id']) { $sql_extra = sprintf(" AND `dfrn-id` = '%s' ", dbesc($contact['issued-id'])); } else { $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($contact['dfrn-id'])); } $x = q("SELECT\t`contact`.*, `contact`.`uid` AS `importer_uid`, \n\t\t\t\t\t\t\t`contact`.`pubkey` AS `cpubkey`, \n\t\t\t\t\t\t\t`contact`.`prvkey` AS `cprvkey`, \n\t\t\t\t\t\t\t`contact`.`thumb` AS `thumb`, \n\t\t\t\t\t\t\t`contact`.`url` as `url`,\n\t\t\t\t\t\t\t`contact`.`name` as `senderName`,\n\t\t\t\t\t\t\t`user`.* \n\t\t\t\t\t\t\tFROM `contact` \n\t\t\t\t\t\t\tLEFT JOIN `user` ON `contact`.`uid` = `user`.`uid` \n\t\t\t\t\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\t\t\tAND `contact`.`network` = '%s' AND `user`.`nickname` = '%s'\n\t\t\t\t\t\t\t{$sql_extra}\n\t\t\t\t\t\t\tAND `user`.`account_expired` = 0 LIMIT 1", dbesc(NETWORK_DFRN), dbesc($nickname)); if (count($x)) { require_once 'library/simplepie/simplepie.inc'; logger('mod-delivery: local delivery'); local_delivery($x[0], $atom); break; } } logger('notifier: dfrndelivery: ' . $contact['name']); $deliver_status = dfrn_deliver($owner, $contact, $atom); logger('notifier: dfrn_delivery returns ' . $deliver_status); if ($deliver_status == -1) { logger('notifier: delivery failed: queuing message'); // queue message for redelivery add_to_queue($contact['id'], NETWORK_DFRN, $atom); } break; case NETWORK_OSTATUS: // Do not send to otatus if we are not configured to send to public networks if ($owner['prvnets']) { break; } if (get_config('system', 'ostatus_disabled') || get_config('system', 'dfrn_only')) { break; } if ($followup && $contact['notify']) { logger('notifier: slapdelivery: ' . $contact['name']); $deliver_status = slapper($owner, $contact['notify'], $slap); if ($deliver_status == -1) { // queue message for redelivery add_to_queue($contact['id'], NETWORK_OSTATUS, $slap); } } else { // only send salmon if public - e.g. if it's ok to notify // a public hub, it's ok to send a salmon if (count($slaps) && $public_message && !$expire) { logger('notifier: slapdelivery: ' . $contact['name']); foreach ($slaps as $slappy) { if ($contact['notify']) { $deliver_status = slapper($owner, $contact['notify'], $slappy); if ($deliver_status == -1) { // queue message for redelivery add_to_queue($contact['id'], NETWORK_OSTATUS, $slappy); } } } } } break; case NETWORK_MAIL: if (get_config('system', 'dfrn_only')) { break; } // WARNING: does not currently convert to RFC2047 header encodings, etc. $addr = $contact['addr']; if (!strlen($addr)) { break; } if ($cmd === 'wall-new' || $cmd === 'comment-new') { $it = null; if ($cmd === 'wall-new') { $it = $items[0]; } else { $r = q("SELECT * FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($argv[2]), intval($uid)); if (count($r)) { $it = $r[0]; } } if (!$it) { break; } $local_user = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($uid)); if (!count($local_user)) { break; } $reply_to = ''; $r1 = q("SELECT * FROM `mailacct` WHERE `uid` = %d LIMIT 1", intval($uid)); if ($r1 && $r1[0]['reply_to']) { $reply_to = $r1[0]['reply_to']; } $subject = $it['title'] ? $it['title'] : t("(no subject)"); $headers = 'From: ' . $local_user[0]['username'] . ' <' . $local_user[0]['email'] . '>' . "\n"; if ($reply_to) { $headers .= 'Reply-to: ' . $reply_to . "\n"; } $headers .= 'Message-id: <' . $it['uri'] . '>' . "\n"; if ($it['uri'] !== $it['parent-uri']) { $header .= 'References: <' . $it['parent-uri'] . '>' . "\n"; if (!strlen($it['title'])) { $r = q("SELECT `title` FROM `item` WHERE `parent-uri` = '%s' LIMIT 1", dbesc($it['parent-uri'])); if (count($r)) { $subtitle = $r[0]['title']; if ($subtitle) { if (strncasecmp($subtitle, 'RE:', 3)) { $subject = $subtitle; } else { $subject = 'Re: ' . $subtitle; } } } } } $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-Type: text/html; charset=UTF-8' . "\n"; $headers .= 'Content-Transfer-Encoding: 8bit' . "\n\n"; $html = prepare_body($it); $message = '<html><body>' . $html . '</body></html>'; logger('notifier: email delivery to ' . $addr); mail($addr, $subject, $message, $headers); } break; case NETWORK_DIASPORA: require_once 'include/diaspora.php'; if (get_config('system', 'dfrn_only') || !get_config('system', 'diaspora_enabled')) { break; } if ($mail) { diaspora_send_mail($item, $owner, $contact); break; } if (!$normal_mode) { break; } // special handling for followup to public post // all other public posts processed as public batches further below if ($public_message) { if ($followup) { diaspora_send_followup($target_item, $owner, $contact, true); } break; } if (!$contact['pubkey']) { break; } if ($target_item['verb'] === ACTIVITY_DISLIKE) { // unsupported break; } elseif ($target_item['deleted'] && $target_item['verb'] !== ACTIVITY_LIKE) { // diaspora delete, diaspora_send_retraction($target_item, $owner, $contact); break; } elseif ($followup) { // send comments, likes and retractions of likes to owner to relay diaspora_send_followup($target_item, $owner, $contact); break; } elseif ($target_item['parent'] != $target_item['id']) { // we are the relay - send comments, likes and unlikes to our conversants diaspora_send_relay($target_item, $owner, $contact); break; } elseif ($top_level && !$walltowall) { // currently no workable solution for sending walltowall diaspora_send_status($target_item, $owner, $contact); break; } break; case NETWORK_FEED: case NETWORK_FACEBOOK: if (get_config('system', 'dfrn_only')) { break; } default: break; } } } // send additional slaps to mentioned remote tags (@foo@example.com) if ($slap && count($url_recipients) && ($followup || $top_level) && $public_message && !$expire) { if (!get_config('system', 'dfrn_only')) { foreach ($url_recipients as $url) { if ($url) { logger('notifier: urldelivery: ' . $url); $deliver_status = slapper($owner, $url, $slap); // TODO: redeliver/queue these items on failure, though there is no contact record } } } } if ($public_message) { $r1 = q("SELECT DISTINCT(`batch`), `id`, `name`,`network` FROM `contact` WHERE `network` = '%s' \n\t\t\tAND `uid` = %d AND `rel` != %d group by `batch` ORDER BY rand() ", dbesc(NETWORK_DIASPORA), intval($owner['uid']), intval(CONTACT_IS_SHARING)); $r2 = q("SELECT `id`, `name`,`network` FROM `contact` \n\t\t\tWHERE `network` = '%s' AND `uid` = %d AND `blocked` = 0 AND `pending` = 0\n\t\t\tAND `rel` != %d order by rand() ", dbesc(NETWORK_DFRN), intval($owner['uid']), intval(CONTACT_IS_SHARING)); $r = array_merge($r2, $r1); if (count($r)) { logger('pubdeliver: ' . print_r($r, true), LOGGER_DEBUG); // throw everything into the queue in case we get killed foreach ($r as $rr) { if (!$mail && !$fsuggest && !$followup) { q("insert into deliverq ( `cmd`,`item`,`contact` ) values ('%s', %d, %d )", dbesc($cmd), intval($item_id), intval($rr['id'])); } } foreach ($r as $rr) { // except for Diaspora batch jobs // Don't deliver to folks who have already been delivered to if ($rr['network'] !== NETWORK_DIASPORA && in_array($rr['id'], $conversants)) { logger('notifier: already delivered id=' . $rr['id']); continue; } if (!$mail && !$fsuggest && !$followup) { logger('notifier: delivery agent: ' . $rr['name'] . ' ' . $rr['id']); proc_run('php', 'include/delivery.php', $cmd, $item_id, $rr['id']); if ($interval) { @time_sleep_until(microtime(true) + (double) $interval); } } } } if (strlen($hub)) { $hubs = explode(',', $hub); if (count($hubs)) { foreach ($hubs as $h) { $h = trim($h); if (!strlen($h)) { continue; } $params = 'hub.mode=publish&hub.url=' . urlencode($a->get_baseurl() . '/dfrn_poll/' . $owner['nickname']); post_url($h, $params); logger('pubsub: publish: ' . $h . ' ' . $params . ' returned ' . $a->get_curl_code()); if (count($hubs) > 1) { sleep(7); } // try and avoid multiple hubs responding at precisely the same time } } } } if ($normal_mode) { call_hooks('notifier_normal', $target_item); } call_hooks('notifier_end', $target_item); return; }
/** * 비회원이 작성한 댓글 삭제시 패스워드를 물을 때 필요합니다. */ public function password($post_id = 0, $cmt_id = 0) { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_comment_list_password'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $cmt_id = (int) $cmt_id; if (empty($cmt_id) or $cmt_id < 1) { show_404(); } $post_id = (int) $post_id; if (empty($post_id) or $post_id < 1) { show_404(); } $comment = $this->Comment_model->get_one($cmt_id); if (!element('cmt_id', $comment)) { show_404(); } if ((int) element('post_id', $comment) !== $post_id) { show_404(); } $post = $this->Post_model->get_one($post_id); if (!element('post_id', $post)) { show_404(); } $board = $this->board->item_all(element('brd_id', $post)); /** * Validation 라이브러리를 가져옵니다 */ $this->load->library('form_validation'); /** * 전송된 데이터의 유효성을 체크합니다 */ $config = array(array('field' => 'modify_password', 'label' => '패스워드', 'rules' => 'trim|required')); $this->form_validation->set_rules($config); /** * 유효성 검사를 하지 않는 경우, 또는 유효성 검사에 실패한 경우입니다. * 즉 글쓰기나 수정 페이지를 보고 있는 경우입니다 */ if ($this->form_validation->run() === false) { // 이벤트가 존재하면 실행합니다 $view['view']['event']['formrunfalse'] = Events::trigger('formrunfalse', $eventname); } else { /** * 유효성 검사를 통과한 경우입니다. * 즉 데이터의 insert 나 update 의 process 처리가 필요한 상황입니다 */ // 이벤트가 존재하면 실행합니다 $view['view']['event']['formruntrue'] = Events::trigger('formruntrue', $eventname); $modify_password = $this->input->post('modify_password'); $return = $this->board->delete_comment_check($cmt_id, $modify_password); $result = json_decode($return, true); if (element('error', $result)) { $view['view']['message'] = element('error', $result); } if (element('password', $result)) { $view['view']['message'] = element('password', $result); } if (element('success', $result)) { redirect(post_url(element('brd_key', $board), $post_id)); return; } } // 이벤트가 존재하면 실행합니다 $view['view']['event']['before_layout'] = Events::trigger('before_layout', $eventname); /** * 레이아웃을 정의합니다 */ $view['view']['info'] = '댓글 삭제를 위한 패스워드 입력페이지입니다.<br />패스워드를 입력하시면 댓글 삭제가 가능합니다'; $page_title = element('board_name', $board) . ' 댓글수정'; $layout_dir = element('board_layout', $board) ? element('board_layout', $board) : $this->cbconfig->item('layout_board'); $mobile_layout_dir = element('board_mobile_layout', $board) ? element('board_mobile_layout', $board) : $this->cbconfig->item('mobile_layout_board'); $use_sidebar = element('board_sidebar', $board) ? element('board_sidebar', $board) : $this->cbconfig->item('sidebar_board'); $use_mobile_sidebar = element('board_mobile_sidebar', $board) ? element('board_mobile_sidebar', $board) : $this->cbconfig->item('mobile_sidebar_board'); $skin_dir = element('board_skin', $board) ? element('board_skin', $board) : $this->cbconfig->item('skin_board'); $mobile_skin_dir = element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : $this->cbconfig->item('mobile_skin_board'); $layoutconfig = array('path' => 'board', 'layout' => 'layout', 'skin' => 'password', 'layout_dir' => $layout_dir, 'mobile_layout_dir' => $mobile_layout_dir, 'use_sidebar' => $use_sidebar, 'use_mobile_sidebar' => $use_mobile_sidebar, 'skin_dir' => $skin_dir, 'mobile_skin_dir' => $mobile_skin_dir, 'page_title' => $page_title); $view['layout'] = $this->managelayout->front($layoutconfig, $this->cbconfig->get_device_view_type()); $this->data = $view; $this->layout = element('layout_skin_file', element('layout', $view)); $this->view = element('view_skin_file', element('layout', $view)); return true; }
function subscribe_to_hub($url, $importer, $contact, $hubmode = 'subscribe') { $a = get_app(); if (is_array($importer)) { $r = q("SELECT `nickname` FROM `user` WHERE `uid` = %d LIMIT 1", intval($importer['uid'])); } // Diaspora has different message-ids in feeds than they do // through the direct Diaspora protocol. If we try and use // the feed, we'll get duplicates. So don't. if (!count($r) || $contact['network'] === NETWORK_DIASPORA) { return; } $push_url = get_config('system', 'url') . '/pubsub/' . $r[0]['nickname'] . '/' . $contact['id']; // Use a single verify token, even if multiple hubs $verify_token = strlen($contact['hub-verify']) ? $contact['hub-verify'] : random_string(); $params = 'hub.mode=' . $hubmode . '&hub.callback=' . urlencode($push_url) . '&hub.topic=' . urlencode($contact['poll']) . '&hub.verify=async&hub.verify_token=' . $verify_token; logger('subscribe_to_hub: ' . $hubmode . ' ' . $contact['name'] . ' to hub ' . $url . ' endpoint: ' . $push_url . ' with verifier ' . $verify_token); if (!strlen($contact['hub-verify']) or $contact['hub-verify'] != $verify_token) { $r = q("UPDATE `contact` SET `hub-verify` = '%s' WHERE `id` = %d", dbesc($verify_token), intval($contact['id'])); } post_url($url, $params); logger('subscribe_to_hub: returns: ' . $a->get_curl_code(), LOGGER_DEBUG); return; }
public function search() { $data['search_term'] = $this->input->post('term', TRUE); if ($data['search_term'] != "") { if ($data['posts'] = $this->blog->get_posts_by_term($data['search_term'])) { foreach ($data['posts'] as $key => $post) { $data['posts'][$key]['url'] = post_url($post['url_title'], $post['date_posted']); $data['posts'][$key]['display_name'] = $this->users->get_user_display_name($post['author']); } $this->_template['page'] = 'blog/search'; } else { $this->_template['page'] = 'errors/search_no_results'; } $this->system_library->load($this->_template['page'], $data); } else { redirect('blog', 'refresh'); } }
function slapper($owner, $url, $slap) { logger('slapper called for ' . $url . '. Data: ' . $slap); // does contact have a salmon endpoint? if (!strlen($url)) { return; } if (!$owner['sprvkey']) { logger(sprintf("user '%s' (%d) does not have a salmon private key. Send failed.", $owner['username'], $owner['uid'])); return; } // add all namespaces to item $namespaces = <<<EOT <entry xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:at="http://purl.org/atompub/tombstones/1.0" xmlns:media="http://purl.org/syndication/atommedia" xmlns:dfrn="http://purl.org/macgirvin/dfrn/1.0" xmlns:as="http://activitystrea.ms/spec/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" \t xmlns:statusnet="http://status.net/schema/api/1/" >\t\t\t\t\t\t\t\t\t\t\t\t\t> EOT; $slap = str_replace('<entry>', $namespaces, $slap); // create a magic envelope $data = base64url_encode($slap); $data_type = 'application/atom+xml'; $encoding = 'base64url'; $algorithm = 'RSA-SHA256'; $keyhash = base64url_encode(hash('sha256', salmon_key($owner['spubkey'])), true); // precomputed base64url encoding of data_type, encoding, algorithm concatenated with periods $precomputed = '.YXBwbGljYXRpb24vYXRvbSt4bWw=.YmFzZTY0dXJs.UlNBLVNIQTI1Ng=='; $signature = base64url_encode(rsa_sign(str_replace('=', '', $data . $precomputed), $owner['sprvkey'])); $signature2 = base64url_encode(rsa_sign($data . $precomputed, $owner['sprvkey'])); $signature3 = base64url_encode(rsa_sign($data, $owner['sprvkey'])); $salmon_tpl = get_markup_template('magicsig.tpl'); $salmon = replace_macros($salmon_tpl, array('$data' => $data, '$encoding' => $encoding, '$algorithm' => $algorithm, '$keyhash' => $keyhash, '$signature' => $signature)); // slap them post_url($url, $salmon, array('Content-type: application/magic-envelope+xml', 'Content-length: ' . strlen($salmon))); $a = get_app(); $return_code = $a->get_curl_code(); // check for success, e.g. 2xx if ($return_code > 299) { logger('compliant salmon failed. Falling back to status.net hack2'); // Entirely likely that their salmon implementation is // non-compliant. Let's try once more, this time only signing // the data, without stripping '=' chars $salmon = replace_macros($salmon_tpl, array('$data' => $data, '$encoding' => $encoding, '$algorithm' => $algorithm, '$keyhash' => $keyhash, '$signature' => $signature2)); // slap them post_url($url, $salmon, array('Content-type: application/magic-envelope+xml', 'Content-length: ' . strlen($salmon))); $return_code = $a->get_curl_code(); if ($return_code > 299) { logger('compliant salmon failed. Falling back to status.net hack3'); // Entirely likely that their salmon implementation is // non-compliant. Let's try once more, this time only signing // the data, without the precomputed blob $salmon = replace_macros($salmon_tpl, array('$data' => $data, '$encoding' => $encoding, '$algorithm' => $algorithm, '$keyhash' => $keyhash, '$signature' => $signature3)); // slap them post_url($url, $salmon, array('Content-type: application/magic-envelope+xml', 'Content-length: ' . strlen($salmon))); $return_code = $a->get_curl_code(); } } logger('slapper for ' . $url . ' returned ' . $return_code); if (!$return_code) { return -1; } if ($return_code == 503 && stristr($a->get_curl_headers(), 'retry-after')) { return -1; } return $return_code >= 200 && $return_code < 300 ? 0 : 1; }
function diaspora_transmit($owner, $contact, $slap, $public_batch, $queue_run = false) { $enabled = intval(get_config('system', 'diaspora_enabled')); if (!$enabled) { return 200; } $a = get_app(); $logid = random_string(4); $dest_url = $public_batch ? $contact['batch'] : $contact['notify']; if (!$dest_url) { logger('diaspora_transmit: no url for contact: ' . $contact['id'] . ' batch mode =' . $public_batch); return 0; } logger('diaspora_transmit: ' . $logid . ' ' . $dest_url); if (!$queue_run && was_recently_delayed($contact['id'])) { $return_code = 0; } else { if (!intval(get_config('system', 'diaspora_test'))) { post_url($dest_url . '/', $slap); $return_code = $a->get_curl_code(); } else { logger('diaspora_transmit: test_mode'); return 200; } } logger('diaspora_transmit: ' . $logid . ' returns: ' . $return_code); if (!$return_code || $return_code == 503 && stristr($a->get_curl_headers(), 'retry-after')) { logger('diaspora_transmit: queue message'); $r = q("SELECT id from queue where cid = %d and network = '%s' and content = '%s' and batch = %d limit 1", intval($contact['id']), dbesc(NETWORK_DIASPORA), dbesc($slap), intval($public_batch)); if (count($r)) { logger('diaspora_transmit: add_to_queue ignored - identical item already in queue'); } else { // queue message for redelivery add_to_queue($contact['id'], NETWORK_DIASPORA, $slap, $public_batch); } } return $return_code ? $return_code : -1; }
/** * 图片截取 */ function shop_imageIntercept($param) { //图片目录 if (in_array($_SERVER['HTTP_HOST'], array("imglocal.boqii.com", "imglocal.boqiicdn.com"))) { $imgdir = 'http://imglocal.boqii.com'; } elseif (in_array($_SERVER['HTTP_HOST'], array('imgtest.boqii.com', 'imgtest.boqiicdn.com'))) { $imgdir = 'http://imgtest.boqii.com'; } elseif (in_array($_SERVER['HTTP_HOST'], array("img1.boqii.com", "img1.boqiicdn.com"))) { $imgdir = 'http://img1.boqii.com'; } elseif (in_array($_SERVER['HTTP_HOST'], array("img.boqii.com", "img.boqiicdn.com"))) { $imgdir = 'http://img.boqii.com'; } elseif (in_array($_SERVER['HTTP_HOST'], array("img.boqii.com", "img3.boqiicdn.com"))) { $imgdir = 'http://img3.boqii.com'; } $post_data = array('filePath' => $param['filePath'], 'width' => $param['width'], 'height' => $param['height'], 'newfile' => $param['newfile'], 'type' => 2, 'subtype' => 5, 'aucode' => 'boqii', 'method' => 'mbprase'); $url = $imgdir . "/Server/upload.php"; $result = post_url($url, $post_data); return $result; }
$challenge = hex2bin($res->challenge); $final_dfrn_id = ''; if ($contact['duplex'] && strlen($contact['prvkey'])) { openssl_private_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['prvkey']); openssl_private_decrypt($challenge, $postvars['challenge'], $contact['prvkey']); } else { openssl_public_decrypt($sent_dfrn_id, $final_dfrn_id, $contact['pubkey']); openssl_public_decrypt($challenge, $postvars['challenge'], $contact['pubkey']); } $final_dfrn_id = substr($final_dfrn_id, 0, strpos($final_dfrn_id, '.')); if ($final_dfrn_id != $idtosend) { // did not decode properly - cannot trust this site continue; } $postvars['dfrn_id'] = $idtosend; $xml = post_url($contact['poll'], $postvars); if (!strlen($xml)) { // an empty response may mean there's nothing new - record the fact that we checked $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", dbesc(datetime_convert()), intval($contact['id'])); continue; } $feed = new SimplePie(); $feed->set_raw_data($xml); $feed->enable_order_by_date(false); $feed->init(); // Check at the feed level for updated contact name and/or photo $name_updated = ''; $new_name = ''; $photo_timestamp = ''; $photo_url = ''; $rawtags = $feed->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, author);
function dfrn_poll_content(&$a) { $dfrn_id = x($_GET, 'dfrn_id') ? $_GET['dfrn_id'] : ''; $type = x($_GET, 'type') ? $_GET['type'] : 'data'; $last_update = x($_GET, 'last_update') ? $_GET['last_update'] : ''; $destination_url = x($_GET, 'destination_url') ? $_GET['destination_url'] : ''; $sec = x($_GET, 'sec') ? $_GET['sec'] : ''; $dfrn_version = x($_GET, 'dfrn_version') ? (double) $_GET['dfrn_version'] : 2.0; $perm = x($_GET, 'perm') ? $_GET['perm'] : 'r'; $direction = -1; if (strpos($dfrn_id, ':') == 1) { $direction = intval(substr($dfrn_id, 0, 1)); $dfrn_id = substr($dfrn_id, 2); } if ($dfrn_id != '') { // initial communication from external contact $hash = random_string(); $status = 0; $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); if ($type !== 'profile') { $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` )\n\t\t\t\tVALUES( '%s', '%s', '%s', '%s', '%s' ) ", dbesc($hash), dbesc($dfrn_id), intval(time() + 60), dbesc($type), dbesc($last_update)); } $sql_extra = ''; switch ($direction) { case -1: if ($type === 'profile') { $sql_extra = sprintf(" AND ( `dfrn-id` = '%s' OR `issued-id` = '%s' ) ", dbesc($dfrn_id), dbesc($dfrn_id)); } else { $sql_extra = sprintf(" AND `issued-id` = '%s' ", dbesc($dfrn_id)); } $my_id = $dfrn_id; break; case 0: $sql_extra = sprintf(" AND `issued-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $my_id = '1:' . $dfrn_id; break; case 1: $sql_extra = sprintf(" AND `dfrn-id` = '%s' AND `duplex` = 1 ", dbesc($dfrn_id)); $my_id = '0:' . $dfrn_id; break; default: goaway(z_root()); break; // NOTREACHED } $r = q("SELECT `contact`.*, `user`.`username`, `user`.`nickname` \n\t\t\tFROM `contact` LEFT JOIN `user` ON `contact`.`uid` = `user`.`uid`\n\t\t\tWHERE `contact`.`blocked` = 0 AND `contact`.`pending` = 0 \n\t\t\tAND `user`.`nickname` = '%s' {$sql_extra} LIMIT 1", dbesc($a->argv[1])); if (count($r)) { $challenge = ''; $encrypted_id = ''; $id_str = $my_id . '.' . mt_rand(1000, 9999); if ($r[0]['duplex'] && strlen($r[0]['pubkey'])) { openssl_public_encrypt($hash, $challenge, $r[0]['pubkey']); openssl_public_encrypt($id_str, $encrypted_id, $r[0]['pubkey']); } else { openssl_private_encrypt($hash, $challenge, $r[0]['prvkey']); openssl_private_encrypt($id_str, $encrypted_id, $r[0]['prvkey']); } $challenge = bin2hex($challenge); $encrypted_id = bin2hex($encrypted_id); } else { $status = 1; $challenge = ''; $encrypted_id = ''; } if ($type === 'profile' && strlen($sec)) { // URL reply if ($dfrn_version < 2.2) { $s = fetch_url($r[0]['poll'] . '?dfrn_id=' . $encrypted_id . '&type=profile-check' . '&dfrn_version=' . DFRN_PROTOCOL_VERSION . '&challenge=' . $challenge . '&sec=' . $sec); } else { $s = post_url($r[0]['poll'], array('dfrn_id' => $encrypted_id, 'type' => 'profile-check', 'dfrn_version' => DFRN_PROTOCOL_VERSION, 'challenge' => $challenge, 'sec' => $sec)); } $profile = $r[0]['nickname']; switch ($destination_url) { case 'profile': $dest = $a->get_baseurl() . '/profile/' . $profile . '?tab=profile'; break; case 'photos': $dest = $a->get_baseurl() . '/photos/' . $profile; break; case 'status': case '': $dest = $a->get_baseurl() . '/profile/' . $profile; break; default: $dest = $destination_url; break; } logger("dfrn_poll: sec profile: " . $s, LOGGER_DATA); if (strlen($s) && strstr($s, '<?xml')) { $xml = parse_xml_string($s); logger('dfrn_poll: profile: parsed xml: ' . print_r($xml, true), LOGGER_DATA); logger('dfrn_poll: secure profile: challenge: ' . $xml->challenge . ' expecting ' . $hash); logger('dfrn_poll: secure profile: sec: ' . $xml->sec . ' expecting ' . $sec); if ((int) $xml->status == 0 && $xml->challenge == $hash && $xml->sec == $sec) { $_SESSION['authenticated'] = 1; $_SESSION['visitor_id'] = $r[0]['id']; $_SESSION['visitor_home'] = $r[0]['url']; $_SESSION['visitor_visiting'] = $r[0]['uid']; info(sprintf(t('%s welcomes %s'), $r[0]['username'], $r[0]['name']) . EOL); // Visitors get 1 day session. $session_id = session_id(); $expire = time() + 86400; q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1", dbesc($expire), dbesc($session_id)); } goaway($dest); } goaway($dest); // NOTREACHED } else { // XML reply header("Content-type: text/xml"); echo '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n" . '<dfrn_poll>' . "\r\n" . "\t" . '<status>' . $status . '</status>' . "\r\n" . "\t" . '<dfrn_version>' . DFRN_PROTOCOL_VERSION . '</dfrn_version>' . "\r\n" . "\t" . '<dfrn_id>' . $encrypted_id . '</dfrn_id>' . "\r\n" . "\t" . '<challenge>' . $challenge . '</challenge>' . "\r\n" . '</dfrn_poll>' . "\r\n"; killme(); // NOTREACHED } } }
public function post_menu() { //构造自定义菜单数据 $WxMenu = M('WxMenu'); $mu_map = array(); $mu_map['p_id'] = array('eq', 0); $mu_map['show'] = array('eq', 1); $list = $WxMenu->where($mu_map)->order('sort asc')->select(); $post_arr = array(); $post_sub_arr = array(); if (is_array($list) && !empty($list)) { foreach ($list as $key => $v) { if ($v['name']) { $post_arr['button'][$key]['name'] = $v['name']; $sub_mu = array(); $sub_mu['p_id'] = array('eq', $v['id']); $sub_mu['is_show'] = array('eq', 1); $sub_list = $WxMenu->where($sub_mu)->order('sort asc')->field('type,name,key_url')->select(); $sb = array(); if (is_array($sub_list) && !empty($sub_list)) { foreach ($sub_list as $k => $sb) { if ($sb['name']) { $post_sub_arr[$k]['type'] = $sb['type']; $post_sub_arr[$k]['name'] = $sb['name']; if ($sb['type'] == 'view') { $post_sub_arr[$k]['url'] = $sb['key_url']; } else { $post_sub_arr[$k]['key'] = $sb['key_url']; } } } } else { $post_arr['button'][$key]['type'] = $v['type']; if ($v['type'] == 'view') { $post_arr['button'][$key]['url'] = $v['key_url']; } else { $post_arr['button'][$key]['key'] = $v['key_url']; } } if (!empty($post_sub_arr)) { $post_arr['button'][$key]['sub_button'] = $post_sub_arr; } unset($post_sub_arr); } } } $post_data = json_encode($post_arr, JSON_UNESCAPED_UNICODE); //防中文转义 $post_data = str_replace("\\/", "/", $post_data); $wx_ACCESS_TOKEN = get_wx_AccessToken('1'); $url = 'https://api.weixin.qq.com/cgi-bin/menu/create?access_token=' . $wx_ACCESS_TOKEN; $return = post_url($url, $post_data); if ($return) { $this->success('操作成功', U('Weixin/wx_menu')); exit; } }
<?php if ($post['content']) { ?> <br /><br /><a href="<?php echo post_url($post['url_title'], $post['date_posted']); ?> "><?php echo lang('read_more'); ?> </a><br /><br /> <?php } ?> <?php if ($links = $this->system_library->generate_social_bookmarking_links(post_url($post['url_title'], $post['date_posted']), $post['title'])) { ?> <p><?php echo lang('add_to'); ?> <?php echo $links; ?> </p> <?php } } ?> <?php if ($posts_count > $posts_per_page) {
/** * 게시판 목록페이지입니다. */ public function _get_list($brd_key, $from_view = '') { // 이벤트 라이브러리를 로딩합니다 $eventname = 'event_board_post_get_list'; $this->load->event($eventname); $view = array(); $view['view'] = array(); // 이벤트가 존재하면 실행합니다 $view['view']['event']['before'] = Events::trigger('before', $eventname); $return = array(); $board = $this->_get_board($brd_key); $mem_id = (int) $this->member->item('mem_id'); $alertmessage = $this->member->is_member() ? '회원님은 이 게시판 목록을 볼 수 있는 권한이 없습니다' : '비회원은 이 게시판에 접근할 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오'; $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $this->accesslevel->check(element('access_list', $board), element('access_list_level', $board), element('access_list_group', $board), $alertmessage, $check); if (element('use_personal', $board) && $this->member->is_member() === false) { alert('이 게시판은 1:1 게시판입니다. 비회원은 접근할 수 없습니다'); return false; } $skindir = $this->cbconfig->get_device_view_type() === 'mobile' ? element('board_mobile_skin', $board) ? element('board_mobile_skin', $board) : element('board_skin', $board) : element('board_skin', $board); $skinurl = base_url(VIEW_DIR . 'board/' . $skindir); $view['view']['is_admin'] = $is_admin = $this->member->is_admin(array('board_id' => element('brd_id', $board), 'group_id' => element('bgr_id', $board))); /** * 페이지에 숫자가 아닌 문자가 입력되거나 1보다 작은 숫자가 입력되면 에러 페이지를 보여줍니다. */ $param =& $this->querystring; $page = (int) $this->input->get('page') > 0 ? (int) $this->input->get('page') : 1; $order_by_field = element('order_by_field', $board) ? element('order_by_field', $board) : 'post_num, post_reply'; $findex = $this->input->get('findex', null, $order_by_field); $sfield = $sfieldchk = $this->input->get('sfield', null, ''); if ($sfield === 'post_both') { $sfield = array('post_title', 'post_content'); } $skeyword = $this->input->get('skeyword', null, ''); if ($this->cbconfig->get_device_view_type() === 'mobile') { $per_page = element('mobile_list_count', $board) ? (int) element('mobile_list_count', $board) : 10; } else { $per_page = element('list_count', $board) ? (int) element('list_count', $board) : 20; } $offset = ($page - 1) * $per_page; $this->Post_model->allow_search_field = array('post_id', 'post_title', 'post_content', 'post_both', 'post_category', 'post_userid', 'post_nickname'); // 검색이 가능한 필드 $this->Post_model->search_field_equal = array('post_id', 'post_userid', 'post_nickname'); // 검색중 like 가 아닌 = 검색을 하는 필드 // 이벤트가 존재하면 실행합니다 $view['view']['event']['step1'] = Events::trigger('step1', $eventname); /** * 상단에 공지사항 부분에 필요한 정보를 가져옵니다. */ $except_all_notice = false; if (element('except_all_notice', $board) && $this->cbconfig->get_device_view_type() !== 'mobile') { $except_all_notice = true; } if (element('mobile_except_all_notice', $board) && $this->cbconfig->get_device_view_type() === 'mobile') { $except_all_notice = true; } $use_sideview = $this->cbconfig->get_device_view_type() === 'mobile' ? element('use_mobile_sideview', $board) : element('use_sideview', $board); $list_date_style = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_list_date_style', $board) : element('list_date_style', $board); $list_date_style_manual = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_list_date_style_manual', $board) : element('list_date_style_manual', $board); if (element('use_gallery_list', $board)) { $this->load->model('Post_file_model'); $board['gallery_cols'] = $gallery_cols = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_cols', $board) : element('gallery_cols', $board); $board['gallery_image_width'] = $gallery_image_width = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_image_width', $board) : element('gallery_image_width', $board); $board['gallery_image_height'] = $gallery_image_height = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_gallery_image_height', $board) : element('gallery_image_height', $board); $board['gallery_percent'] = floor(102 / $board['gallery_cols']) - 2; } if (element('use_category', $board)) { $this->load->model('Board_category_model'); $board['category'] = $this->Board_category_model->get_all_category(element('brd_id', $board)); } $noticeresult = $this->Post_model->get_notice_list(element('brd_id', $board), $except_all_notice, $sfield, $skeyword); if ($noticeresult) { foreach ($noticeresult as $key => $val) { $notice_brd_key = $this->board->item_id('brd_key', element('brd_id', $val)); $noticeresult[$key]['post_url'] = post_url($notice_brd_key, element('post_id', $val)); $noticeresult[$key]['meta'] = $meta = $this->Post_meta_model->get_all_meta(element('post_id', $val)); if ($this->cbconfig->get_device_view_type() === 'mobile') { $noticeresult[$key]['title'] = element('mobile_subject_length', $board) ? cut_str(element('post_title', $val), element('mobile_subject_length', $board)) : element('post_title', $val); } else { $noticeresult[$key]['title'] = element('subject_length', $board) ? cut_str(element('post_title', $val), element('subject_length', $board)) : element('post_title', $val); } if (element('post_del', $val)) { $noticeresult[$key]['title'] = '게시물이 삭제 되었습니다'; } $noticeresult[$key]['display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val), element('mem_icon', $val), $use_sideview ? 'Y' : 'N'); $noticeresult[$key]['display_datetime'] = display_datetime(element('post_datetime', $val), $list_date_style, $list_date_style_manual); $noticeresult[$key]['category'] = ''; if (element('use_category', $board) && element('post_category', $val)) { $noticeresult[$key]['category'] = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val)); } if ($param->output()) { $noticeresult[$key]['post_url'] .= '?' . $param->output(); } $noticeresult[$key]['is_mobile'] = element('post_device', $val) === 'mobile' ? true : false; } } /** * 게시판 목록에 필요한 정보를 가져옵니다. */ $where = array('brd_id' => $this->board->item_key('brd_id', $brd_key)); $where['post_del <>'] = 2; if (element('except_notice', $board) && $this->cbconfig->get_device_view_type() !== 'mobile') { $where['post_notice'] = 0; } if (element('mobile_except_notice', $board) && $this->cbconfig->get_device_view_type() === 'mobile') { $where['post_notice'] = 0; } if (element('use_personal', $board) && $is_admin === false) { $where['post.mem_id'] = $mem_id; } $category_id = (int) $this->input->get('category_id'); if (empty($category_id) or $category < 1) { $category_id = ''; } $result = $this->Post_model->get_post_list($per_page, $offset, $where, $category_id, $findex, $sfield, $skeyword); $list_num = $result['total_rows'] - ($page - 1) * $per_page; if (element('list', $result)) { foreach (element('list', $result) as $key => $val) { $result['list'][$key]['post_url'] = post_url(element('brd_key', $board), element('post_id', $val)); $result['list'][$key]['meta'] = $meta = $this->Post_meta_model->get_all_meta(element('post_id', $val)); if ($this->cbconfig->get_device_view_type() === 'mobile') { $result['list'][$key]['title'] = element('mobile_subject_length', $board) ? cut_str(element('post_title', $val), element('mobile_subject_length', $board)) : element('post_title', $val); } else { $result['list'][$key]['title'] = element('subject_length', $board) ? cut_str(element('post_title', $val), element('subject_length', $board)) : element('post_title', $val); } if (element('post_del', $val)) { $result['list'][$key]['title'] = '게시물이 삭제 되었습니다'; } $is_blind = element('blame_blind_count', $board) > 0 && element('post_blame', $val) >= element('blame_blind_count', $board) ? true : false; if ($is_blind) { $result['list'][$key]['title'] = '신고가 접수된 게시글입니다.'; } $result['list'][$key]['display_name'] = display_username(element('post_userid', $val), element('post_nickname', $val), element('mem_icon', $val), $use_sideview ? 'Y' : 'N'); $result['list'][$key]['display_datetime'] = display_datetime(element('post_datetime', $val), $list_date_style, $list_date_style_manual); $result['list'][$key]['category'] = ''; if (element('use_category', $board) && element('post_category', $val)) { $result['list'][$key]['category'] = $this->Board_category_model->get_category_info(element('brd_id', $val), element('post_category', $val)); } if ($param->output()) { $result['list'][$key]['post_url'] .= '?' . $param->output(); } $result['list'][$key]['num'] = $list_num--; $result['list'][$key]['is_hot'] = false; $hot_icon_day = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_hot_icon_day', $board) : element('hot_icon_day', $board); $hot_icon_hit = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_hot_icon_hit', $board) : element('hot_icon_hit', $board); if ($hot_icon_day && ctimestamp() - strtotime(element('post_datetime', $val)) <= $hot_icon_day * 86400) { if ($hot_icon_hit && $hot_icon_hit <= element('post_hit', $val)) { $result['list'][$key]['is_hot'] = true; } } $result['list'][$key]['is_new'] = false; $new_icon_hour = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_new_icon_hour', $board) : element('new_icon_hour', $board); if ($new_icon_hour && ctimestamp() - strtotime(element('post_datetime', $val)) <= $new_icon_hour * 3600) { $result['list'][$key]['is_new'] = true; } $result['list'][$key]['is_mobile'] = element('post_device', $val) === 'mobile' ? true : false; $result['list'][$key]['thumb_url'] = ''; $result['list'][$key]['origin_image_url'] = ''; if (element('use_gallery_list', $board)) { if (element('post_image', $val)) { $filewhere = array('post_id' => element('post_id', $val), 'pfi_is_image' => 1); $file = $this->Post_file_model->get_one('', '', $filewhere, '', '', 'pfi_id', 'ASC'); $result['list'][$key]['thumb_url'] = thumb_url('post', element('pfi_filename', $file), $gallery_image_width, $gallery_image_height); $result['list'][$key]['origin_image_url'] = thumb_url('post', element('pfi_filename', $file)); } else { $thumb_url = get_post_image_url(element('post_content', $val), $gallery_image_width, $gallery_image_height); $result['list'][$key]['thumb_url'] = $thumb_url ? $thumb_url : thumb_url('', '', $gallery_image_width, $gallery_image_height); $result['list'][$key]['origin_image_url'] = $thumb_url; } } } } $return['data'] = $result; $return['notice_list'] = $noticeresult; if (empty($from_view)) { $board['headercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_header_content', $board) : element('header_content', $board); } $board['footercontent'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_footer_content', $board) : element('footer_content', $board); $board['cat_display_style'] = $this->cbconfig->get_device_view_type() === 'mobile' ? element('mobile_category_display_style', $board) : element('category_display_style', $board); $return['board'] = $board; $return['point_info'] = ''; if ($this->cbconfig->item('use_point') && element('use_point', $board) && element('use_point_info', $board)) { $point_info = ''; if (element('point_write', $board)) { $point_info .= '원글작성 : ' . element('point_write', $board) . '<br />'; } if (element('point_comment', $board)) { $point_info .= '댓글작성 : ' . element('point_comment', $board) . '<br />'; } if (element('point_fileupload', $board)) { $point_info .= '파일업로드 : ' . element('point_fileupload', $board) . '<br />'; } if (element('point_filedownload', $board)) { $point_info .= '파일다운로드 : ' . element('point_filedownload', $board) . '<br />'; } if (element('point_filedownload_uploader', $board)) { $point_info .= '파일다운로드시업로더에게 : ' . element('point_filedownload_uploader', $board) . '<br />'; } if (element('point_read', $board)) { $point_info .= '게시글조회 : ' . element('point_read', $board) . '<br />'; } if (element('point_post_like', $board)) { $point_info .= '원글추천함 : ' . element('point_post_like', $board) . '<br />'; } if (element('point_post_dislike', $board)) { $point_info .= '원글비추천함 : ' . element('point_post_dislike', $board) . '<br />'; } if (element('point_post_liked', $board)) { $point_info .= '원글추천받음 : ' . element('point_post_liked', $board) . '<br />'; } if (element('point_post_disliked', $board)) { $point_info .= '원글비추천받음 : ' . element('point_post_disliked', $board) . '<br />'; } if (element('point_comment_like', $board)) { $point_info .= '댓글추천함 : ' . element('point_comment_like', $board) . '<br />'; } if (element('point_comment_dislike', $board)) { $point_info .= '댓글비추천함 : ' . element('point_comment_dislike', $board) . '<br />'; } if (element('point_comment_liked', $board)) { $point_info .= '댓글추천받음 : ' . element('point_comment_liked', $board) . '<br />'; } if (element('point_comment_disliked', $board)) { $point_info .= '댓글비추천받음 : ' . element('point_comment_disliked', $board) . '<br />'; } $return['point_info'] = $point_info; } // 이벤트가 존재하면 실행합니다 $view['view']['event']['step2'] = Events::trigger('step2', $eventname); /** * primary key 정보를 저장합니다 */ $return['primary_key'] = $this->Post_model->primary_key; $highlight_keyword = ''; if ($skeyword) { if (!$this->session->userdata('skeyword_' . $skeyword)) { $sfieldarray = array('post_title', 'post_content', 'post_both'); if (in_array($sfieldchk, $sfieldarray)) { $this->load->model('Search_keyword_model'); $searchinsert = array('sek_keyword' => $skeyword, 'sek_datetime' => cdate('Y-m-d H:i:s'), 'sek_ip' => $this->input->ip_address(), 'mem_id' => $mem_id); $this->Search_keyword_model->insert($searchinsert); $this->session->set_userdata('skeyword_' . $skeyword, 1); } } $key_explode = explode(' ', $skeyword); if ($key_explode) { foreach ($key_explode as $seval) { if ($highlight_keyword) { $highlight_keyword .= ','; } $highlight_keyword .= '\'' . html_escape($seval) . '\''; } } } $return['highlight_keyword'] = $highlight_keyword; /** * 페이지네이션을 생성합니다 */ $config['base_url'] = board_url($brd_key) . '?' . $param->replace('page'); $config['total_rows'] = $result['total_rows']; $config['per_page'] = $per_page; if ($this->cbconfig->get_device_view_type() === 'mobile') { $config['num_links'] = element('mobile_page_count', $board) ? element('mobile_page_count', $board) : 3; } else { $config['num_links'] = element('page_count', $board) ? element('page_count', $board) : 5; } $this->pagination->initialize($config); $return['paging'] = $this->pagination->create_links(); $return['page'] = $page; /** * 쓰기 주소, 삭제 주소등 필요한 주소를 구합니다 */ $search_option = array('post_title' => '제목', 'post_content' => '내용'); $return['search_option'] = search_option($search_option, $sfield); if ($skeyword) { $return['list_url'] = board_url(element('brd_key', $board)); $return['search_list_url'] = board_url(element('brd_key', $board) . '?' . $param->output()); } else { $return['list_url'] = board_url(element('brd_key', $board) . '?' . $param->output()); $return['search_list_url'] = ''; } $check = array('group_id' => element('bgr_id', $board), 'board_id' => element('brd_id', $board)); $can_write = $this->accesslevel->is_accessable(element('access_write', $board), element('access_write_level', $board), element('access_write_group', $board), $check); $return['write_url'] = ''; if ($can_write === true) { $return['write_url'] = write_url($brd_key); } elseif ($this->cbconfig->get_device_view_type() !== 'mobile' && element('always_show_write_button', $board)) { $return['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');'; } elseif ($this->cbconfig->get_device_view_type() === 'mobile' && element('mobile_always_show_write_button', $board)) { $return['write_url'] = 'javascript:alert(\'비회원은 글쓰기 권한이 없습니다.\\n\\n회원이시라면 로그인 후 이용해 보십시오.\');'; } $return['list_delete_url'] = site_url('postact/listdelete/' . $brd_key . '?' . $param->output()); return $return; }