Example #1
0
 /**
 		Deletes a noticed by notice id, as long as the notice belongs to the 
 	**/
 function deleteUserNotice()
 {
     loggedInSection();
     if (isAJAXRequest()) {
         $this->load->model("notice_model");
         $notice = $this->notice_model->getNotice($_POST["notice_id"])->row();
         // check if this notice belongs the user requesting it
         if ($notice->n_object_user_id == $this->session->userdata("user_id")) {
             // now delete
             $delete = $this->notice_model->deleteNotice($_POST["notice_id"]);
             if ($delete == true) {
                 echo "true";
             } else {
                 echo "false";
             }
         } else {
             echo "false";
         }
     } else {
         $data = array("errorTitle" => "Request Denied", "content" => "An error has occurred: you cannot access this page from the browser.");
         $this->template->write_view("content", "general/error", $data, TRUE);
         //now render templates
         $this->template->render();
     }
 }
Example #2
0
 /**
 	As with upload, but for avatar so a slightly different deal
 	
 	@param get : get variable passed by the qqUploader
 */
 function uploadAvatar($get = null)
 {
     loggedInSection();
     $canContinue = false;
     $maxdim = 200;
     $maxsize = 0.5 * 1024 * 1024;
     $allowedExtensions = array("jpg", "jpeg", "gif", "png");
     $qq = null;
     //qq uploader object
     //make filename
     $filename = $this->session->userdata("username") . "_" . time() . "_avatar_";
     if (isAJAXRequest()) {
         $explode = explode("x.urika.amp.x", $get);
         $explode = explode(".urika.eq.", $explode[1]);
         $filename .= $explode[1];
     } else {
         if (isset($_FILES["qqfile"])) {
             $filename .= $_FILES["qqfile"]["name"];
         } else {
             redirect("", "location");
         }
     }
     if (isAJAXRequest()) {
         $qq = new qqFileUploader("xhr", $allowedExtensions, $maxsize, $filename);
         $result = $qq->handleUpload(UPLOAD_TEMP_PATH, TRUE);
         if (isset($result["success"])) {
             $canContinue = true;
         } else {
             $error = $result["error"];
         }
     } else {
         $qq = new qqFileUploader("fileForm", $allowedExtensions, $maxsize, $filename);
         $result = $qq->handleUpload(UPLOAD_TEMP_PATH, TRUE);
         if (isset($result["success"])) {
             $canContinue = true;
         } else {
             $error = $result["error"];
         }
     }
     // after intial detection etc do the same thing throughout
     // now take temp path and copy resampled to main upload directory
     if ($canContinue) {
         // resized to 60x60 and placed in images folder
         // grab temp image and get image dimensions
         $img_r = imagecreatefromjpeg(UPLOAD_TEMP_PATH . $filename);
         list($dwidth, $dheight, $dtype, $dattr) = getimagesize(UPLOAD_TEMP_PATH . $filename);
         // check the width and ehight
         if ($dwidth > $maxdim || $dheight > $maxdim) {
             unlink(UPLOAD_TEMP_PATH . $filename);
             echo json_encode(array("error" => "The image must be smaller than " . $maxdim . "x" . $maxdim . " pixels, the image you uploaded was too large"));
         } else {
             // create blank image
             $full_img = ImageCreateTrueColor(70, 70);
             // copy temp into blank image
             imagecopyresampled($full_img, $img_r, 0, 0, 0, 0, 70, 70, $dwidth, $dheight);
             // now save new img, and delete temp
             imagejpeg($full_img, UPLOAD_FINAL_PATH . $filename, 150);
             if (unlink(UPLOAD_TEMP_PATH . $filename)) {
                 // last step, update user record to contain url
                 $user_id = $this->session->userdata("user_id");
                 // grab current user
                 $this->load->model("user_model");
                 $user_details = $this->user_model->getUser($user_id)->row();
                 $current_value = $user_details->u_profile_id;
                 $new_value = "";
                 $update_to_avatar = "false";
                 // if usegravatar:: is there just append to the end
                 if (strpos($current_value, "usegravatar::") !== FALSE) {
                     $new_value = "usegravatar::" . UPLOAD_URL . $filename;
                 } else {
                     $new_value = UPLOAD_URL . $filename;
                     $update_to_avatar == true;
                 }
                 $details_data = array("u_profile_id" => $new_value);
                 $update = $this->user_model->updateUser($details_data, $user_id, "user_id");
                 $returnArray = array("filename" => $filename, "file_url" => UPLOAD_URL . $filename, "update_to_avatar" => $update_to_avatar);
                 echo json_encode($returnArray);
             } else {
                 echo json_encode(array("error" => "Something went wrong with the image resizing"));
             }
         }
     } else {
         echo json_encode(array("error" => $error));
     }
 }
Example #3
0
function passesPageCacheValidation()
{
    if (NITRO_IGNORE_AJAX_REQUESTS && isAJAXRequest()) {
        return false;
    }
    if (NITRO_IGNORE_POST_REQUESTS && isPOSTRequest()) {
        return false;
    }
    if (isItemsInCart() || isCustomerLogged() || isWishlistAdded() || isAdminLogged() && NITRO_DISABLE_FOR_ADMIN || isYMM()) {
        return false;
    }
    $ignoredRoutes = getIgnoredRoutes();
    global $registry;
    if (!empty($registry)) {
        $current_route = !empty($registry->get('request')->get['route']) ? $registry->get('request')->get['route'] : NULL;
    }
    if (!empty($_GET['route']) && in_array($_GET['route'], $ignoredRoutes) || !empty($current_route) && in_array($current_route, $ignoredRoutes)) {
        return false;
    }
    if (areWeInIgnoredUrl()) {
        return false;
    }
    return true;
}
Example #4
0
File: top.php Project: BulatSa/Ctex
function passesPageCacheValidation()
{
    if (NITRO_IGNORE_AJAX_REQUESTS == TRUE && isAJAXRequest()) {
        return false;
    }
    if (NITRO_IGNORE_POST_REQUESTS == TRUE && isPOSTRequest()) {
        return false;
    }
    if (isItemsInCart() || isCustomerLogged() || isWishlistAdded()) {
        return false;
    }
    $ignoredRoutes = getIgnoredRoutes();
    if (!empty($_GET['route']) && in_array($_GET['route'], $ignoredRoutes)) {
        return false;
    }
    if (areWeInIgnoredUrl()) {
        return false;
    }
    return true;
}