use components\Helper; ?> <?php Helper::renderStatic('main/_filterUserForm', compact('options'), false); if (!empty($userInfo)) { ?> <?php Helper::renderStatic('main/_summaryUserInfo', compact('userInfo', 'options'), false); } ?> <table border="1" align="center" cellpadding="0" cellspacing="0" id="mainTable"> <thead align="center" style="background-color: lightblue;"> <tr> <td style="width: 100px;">Link</td> <td style="width: 20px;">Type</td> <td style="width: 30px;">Likes</td> <td style="width: 30px;">Comments</td> <td style="width: 100px;">Caption</td> <td style="width: 100px;">Tags</td> <td style="width: 100px;">Create Date</td> </tr> </thead> <tbody align="center"> <?php Helper::renderStatic('main/_viewMediaMore', compact('media', 'options'), false); ?> </tbody> </table>
public static function appRedirect($url, $permanent = false) { $current_url = self::$url->getAddressElements(); $path_info = self::$url->getPath(); $path = ''; foreach ($current_url as $element) { $path .= $element; } $url = Helper::stringFilter($url); $url = str_replace('http://', '', $url); $url = str_replace('www.', '', $url); $url = str_replace($_SERVER['SERVER_NAME'], '', $url); $redirect_path = str_replace($path_info, '', $path); $redirect_path = str_replace('?', '', $redirect_path); $redirect_path = str_replace($_SERVER['QUERY_STRING'], '', $redirect_path); $redirect_path = 'http://' . $redirect_path . $url; $current_path = 'http://' . $path; if ($redirect_path != $current_path) { header('Location: ' . $redirect_path, true, true === $permanent ? 301 : 302); } }
<?php use config\Config; use components\Helper; ?> <a href="<?php echo Helper::generateUrl(Config::get('defaultController'), Config::get('mainViewAction'), ['code' => $options['code'], 'userName' => $options['userName']]); ?> "><< Back to user</a>
<?php foreach ($media as $i => $value) { ?> <?php $bgTr = ''; if ($i % 2) { $bgTr = 'background-color: lightgreen;'; } ?> <tr style="<?php echo $bgTr; ?> height: 40px;"> <td> <?php Helper::renderStatic('main/_likesDetailTables', ['media' => [$value->from], 'options' => $options]); ?> </td> <td> <?php echo $value->text; ?> </td> <td> <?php echo date('d F, Y H:i:s', $value->created_time); ?> </td> </tr> <?php }
</td> </tr> <?php } if ($options['hasNextUrl']) { ?> <tr class="loadmoretr"> <td colspan="10"> <img id="preloaderImg" src="/<?php echo Config::CONST_INFOLDER . 'css/292.GIF'; ?> " style="display: none;"/> <button id="loadmoreFollowers" data-href="<?php echo Helper::generateUrl($options['c'], $options['a_next']); ?> " data-code="<?php echo $options['code']; ?> " data-username="******" >Load more... </button> </td> </tr> <?php }
/** * */ public function followsAction() { $code = Helper::requestGet('code', null); $userName = Helper::requestGet('userName', null); if ($userName) { $token = $this->getTokenByCode($code); $this->instagram->setAccessToken($token); $search = $this->instagram->searchUser($userName, self::COUNT_SEARCH_USER); $this->hasError($search); if ($search->meta->code == self::SUCCESS_RESPONSE && !empty($search->data)) { $userId = current($search->data)->id; $data = $this->instagram->getUserFollows($userId, self::COUNT_FOLLOWS_DATA); $this->hasError($data); if ($data->meta->code == self::SUCCESS_RESPONSE && !empty($data->data)) { $media = $data->data; $options = ['c' => Config::get('defaultController'), 'a' => 'follows', 'code' => $code, 'userName' => $userName]; Helper::renderStatic('main/follows', compact('media', 'options')); exit; } } } }
<?php use config\Config; use components\Init; use components\Helper; error_reporting(E_ALL); ini_set('display_errors', 'on'); // main loaders include '../loader.php'; $code = isset($_GET['code']) ? $_GET['code'] : null; // save token value for using in future $saveToken = (new Init())->setToken($code); // if token success saved - welcome to main view page! if ($saveToken) { Helper::redirect(Config::get('defaultController'), Config::get('mainViewAction'), compact('code')); } exit;
use config\config; use components\Helper; error_reporting(E_ALL); ini_set('display_errors', 'on'); // main loaders include '../loader.php'; // set conntroller $controller = !empty($_GET['c']) ? $_GET['c'] : Config::get('defaultController'); // set action $action = !empty($_GET['a']) ? $_GET['a'] : Config::get('defaultAction'); // generate full controller name $controller = 'controllers\\' . Helper::ucfirst(mb_strtolower($controller)) . 'Controller'; if (class_exists($controller)) { // init controller $controller = new $controller(); // generate action name $action_name = mb_strtolower($action) . 'Action'; // check if action(method) exist if (!method_exists($controller, $action_name)) { Helper::HException('Action "' . $action . '" not exist', 403); } try { // call action $controller->{$action_name}(); } catch (Exception $e) { Helper::HException($e->getMessage(), 409); } } else { Helper::HException('Controller "' . $controller . '" not exist', 403); }
/** * @param $result * @return bool */ protected function hasError($result) { if (empty($result)) { Helper::HException('No data found', self::HTTP_NOT_FOUND); } if (isset($result->code, $result->error_message) && $result->code === self::INVALID_RESPONSE || isset($result->meta, $result->meta->code) && $result->meta->code === self::INVALID_RESPONSE) { $error_message = isset($result->error_message) ? $result->error_message : $result->meta->error_message; $error_code = isset($result->code) ? $result->code : $result->meta->code; Helper::HException($error_message, $error_code); } return false; }
<?php use components\Helper; ?> <?php Helper::renderStatic('main/_back_to_user', ['options' => $options], false); ?> <table border="1" align="center" id="followersTable"> <tr style="background-color: lightblue;"> <td>User ID</td> <td>Username</td> <td>Full Name</td> <td>Profile Picture</td> </tr> <?php Helper::renderStatic('main/_followersList', compact('media', 'options'), false); ?> </table>
<td>Counts Followed By</td> <td> <a href="<?php echo Helper::generateUrl('main', 'followers', ['code' => $options['code'], 'userName' => $userInfo->username]); ?> " target="_blank" ><?php echo $userInfo->counts->followed_by; ?> </a> </td> </tr> <tr> <td>Counts Follows</td> <td> <a href="<?php echo Helper::generateUrl('main', 'follows', ['code' => $options['code'], 'userName' => $userInfo->username]); ?> " target="_blank" ><?php echo $userInfo->counts->follows; ?> </a> </td> </tr> </table>