Esempio n. 1
0
 /**
  * Takes a Feed object from a completed search and saves it
  *
  * @param Feed $feed
  */
 public function __construct(Feed $feed)
 {
     $this->upload_dir = wp_upload_dir();
     $this->feed = $feed;
     $this->mls = $feed->mls;
     self::posts($feed->get());
 }
Esempio n. 2
0
function feed_controller()
{
    global $mysqli, $redis, $session, $route, $feed_settings;
    $result = false;
    require_once "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/feed/Views/feedlist_view.php", array());
        } else {
            if ($route->action == "api" && $session['write']) {
                $result = view("Modules/feed/Views/feedapi_view.php", array());
            }
        }
    } else {
        if ($route->format == 'json') {
            // Public actions available on public feeds.
            if ($route->action == "list") {
                if ($session['read']) {
                    if (!isset($_GET['userid']) || isset($_GET['userid']) && $_GET['userid'] == $session['userid']) {
                        $result = $feed->get_user_feeds($session['userid']);
                    } else {
                        if (isset($_GET['userid']) && $_GET['userid'] != $session['userid']) {
                            $result = $feed->get_user_public_feeds(get('userid'));
                        }
                    }
                } else {
                    if (isset($_GET['userid'])) {
                        $result = $feed->get_user_public_feeds(get('userid'));
                    }
                }
            } elseif ($route->action == "create" && $session['write']) {
                $result = $feed->create($session['userid'], get('tag'), get('name'), get('datatype'), get('engine'), json_decode(get('options')));
            } elseif ($route->action == "updatesize" && $session['write']) {
                $result = $feed->update_user_feeds_size($session['userid']);
            } elseif ($route->action == "buffersize" && $session['write']) {
                $result = $feed->get_buffer_size();
                // To "fetch" multiple feed values in a single request
                // http://emoncms.org/feed/fetch.json?ids=123,567,890
            } elseif ($route->action == "fetch" && $session['read']) {
                $feedids = (array) explode(",", get('ids'));
                for ($i = 0; $i < count($feedids); $i++) {
                    $feedid = (int) $feedids[$i];
                    if ($feed->exist($feedid)) {
                        // if the feed exists
                        $result[$i] = $feed->get_value($feedid);
                        // null is a valid response
                    } else {
                        $result[$i] = false;
                    }
                    // false means feed not found
                }
            } else {
                $feedid = (int) get('id');
                // Actions that operate on a single existing feed that all use the feedid to select:
                // First we load the meta data for the feed that we want
                if ($feed->exist($feedid)) {
                    $f = $feed->get($feedid);
                    // if public or belongs to user
                    if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
                        if ($route->action == "timevalue") {
                            $result = $feed->get_timevalue($feedid);
                        } else {
                            if ($route->action == 'data') {
                                $skipmissing = 1;
                                $limitinterval = 1;
                                if (isset($_GET['skipmissing']) && $_GET['skipmissing'] == 0) {
                                    $skipmissing = 0;
                                }
                                if (isset($_GET['limitinterval']) && $_GET['limitinterval'] == 0) {
                                    $limitinterval = 0;
                                }
                                $result = $feed->get_data($feedid, get('start'), get('end'), get('interval'), $skipmissing, $limitinterval);
                            } else {
                                if ($route->action == "value") {
                                    $result = $feed->get_value($feedid);
                                } else {
                                    if ($route->action == "get") {
                                        $result = $feed->get_field($feedid, get('field'));
                                    } else {
                                        if ($route->action == "aget") {
                                            $result = $feed->get($feedid);
                                        } else {
                                            if ($route->action == 'histogram') {
                                                $result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
                                            } else {
                                                if ($route->action == 'kwhatpower') {
                                                    $result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
                                                } else {
                                                    if ($route->action == 'kwhatpowers') {
                                                        $result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // write session required
                    if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $f['userid'] == $session['userid']) {
                        // Storage engine agnostic
                        if ($route->action == 'set') {
                            $result = $feed->set_feed_fields($feedid, get('fields'));
                        } else {
                            if ($route->action == "insert") {
                                $result = $feed->insert_data($feedid, time(), get("time"), get("value"));
                            } else {
                                if ($route->action == "update") {
                                    $result = $feed->update_data($feedid, time(), get("time"), get('value'));
                                } else {
                                    if ($route->action == "delete") {
                                        $result = $feed->delete($feedid);
                                    } else {
                                        if ($route->action == "getmeta") {
                                            $result = $feed->get_meta($feedid);
                                        } else {
                                            if ($route->action == "csvexport") {
                                                $result = $feed->csv_export($feedid, get('start'), get('end'), get('interval'), get('timeformat'));
                                            } else {
                                                if ($route->action == "process") {
                                                    if ($f['engine'] != Engine::VIRTUALFEED) {
                                                        $result = array('success' => false, 'message' => 'Feed is not Virtual');
                                                    } else {
                                                        if ($route->subaction == "get") {
                                                            $result = $feed->get_processlist($feedid);
                                                        } else {
                                                            if ($route->subaction == "set") {
                                                                $result = $feed->set_processlist($feedid, post('processlist'));
                                                            } else {
                                                                if ($route->subaction == "reset") {
                                                                    $result = $feed->reset_processlist($feedid);
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if ($f['engine'] == Engine::MYSQL || $f['engine'] == Engine::MYSQLMEMORY) {
                            if ($route->action == "export") {
                                $result = $feed->mysqltimeseries_export($feedid, get('start'));
                            } else {
                                if ($route->action == "deletedatapoint") {
                                    $result = $feed->mysqltimeseries_delete_data_point($feedid, get('feedtime'));
                                } else {
                                    if ($route->action == "deletedatarange") {
                                        $result = $feed->mysqltimeseries_delete_data_range($feedid, get('start'), get('end'));
                                    }
                                }
                            }
                        } elseif ($f['engine'] == Engine::PHPTIMESERIES) {
                            if ($route->action == "export") {
                                $result = $feed->phptimeseries_export($feedid, get('start'));
                            }
                        } elseif ($f['engine'] == Engine::PHPFIWA) {
                            if ($route->action == "export") {
                                $result = $feed->phpfiwa_export($feedid, get('start'), get('layer'));
                            }
                        } elseif ($f['engine'] == Engine::PHPFINA) {
                            if ($route->action == "export") {
                                $result = $feed->phpfina_export($feedid, get('start'));
                            }
                        }
                    }
                } else {
                    $result = array('success' => false, 'message' => 'Feed does not exist');
                }
            }
        }
    }
    return array('content' => $result);
}
Esempio n. 3
0
function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $feed_settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    require "Modules/vis/vis_object.php";
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/Views/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        } else {
            if ($route->action == "auto") {
                $feedid = intval(get('feedid'));
                $datatype = $feed->get_field($feedid, 'datatype');
                if ($datatype == 0) {
                    $result = "Feed type or authentication not valid";
                }
                if ($datatype == 1) {
                    $route->action = 'graph';
                }
                if ($datatype == 2) {
                    $route->action = 'bargraph';
                }
                if ($datatype == 3) {
                    $route->action = 'histgraph';
                }
            }
        }
        while ($vis = current($visualisations)) {
            $viskey = key($visualisations);
            // If the visualisation has a set property called action
            // then override the visualisation key and use the set action instead
            if (isset($vis['action'])) {
                $viskey = $vis['action'];
            }
            if ($route->action == $viskey) {
                $array = array();
                $array['valid'] = true;
                if (isset($vis['options'])) {
                    foreach ($vis['options'] as $option) {
                        $key = $option[0];
                        $type = $option[2];
                        if (isset($option[3])) {
                            $default = $option[3];
                        } else {
                            $default = "";
                        }
                        if ($type == 0 || $type == 1 || $type == 2 || $type == 3) {
                            $feedid = (int) get($key);
                            if ($feedid) {
                                $f = $feed->get($feedid);
                                $array[$key] = $feedid;
                                $array[$key . 'name'] = $f['name'];
                                if ($f['userid'] != $session['userid']) {
                                    $array['valid'] = false;
                                }
                                if ($f['public']) {
                                    $array['valid'] = true;
                                }
                            } else {
                                $array['valid'] = false;
                            }
                        } else {
                            if ($type == 4) {
                                // Boolean not used at the moment
                                if (get($key) == true || get($key) == false) {
                                    $array[$key] = get($key);
                                } else {
                                    $array[$key] = $default;
                                }
                            } else {
                                if ($type == 5) {
                                    $array[$key] = preg_replace('/[^\\p{L}_\\p{N}\\s£$€¥]/u', '', get($key)) ? get($key) : $default;
                                } else {
                                    if ($type == 6) {
                                        $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                                    } else {
                                        if ($type == 7) {
                                            $array[$key] = intval(get($key) ? get($key) : $default);
                                        } else {
                                            if ($type == 8) {
                                                $mid = (int) get($key);
                                                if ($mid) {
                                                    $f = $multigraph->get($mid, $session['userid']);
                                                    $array[$key] = intval($mid ? $mid : $default);
                                                    if (!isset($f['feedlist'])) {
                                                        $array['valid'] = false;
                                                    }
                                                } else {
                                                    $array['valid'] = false;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        # we need to either urlescape the colour, or just scrub out invalid chars. I'm doing the second, since
                        # we can be fairly confident that colours are eiter a hex or a simple word (e.g. "blue" or such)
                        if ($key == "colour") {
                            $array[$key] = preg_replace('/[^\\dA-Za-z]/', '', $array[$key]);
                        }
                    }
                }
                $array['apikey'] = $read_apikey;
                $array['write_apikey'] = $write_apikey;
                if ($array['valid'] == false) {
                    $result .= "<div style='position:absolute; top:0px; left:0px; width:100%; height:100%; display: table;'><div class='alert-error' style='text-align:center; display:table-cell; vertical-align:middle;'><h4>" . _('Not configured') . "<br>" . _('or') . "<br>" . _('Authentication not valid') . "</h4></div></div>";
                } else {
                    $result .= view("Modules/" . $visdir . $viskey . ".php", $array);
                }
            }
            next($visualisations);
        }
    } else {
        if ($route->format == 'json' && $route->action == 'multigraph') {
            if ($route->subaction == 'get') {
                $result = $multigraph->get(get('id'), $session['userid']);
            } else {
                if ($route->subaction == 'getlist') {
                    $result = $multigraph->getlist($session['userid']);
                } else {
                    if ($session['write']) {
                        if ($route->subaction == 'new') {
                            $result = $multigraph->create($session['userid']);
                        } else {
                            if ($route->subaction == 'delete') {
                                $result = $multigraph->delete(get('id'), $session['userid']);
                            } else {
                                if ($route->subaction == 'set') {
                                    $result = $multigraph->set(get('id'), $session['userid'], get('feedlist'), get('name'));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return array('content' => $result);
}
Esempio n. 4
0
<?php
	define('ROOT', '..');
	include ROOT . '/lib/include.php';
	
	$searchFeedId = $accessInfo['action'];
	$searchType = 'blogURL';
	if(is_numeric($searchFeedId)) {
		$searchKeyword = 'http://'.str_replace('http://', '', Feed::get($searchFeedId, 'blogURL'));	
		$searchExtraValue = $searchFeedId;
	} else {
		$searchKeyword = 'http://'.str_replace('http://', '', $accessInfo['address']);
		$searchExtraValue = Feed::blogURL2Id('http://'.str_replace('http://', '', $searchKeyword));
	}

	include ROOT . '/lib/begin.php';

	$pageCount = $skinConfig->postList; // ÆäÀÌÁö°¹¼ö
	list($posts, $totalFeedItems) = FeedItem::getFeedItems($searchType, $searchKeyword, $searchExtraValue, $page, $pageCount);
	$paging = Func::makePaging($page, $pageCount, $totalFeedItems);

	include ROOT . '/lib/piece/message.php';
	include ROOT . '/lib/piece/postlist.php';
	include ROOT . '/lib/end.php';
?>
Esempio n. 5
0
		
		$skin->replace('tags', $event->on('Text.linker.tags',UTF8::clear($linker_post['tags'])));

		$skin->replace('date', $event->on('Text.linker.date',(Validator::is_digit($linker_post['written']) ? date('Y-m-d h:i a', $linker_post['written']) : $linker_post['written'])));
		$skin->replace('view', $linker_post['click']);


		$linker_post['description'] = func::stripHTML($linker_post['description'].'>');
		if (substr($linker_post['description'], -1) == '>') $linker_post['description'] = substr($linker_post['description'], 0, strlen($linker_post['description']) - 1);
		$description = $linker_post['description'];
		if (strlen(trim($description)) == 0) $description = _t('(글의 앞부분이 이미지 혹은 HTML 태그만으로 되어있습니다)');

		$skin->replace('description_slashed', addslashes($post_description));
		$skin->replace('description', $event->on('Text.linker.description', $post_description));
		$skin->replace('blogname', UTF8::clear(Feed::get($linker_post['feed'], 'title')));
		$skin->replace('blogurl', htmlspecialchars(Feed::get($linker_post['feed'], 'blogURL')));
	
		$skin->replace('boom_rank', Boom::getRank($linker_post['id']));				
		$skin->replace('boom_rank_id', 'boomRank'.$linker_post['id']);
		$skin->replace('boomup_count', $linker_post['boomUp']);		
		$skin->replace('boomdown_count', $linker_post['boomDown']);		

		$skin->replace('boomup_onclick', 'javascript: boom(\''.$linker_post['id'].'\',\'up\');');
		$skin->replace('boomdown_onclick', 'javascript: boom(\''.$linker_post['id'].'\',\'down\');');

		$skin->replace('boomup_id', 'boomUp'.$linker_post['id']);
		$skin->replace('boomdown_id', 'boomDown'.$linker_post['id']);

		$boomedUp = Boom::isBoomedUp($linker_post['id']);
		$boomedDown = Boom::isBoomedDown($linker_post['id']);
Esempio n. 6
0
function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $feed_settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    require "Modules/vis/vis_object.php";
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        } else {
            // and is used primarily for quick checking feeds from the feeds page.
            if ($route->action == "auto") {
                $feedid = (int) get('feedid');
                $route->action = 'graph';
            }
            while ($vis = current($visualisations)) {
                $viskey = key($visualisations);
                // If the visualisation has a set property called action
                // then override the visualisation key and use the set action instead
                if (isset($vis['action'])) {
                    $viskey = $vis['action'];
                }
                if ($route->action == $viskey) {
                    $array = array();
                    $array['valid'] = true;
                    if (isset($vis['options'])) {
                        foreach ($vis['options'] as $option) {
                            $key = $option[0];
                            $type = $option[1];
                            if (isset($option[2])) {
                                $default = $option[2];
                            } else {
                                $default = "";
                            }
                            if ($type == 0 || $type == 1 || $type == 2 || $type == 3) {
                                $feedid = (int) get($key);
                                if ($feedid) {
                                    $f = $feed->get($feedid);
                                    $array[$key] = $feedid;
                                    $array[$key . 'name'] = $f['name'];
                                    if ($f['userid'] != $session['userid']) {
                                        $array['valid'] = false;
                                        $array['error'] = "You dont have the required permission to view this feed";
                                    }
                                    if ($f['public']) {
                                        $array['valid'] = true;
                                    }
                                } else {
                                    $array['valid'] = false;
                                    $array['error'] = "Please select a feed";
                                }
                            }
                            // Boolean not used at the moment
                            if ($type == 4) {
                                if (get($key) == true || get($key) == false) {
                                    $array[$key] = get($key);
                                } else {
                                    $array[$key] = $default;
                                }
                            }
                            if ($type == 5) {
                                $array[$key] = preg_replace('/[^\\w\\s£$€¥]/', '', get($key)) ? get($key) : $default;
                            }
                            if ($type == 6) {
                                $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                            }
                            if ($type == 7) {
                                $array[$key] = intval(get($key) ? get($key) : $default);
                            }
                            # we need to either urlescape the colour, or just scrub out invalid chars. I'm doing the second, since
                            # we can be fairly confident that colours are eiter a hex or a simple word (e.g. "blue" or such)
                            if ($key == "colour") {
                                $array[$key] = preg_replace('/[^\\dA-Za-z]/', '', $array[$key]);
                            }
                        }
                    }
                    $array['apikey'] = $read_apikey;
                    $array['write_apikey'] = $write_apikey;
                    $result = view("Modules/" . $visdir . $viskey . ".php", $array);
                    if ($array['valid'] == false) {
                        $result .= "<div style='position:absolute; top:0px; left:0px; background-color:rgba(240,240,240,0.5); width:100%; height:100%; text-align:center; padding-top:100px;'><h3>" . $array['error'] . "</h3></div>";
                    }
                }
                next($visualisations);
            }
        }
    }
    /*
    MULTIGRAPH ACTIONS
    */
    if ($route->format == 'json' && $route->action == 'multigraph') {
        if ($route->subaction == 'new' && $session['write']) {
            $result = $multigraph->create($session['userid']);
        }
        if ($route->subaction == 'delete' && $session['write']) {
            $result = $multigraph->delete(get('id'), $session['userid']);
        }
        if ($route->subaction == 'set' && $session['write']) {
            $result = $multigraph->set(get('id'), $session['userid'], get('feedlist'), get('name'));
        }
        if ($route->subaction == 'get') {
            $result = $multigraph->get(get('id'), $session['userid']);
        }
        if ($route->subaction == 'getlist') {
            $result = $multigraph->getlist($session['userid']);
        }
        if ($route->subaction == 'getname') {
            $result = $multigraph->getname(get('id'), $session['userid']);
        }
    }
    return array('content' => $result);
}
Esempio n. 7
0
			$sp_post = $skin->parseTag('post_title', UTF8::clear($event->on('Text.postTitle', func::stripHTML($post['title']))), $sp_post);
			$sp_post = $skin->parseTag('post_author', UTF8::clear($event->on('Text.postAuthor',$post['author'])), $sp_post);

			list($post_category) = explode(',', UTF8::clear($post['tags']), 2);
			$sp_post = $skin->parseTag('post_category', $post_category, $sp_post);
			$sp_post = $skin->parseTag('post_date', $event->on('Text.postDate',(Validator::is_digit($post['written']) ? date('Y-m-d h:i a', $post['written']) : $post['written'])), $sp_post);
			$sp_post = $skin->parseTag('post_view', $post['click'], $sp_post);

			$post_description = $event->on('Text.postDescription', $post['description']);
			$post_description = str_replace('/cache/images/',$service['path'] . '/cache/images/', $post_description);

			$sp_post = $skin->parseTag('post_description', $post_description, $sp_post);
			$sp_post = $skin->parseTag('post_blogname', UTF8::clear(Feed::get($post['feed'], 'title')), $sp_post);
			$sp_post = $skin->parseTag('post_blogurl', htmlspecialchars(Feed::get($post['feed'], 'blogURL')), $sp_post);
			$sp_post = $skin->parseTag('post_bloglink', $service['path'].'/blog/'.Feed::get($post['feed'], 'id') , $sp_post);
			
			$sp_post = $skin->parseTag('boom_rank', Boom::getRank($post['id']), $sp_post);	
			$sp_post = $skin->parseTag('boom_rank_id', 'boomRank'.$post['id'], $sp_post);
			$sp_post = $skin->parseTag('boom_rank_class', 'boom_rank_'.Boom::getRank($post['id']), $sp_post);
			$sp_post = $skin->parseTag('boomup_count', $post['boomUp'], $sp_post);		
			$sp_post = $skin->parseTag('boomdown_count', $post['boomDown'], $sp_post);

			$sp_post = $skin->parseTag('boom_count_id', 'boomCount'.$post['id'], $sp_post);
			$sp_post = $skin->parseTag('boom_count', $post['boomUp'] - $post['boomDown'], $sp_post);
			$sp_post = $skin->parseTag('boom_count_class', 'boomCount boomCount'.($post['boomUp'] - $post['boomDown']), $sp_post);

			$sp_post = $skin->parseTag('boomup_onclick', 'boom(\''.$post['id'].'\',\'up\');', $sp_post);
			$sp_post = $skin->parseTag('boomdown_onclick', 'boom(\''.$post['id'].'\',\'down\');', $sp_post);

			$sp_post = $skin->parseTag('boomup_id', 'boomUp'.$post['id'], $sp_post);
Esempio n. 8
0
function feed_controller()
{
    global $mysqli, $redis, $session, $route, $feed_settings;
    $result = false;
    include "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $feed_settings);
    if ($route->format == 'html') {
        if ($route->action == "list" && $session['write']) {
            $result = view("Modules/feed/Views/feedlist_view.php", array());
        }
        if ($route->action == "api" && $session['write']) {
            $result = view("Modules/feed/Views/feedapi_view.php", array());
        }
    }
    if ($route->format == 'json') {
        // Public actions available on public feeds.
        if ($route->action == "list") {
            if (!isset($_GET['userid']) && $session['read']) {
                $result = $feed->get_user_feeds($session['userid']);
            }
            if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] == $session['userid']) {
                $result = $feed->get_user_feeds($session['userid']);
            }
            if (isset($_GET['userid']) && $session['read'] && $_GET['userid'] != $session['userid']) {
                $result = $feed->get_user_public_feeds(get('userid'));
            }
            if (isset($_GET['userid']) && !$session['read']) {
                $result = $feed->get_user_public_feeds(get('userid'));
            }
        } elseif ($route->action == "getid" && $session['read']) {
            $result = $feed->get_id($session['userid'], get('name'));
        } elseif ($route->action == "create" && $session['write']) {
            $result = $feed->create($session['userid'], get('name'), get('datatype'), get('engine'), json_decode(get('options')));
        } elseif ($route->action == "updatesize" && $session['write']) {
            $result = $feed->update_user_feeds_size($session['userid']);
            // To "fetch" multiple feed values in a single request
            // http://emoncms.org/feed/fetch.json?ids=123,567,890
        } elseif ($route->action == "fetch" && $session['read']) {
            $feedids = (array) explode(",", get('ids'));
            for ($i = 0; $i < count($feedids); $i++) {
                $feedid = (int) $feedids[$i];
                if ($feed->exist($feedid)) {
                    $result[$i] = (double) $feed->get_value($feedid);
                } else {
                    $result[$i] = "";
                }
            }
        } else {
            $feedid = (int) get('id');
            // Actions that operate on a single existing feed that all use the feedid to select:
            // First we load the meta data for the feed that we want
            if ($feed->exist($feedid)) {
                $f = $feed->get($feedid);
                // if public or belongs to user
                if ($f['public'] || $session['userid'] > 0 && $f['userid'] == $session['userid'] && $session['read']) {
                    if ($route->action == "value") {
                        $result = $feed->get_value($feedid);
                    }
                    if ($route->action == "timevalue") {
                        $result = $feed->get_timevalue_seconds($feedid);
                    }
                    if ($route->action == "get") {
                        $result = $feed->get_field($feedid, get('field'));
                    }
                    // '/[^\w\s-]/'
                    if ($route->action == "aget") {
                        $result = $feed->get($feedid);
                    }
                    if ($route->action == 'histogram') {
                        $result = $feed->histogram_get_power_vs_kwh($feedid, get('start'), get('end'));
                    }
                    if ($route->action == 'kwhatpower') {
                        $result = $feed->histogram_get_kwhd_atpower($feedid, get('min'), get('max'));
                    }
                    if ($route->action == 'kwhatpowers') {
                        $result = $feed->histogram_get_kwhd_atpowers($feedid, get('points'));
                    }
                    if ($route->action == 'data') {
                        $result = $feed->get_data($feedid, get('start'), get('end'), get('dp'));
                    }
                    if ($route->action == 'average') {
                        $result = $feed->get_average($feedid, get('start'), get('end'), get('interval'));
                    }
                    if ($route->action == 'history') {
                        $result = $feed->get_history($feedid, get('start'), get('end'), get('interval'));
                    }
                }
                // write session required
                if (isset($session['write']) && $session['write'] && $session['userid'] > 0 && $f['userid'] == $session['userid']) {
                    // Storage engine agnostic
                    if ($route->action == 'set') {
                        $result = $feed->set_feed_fields($feedid, get('fields'));
                    }
                    if ($route->action == "insert") {
                        $result = $feed->insert_data($feedid, time(), get("time"), get("value"));
                    }
                    if ($route->action == "update") {
                        $result = $feed->update_data($feedid, time(), get("time"), get('value'));
                    }
                    if ($route->action == "delete") {
                        $result = $feed->delete($feedid);
                    }
                    if ($route->action == "getmeta") {
                        $result = $feed->get_meta($feedid);
                    }
                    if ($route->action == "csvexport") {
                        $feed->csv_export($feedid, get('start'), get('end'), get('interval'));
                    }
                    if ($f['engine'] == Engine::TIMESTORE) {
                        if ($route->action == "export") {
                            $result = $feed->timestore_export($feedid, get('start'), get('layer'));
                        }
                        if ($route->action == "exportmeta") {
                            $result = $feed->timestore_export_meta($feedid);
                        }
                        if ($route->action == "scalerange") {
                            $result = $feed->timestore_scale_range($feedid, get('start'), get('end'), get('value'));
                        }
                    } elseif ($f['engine'] == Engine::MYSQL) {
                        if ($route->action == "export") {
                            $result = $feed->mysqltimeseries_export($feedid, get('start'));
                        }
                        if ($route->action == "deletedatapoint") {
                            $result = $feed->mysqltimeseries_delete_data_point($feedid, get('feedtime'));
                        }
                        if ($route->action == "deletedatarange") {
                            $result = $feed->mysqltimeseries_delete_data_range($feedid, get('start'), get('end'));
                        }
                    } elseif ($f['engine'] == Engine::PHPTIMESERIES) {
                        if ($route->action == "export") {
                            $result = $feed->phptimeseries_export($feedid, get('start'));
                        }
                    } elseif ($f['engine'] == Engine::PHPFIWA) {
                        if ($route->action == "export") {
                            $result = $feed->phpfiwa_export($feedid, get('start'), get('layer'));
                        }
                    } elseif ($f['engine'] == Engine::PHPFINA) {
                        if ($route->action == "export") {
                            $result = $feed->phpfina_export($feedid, get('start'));
                        }
                    }
                }
            } else {
                $result = array('success' => false, 'message' => 'Feed does not exist');
            }
        }
    }
    return array('content' => $result);
}
Esempio n. 9
0
		function getPredictionPage($id, $pageCount, $searchQuery='', $feedListPageOrder = 'created') {
			global $db, $database;

			$page = 1;

			$created = Feed::get($id,'created');
			if(!empty($created)) {	
				$searchQuery = 'created > ' . $created . (!empty($searchQuery)?' AND '.$searchQuery:'');
			}			

			if(!isAdmin()) {
				$sQuery = 'WHERE visibility = "y"';
			} else {
				$sQuery = 'WHERE 1=1';
			}

			if(!empty($searchQuery)) {
				$sQuery .= ' AND ' . $searchQuery;
			}

			$count = $db->queryCell('SELECT count(*) as count FROM '.$database['prefix'].'Feeds '.$sQuery.' ORDER BY '.$feedListPageOrder.' DESC');
			if($count > 0) {
				$page = ceil(($count + 1) / $pageCount);
			}
			
			return $page;
		}
Esempio n. 10
0
function vis_controller()
{
    global $mysqli, $redis, $session, $route, $user, $settings;
    $result = false;
    require "Modules/feed/feed_model.php";
    $feed = new Feed($mysqli, $redis, $settings);
    require "Modules/vis/multigraph_model.php";
    $multigraph = new Multigraph($mysqli);
    $visdir = "vis/visualisations/";
    /*
      1 - realtime
      2 - daily
      3 - histogram
      4 - boolean (not used uncomment line 122)
      5 - text
      6 - float value
      7 - int value
    */
    $visualisations = array('realtime' => array('options' => array(array('feedid', 1))), 'rawdata' => array('options' => array(array('feedid', 1), array('fill', 7, 0), array('units', 5, 'W'), array('colour', 5, 'EDC240'))), 'bargraph' => array('options' => array(array('feedid', 2), array('colour', 5, 'EDC240'))), 'timestoredaily' => array('options' => array(array('feedid', 1), array('units', 5, 'kWh'))), 'smoothie' => array('options' => array(array('feedid', 1), array('ufac', 6))), 'histgraph' => array('options' => array(array('feedid', 3), array('barwidth', 7, 50), array('start', 7, 0), array('end', 7, 0))), 'zoom' => array('options' => array(array('power', 1), array('kwhd', 2), array('currency', 5, '&pound;'), array('currency_after_val', 7, 0), array('pricekwh', 6, 0.14))), 'stacked' => array('options' => array(array('bottom', 2), array('top', 2))), 'stackedsolar' => array('options' => array(array('solar', 2), array('consumption', 2))), 'threshold' => array('options' => array(array('feedid', 3), array('thresholdA', 6, 500), array('thresholdB', 6, 2500))), 'simplezoom' => array('options' => array(array('power', 1), array('kwhd', 2))), 'orderbars' => array('options' => array(array('feedid', 2))), 'orderthreshold' => array('options' => array(array('feedid', 3), array('power', 1), array('thresholdA', 6, 500), array('thresholdB', 6, 2500))), 'editrealtime' => array('options' => array(array('feedid', 1))), 'editdaily' => array('options' => array(array('feedid', 2))), 'multigraph' => array('action' => 'multigraph', 'options' => array(array('mid', 7))), 'compare' => array('action' => 'compare', 'options' => array(array('powerx', 1), array('powery', 1))));
    $write_apikey = "";
    $read_apikey = "";
    if ($session['read']) {
        $read_apikey = $user->get_apikey_read($session['userid']);
    }
    if ($session['write']) {
        $write_apikey = $user->get_apikey_write($session['userid']);
    }
    if ($route->format == 'html') {
        if ($route->action == 'list' && $session['write']) {
            $multigraphs = $multigraph->getlist($session['userid']);
            $feedlist = $feed->get_user_feeds($session['userid']);
            $result = view("Modules/vis/vis_main_view.php", array('user' => $user->get($session['userid']), 'feedlist' => $feedlist, 'apikey' => $read_apikey, 'visualisations' => $visualisations, 'multigraphs' => $multigraphs));
        }
        // Auto - automatically selects visualisation based on datatype
        // and is used primarily for quick checking feeds from the feeds page.
        if ($route->action == "auto") {
            $feedid = intval(get('feedid'));
            $datatype = $feed->get_field($feedid, 'datatype');
            if ($datatype == 0) {
                $result = "Feed type or authentication not valid";
            }
            if ($datatype == 1) {
                $route->action = 'rawdata';
            }
            if ($datatype == 2) {
                $route->action = 'bargraph';
            }
            if ($datatype == 3) {
                $route->action = 'histgraph';
            }
        }
        while ($vis = current($visualisations)) {
            $viskey = key($visualisations);
            // If the visualisation has a set property called action
            // then override the visualisation key and use the set action instead
            if (isset($vis['action'])) {
                $viskey = $vis['action'];
            }
            if ($route->action == $viskey) {
                $array = array();
                $array['valid'] = true;
                if (isset($vis['options'])) {
                    foreach ($vis['options'] as $option) {
                        $key = $option[0];
                        $type = $option[1];
                        if (isset($option[2])) {
                            $default = $option[2];
                        } else {
                            $default = "";
                        }
                        if ($type == 1 || $type == 2 || $type == 3) {
                            $feedid = (int) get($key);
                            if ($feedid) {
                                $f = $feed->get($feedid);
                                $array[$key] = $feedid;
                                $array[$key . 'name'] = $f['name'];
                                if ($f['userid'] != $session['userid'] || $f['datatype'] != $type) {
                                    $array['valid'] = false;
                                }
                                if ($f['public'] && $f['datatype'] == $type) {
                                    $array['valid'] = true;
                                }
                            } else {
                                $array['valid'] = false;
                            }
                        }
                        // Boolean not used at the moment
                        if ($type == 4) {
                            if (get($key) == true || get($key) == false) {
                                $array[$key] = get($key);
                            } else {
                                $array[$key] = $default;
                            }
                        }
                        if ($type == 5) {
                            $array[$key] = preg_replace('/[^\\w\\s£$€¥]/', '', get($key)) ? get($key) : $default;
                        }
                        if ($type == 6) {
                            $array[$key] = str_replace(',', '.', floatval(get($key) ? get($key) : $default));
                        }
                        if ($type == 7) {
                            $array[$key] = intval(get($key) ? get($key) : $default);
                        }
                        # we need to either urlescape the colour, or just scrub out invalid chars. I'm doing the second, since
                        # we can be fairly confident that colours are eiter a hex or a simple word (e.g. "blue" or such)
                        if ($key == "colour") {
                            $array[$key] = preg_replace('/[^\\dA-Za-z]/', '', $array[$key]);
                        }
                    }
                }
                $array['apikey'] = $read_apikey;
                $array['write_apikey'] = $write_apikey;
                $result = view("Modules/" . $visdir . $viskey . ".php", $array);
                if ($array['valid'] == false) {
                    $result .= "<div style='position:absolute; top:0px; left:0px; background-color:rgba(240,240,240,0.5); width:100%; height:100%; text-align:center; padding-top:100px;'><h3>Feed type or authentication not valid</h3></div>";
                }
            }
            next($visualisations);
        }
    }
    /*
    MULTIGRAPH ACTIONS
    */
    if ($route->format == 'json' && $route->action == 'multigraph') {
        if ($route->subaction == 'new' && $session['write']) {
            $result = $multigraph->create($session['userid']);
        }
        if ($route->subaction == 'delete' && $session['write']) {
            $result = $multigraph->delete(get('id'), $session['userid']);
        }
        if ($route->subaction == 'set' && $session['write']) {
            $result = $multigraph->set(get('id'), $session['userid'], get('feedlist'));
        }
        if ($route->subaction == 'get') {
            $result = $multigraph->get(get('id'), $session['userid']);
        }
        if ($route->subaction == 'getlist') {
            $result = $multigraph->getlist($session['userid']);
        }
    }
    return array('content' => $result);
}
Esempio n. 11
0
	function getNoticePage($input, $config) {
		global $database, $db, $event, $service;
		if(!isAdmin()) {
?>
<?php
			return $input;
		} 

		$blogId = isset($config['blog'])?$config['blog']:0;
		$tag = isset($config['tag'])?$config['tag']:'';
		$pluginURL = $event->pluginURL;
		
		$params = '';

		if(!empty($blogId)) {
			
			$pageCount = 15; // 페이지갯수
			$page = isset($_GET['page']) ? $_GET['page'] : 1;
			if(!isset($page) || empty($page)) $page = 1;

			list($posts, $totalFeedItems) = getNoticeFeedItems($blogId,$page,$pageCount);							
			$paging = Func::makePaging($page, $pageCount, $totalFeedItems);
			
			ob_start();

?>
		<link rel="stylesheet" href="<?php echo $pluginURL;?>/style.css" type="text/css" />

		<script type="text/javascript">
			var is_checked = false;
			function toggleCheckAll(className) {
				is_checked = !is_checked;
				$("."+className).each( function() {
						this.checked = is_checked;
				});
			}

			function deleteItem(id) {
				if(confirm("<?php echo _t('이 글을 삭제하시겠습니까?');?>")) {
					$.ajax({
					  type: "POST",
					  url: '<?php echo $pluginURL;?>/delete.php',
					  data: 'id=' + id,
					  dataType: 'xml',
					  success: function(msg){		
						error = $("response error", msg).text();
						if(error == "0") {
							document.location.reload();
						} else {
							alert($("response message", msg).text());
						}
					  },
					  error: function(msg) {
						 alert('unknown error');
					  }
					});
				}
			}

			function deleteAllItem(className) {
				var ids = '';
				$("."+className).each( function() {
						if(this.checked) {
							ids += $(this).val() + ',';
						}
				});

				if(ids == '') {
					return false;
				}		
				
				if(confirm("<?php echo _t('선택된 모든 글을 삭제하시겠습니까?');?>")) {
					$.ajax({
					  type: "POST",
					  url:  '<?php echo $pluginURL;?>/delete.php',
					  data: 'id=' + ids,
					  dataType: 'xml',
					  success: function(msg){		
						error = $("response error", msg).text();
						if(error == "0") {
							document.location.reload();
						} else {
							alert($("response message", msg).text());
						}
					  },
					  error: function(msg) {
						 alert('unknown error');
					  }
					});
				}
			}
		</script>

		<div class="title_wrap">
			<h3><?php echo _t('공지사항');?> <span class="cnt">(<?php echo $totalFeedItems;?>)</span></h3>
		</div>
		
		<div class="notice_wrap">
<?php
	$headers = array(array('title'=>_t('선택'),'class'=>'entrylist_select','width'=>'50px'),
					array('title'=>_t('날짜'),'class'=>'entrylist_date','width'=>'100px'),
					array('title'=>_t('제목'),'class'=>'entrylist_title','width'=>'790px'),
					array('title'=>_t('실행'),'class'=>'entrylist_execute','width'=>'auto'));
	
	$datas = array();

	if(count($posts)>0) {
		foreach($posts as $post) {		
			$data = array();

			$date = Func::dateToString($post['written']);
			$feedvisibility = Feed::get($post['feed'], 'visibility');

			$data['id'] = 'list_item_'.$post['id'];
			$data['class'] = ($post['visibility']=='n'?'list_item_hide':'').($post['id']==$read?' list_item_select':'');
			
			$data['datas'] = array();
			
			// 글 선택
			array_push($data['datas'], array('class'=>'noticelist_select','data'=> '<input type="checkbox" class="postid" value="'.$post['id'].'" />' ));
	
			// 글 등록날짜		
			ob_start();
?>
			<?php echo date('y.m.d H:i:s', $post['written']);?><br />
			<span class="date_text">(<?php echo $date;?>)</span>
<?php
			$content = ob_get_contents();
			ob_end_clean();
			array_push($data['datas'], array('class'=>'noticelist_date','data'=> $content ));
			
			// 글 제목
			ob_start();
?>

<?php
			$desc = UTF8::lessenAsEm(str_replace('&nbsp;','',func::stripHTML($post['description'])),82);
			if(empty($desc)) {
				$desc = '<span class="empty">'._t('내용이 비어있거나 HTML로만 작성되어 있습니다.').'</span>';
			}	
			$isNew = Func::isNew($post['written'],1);
?>

			<div class="title"><?php echo UTF8::lessenAsEm(stripcslashes(func::stripHTML($post['title'])), 60);?> <?php echo ($isNew?' <img	src="'.$service['path'].'/images/admin/icon_new.gif" alt="new" align="absmiddle" class="new" />':'');?></div>
			<?php echo $desc?>
<?php
			$content = ob_get_contents();
			ob_end_clean();

			array_push($data['datas'], array('class'=>'noticelist_title','data'=> $content ));

			// 글 실행
			ob_start();
?>
			<a href="#" class="microbutton alertbutton" onclick="deleteItem(<?php echo $post['id'];?>); return false;"><span><?php echo _t('삭제');?></span></a>
<?php

			$content = ob_get_contents();
			ob_end_clean();

			array_push($data['datas'], array('class'=>'noticelist_execute','data'=> $content ));
			
			array_push($datas, $data);
		}

	} else {
			array_push( $datas, array( 'class'=>"list_empty", 'datas'=>array(array('data'=>empty($keyword)?_t('공지사항이 없습니다.'):_t('검색된 공지사항이 없습니다.')) )) );
	}

	ob_start();
?>
		<div class="select">
			<a href="#" onclick="toggleCheckAll('postid'); return false;"><img src="<?php echo $service['path'];?>/images/admin/bt_arrow.gif" /></a>
		</div>
		<div class="action">
			<strong><a href="#" onclick="deleteAllItem('postid'); return false;"><?php echo _t('삭제');?></a></strong>
		</div>				
		<div class="clear"></div>
<?php
	$footers = ob_get_contents();
	ob_end_clean();

	echo makeTableBox('noticelist', $headers, $datas, $footers);	
?>
</div>

<div class="wrap">
	<br />
	<div class="paging">
		<?php echo func::printPaging($paging, $params);?>
	</div>
</div>
<?php
			$input .= ob_get_contents();
			ob_end_clean();
		}

		return $input;
	}
Esempio n. 12
0
	function getMagazineFocus($input, $config) {	
		global $database, $db, $skin, $event, $service, $accessInfo;

		// 첫페이지에만 보이기 ..
		/*
		if(!(empty($accessInfo['controller']) && ($accessInfo['page']==1))) {
			return $input;
		}
		*/

		$pluginURL = $event->pluginURL;
		requireComponent('LZ.PHP.Media');

		if(!isset($config['tabDelay'])) {
			$config['tabDelay'] = 0;
		}
		
		ob_start();
?>
		<style type="text/css">
			.magazineFocusWrap {  padding-top:10px; }
				.magazineFocusTable { width:100%; border:5px solid #b2c941; }
				.magazineFocusTable .leftTab { width:166px; overflow:hidden; background:url("<?php echo $pluginURL;?>/images/bg_left_tab.gif") repeat-y right #fafafa; vertical-align:top; }
					.magazineFocusTable .leftTab ul { list-style:none; margin:0; padding:0; }
						.magazineFocusTable .leftTab ul li { color:#989898; padding-left:20px; padding-top:8px; padding-bottom:8px; margin-right:1px; background:url("<?php echo $pluginURL;?>/images/bg_left_line.gif") repeat-x top; cursor:pointer; font-size:13px; }
						
						.magazineFocusTable .leftTab ul li a { color:#989898; text-decoration:none; }

						.magazineFocusTable .leftTab ul li.first { background-image:none; }
						.magazineFocusTable .leftTab ul li.selected { background-color:#ffffff; margin-right:0; color:#333; font-weight:bold; }
						.magazineFocusTable .leftTab ul li.selected span { background:url("<?php echo $pluginURL;?>/images/bg_left_select.gif") no-repeat right; padding-right:14px; }

						.magazineFocusTable .leftTab ul li.selected a { color:#333; }

						.magazineFocusTable .leftTab ul li.dummy { cursor:default; }
				
				.magazineFocusTable .mainData { vertical-align:top; }

					.magazineFocusTable .mainData ul.item { list-style:none; padding:10px; padding-right:0; padding-bottom:0px; margin:0; display:none; overflow:hidden;  }
						.magazineFocusTable .mainData ul.viewed { display:block; }
					.magazineFocusTable .mainData ul.item li { width:430px; height:68px; padding-bottom:5px; margin-bottom:10px; overflow:hidden; border-bottom:1px solid #ececec; }
						.magazineFocusTable .mainData ul.item li.empty { color:#aaa; font-size:11px; padding-bottom:14px; }
						
						.magazineFocusTable .mainData ul.item li .thumbnail { float:left; margin-right:10px; width:62px; }
							.magazineFocusTable .mainData ul.item li .thumbnail img { width:62px; }

						.magazineFocusTable .mainData ul.item li .data { float:left; width:350px; }
							.magazineFocusTable .mainData ul.item li .data h3 { font-size:14px; color:#595959; font-weight:bold; margin:0; margin-bottom:2px; }
								.magazineFocusTable .mainData ul.item li .data h3 a { color:#4e4e4e; text-decoration:none; }
								.magazineFocusTable .mainData ul.item li .data h3 a:hover { text-decoration:underline; }
							
							.magazineFocusTable .mainData ul.item li .permalink { font-size:11px; margin-bottom:8px; height:12px; line-height:12px; overflow:hidden; }
								.magazineFocusTable .mainData ul.item li .permalink a { color:#909090; text-decoration:none; }
								.magazineFocusTable .mainData ul.item li .permalink a:hover { text-decoration:underline; }

							.magazineFocusTable .mainData ul.item li .data .desc { color:#5d5d5d; line-height:14px; font-size:11px; }

						.magazineFocusTable .mainData ul.item li .data2 { width: 430px; }

						.magazineFocusTable .mainData ul.item li.title_only { padding-bottom:0; border:0; height:14px; background:url("<?php echo $pluginURL;?>/images/bg_li.gif") no-repeat 0px 6px; padding-left:8px; letter-spacing:0px; }
							.magazineFocusTable .mainData ul.item li.title_only a { color:#4e4e4e; text-decoration:none; }
							.magazineFocusTable .mainData ul.item li.title_only a:hover { text-decoration:underline; }

							.magazineFocusTable .mainData ul.item li.title_only .sep { color:#eee; }
							.magazineFocusTable .mainData ul.item li.title_only .feedTitle { color:#999; font:11px Dotum; }
			
				.magazineFocusTable .focusImageWrap { padding:5px;  }
				.magazineFocusTable .focusImageWrap .focusImageDataWrap { padding:10px; padding-bottom:0px; background:url("<?php echo $pluginURL;?>/images/bg.gif") repeat-x; }
				.magazineFocusTable .focusImageWrap .focusImageDatas { float:left; width: 300px; height:164px; position: relative; overflow: hidden; }
				
					.magazineFocusTable .focusImageWrap #focusImageData { position:absolute; z-index:98; }
					
						.magazineFocusTable .focusImageWrap .focusImage { position:absolute; width: 300px; height: 160px; overflow:hidden; }
							.magazineFocusTable .focusImageWrap .focusImage img { width:300px; height: 344px; }

						.magazineFocusTable .focusImageWrap .focusShadow { position:absolute;  top:160px; width:300px; height:4px; background:url("<?php echo $pluginURL;?>/images/bg_image_shadow.gif") repeat-x; font-size:0; line-height:0; z-index:102; }
						
						.magazineFocusTable .focusImageWrap .focusTitleBG { width:300px; position:absolute; height:40px; background:#000000; opacity:0.3; filter: alpha(opacity = 30); z-index: 100; }
						
						.magazineFocusTable .focusImageWrap .focusImageTitle { width: 300px; color:#ffffff;  position:absolute; top:137px; padding:5px; z-index: 101; font-size:13px; line-height:15px; }

							.magazineFocusTable .focusImageWrap .focusImageTitle a { color:#ffffff; text-decoration:none; font-weight:bold; }
							.magazineFocusTable .focusImageWrap .focusImageTitle a:hover { text-decoration:underline; }	

							.magazineFocusTable .focusImageWrap .focusImageTitle .blogtitle { font-size:11px; color:#cdcdcd; }

				.magazineFocusTable .focusImageWrap .focusImageNav { float:left; margin-left:14px; }
					.magazineFocusTable .focusImageWrap .focusImageNav ul { list-style:none; margin:0; padding:0; }
					.magazineFocusTable .focusImageWrap .focusImageNav ul li { margin-bottom:6px; }
					.magazineFocusTable .focusImageWrap .focusImageNav ul li .thumbnail { width:30px; height:30px; overflow:hidden; border:1px solid #000; }
					.magazineFocusTable .focusImageWrap .focusImageNav ul li .thumbnail img { height:30px; }

					.magazineFocusTable .focusImageWrap .focusImageNav ul li.selected .thumbnail { opacity:0.5; filter: alpha(opacity = 50); }

					.magazineFocusTable .focusImageWrap .focusImageNav ul li .shadow { width:32px; height:4px; background:url("<?php echo $pluginURL;?>/images/bg_image_shadow.gif") repeat-x; font-size:0; line-height:0; }

					.magazineFocusTable .focusImageEmpty { text-align: center; color: #999; }					
		</style>
<?php
		$css = ob_get_contents();
		ob_end_clean();

		$skin->css($css);

		ob_start();
?>
	<script type="text/javascript"> 		
		var magazineFocusTabIntervalId = 0;

		function magazineFocusMouseOverMenu(id) {	
<?php
	if($config['tabDelay']>0) {
?>
			if(magazineFocusTabIntervalId!=0) {
				clearInterval(magazineFocusTabIntervalId);
				magazineFocusTabIntervalId = 0;
			}

			magazineFocusTabIntervalId = setInterval( function() {
<?php
	}
?>
				var menu = $("#"+id+"_menu");
				var item = $("#"+id+"_item");

				$('._magazineFocus_menu').each( function() {
					$(this).removeClass('selected');
				});
				$('._magazineFocus_item').each( function() {
					$(this).removeClass('viewed');
				});

			menu.addClass('selected');
			item.addClass('viewed');	
<?php
		if($config['tabDelay']>0) {
?>				
				clearInterval(magazineFocusTabIntervalId);
				magazineFocusTabIntervalId = 0;
			},<?php echo $config['tabDelay'];?>);
<?php
		}
?>
		}
		function magazineFocusMouseOut() {		
			if(magazineFocusTabIntervalId!=0) {
				clearInterval(magazineFocusTabIntervalId);
				magazineFocusTabIntervalId = 0;
			}
		}
		var lastSelectFocusImage = null;
		function moveFocusImagePosition(objId,pos) {
		//	$("#focusImageData").animate({'top':pos+'px'},'fast');
			$("#focusImageData").css('top',pos+'px');

			var obj = $("#"+objId);
			if(lastSelectFocusImage!=null) {
				lastSelectFocusImage.removeClass('selected');
			}
			obj.addClass('selected');
			lastSelectFocusImage = obj;
		}
	</script>
<?php
		$javascript = ob_get_contents();
		ob_end_clean();
		
		$skin->javascript($javascript);
		
		// 포커스이미지
		$count = 4;

		$focusImages = $db->queryAll('SELECT fi.id,fi.feed,fi.permalink,fi.title,fi.description,fi.author,fi.written,m.source FROM '.$database['prefix'].'FeedItems fi LEFT JOIN '.$database['prefix'].'Medias m ON ( m.feeditem = fi.id ) WHERE fi.focus = "y" AND fi.visibility = "y" AND m.width >= 300 GROUP BY fi.id ORDER BY fi.written DESC LIMIT '. $count);
		
		$path = ROOT . '/cache/thumbnail/m_focus';
		if (!is_dir($path)) {
			mkdir($path);
			@chmod($path, 0777);
		}
		
		$media = new Media;
		foreach($focusImages as $item) {
			if(!file_exists($path.'/'.$item['id'].'.jpg')) {
				$media->getThumbnail($item['source'], 350, 160, $path, $item['id'], 'crop');
			}
		}
		
		// 이슈태그
		
		if($config['issueType'] == 'auto') {
			$issueTags = Tag::getIssueTags($config['issueCount']);
		} else {
			$issueTags = explode(',', $config['issueTag']);
			foreach($issueTags as $key=>$tag) {
				$issueTags[$key] = array('name'=>trim($tag));
			}
		}
	
		// 이슈태그

		ob_start();
?>
		<div class="magazineFocusWrap">
			<table class="magazineFocusTable" cellpadding="0" cellspacing="0">
				<tr>
					<td class="leftTab">
						<ul>
<?php
			$index = 0;
			foreach($issueTags as $key=>$tag) {
				list($issueTags[$key]['feedItems'], $totalFeedItemCount) = FeedItem::getFeedItems('tag', $tag['name'], null, 1, $config['issueFeedCount']);
				$index++;
?>
							<li id="_magazineFocus_<?php echo $index;?>_menu" class="<?php echo ($index==1)?'first selected ':'';?>_magazineFocus_menu" onclick="goto('<?php echo $service['path'];?>/search/tag/<?php echo rawurlencode($tag['name']);?>'); return false;" onmouseover="magazineFocusMouseOverMenu('_magazineFocus_<?php echo $index;?>');" title="클릭하시면 태그검색이 가능합니다."><span><?php echo UTF8::lessen($tag['name'],10);?></span></li>
<?php
		}
?>							<li class="dummy"></li>
						</ul>
					</td>
					<td class="mainData">
<?php
	// 이슈태그 내용
	$index = 0;
	foreach($issueTags as $tag) {
		$index ++;
?>
						<ul id="_magazineFocus_<?php echo $index;?>_item" class="item _magazineFocus_item<?php echo ($index==1)?' viewed':'';?>">
<?php
	if(count($tag['feedItems'])>0) {
			$feedItem = current($tag['feedItems']);

			$thumbnailFile = '';
			if($media = Media::getMedia($feedItem['thumbnailId'])) {
				$thumbnailFile = Media::getMediaFile($media['thumbnail']);
			}			
			
			$link_url = $config->addressType == 'id' ? $service['path'].'/go/'.$feedItem['id'] : $service['path'].'/go/'.$feedItem['permalink'];

?>
							<li>
<?php
			if(!empty($thumbnailFile)) {
?>
								<div class="thumbnail">
									<img src="<?php echo $thumbnailFile;?>" alt="미리보기" />
								</div>
<?php
			}
?>
								<div class="data <?php echo empty($thumbnailFile)?'data2':'';?>">
									<h3><a href="<?php echo $link_url;?>" target="_blank"><?php echo UTF8::lessenAsByte(func::stripHTML($feedItem['title']),60);?></a></h3>
									<div class="permalink">
										<a href="<?php echo $feedItem['permalink'];?>" target="_blank"><?php echo $feedItem['permalink'];?></a>
									</div>
									<div class="desc">
										<?php echo UTF8::lessenAsByte(func::stripHTML($feedItem['description']),140);?>
									</div>
								</div>

								<div class="clear"></div>
							</li>
<?php
			if(count($tag['feedItems'])>1) {
					for($i=1;$i<count($tag['feedItems']);$i++) {
						$tagItem = $tag['feedItems'][$i];

							$link_url = $config->addressType == 'id' ? $service['path'].'/go/'.$tagItem['id'] : $service['path'].'/go/'.$tagItem['permalink'];

?>
							<li class="title_only">
								<a href="<?php echo $link_url;?>" target="_blank"><?php echo UTF8::lessenAsByte(func::stripHTML($tagItem['title']),60);?></a> <span class="sep">|</span> <span class="feedTitle"><?php echo Feed::get($tagItem['feed'],'title');?></span>
							</li>
<?php			
					}
			} else {
?>				
							<li class="title_only"></li>
<?php
			}
	}
?>
						</ul>
<?php
}
?>
					</td>
					<td class="focusImageWrap">
<?php
	if(count($focusImages)) {
?>
					<div class="focusImageDataWrap">
						<div class="focusImageDatas">

						

							<div id="focusImageData">
<?php	
		$i = 1;		
		foreach($focusImages as $focusImage) {
								$link_url = $config->addressType == 'id' ? $service['path'].'/go/'.$focusImage['id'] : $service['path'].'/go/'.$focusImage['permalink'];

?>
								<div class="focusImage" style="top:<?php echo ($i-1)*160;?>px; background:url('<?php echo $service['path'];?>/cache/thumbnail/m_focus/<?php echo $focusImage['id'];?>.jpg') no-repeat top center;">
									<a href="<?php echo $link_url;?>" target="_blank"><img src="<?php echo $pluginURL;?>/images/empty.gif" alt="" /></a>
								</div>

								<div class="focusTitleBG" style="top:<?php echo ($i-1)*160 + 120;?>px;"></div>
								<div class="focusImageTitle" style="top:<?php echo ($i-1)*160 + 120;?>px;">	
									<a href="<?php echo $link_url;?>" target="_blank"><?php echo UTF8::lessenAsByte($focusImage['title'],60);?></a><br />
									<span class="blogtitle"><?php echo Feed::get($focusImage['feed'],'title');?></span>
								</div>
<?php
			$i ++;
		}

?>
							</div>		
							<div class="focusShadow">&nbsp;</div>

						</div>
						<div class="focusImageNav">
							<ul>
<?php
		$i = 1;
		foreach($focusImages as $focusImage) {
?>
								<li id="thumbnail<?php echo $i;?>">
									<div class="thumbnail">
										<a href="#" onmouseover="moveFocusImagePosition('thumbnail<?php echo $i;?>',-<?php echo ($i-1)*160;?>);" onclick="return false;"><img src="<?php echo $service['path'];?>/cache/thumbnail/m_focus/<?php echo $focusImage['id'];?>.jpg" alt="썸네일" /></a>
									</div>
									<div class="shadow">&nbsp;</div>
								</li>
<?php		
			$i ++;
		}
?>
							</ul>
						</div>
						<div class="clear"></div>
					</div> <!-- focusImageDataWrap close -->
					
<?php		
	} else {
?>
					<div class="focusImageEmpty">
						포커스로 지정된 글이 없습니다. 
					</div>
<?php	
	}
?>
					</td>
				</tr>
			</table>
		</div>
<?php
		$result = ob_get_contents();
		ob_end_clean();

		return $input . $result;
	}
Esempio n. 13
0
?>
					<div class="data<?php echo !empty($thumbnailFile)?'':' no_thumbnail_data';?>">
						<div class="title"><a href="<?php echo $service['path'];?>/admin/blog/entrylist?read=<?php echo $post['id'];?>"><?php echo UTF8::lessenAsEm(stripcslashes(func::stripHTML($post['title'])), 36);?></a><?php echo ($isNew?'<img src="'.$service['path'].'/images/admin/icon_new.gif" alt="new" align="absmiddle" class="new" />':'');?></div>
						<a href="<?php echo $service['path'];?>/admin/blog/entrylist?read=<?php echo $post['id'];?>"><?php echo $desc?></a>
					</div>
					<div class="clear"></div>
<?php
			$content = ob_get_contents();
			ob_end_clean();

			array_push($data['datas'], array('class'=>'entrylist_title','data'=> $content ));

			// 글 블로그
			ob_start();
?>
					<a href="<?php echo $service['path'];?>/admin/blog/list?read=<?php echo $post['feed'];?>" title="<?php echo _f('\'%1\' 정보보기', stripcslashes(Feed::get($post['feed'], 'title')));?>"><?php echo UTF8::lessenAsEm(stripcslashes(Feed::get($post['feed'], 'title')), 30);?></a> <?php echo $feedvisibility=='n'?'<span class="hide">'._t('(비공개)').'</span>':'';?>
<?php

			$content = ob_get_contents();
			ob_end_clean();

			array_push($data['datas'], array('class'=>'entrylist_blog','data'=> $content ));
			
			// 글 랭크
			$rank = Boom::getRank($post['id']);
			array_push($data['datas'], array('class'=>'entrylist_rank','data'=> '<span class="rank'.$rank.'">'.$rank.'</span>' ));
			
			// 글 읽은 수
			array_push($data['datas'], array('class'=>'entrylist_hit','data'=> $post['click']));
			
			// 글 실행