public static function render_views($view, $arr = array()) { extract($arr); $temp = explode("/", $view); $plug_name = $temp[0]; $view_name = $temp[1]; $path1 = __DIR__ . "/views/" . Settings::get("theme") . "/plugins/{$plug_name}/{$view_name}"; $path2 = __DIR__ . "/plugins/{$plug_name}/views/{$view_name}"; if (file_exists($path1)) { $full_path_to_view = $path1; } else { $full_path_to_view = $path2; } include $full_path_to_view; }
<h1 >profile view</h1> <!-- start of profile edit pluging render--> <div style = "float:right"> <?php echo Plugin::render("edit_profile"); ?> </div> <!-- end of profile edit pluging render--> <p >User Name : <?php echo $user->name; ?> </p> <img src="<?php if ($user != null) { echo Settings::get('base_url') . "uploads/profile_pic/" . $user->profile_pic; } ?> " width="200px" height="200px" /><br /><br /> <div> <?php if (isset($post_status)) { Plugin::render("create_post", array("user" => $user, "post_status" => $post_status)); } else { Plugin::render("create_post", array("user" => $user)); } ?> </div> <div style= "width : 500px;" >
?> <label style = "color : white">what's on your mind</label><br/> <textarea rows = "5" cols = "100" name = "wallpost"> </textarea> <button type = "submit">Post</button> </form> </div> <div> <?php if (isset($arr)) { foreach ($arr as $a) { echo '<p style = "color : white;">' . $a->text . '</p><br/>'; } } ?> </div> <div style = "float : right;"> <h1 style = "color : white;">All users list</h1> <?php if (isset($users)) { foreach ($users as $u) { $url = Settings::get('base_url'); echo '<a href = "' . $url . 'profile/' . $u->id . '" style = "color : white;"><img src = "' . $url . '/uploads/' . $u->profile_pic . '" width = "50" height = "50">' . $u->name . '</a><br/>'; } } ?> </div> </body> </html>
public static function render($view, $arr = array()) { extract($arr); include __DIR__ . '/views/' . Settings::get("theme") . "/{$view}.php"; }
public function post($id) { if (isset($_POST['wallpost'])) { //this code is for wall post $p_status = Post::create(array("text" => $_POST['wallpost'], "user1" => Session::get('id'), "user2" => $id, "activityid" => "1")); $objs = Post::where("(user1 = {$id}", "or", "user2 = {$id}) && activityid = 1 ORDER BY timestamp DESC"); $posts = null; $count = 0; foreach ($objs as $obj) { $user1 = User::get(array("id" => $obj->user1)); $user2 = User::get(array("id" => $obj->user2)); $obx = new stdClass(); $obx->timestamp = $obj->timestamp; $obx->postid = $obj->id; $obx->text = $obj->text; $obx->user1_pic = Settings::get("base_url") . 'uploads/profile_pic' . $user1->profile_pic; $obx->user1_coverpic = Settings::get("base_url") . 'uploads/cover_pic/' . $user1->cover_pic; $obx->user1_link = Settings::get("base_url") . 'profile/' . $user1->id; $obx->user1_name = $user1->name; $obx->user1_id = $user1->id; $obx->user2_link = Settings::get("base_url") . 'profile/' . $user2->id; $obx->user2_name = $user2->name; $obx->user2_id = $user2->id; $posts[$count++] = $obx; } $user = User::get(array("id" => $id)); if ($user && $posts) { View::render("profile_view", array("post_status" => $p_status, "user" => $user, "posts" => $posts)); } } if (isset($_POST['edit_profile'])) { $user = User::get(array("id" => Session::get("id"))); $user->name = $_POST['name']; $user->email = $_POST['email']; $user->age = $_POST['age']; $user->password = $_POST['password']; $user->gender = $_POST['gender']; $user->save(); $objs = Post::where("(user1 = {$id}", "or", "user2 = {$id}) && activityid = 1 ORDER BY timestamp DESC"); $posts = null; $count = 0; foreach ($objs as $obj) { $user1 = User::get(array("id" => $obj->user1)); $user2 = User::get(array("id" => $obj->user2)); $obx = new stdClass(); $obx->timestamp = $obj->timestamp; $obx->postid = $obj->id; $obx->text = $obj->text; $obx->user1_pic = Settings::get("base_url") . 'uploads/profile_pic' . $user1->profile_pic; $obx->user1_link = Settings::get("base_url") . 'profile/' . $user1->id; $obx->user1_name = $user1->name; $obx->user1_id = $user1->id; $obx->user2_link = Settings::get("base_url") . 'profile/' . $user2->id; $obx->user2_name = $user2->name; $obx->user2_id = $user2->id; $posts[$count++] = $obx; } $user = User::get(array("id" => $id)); if ($user && $posts) { View::render("profile_view", array("user" => $user, "posts" => $posts)); } } if (isset($_FILES['upload'])) { //this code for upload picture $ext = ""; $flag = false; if (preg_match('/^image\\/p?jpeg$/i', $_FILES['upload']['type'])) { $ext = '.jpeg'; $flag = true; } else { if (preg_match('/^image\\/gif$/i', $_FILES['upload']['type'])) { $ext = '.gif'; $flag = true; } else { if (preg_match('/^image\\/(x-)?png$/i', $_FILES['upload']['type'])) { $ext = '.png'; $flag = true; } } } if ($flag) { // The complete path/filename $file = Session::get("id"); $dir = __DIR__; $dir = substr($dir, 0, count($dir) - 13); $filename = "{$dir}/uploads/cover_pic/{$file}" . $ext; //die(print_r($_FILES['upload']['tmp_name'])); // Copy the file (if it is deemed safe) if (!is_uploaded_file($_FILES['upload']['tmp_name']) or !copy($_FILES['upload']['tmp_name'], $filename)) { $error = "Could not save file as {$filename}!"; exit; } else { if (User::updateCoverPicture("{$file}{$ext}")) { $users = User::all(); $hre = Session::get('id'); header("Location: {$hre}"); } } } // if flag statement ends } // upload ends if (isset($_POST['friendbutton'])) { } }
public static function init() { $dbhandle = mysql_connect(Settings::get("servername"), Settings::get("username"), Settings::get("pass")) or die("Unable to connect to MySQL"); mysql_select_db(Settings::get("dbname"), $dbhandle) or die("Could not select examples"); }