Пример #1
0
 public function action_removeimage()
 {
     $user = Auth::instance()->get_user();
     $user->avatar = "";
     $user->save();
     $image = CacheImage::instance();
     $src = $image->resize($user->avatar, 100, 100);
     echo $src;
     exit;
 }
Пример #2
0
 protected function menu_init()
 {
     $this->view->bind('topmenu', $topmenu)->bind('myaccount', $myaccount)->bind('sidemenu', $profilemenu)->bind('image', $image)->bind('role', $role)->bind('username', $username)->bind('user', $user);
     $user_id = $this->request->param('id');
     $user = ORM::factory('user', $user_id);
     $role = $user->role()->name;
     $username = $user->firstname;
     $avatar = $user->avatar;
     $avatar = $avatar === null ? '' : $avatar;
     $img_user = CacheImage::instance()->resize($avatar, 100, 100);
     $view_avatar = View::factory('account/sidemenu/profile')->bind('avatar_user', $img_user)->bind('user', $user)->bind('role', $role);
     $this->view->set('avatar', $view_avatar);
     $menu = Acl_Menu::factory('profile');
     $topmenu = $menu->get('topmenu');
     $profilemenu = $menu->get('profilemenu');
     $myaccount = $menu->get('myaccount');
     $institution = ORM::factory('institution', $id = 1);
     $image = CacheImage::instance()->resize($institution->logo, 240, 60);
 }
