function ossn_search_page($pages) { $page = $pages[0]; if (empty($page)) { $page = 'search'; } ossn_trigger_callback('page', 'load:search'); switch ($page) { case 'search': $query = input('q'); $type = input('type'); $title = ossn_print("search:result", array($query)); if (empty($type)) { $params['type'] = 'users'; } else { $params['type'] = $type; } $type = $params['type']; if (ossn_is_hook('search', "type:{$type}")) { $contents['contents'] = ossn_call_hook('search', "type:{$type}", array('q' => input('q'))); } $contents = array('content' => ossn_plugin_view('search/pages/search', $contents)); $content = ossn_set_page_layout('search', $contents); echo ossn_view_page($title, $content); break; default: ossn_error_page(); break; } }
/** * Register a plugins by path * This will help us to override components files easily. * * @param string $path A valid path; * @return boolean */ function ossn_register_plugins_by_path($path) { global $Ossn; if (ossn_site_settings('cache') == 1) { return false; } $type = 'default'; $type = ossn_call_hook('plugins', 'type', false, $type); $path = $path . $type . '/'; if (!is_dir($path)) { //disable error log, will cause a huge log file //error_log("Ossn tried to register invalid plugins by path: {$path}"); return false; } $path = str_replace("\\", "/", $path); $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS); $iterator = new RecursiveIteratorIterator($directory); if ($iterator) { foreach ($iterator as $file) { if (pathinfo($file, PATHINFO_EXTENSION) == "php") { $file = str_replace("\\", "/", $file); $location = str_replace(dirname(__FILE__) . '/plugins/', '', $file); $name = str_replace($path, '', $location); $name = substr($name, 0, -4); $fpath = substr($file, 0, -4); $fpath = str_replace(array($name, ossn_route()->www), '', $fpath); $Ossn->plugins[$name] = $fpath; } } } return true; }
/** * Add css page handler * * @return false|null */ function ossn_css_pagehandler($css) { if (ossn_site_settings('cache') == 1) { return false; } header("Content-type: text/css"); $page = $css[0]; if (empty($css[1])) { header('Content-Type: text/html; charset=utf-8'); ossn_error_page(); } if (empty($page)) { $page = 'view'; } switch ($page) { case 'view': if (ossn_site_settings('cache') == 1) { return false; } if (ossn_is_hook('css', "register")) { echo ossn_call_hook('css', "register", $css); } break; default: header('Content-Type: text/html; charset=utf-8'); ossn_error_page(); break; } }
function ossn_css_pagehandler($css) { if (ossn_site_settings('cache') == 1) { return false; } header("Content-type: text/css"); $page = $css[0]; if (empty($css[1])) { echo '404 SWITCH ERROR'; } if (empty($page)) { $page = 'view'; } switch ($page) { case 'view': if (ossn_site_settings('cache') == 1) { return false; } if (ossn_is_hook('css', "register")) { echo ossn_call_hook('css', "register", $css); } break; default: echo '404 SWITCH ERROR'; break; } }
/** * View a plugin * Plugins are registered using ossn_register_plugins_by_path() * * @param string $plugin A valid plugin name; * @param array|object $vars A valid arrays or object * @return void|mixed */ function ossn_plugin_view($plugin = '', $vars = array(), $type = 'default') { global $Ossn; $args = array('plugin' => $plugin); $plugin_type = ossn_call_hook('plugin', 'view:type', $args, $type); if (isset($Ossn->plugins[$plugin_type][$plugin])) { $extended_views = ossn_fetch_extend_views($plugin, $vars); return ossn_view($Ossn->plugins[$plugin_type][$plugin] . $plugin, $vars) . $extended_views; } }
/** * View a file * * @param string $file valid file name of php file without extension; * @param array $params Options; * @last edit: $arsalanshah * @return mixed data */ function ossn_view($path = '', $params = array()) { global $VIEW; if (isset($path) && !empty($path)) { //call hook in case to over ride the view if (ossn_is_hook('halt', "view:{$path}")) { return ossn_call_hook('halt', "view:{$path}", $params); } $path = ossn_route()->www . $path; $file = ossn_include($path . '.php', $params); return $file; } }
function ossn_load_page($handler, $page) { global $Ossn; ossn_add_context($handler); $page = explode('/', $page); if (isset($Ossn->page) && isset($Ossn->page[$handler]) && !empty($handler) && is_callable($Ossn->page[$handler])) { ob_start(); call_user_func($Ossn->page[$handler], $page, $handler); $contents = ob_get_clean(); $params['page'] = $page; $params['handler'] = $handler; return ossn_call_hook('page', 'load', $params, $contents); } else { return ossn_error_page(); } }
/** * Execute a mysqli query and store result in memory * * @return bool; */ public function execute() { $this->database = $this->Connect(); if (isset($this->query) && !empty($this->query)) { $this->database->set_charset("utf8"); $this->exe = $this->database->query($this->query); $exception = ossn_call_hook('database', 'execution:message', false, true); if (!$this->exe && $exception) { throw new OssnDatabaseException("{$this->database->error} \n {$this->query} "); } if (isset($this->database->insert_id)) { $this->last_id = $this->database->insert_id; } unset($this->query); $this->database->close(); return true; } return false; }
/** * Send email to user. * * @param string $email User email address * @param string $subject Email subject * @param string $body Email body * * @return boolean */ public function NotifiyUser($email, $subject, $body) { if (empty($email)) { error_log('Can not send email to empty email address', 0); } $this->setFrom(ossn_site_settings('notification_email'), ossn_site_settings('site_name')); $this->addAddress($email); $this->Subject = $subject; $this->Body = $body; $this->CharSet = "UTF-8"; try { $send = ossn_call_hook('email', 'send', $this->send(), $this); if ($send) { return true; } } catch (phpmailerException $e) { error_log("Cannot send email " . $e->errorMessage(), 0); } return false; }
/** * Output a page. * * If page is not registered then user will see a 404 page; * * @param (string) $handler Page handler name; * @param (string) $page handler/page; * @last edit: $arsalanshah * @Reason: Initial; * * @return mix|null data * @access private */ function ossn_load_page($handler, $page) { global $Ossn; $context = $handler; if (isset($page) && !empty($page)) { $context = "{$handler}/{$page}"; } //set context ossn_add_context($context); $page = explode('/', $page); if (isset($Ossn->page) && isset($Ossn->page[$handler]) && !empty($handler) && is_callable($Ossn->page[$handler])) { //get page contents ob_start(); call_user_func($Ossn->page[$handler], $page, $handler); $contents = ob_get_clean(); //supply params to hook $params['page'] = $page; $params['handler'] = $handler; return ossn_call_hook('page', 'load', $params, $contents); } else { return ossn_error_page(); } }
/** * MIME types. * * This function contains most commonly used MIME types in Ossn * * You can find mimtypes on the url below: * http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/mime.types?view=markup * * Extra mimetypes has been removed in Ossn v3.1. You can add a hook to extends mimetypes * * @return array */ public static function mimeTypes() { $mimetypes = array('doc' => array('application/msword'), 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document'), 'gif' => array('image/gif'), 'jpeg' => array('image/jpeg'), 'jpg' => array('image/jpeg'), 'mp3' => array('audio/mpeg'), 'mp4' => array('video/mp4'), 'pdf' => array('application/pdf'), 'png' => array('image/png'), 'zip' => array('application/zip')); return ossn_call_hook('file', 'mimetypes', false, $mimetypes); }
<?php } ?> <?php } ?> </div> </div> </div> <!-- End of Header --> <div class="group-body"> <?php if (isset($params['subpage']) && !empty($params['subpage']) && ossn_is_group_subapge($params['subpage'])) { if (ossn_is_hook('group', 'subpage')) { echo ossn_call_hook('group', 'subpage', $params); } } else { ?> <div class="group-wall"> <?php //#113 make contents of public groups visible. //send ismember, and member ship param to group wall echo ossn_plugin_view('wall/group', array('group' => $params, 'ismember' => $ismember, 'membership' => $params['group']->membership)); if ($params['group']->membership == OSSN_PRIVATE && $ismember !== 1) { ?> <div class="group-closed-container"> <div class="title-h3"><?php echo ossn_print('closed:group'); ?> </div>
/** * Wall template view * Depends on wall post type * * @param string $callback Name of callback * @param string $type Callback type * @param array $params Arrays or Objects * * @return mixed data * @access private */ function ossn_wall_templates($hook, $type, $return, $params) { $params = ossn_call_hook('wall', 'templates:item', $params, $params); return ossn_plugin_view("wall/templates/wall/{$type}/item", $params); }
* @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://opensource-socialnetwork.com/licence * @link http://www.opensource-socialnetwork.com/licence */ ?> <style> body { background: #FDFDFD; } </style> <div class="ossn-layout-newsfeed"> <div class="ossn-inner"> <div class="coloum-left"> <?php if (ossn_is_hook('search', "left")) { $searchleft = ossn_call_hook('search', "left", NULL, array()); echo implode('', $searchleft); } ?> </div> <div class="coloum-middle"> <?php echo $params['content']; ?> </div> <div class="coloum-right"> <div style="padding:12px;min-height:300px;"> <?php if (com_is_active('OssnAds')) {
</a> <br/> <table border="0" class="ossn-photo-viewer"> <tr> <td class="image-block" style="text-align: center;width:465px;min-height:200px;"> <img src="<?php echo ossn_site_url("album/getphoto/") . $image->owner_guid; ?> /<?php echo $img; ?> ?type=1"/> </td> </tr> </table> </div> <br/> <br/> <?php $vars['entity'] = $image; echo ossn_plugin_view('entity/comment/like/share/view', $vars); ?> <div class="ossn-photo-view-controls"> <?php if (ossn_is_hook('photo:view', 'profile:controls')) { echo ossn_call_hook('photo:view', 'profile:controls', $image); } ?> </div>
/** * Send user reset password link * * @return bool; */ public function SendResetLogin() { self::initAttributes(); $this->old_code = $this->getParam('login:reset:code'); $this->type = 'user'; $this->subtype = 'login:reset:code'; $this->owner_guid = $this->guid; if (!isset($this->{'login:reset:code'}) && empty($this->old_code)) { $this->value = md5(time() . $this->guid); $this->add(); } else { $this->value = md5(time() . $this->guid); $this->data->{'login:reset:code'} = $this->value; $this->save(); } $emailreset_url = ossn_site_url("resetlogin?user={$this->username}&c={$this->value}"); $emailreset_url = ossn_call_hook('user', 'icon:urls', $this, $emailreset_url); $sitename = ossn_site_settings('site_name'); $emailmessage = ossn_print('ossn:reset:password:body', array($this->first_name, $emailreset_url, $sitename)); $emailsubject = ossn_print('ossn:reset:password:subject'); if (!empty($this->value)) { return true; } return false; }
<?php /** * Open Source Social Network * * @package (Informatikon.com).ossn * @author OSSN Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ //unused pagebar skeleton when ads are disabled #628 if (ossn_is_hook('newsfeed', "sidebar:right")) { $newsfeed_right = ossn_call_hook('newsfeed', "sidebar:right", NULL, array()); $sidebar = implode('', $newsfeed_right); $isempty = trim($sidebar); } ?> <div class="container"> <div class="row"> <?php echo ossn_plugin_view('theme/page/elements/system_messages'); ?> <div class="ossn-layout-newsfeed"> <div class="col-md-7"> <div class="newsfeed-middle"> <?php echo $params['content']; ?> </div>
/** * Search object by its title, description etc * * @param array $params A valid options in format: * 'search_type' => true(default) to performs matching on a per-character basis * false for performs matching on exact value. * 'subtype' => Valid object subtype * 'type' => Valid object type * 'title' => Valid object title * 'description' => Valid object description * 'owner_guid' => A valid owner guid, which results integer value * 'limit' => Result limit default, Default is 20 values * 'order_by' => To show result in sepcific order. There is no default order. * * reutrn array|false; * */ public function searchObject(array $params = array()) { self::initAttributes(); if (empty($params)) { return false; } //prepare default attributes $default = array('search_type' => true, 'subtype' => false, 'type' => false, 'owner_guid' => false, 'limit' => false, 'order_by' => false, 'offset' => input('offset', '', 1), 'page_limit' => ossn_call_hook('pagination', 'page_limit', false, 10), 'count' => false); $options = array_merge($default, $params); $wheres = array(); //validate offset values if ($options['limit'] !== false && $options['limit'] != 0 && $options['page_limit'] != 0) { $offset_vals = ceil($options['limit'] / $options['page_limit']); $offset_vals = abs($offset_vals); $offset_vals = range(1, $offset_vals); if (!in_array($options['offset'], $offset_vals)) { return false; } } //get only required result, don't bust your server memory $getlimit = $this->generateLimit($options['limit'], $options['page_limit'], $options['offset']); if ($getlimit) { $options['limit'] = $getlimit; } if (!empty($options['object_guid'])) { $wheres[] = "o.guid='{$options['object_guid']}'"; } if (!empty($options['subtype'])) { $wheres[] = "o.subtype='{$options['subtype']}'"; } if (!empty($params['type'])) { $wheres[] = "o.type='{$options['type']}'"; } if (!empty($params['owner_guid'])) { $wheres[] = "o.owner_guid ='{$options['owner_guid']}'"; } //check if developer want to search title or description if ($options['search_type'] === true) { if (!empty($params['title'])) { $wheres[] = "o.title LIKE '%{$options['title']}%'"; } if (!empty($params['description'])) { $wheres[] = "o.description LIKE '%{$options['description']}%'"; } } elseif ($options['search_type'] === false) { if (!empty($params['title'])) { $wheres[] = "o.title = '{$options['title']}'"; } if (!empty($params['description'])) { $wheres[] = "o.description = '{$options['description']}'"; } } //prepare search $params = array(); $params['from'] = 'ossn_object as o'; $params['params'] = array('o.guid', 'o.time_created', 'o.owner_guid', 'o.description', 'o.title', 'o.subtype'); $params['wheres'] = array($this->constructWheres($wheres)); $params['order_by'] = $options['order_by']; $params['limit'] = $options['limit']; if (!$options['order_by']) { $params['order_by'] = "o.guid ASC"; } $this->get = $this->select($params, true); //prepare count data; if ($options['count'] === true) { unset($params['params']); unset($params['limit']); $count = array(); $count['params'] = array("count(*) as total"); $count = array_merge($params, $count); return $this->select($count)->total; } if ($this->get) { foreach ($this->get as $object) { $this->object_guid = $object->guid; $objects[] = $this->getObjectById(); } return $objects; } return false; }
/** * Comment view * * @param array $vars Options * @param string $template Template name * @return mixed data */ function ossn_comment_view($params, $template = 'comment') { $vars = ossn_call_hook('comment:view', 'template:params', $params, $params); return ossn_plugin_view("comments/templates/{$template}", $vars); }
/** * Get user group posts guids * * @param integer $userguid Guid of user * * @return array; */ public function getFriendsPosts($params = array()) { $user = ossn_loggedin_user(); if (isset($user->guid) && !empty($user->guid)) { $friends = $user->getFriends(); $friend_guids = ''; if ($friends) { foreach ($friends as $friend) { $friend_guids[] = $friend->guid; } } // add all users posts; // (if user has 0 friends, show at least his own postings if wall access type = friends only) $friend_guids[] = $user->guid; $friend_guids = implode(',', $friend_guids); //prepare default attributes $default = array('limit' => false, 'offset' => input('offset', '', 1), 'page_limit' => ossn_call_hook('pagination', 'page_limit', false, 10), 'count' => false); $options = array_merge($default, $params); //get only required result, don't bust your server memory $getlimit = $this->generateLimit($options['limit'], $options['page_limit'], $options['offset']); if ($getlimit) { $options['limit'] = $getlimit; } $wheres = array("md.guid = e.guid", "e.subtype='poster_guid'", "e.type = 'object'", "md.value IN ({$friend_guids})", "o.guid = e.owner_guid"); $vars = array(); $vars['from'] = 'ossn_entities as e, ossn_entities_metadata as md, ossn_object as o'; $vars['params'] = array("o.*"); $vars['wheres'] = array($this->constructWheres($wheres)); $vars['order_by'] = "o.guid DESC"; $vars['limit'] = $options['limit']; //prepare count data; if ($options['count'] === true) { unset($vars['params']); unset($vars['limit']); $count = array(); $count['params'] = array("count(*) as total"); $count = array_merge($vars, $count); return $this->select($count)->total; } $data = $this->select($vars, true); if ($data) { return $data; } } return false; }
?> ?size=view"/> </td> </tr> </table> </div> <br/> <br/> <div class="comments-likes ossn-photos-comments" style="width:525px;"> <?php if (ossn_is_hook('post', 'likes:entity')) { $entity['entity_guid'] = $params['photo']; echo ossn_call_hook('post', 'likes:entity', $entity); } ?> <?php if (ossn_is_hook('post', 'comments:entity')) { $entity['entity_guid'] = $params['photo']; echo ossn_call_hook('post', 'comments:entity', $entity); } ?> </div> <div class="ossn-photo-view-controls"> <?php if (ossn_is_hook('photo:view', 'album:controls')) { echo ossn_call_hook('photo:view', 'album:controls', $image); } ?> </div>
<?php /** * Open Source Social Network * * @package Open Source Social Network * @author Open Social Website Core Team <*****@*****.**> * @copyright 2014 iNFORMATIKON TECHNOLOGIES * @license General Public Licence http://www.opensource-socialnetwork.org/licence * @link http://www.opensource-socialnetwork.org/licence */ echo '<div class="comments-likes">'; if (ossn_is_hook('post', 'likes:entity')) { $entity['entity_guid'] = $params['entity_guid']; echo ossn_call_hook('post', 'likes:entity', $entity); } if (ossn_is_hook('post', 'comments:entity')) { $entity['entity_guid'] = $params['entity_guid']; echo ossn_call_hook('post', 'comments:entity', $entity); } echo '</div>';
echo $params['post']->guid; ?> "> <div class="activity-item-container"> <div class="owner"> <img src="<?php echo $params['user']->iconURL()->small; ?> " width="40" height="40"/> </div> <div class="post-controls"> <?php if (ossn_is_hook('wall', 'post:menu') && ossn_isLoggedIn()) { $menu['post'] = $params['post']; echo ossn_call_hook('wall', 'post:menu', $menu); } ?> </div> <div class="subject"> <?php if ($params['user']->guid == $params['post']->owner_guid) { ?> <a class="owner-link" href="<?php echo $params['user']->profileURL(); ?> "> <?php echo $params['user']->fullname; ?>
/** * Can Moderate * Check if user can moderate the requested item or not * * @return boolean */ public function canModerate() { $allowed = false; if (isset($this->guid) && $this instanceof OssnUser) { if ($this->type == 'normal' && $this->can_moderate == 'yes' || $this->type == 'admin') { $allowed = true; } } return ossn_call_hook('user', 'can:moderate', $this, $allowed); }
?> </div> <?php if (!empty($image)) { ?> <img src="<?php echo ossn_site_url("post/photo/{$params['post']->guid}/{$image}"); ?> "/> <?php } ?> </div> </div> <div class="comments-likes"> <?php if (ossn_is_hook('post', 'likes')) { echo ossn_call_hook('post', 'likes', $params['post']); } ?> <div class="comments-item" style="border-bottom:1px solid #ddd;"> <?php if (ossn_is_hook('post', 'comments')) { echo ossn_call_hook('post', 'comments', $params['post']); } ?> </div> </div> </div>
<table border="0" class="ossn-photo-viewer"> <tr> <td class="image-block" style="text-align: center;width:465px;min-height:200px;"> <img src="<?php echo ossn_site_url("album/getcover/") . $image->owner_guid; ?> /<?php echo $img; ?> "/> </td> </tr> </table> </div> <br/> <br/> <?php $vars['entity'] = $image; $vars['full_view'] = true; echo ossn_plugin_view('entity/comment/like/share/view', $params); ?> <div class="ossn-photo-view-controls"> <?php if (ossn_is_hook('cover:view', 'profile:controls')) { echo ossn_call_hook('cover:view', 'profile:controls', $image); } ?> </div>
/** * Get group latest cover url * * @return url; * @access public; */ public function coverURL() { $this->latestcover = $this->groupCovers()->getParam(0); $file = str_replace('cover/', '', $this->latestcover->value); $this->coverurl = ossn_site_url("groups/cover/{$this->latestcover->guid}/{$file}"); return ossn_call_hook('group', 'cover:url', $this, $this->coverurl); }
} ?> </div> <div class="ossn-profile-bottom"> <?php if (isset($params['subpage']) && !empty($params['subpage']) && ossn_is_profile_subapge($params['subpage'])) { if (ossn_is_hook('profile', 'subpage')) { echo ossn_call_hook('profile', 'subpage', $params); } } else { ?> <div class="ossn-profile-modules"> <?php if (ossn_is_hook('profile', 'modules')) { $params['user'] = $user; $modules = ossn_call_hook('profile', 'modules', $params); echo implode('', $modules); } ?> </div> <div class="ossn-profile-wall"> <?php if (com_is_active('OssnWall')) { $params['user'] = $user; echo ossn_plugin_view('wall/user/wall', $params); } ?> </div> <?php
<?php if (!ossn_isLoggedin()) { return; } ?> <div class="sidebar"> <div class="sidebar-contents"> <?php if (ossn_is_hook('newsfeed', "sidebar:left")) { $newsfeed_left = ossn_call_hook('newsfeed', "sidebar:left", NULL, array()); echo implode('', $newsfeed_left); } echo ossn_view_form('search', array('component' => 'OssnSearch', 'class' => 'ossn-search', 'autocomplete' => 'off', 'method' => 'get', 'security_tokens' => false, 'action' => ossn_site_url("search")), false); ?> </div> </div>
/** * Validate an action token on requested action. * * Calls to actions will automatically validate tokens. If token is invalid * the action stops and user will be redirected with warning of invalid token. * * @param string $callback Name of callback * @param string $type Type of callback * @param array $params * * @access private * @return void */ function ossn_action_validate_callback($callback, $type, $params) { $action = $params['action']; $bypass = array(); $bypass = ossn_call_hook('action', 'validate:bypass', null, $bypass); //validate post request also ossn_post_size_exceed_error(); if (!in_array($action, $bypass)) { if (!ossn_validate_actions()) { if (ossn_is_xhr()) { header("HTTP/1.0 404 Not Found"); exit; } else { ossn_trigger_message(ossn_print('ossn:securitytoken:failed'), 'error'); redirect(REF); } } } }