Пример #3
0
 }
 if ($FileInfo->isFile() && $FileInfo->isReadable()) {
     $setnamematch = preg_match('/(?P<Prefix>[A-Z]+[_ -])?(?P<Name>[A-Z0-9]+)(?P<Number>\\d\\d)(?P<Suffix>[a-z])?\\.(?P<Extension>[^.]+)$/i', $FileInfo->getFilename(), $matches);
     if (isset($matches) && count($matches) > 0) {
         $Set = Set::Filter($Sets, $Model->getID(), NULL, $matches['Name'] . $matches['Number'], $matches['Prefix']);
         if (!$Set) {
             continue;
         } else {
             $Set = $Set[0];
         }
         /* @var $VideoInDB Video */
         $VideosInDB = Video::Filter($Videos, $ModelID, $Set->getID(), $matches['Name'] . $matches['Number'] . $matches['Suffix']);
         if ($VideosInDB) {
             $VideoInDB = $VideosInDB[0];
             $cis = CacheImage::Filter($CacheImages, NULL, NULL, NULL, NULL, NULL, $VideoInDB->getID());
             CacheImage::DeleteMulti($cis, $CurrentUser);
         } else {
             $VideoInDB = new Video();
             $VideoInDB->setSet($Set);
         }
         $VideoInDB->setFileName($matches['Prefix'] . $matches['Name'] . $matches['Number'] . $matches['Suffix']);
         $VideoInDB->setFileExtension($matches['Extension']);
         $VideoInDB->setFileSize($FileInfo->getSize());
         $VideoInDB->setFileCheckSum(Utils::CalculateMD5($FileInfo->getRealPath()));
         $VideoInDB->setFileCRC32(Utils::CalculateCRC32($FileInfo->getRealPath()));
         if (!$VideoInDB->getID() && $CurrentUser->hasPermission(RIGHT_VIDEO_ADD)) {
             Video::Insert($VideoInDB, $CurrentUser);
         } else {
             if ($CurrentUser->hasPermission(RIGHT_VIDEO_EDIT)) {
                 Video::Update($VideoInDB, $CurrentUser);
             }
Пример #4
0
 public function action_show_map()
 {
     $room = ORM::factory('room', $this->request->param('id'));
     $location = ORM::factory('location', $room->location_id);
     $images = CacheImage::instance();
     $image = $images->resize($location->image, 400, 200);
     $html = '<img src ="' . $image . '" />';
     $json = array('success' => 0, 'html' => $html);
     echo json_encode($json);
     exit;
 }
Пример #5
0
<?php

$image = CacheImage::instance();
$avatar = $image->resize($user->avatar, 75, 75);
$curr_user = Auth::instance()->get_user();
$curr_avatar = $image->resize($curr_user->avatar, 40, 40);
?>

    
    <table class="fullwidth">
        <tr>
            <td class="w8">
                <a href="<?php 
echo $url . "/" . $user->id;
?>
"><img src = "<?php 
echo $avatar;
?>
" class = "h70 "></img></a>
            </td>
            <td class="vatop hpad10">
                <p class="h3"><span class = "roleIcon <?php 
echo $user->role();
?>
">&nbsp;</span><a href="<?php 
echo $url . "/" . $user->id;
?>
"><?php 
echo $user->fullname();
?>
</a></p><br>
Пример #6
0
 public function action_removeimage()
 {
     $image = CacheImage::instance();
     $src = $image->resize('', 100, 100);
     echo $src;
     exit;
 }
Пример #7
0
         }
     }
 } else {
     if ($ImageID) {
         $CacheImage = CacheImage::GetCacheImages(new CacheImageSearchParameters(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, $ImageID, FALSE, FALSE, FALSE, $Width, $Height));
         if ($CacheImage) {
             $CacheImage = $CacheImage[0];
             Image::OutputImage($CacheImage->getFilenameOnDisk(), $CacheImage->getImageWidth(), $CacheImage->getImageHeight(), TRUE);
         } else {
             $Image = Image::GetImages(new ImageSearchParameters($ImageID));
             if ($Image) {
                 $Image = $Image[0];
                 $Set = $Image->getSet();
                 $Model = $Set->getModel();
                 if (file_exists($Image->getFilenameOnDisk())) {
                     $CacheImage = new CacheImage();
                     $CacheImage->setImageID($ImageID);
                     $CacheImage->setKind(CACHEIMAGE_KIND_IMAGE);
                     $CacheImage->setImageWidth($Width);
                     $CacheImage->setImageHeight($Height);
                     CacheImage::Insert($CacheImage, $CurrentUser);
                     Image::OutputImage($Image->getFilenameOnDisk(), $Width, $Height, TRUE, $CacheImage->getFilenameOnDisk());
                 } else {
                     Image::OutputImage();
                 }
             } else {
                 Image::OutputImage();
             }
         }
     } else {
         HTMLstuff::RefererRedirect();
Пример #8
0
 public function action_edit()
 {
     $submitted = false;
     $id = $this->request->param('id');
     if (!$id) {
         Request::current()->redirect('location');
     }
     $location = ORM::factory('location', $id);
     if ($this->request->method() === 'POST' && $this->request->post()) {
         if (Arr::get($this->request->post(), 'save') !== null) {
             $submitted = true;
             $validator = $location->validator($this->request->post());
             if ($validator->check()) {
                 $location->name = $this->request->post('name');
                 $location->image = $this->request->post('image');
                 $location->save();
                 Request::current()->redirect('location');
                 exit;
             } else {
                 $this->_errors = $validator->errors('location');
             }
         }
     }
     $form = $this->form('location/edit/id/' . $id, $submitted, array('name' => $location->name, 'image' => $location->image));
     $links = array('cancel' => Html::anchor('/location/', 'or cancel'));
     $upload_url = URL::site('location/uploadmap');
     $images = CacheImage::instance();
     $image = $images->resize($location->image, 400, 200);
     //$image = $location->image;
     $view = View::factory('location/form')->bind('links', $links)->bind('form', $form)->bind('image', $image)->bind('upload_url', $upload_url);
     Breadcrumbs::add(array('System', Url::site('system')));
     Breadcrumbs::add(array('Location', Url::site('location')));
     Breadcrumbs::add(array('Edit', Url::site('location/edit/id/' . $id)));
     $this->content = $view;
 }
Пример #9
0
foreach ($Users as $User) {
    $UsersOptions .= sprintf("<option value=\"%1\$d\"%3\$s>%2\$s</option>", $User->getID(), htmlentities($User->GetFullName()), HTMLstuff::SelectedStr($User->getID() == $CommandlineUserID));
}
$ModelsOptions = '';
$Models = Model::GetModels();
/* @var $Model Model */
foreach ($Models as $Model) {
    $ModelsOptions .= sprintf("<option value=\"%1\$d\">%2\$s</option>", $Model->getID(), htmlentities($Model->GetFullName()));
}
$ThumbsPerPageOptions = '';
$ThumbsPerPageInts = array(1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36, 42, 49, 56, 64, 72, 81, 90);
foreach ($ThumbsPerPageInts as $Int) {
    $ThumbsPerPageOptions .= sprintf("<option value=\"%1\$d\">%1\$d</option>", $Int);
}
$CacheFolder = 'cache';
$CacheImages = CacheImage::GetCacheImages();
/* @var $it RecursiveDirectoryIterator */
$it = new RecursiveDirectoryIterator($CacheFolder, FileSystemIterator::SKIP_DOTS | FileSystemIterator::CURRENT_AS_FILEINFO);
$PhysicalCacheImageCount = 0;
/* @var $file SplFileInfo */
foreach ($it as $file) {
    if ($file->isFile()) {
        $PhysicalCacheImageCount++;
    }
}
$CacheInSync = sprintf('<span>%1$s</span>', $lang->g('LabelOrphanFiles0'));
if ($PhysicalCacheImageCount > count($CacheImages)) {
    $CacheInSync = '<span class="WarningRed">' . sprintf($PhysicalCacheImageCount - count($CacheImages) == 1 ? $lang->g('LabelOrphanFiles1') : $lang->g('LabelOrphanFilesX'), $PhysicalCacheImageCount - count($CacheImages)) . '</span>';
} elseif ($PhysicalCacheImageCount < count($CacheImages)) {
    $CacheInSync = '<span class="WarningRed">' . sprintf(count($CacheImages) - $PhysicalCacheImageCount == 1 ? $lang->g('LabelMissingFiles1') : $lang->g('LabelMissingFilesX'), count($CacheImages) - $PhysicalCacheImageCount) . '</span>';
}
Пример #10
0
DROP VIEW IF EXISTS `vw_Tag2All`;
CREATE ALGORITHM=UNDEFINED VIEW `vw_Tag2All` AS\tselect `Tag2All`.`tag_id` AS `tag_id`, `Tag`.`tag_name` AS `tag_name`, `Tag2All`.`model_id` AS `model_id`, `Tag2All`.`set_id` AS `set_id`, `Tag2All`.`image_id` AS `image_id`, `Tag2All`.`video_id` AS `video_id` from `Tag2All` join `Tag` on `Tag`.`tag_id` = `Tag2All`.`tag_id`;

UPDATE `Model` SET `model_firstname` = 'Yuliya'
WHERE `model_lastname` = 'Semenishyna';

UPDATE `CacheImage` SET `index_sequence_number` = 1, `index_sequence_total` = 1 
WHERE `index_id` IS NOT NULL;
  
COMMIT;
SET AUTOCOMMIT=1;

FjbMNnvUJheiwewUJfheJheuehFJDUHdywgwwgHGfgywug;
    if ($NoError && $dbi->ExecuteMulti($UpdateDBSQL)) {
        /* Rename all cached images on disk to include prefix */
        $CacheImagesInDB = CacheImage::GetCacheImages();
        /* @var $ci CacheImage */
        foreach ($CacheImagesInDB as $ci) {
            if ($ci->getKind() == CACHEIMAGE_KIND_INDEX) {
                if (file_exists($ci->getFilenameOnDisk(TRUE, TRUE))) {
                    rename($ci->getFilenameOnDisk(TRUE, TRUE), $ci->getFilenameOnDisk(FALSE, FALSE));
                }
                if (file_exists($ci->getFilenameOnDisk(FALSE, TRUE))) {
                    rename($ci->getFilenameOnDisk(FALSE, TRUE), $ci->getFilenameOnDisk(FALSE, FALSE));
                }
            } else {
                if (file_exists($ci->getFilenameOnDisk(TRUE))) {
                    rename($ci->getFilenameOnDisk(TRUE), $ci->getFilenameOnDisk(FALSE));
                }
            }
        }
Пример #11
0
 public function action_uploadinst()
 {
     $filename = 'inst_' . time() . '_' . $_FILES['image']['name'];
     $file_validation = new Validation($_FILES);
     $file_validation->rule('image', 'upload::valid');
     $file_validation->rule('image', 'upload::type', array(':value', array('jpg', 'png', 'gif', 'jpeg')));
     if ($file_validation->check()) {
         if ($path = Upload::save($_FILES['image'], $filename, DIR_IMAGE)) {
             $images = CacheImage::instance();
             $src = $images->resize($filename, 100, 100);
             $json = array('success' => 1, 'image' => $src, 'filename' => $filename);
         } else {
             $json = array('success' => 0, 'errors' => array('image' => 'The file is not a valid Image'));
         }
     } else {
         $json = array('success' => 0, 'errors' => (array) $file_validation->errors('profile'));
     }
     echo json_encode($json);
     exit;
 }
Пример #12
0
 public function action_comment()
 {
     $feed_id = $this->request->post('id');
     $data = $this->request->post('data');
     $comment = ORM::factory('feedcomment');
     $comment->comment = $data;
     $comment->feed_id = $feed_id;
     $comment->date = strtotime(date('d-m-Y G:i:s'));
     $comment->user_id = Auth::instance()->get_user()->id;
     $comment->save();
     $image = CacheImage::instance();
     $curr_user = Auth::instance()->get_user();
     $curr_avatar = $image->resize($curr_user->avatar, 40, 40);
     $span = Date::fuzzy_span($comment->date);
     $json = array('name' => $curr_user->firstname . " " . $curr_user->lastname, 'img' => $curr_avatar, 'text' => Html::chars($comment->comment), 'time' => $span, 'comment_id' => $comment->id);
     echo json_encode($json);
     exit;
 }
Пример #13
0
$Sets = Set::GetSets(new SetSearchParameters(FALSE, FALSE, $ModelID));
$Model = $Sets ? $Sets[0]->getModel() : NULL;
if (!$Sets || in_array($Sets[0]->getModel()->getFullName(), array('Promotions', 'Interviews'))) {
    Image::OutputImage();
}
$pageIterator = 1;
$perPage = $perPage && $perPage > 0 ? $perPage : count($Sets);
$uuid = Utils::UUID();
$cacheImages = array();
while (($pageIterator - 1) * $perPage < count($Sets)) {
    $Sets2Process = array_slice($Sets, ($pageIterator - 1) * $perPage, $perPage);
    $img = GenerateModelIndex($Sets2Process, $Images, $finalWidth, $finalHeight);
    if (is_null($img)) {
        $img = imagecreatefromjpeg($pathPrefix . 'images/missing.jpg');
    }
    $CacheImage = new CacheImage($uuid);
    $CacheImage->setModelIndexID($ModelID);
    $CacheImage->setKind(CACHEIMAGE_KIND_INDEX);
    $CacheImage->setImageWidth($finalWidth);
    $CacheImage->setImageHeight($finalHeight);
    $CacheImage->setSequenceNumber($pageIterator);
    $CacheImage->setSequenceTotal(ceil(count($Sets) / $perPage));
    CacheImage::Insert($CacheImage, $CurrentUser);
    imagejpeg($img, $CacheImage->getFilenameOnDisk());
    imagedestroy($img);
    $cacheImages[] = $CacheImage;
    $pageIterator++;
}
if ($outputMode == EXPORT_OPTION_IMAGE && count($cacheImages) == 1) {
    $CacheImage = $cacheImages[0];
    Image::OutputImage($CacheImage->getFilenameOnDisk(), $CacheImage->getImageWidth(), $CacheImage->getImageHeight(), TRUE, NULL, $PromptDownload ? sprintf('%1$s.jpg', $Model->GetFullName()) : NULL);
Пример #14
0
 public function action_get_students()
 {
     if (!$this->request->post('course_id')) {
         $response = '<p>No Course Selected</p>';
         echo json_encode(array('html' => $response));
         exit;
     }
     $course = ORM::factory('course', $this->request->post('course_id'));
     $users = Model_Course::get_students($course);
     $cacheimage = CacheImage::instance();
     $view = View::factory('course/ajax_show_students')->bind('cacheimage', $cacheimage)->bind('course', $course)->bind('users', $users);
     $response = $this->response->body($view)->body();
     echo json_encode(array('html' => $response));
 }
Пример #15
0
 protected function menu_init()
 {
     $this->view->bind('topmenu', $topmenu)->bind('sidemenu', $sidemenu)->bind('coursemenu', $coursemenu)->bind('myaccount', $myaccount)->bind('image', $image)->bind('role', $role)->bind('username', $username)->bind('user', $user);
     if (!Auth::instance()->logged_in()) {
         $role = 'guest';
     } else {
         $user = Auth::instance()->get_user();
         $role = $user->role()->name;
         $username = Auth::instance()->get_user()->firstname;
         //if ($user->is_role('student') || $user->is_role('parent') || $user->is_role('admin')) {
         $avatar = Auth::instance()->get_user()->avatar;
         $avatar = $avatar === null ? '' : $avatar;
         $img_user = CacheImage::instance()->resize($avatar, 72, 72);
         $childs = ORM::factory('user')->where('parent_user_id', '=', $user->id)->find_all();
         $img_child = array();
         foreach ($childs as $child) {
             $child_avatar = $child->avatar;
             $child_avatar = $child_avatar === null ? '' : $child_avatar;
             $img_child[$child->firstname] = CacheImage::instance()->resize($child_avatar, 30, 30);
         }
         $change_img_url = Url::site('account');
         $view_avatar = View::factory('account/sidemenu/' . strtolower($role))->bind('avatar_user', $img_user)->bind('avatar_students', $img_child)->bind('user', $user)->bind('role', $role)->bind('change_img_url', $change_img_url);
         $this->view->set('avatar', $view_avatar);
         //}
     }
     $menu = Acl_Menu::factory($role);
     // var_dump($menu); exit;
     $topmenu = $menu->get('topmenu');
     $sidemenu = $menu->get('sidemenu');
     $coursemenu = $menu->get('coursemenu');
     $myaccount = $menu->get('myaccount');
     $institution = ORM::factory('institution', $id = 1);
     $image = CacheImage::instance()->resize($institution->logo, 240, 60);
 }
Пример #16
0
$FileToFind = '';
$CacheFolder = NULL;
$CacheImages = CacheImage::GetCacheImages();
if (isset($argv) && $argc > 0) {
    $CacheFolder = sprintf('%1$s/cache', dirname($_SERVER['PHP_SELF']));
} else {
    $CacheFolder = 'cache';
}
/* @var $it RecursiveIteratorIterator */
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($CacheFolder, FileSystemIterator::SKIP_DOTS | FileSystemIterator::CURRENT_AS_FILEINFO));
/* @var $file SplFileInfo */
foreach ($it as $file) {
    $idToFind = $file->getBasename('.jpg');
    $matches = array();
    if (preg_match_all('/^(?<Prefix>[MXSIV]-)?[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?<Suffix>-[1-9][0-9]*-[1-9][0-9]*)?$/i', $idToFind, $matches) > 0) {
        $CacheImageInDB = CacheImage::GetCacheImages(new CacheImageSearchParameters(str_ireplace($matches['Prefix'], '', str_ireplace($matches['Suffix'], '', $idToFind))));
        if (!$CacheImageInDB) {
            unlink($file->getRealPath());
        }
    }
}
/* @var $CacheImage CacheImage */
foreach ($CacheImages as $CacheImage) {
    $FileToFind = $CacheImage->getFilenameOnDisk();
    if (!file_exists($FileToFind)) {
        CacheImage::Delete($CacheImage, $CurrentUser);
    }
}
$infoSuccess = new Info($lang->g('MessageCacheImagesCleaned'));
Info::AddInfo($infoSuccess);
HTMLstuff::RefererRedirect();