예제 #1
0
 /**
  * Loads the gadget model file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @return  mixed   Model class object on successful, Jaws_Error otherwise
  */
 public function &loadInstaller()
 {
     $classname = $this->gadget->name . '_Installer';
     $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . '/Installer.php';
     if (!file_exists($file)) {
         return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
     }
     include_once $file;
     if (!Jaws::classExists($classname)) {
         return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
     }
     $objInstaller = new $classname($this->gadget);
     return $objInstaller;
 }
예제 #2
0
파일: Hook.php 프로젝트: juniortux/jaws
 /**
  * Loads the gadget hook file class in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string  $hook  Hook name
  * @return  mixed   Hook class object on successful, Jaws_Error otherwise
  */
 public function &load($hook)
 {
     // filter non validate character
     $hook = preg_replace('/[^[:alnum:]_]/', '', $hook);
     if (!isset($this->objects[$hook])) {
         $classname = $this->gadget->name . '_Hooks_' . $hook;
         $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . "/Hooks/{$hook}.php";
         if (!file_exists($file)) {
             return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
         }
         include_once $file;
         if (!Jaws::classExists($classname)) {
             return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
         }
         $this->objects[$hook] = new $classname($this->gadget);
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, "Loaded gadget hook: [{$classname}]");
     }
     return $this->objects[$hook];
 }
예제 #3
0
파일: Model.php 프로젝트: juniortux/jaws
 /**
  * Loads the gadget model file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string  $filename   Model class file name
  * @return  mixed   Model class object on successful, Jaws_Error otherwise
  */
 public function &loadAdmin($filename = '')
 {
     // filter non validate character
     $filename = preg_replace('/[^[:alnum:]_]/', '', $filename);
     if (!isset($this->objects['AdminModel'][$filename])) {
         if (empty($filename)) {
             $classname = $this->gadget->name . '_AdminModel';
             $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . '/AdminModel.php';
             if (!file_exists($file)) {
                 return $this;
             }
         } else {
             $classname = $this->gadget->name . "_Model_Admin_{$filename}";
             $file = JAWS_PATH . 'gadgets/' . $this->gadget->name . "/Model/Admin/{$filename}.php";
         }
         if (!file_exists($file)) {
             return Jaws_Error::raiseError("File [{$file}] not exists!", __FUNCTION__);
         }
         include_once $file;
         if (!Jaws::classExists($classname)) {
             return Jaws_Error::raiseError("Class [{$classname}] not exists!", __FUNCTION__);
         }
         $this->objects['AdminModel'][$filename] = new $classname($this->gadget);
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, "Loaded gadget model: [{$classname}]");
     }
     return $this->objects['AdminModel'][$filename];
 }
예제 #4
0
파일: ControlPanel.php 프로젝트: uda/jaws
 /**
  * Calls default action
  *
  * @access  public
  * @return  string   XHTML template content
  */
 function DefaultAction()
 {
     $gadgetsections = array();
     $cmpModel = Jaws_Gadget::getInstance('Components')->model->load('Gadgets');
     $gadgets = $cmpModel->GetGadgetsList(null, true, true);
     unset($gadgets['ControlPanel']);
     foreach ($gadgets as $gadget => $gInfo) {
         if ($this->gadget->GetPermission('default_admin', '', $gadget)) {
             $section = $gInfo['section'];
             if (!isset($gadgetsections[$section])) {
                 $gadgetsections[$section] = array();
             }
             $gadgetsections[$section][] = array('name' => $gadget, 'tname' => $gInfo['title'], 'desc' => $gInfo['description']);
         }
     }
     if ($this->gadget->registry->fetch('show_viewsite', 'Settings') == 'true') {
         $gadgetsections['general'][] = array('name' => 'Index', 'tname' => _t('GLOBAL_VIEW_SITE'), 'desc' => _t('GLOBAL_VIEW_SITE'));
     }
     // Load the template
     $tpl = $this->gadget->template->loadAdmin('ControlPanel.html');
     $this->AjaxMe('script.js');
     foreach ($gadgetsections as $section => $gadgets) {
         $tpl->SetBlock('main');
         $tpl->SetVariable('title', _t('GLOBAL_GI_' . strtoupper($section)));
         foreach ($gadgets as $gadget) {
             $tpl->SetBlock('main/item');
             $tpl->SetVariable('name', $gadget['tname']);
             $tpl->SetVariable('desc', $gadget['desc']);
             if ($gadget['name'] === 'Index') {
                 $tpl->SetVariable('icon', Jaws::CheckImage('gadgets/ControlPanel/Resources/images/view_site.png'));
                 $tpl->SetVariable('url', $GLOBALS['app']->getSiteURL('/'));
             } else {
                 $tpl->SetVariable('icon', Jaws::CheckImage('gadgets/' . $gadget['name'] . '/Resources/images/logo.png'));
                 $tpl->SetVariable('url', BASE_SCRIPT . '?gadget=' . $gadget['name']);
             }
             $tpl->ParseBlock('main/item');
         }
         $tpl->ParseBlock('main');
     }
     if ($this->gadget->GetPermission('default_admin', '', 'Components')) {
         //Count non-installed gadgets
         $noninstalled = $cmpModel->GetGadgetsList(null, false);
         if (count($noninstalled) > 0) {
             $tpl->SetBlock('notifybox');
             $tpl->SetVariable('title', _t('COMPONENTS_GADGETS_NOTINSTALLED'));
             foreach ($noninstalled as $key => $gadget) {
                 $tpl->SetBlock('notifybox/item');
                 $gadgetCompleteDesc = $gadget['title'] . ' - ' . $gadget['description'];
                 $icon = Jaws::CheckImage('gadgets/' . $key . '/Resources/images/logo.png');
                 $tpl->SetVariable('title', $gadgetCompleteDesc);
                 $tpl->SetVariable('name', $gadget['title']);
                 $tpl->SetVariable('icon', $icon);
                 $tpl->SetVariable('url', BASE_SCRIPT . '?gadget=Components&action=InstallGadget&comp=' . $key);
                 $tpl->SetVariable('install', _t('COMPONENTS_INSTALL'));
                 $tpl->ParseBlock('notifybox/item');
             }
             $tpl->ParseBlock('notifybox');
         }
         //Count out date gadgets
         $nonupdated = $cmpModel->GetGadgetsList(null, true, false);
         if (count($nonupdated) > 0) {
             $tpl->SetBlock('notifybox');
             $tpl->SetVariable('title', _t('COMPONENTS_GADGETS_OUTDATED'));
             foreach ($nonupdated as $key => $gadget) {
                 $tpl->SetBlock('notifybox/item');
                 $gadgetCompleteDesc = $gadget['title'] . ' - ' . $gadget['description'];
                 $icon = Jaws::CheckImage('gadgets/' . $key . '/Resources/images/logo.png');
                 $tpl->SetVariable('title', $gadgetCompleteDesc);
                 $tpl->SetVariable('name', $gadget['title']);
                 $tpl->SetVariable('icon', $icon);
                 $tpl->SetVariable('url', BASE_SCRIPT . '?gadget=Components&action=UpgradeGadget&comp=' . $key);
                 $tpl->SetVariable('install', _t('COMPONENTS_UPDATE'));
                 $tpl->ParseBlock('notifybox/item');
             }
             $tpl->ParseBlock('notifybox');
         }
     }
     // login history
     if (Jaws_Gadget::IsGadgetInstalled('Logs')) {
         $logModel = Jaws_Gadget::getInstance('Logs')->model->load('Logs');
         $logs = $logModel->GetLogs(array('gadget' => 'Users', 'action' => 'Login', 'user' => $GLOBALS['app']->Session->GetAttribute('user')), 10);
         if (!Jaws_Error::IsError($logs) && !empty($logs)) {
             $tpl->SetBlock('login_history');
             $date = Jaws_Date::getInstance();
             $tpl->SetVariable('title', _t('LOGS_LOGIN_HISTORY'));
             foreach ($logs as $log) {
                 $tpl->SetBlock('login_history/item');
                 $tpl->SetVariable('ip', long2ip($log['ip']));
                 $tpl->SetVariable('agent', $log['agent']);
                 $tpl->SetVariable('status_code', $log['status']);
                 $tpl->SetVariable('status_title', _t('GLOBAL_HTTP_ERROR_TITLE_' . $log['status']));
                 $tpl->SetVariable('icon', 'images/stock/' . ($log['status'] == 200 ? 'info.png' : 'stop.png'));
                 $tpl->SetVariable('date', $date->Format($log['insert_time'], 'd MN Y H:i'));
                 $tpl->ParseBlock('login_history/item');
             }
             $tpl->ParseBlock('login_history');
         }
     }
     $last_checking = unserialize($this->gadget->registry->fetch('update_last_checking'));
     $do_checking = time() - $last_checking['time'] > 86400;
     // lesser do checking if need check
     $do_checking = $do_checking && mt_rand(1, 10) == mt_rand(1, 10);
     $tpl->SetBlock('versionbox');
     $tpl->SetVariable('do_checking', (int) $do_checking);
     $tpl->SetVariable('jaws_version', JAWS_VERSION);
     $tpl->SetVariable('latest_jaws_version', $last_checking['version']);
     $tpl->SetVariable('lbl_latest_jaws_version', _t('CONTROLPANEL_LATEST_JAWS_VERSION'));
     $tpl->ParseBlock('versionbox');
     return $tpl->Get();
 }
예제 #5
0
파일: Layout.php 프로젝트: juniortux/jaws
 /**
  * Returns the HTML content to manage the layout in the browser
  *
  * @access  public
  * @return  string  XHTML template content
  */
 function Layout()
 {
     $rqst = jaws()->request->fetch(array('user', 'theme', 'index_layout'));
     // dashboard_user
     if (empty($rqst['user']) && $this->gadget->GetPermission('ManageLayout')) {
         $user = 0;
     } else {
         $GLOBALS['app']->Session->CheckPermission('Users', 'ManageDashboard');
         $user = (int) $GLOBALS['app']->Session->GetAttribute('user');
     }
     // theme
     @(list($rqst['theme'], $rqst['locality']) = explode(',', $rqst['theme']));
     $default_theme = unserialize($this->gadget->registry->fetchByUser('theme', 'Settings', $user));
     if (empty($rqst['theme']) || $rqst['locality'] == $default_theme['locality'] && $rqst['theme'] == $default_theme['name']) {
         $theme = $default_theme['name'];
         $theme_locality = $default_theme['locality'];
     } else {
         $this->gadget->CheckPermission('ManageThemes');
         $this->UpdateTheme($rqst['theme'], $rqst['locality'], $user);
         $default_theme = unserialize($this->gadget->registry->fetchByUser('theme', 'Settings', $user));
         $theme = $default_theme['name'];
         $theme_locality = $default_theme['locality'];
     }
     $GLOBALS['app']->SetTheme($theme, $theme_locality);
     // index_layout
     $index_layout = (bool) $rqst['index_layout'];
     $lModel = $this->gadget->model->loadAdmin('Layout');
     $eModel = $this->gadget->model->loadAdmin('Elements');
     $t_item = $this->gadget->template->load('LayoutManager.html');
     $t_item->SetBlock('working_notification');
     $t_item->SetVariable('loading-message', _t('GLOBAL_LOADING'));
     $working_box = $t_item->ParseBlock('working_notification');
     $t_item->Blocks['working_notification']->Parsed = '';
     $t_item->SetBlock('msgbox-wrapper');
     $responses = $GLOBALS['app']->Session->PopLastResponse();
     if ($responses) {
         foreach ($responses as $msg_id => $response) {
             $t_item->SetBlock('msgbox-wrapper/msgbox');
             $t_item->SetVariable('text', $response['text']);
             $t_item->SetVariable('type', $response['type']);
             $t_item->SetVariable('msg-id', $msg_id);
             $t_item->ParseBlock('msgbox-wrapper/msgbox');
         }
     }
     $msg_box = $t_item->ParseBlock('msgbox-wrapper');
     $t_item->Blocks['msgbox-wrapper']->Parsed = '';
     $t_item->SetBlock('drag_drop');
     $t_item->SetVariable('empty_section', _t('LAYOUT_SECTION_EMPTY'));
     $t_item->SetVariable('display_always', _t('LAYOUT_ALWAYS'));
     $t_item->SetVariable('display_never', _t('LAYOUT_NEVER'));
     $t_item->SetVariable('displayWhenTitle', _t('LAYOUT_CHANGE_DW'));
     $t_item->SetVariable('actionsTitle', _t('LAYOUT_ACTIONS'));
     $t_item->SetVariable('confirmDelete', _t('LAYOUT_CONFIRM_DELETE'));
     $dragdrop = $t_item->ParseBlock('drag_drop');
     $t_item->Blocks['drag_drop']->Parsed = '';
     // Init layout
     $GLOBALS['app']->InstanceLayout();
     $fakeLayout = new Jaws_Layout();
     $fakeLayout->Load('', $index_layout ? 'index.html' : 'layout.html');
     $fakeLayout->AddScriptLink('libraries/mootools/core.js');
     $fakeLayout->AddScriptLink('libraries/mootools/more.js');
     $fakeLayout->AddScriptLink('include/Jaws/Resources/Ajax.js');
     $fakeLayout->AddScriptLink('gadgets/Layout/Resources/script.js');
     $layoutContent = $fakeLayout->_Template->Blocks['layout']->Content;
     $layoutContent = preg_replace('$<body([^>]*)>$i', '<body\\1>' . $working_box . $msg_box . $this->LayoutBar($theme, $theme_locality, $user, $index_layout), $layoutContent);
     $layoutContent = preg_replace('$</body([^>]*)>$i', $dragdrop . '</body\\1>', $layoutContent);
     $fakeLayout->_Template->Blocks['layout']->Content = $layoutContent;
     $fakeLayout->_Template->SetVariable('site-title', $this->gadget->registry->fetch('site_name', 'Settings'));
     $fakeLayout->AddHeadLink(PIWI_URL . 'piwidata/css/default.css', 'stylesheet', 'text/css', 'default');
     $fakeLayout->AddHeadLink('gadgets/Layout/Resources/style.css', 'stylesheet', 'text/css');
     foreach ($fakeLayout->_Template->Blocks['layout']->InnerBlock as $name => $data) {
         if ($name == 'head') {
             continue;
         }
         $fakeLayout->_Template->SetBlock('layout/' . $name);
         $js_section_array = '<script type="text/javascript">items[\'' . $name . '\'] = new Array(); sections.push(\'' . $name . '\');</script>';
         $gadgets = $lModel->GetGadgetsInSection($index_layout, $name, $user);
         if (!is_array($gadgets)) {
             continue;
         }
         foreach ($gadgets as $gadget) {
             if ($gadget['gadget'] == '[REQUESTEDGADGET]') {
                 $t_item->SetBlock('item');
                 $t_item->SetVariable('section_id', $name);
                 $t_item->SetVariable('item_id', $gadget['id']);
                 $t_item->SetVariable('user', $user);
                 $t_item->SetVariable('pos', $gadget['layout_position']);
                 $t_item->SetVariable('gadget', _t('LAYOUT_REQUESTED_GADGET'));
                 $t_item->SetVariable('action', '&nbsp;');
                 $t_item->SetVariable('icon', 'gadgets/Layout/Resources/images/requested-gadget.png');
                 $t_item->SetVariable('description', _t('LAYOUT_REQUESTED_GADGET_DESC'));
                 $t_item->SetVariable('lbl_display_when', _t('LAYOUT_DISPLAY_IN'));
                 $t_item->SetVariable('display_when', _t('GLOBAL_ALWAYS'));
                 $t_item->SetVariable('void_link', 'return;');
                 $t_item->SetVariable('section_name', $name);
                 $t_item->SetVariable('delete', 'void(0);');
                 $t_item->SetVariable('delete-img', 'gadgets/Layout/Resources/images/no-delete.gif');
                 $t_item->SetVariable('lbl_delete', _t('GLOBAL_DELETE'));
                 $t_item->SetVariable('item_status', 'none');
                 $t_item->ParseBlock('item');
             } else {
                 $controls = '';
                 $t_item->SetBlock('item');
                 $t_item->SetVariable('section_id', $name);
                 $t_item->SetVariable('pos', $gadget['layout_position']);
                 $t_item->SetVariable('item_id', $gadget['id']);
                 $t_item->SetVariable('base_script_url', $GLOBALS['app']->getSiteURL('/' . BASE_SCRIPT));
                 $t_item->SetVariable('icon', Jaws::CheckImage('gadgets/' . $gadget['gadget'] . '/Resources/images/logo.png'));
                 $t_item->SetVariable('delete', "deleteElement('{$gadget['id']}');");
                 $t_item->SetVariable('delete-img', 'gadgets/Layout/Resources/images/delete-item.gif');
                 $t_item->SetVariable('lbl_delete', _t('GLOBAL_DELETE'));
                 $actions = $eModel->GetGadgetLayoutActions($gadget['gadget'], true);
                 if (isset($actions[$gadget['gadget_action']]) && Jaws_Gadget::IsGadgetEnabled($gadget['gadget'])) {
                     $t_item->SetVariable('gadget', _t(strtoupper($gadget['gadget']) . '_TITLE'));
                     if (isset($actions[$gadget['gadget_action']]['name'])) {
                         $t_item->SetVariable('action', $actions[$gadget['gadget_action']]['name']);
                     } else {
                         $t_item->SetVariable('action', $gadget['gadget_action']);
                     }
                     $t_item->SetVariable('description', $actions[$gadget['gadget_action']]['desc']);
                     $t_item->SetVariable('item_status', 'none');
                 } else {
                     $t_item->SetVariable('gadget', $gadget['gadget']);
                     $t_item->SetVariable('action', $gadget['gadget_action']);
                     $t_item->SetVariable('description', $gadget['gadget_action']);
                     $t_item->SetVariable('item_status', 'line-through');
                 }
                 unset($actions);
                 $t_item->SetVariable('controls', $controls);
                 $t_item->SetVariable('void_link', '');
                 $t_item->SetVariable('lbl_display_when', _t('LAYOUT_DISPLAY_IN'));
                 if ($gadget['display_when'] == '*') {
                     $t_item->SetVariable('display_when', _t('GLOBAL_ALWAYS'));
                 } elseif (empty($gadget['display_when'])) {
                     $t_item->SetVariable('display_when', _t('LAYOUT_NEVER'));
                 } else {
                     $t_item->SetVariable('display_when', str_replace(',', ', ', $gadget['display_when']));
                 }
                 $t_item->ParseBlock('item');
             }
         }
         $fakeLayout->_Template->SetVariable('ELEMENT', '<div id="layout_' . $name . '" class="layout-section" title="' . $name . '">' . $js_section_array . $t_item->Get() . '</div>');
         $fakeLayout->_Template->ParseBlock('layout/' . $name);
         $t_item->Blocks['item']->Parsed = '';
     }
     return $fakeLayout->Get(true);
 }
예제 #6
0
파일: Gadget.php 프로젝트: juniortux/jaws
 /**
  * Returns an URL to the gadget icon
  *
  * @access  public
  * @return  string Icon URL
  * @param   string $name Name of the gadget, if no name is provided use instanced gadget
  */
 function GetIconURL($name = null)
 {
     if (empty($name)) {
         $name = $this->name;
     }
     $image = Jaws::CheckImage('gadgets/' . $name . '/Resources/images/logo.png');
     return $image;
 }
예제 #7
0
파일: Jaws.php 프로젝트: juniortux/jaws
 /**
  * Loads the plugin file in question, makes a instance and
  * stores it globally for later use so we do not have duplicates
  * of the same instance around in our code.
  *
  * @access  public
  * @param   string $plugin Name of the plugin
  * @return  mixed Plugin class object on successful, Jaws_Error otherwise
  */
 function LoadPlugin($plugin)
 {
     // filter non validate character
     $plugin = preg_replace('/[^[:alnum:]_]/', '', $plugin);
     if (!isset($this->_Plugins[$plugin])) {
         if (!is_dir(JAWS_PATH . 'plugins/' . $plugin)) {
             $error = new Jaws_Error(_t('GLOBAL_ERROR_PLUGIN_DOES_NOT_EXIST', $plugin), 'Plugin directory check');
             return $error;
         }
         // is plugin available?
         if (defined('JAWS_AVAILABLE_PLUGINS')) {
             static $available_plugins;
             if (!isset($available_plugins)) {
                 $available_plugins = array_filter(array_map('trim', explode(',', JAWS_AVAILABLE_PLUGINS)));
             }
             if (!in_array($plugin, $available_plugins)) {
                 $error = new Jaws_Error(_t('GLOBAL_ERROR_PLUGIN_NOT_AVAILABLE', $plugin), 'Plugin availability check');
                 return $error;
             }
         }
         $file = JAWS_PATH . 'plugins/' . $plugin . '/Plugin.php';
         if (file_exists($file)) {
             include_once $file;
         }
         $plugin_class = $plugin . '_Plugin';
         if (!Jaws::classExists($plugin_class)) {
             // return a error
             $error = new Jaws_Error(_t('GLOBAL_ERROR_CLASS_DOES_NOT_EXIST', $plugin_class), 'Plugin class check');
             return $error;
         }
         $objPlugin = new $plugin_class($plugin);
         if (Jaws_Error::IsError($objPlugin)) {
             $error = new Jaws_Error(_t('GLOBAL_ERROR_FAILED_CREATING_INSTANCE', $file, $plugin_class), 'Plugin file loading');
             return $error;
         }
         $this->_Plugins[$plugin] = $objPlugin;
         $GLOBALS['log']->Log(JAWS_LOG_DEBUG, 'Loaded plugin: ' . $plugin);
     }
     return $this->_Plugins[$plugin];
 }
예제 #8
0
파일: InitPiwi.php 프로젝트: juniortux/jaws
<?php

/**
 * Initiates Piwi Project.
 *
 * @category   Application
 * @package    Core
 * @author     Ali Fazelzadeh <*****@*****.**>
 * @copyright  2007-2014 Jaws Development Group
 * @license    http://www.gnu.org/copyleft/lesser.html
 */
if (!Jaws::classExists('Piwi')) {
    if (!defined('PIWI_URL')) {
        define('PIWI_URL', 'libraries/piwi/');
    }
    if (!defined('PIWI_CREATE_PIWIXML')) {
        define('PIWI_CREATE_PIWIXML', 'no');
    }
    if (!defined('PIWI_LOAD')) {
        define('PIWI_LOAD', 'SMART');
    }
    require JAWS_PATH . 'libraries/piwi/Piwi.php';
    $config = array('LINK_PRIFIX' => '', 'DATAGRID_ACTION_LABEL' => _t('GLOBAL_ACTIONS'), 'DATAGRID_PAGER_PAGEBY' => 10, 'DATAGRID_PAGER_MODE' => 'PIWI_PAGER_NORMAL', 'CLASS_ODD' => 'piwi_option_odd', 'CLASS_EVEN' => 'piwi_option_even', 'DATAGRID_CLASS_CSS' => 'jawsDatagrid', 'DATAGRID_PAGER_LABEL_FIRST' => _t('GLOBAL_FIRST'), 'DATAGRID_PAGER_LABEL_PREV' => _t('GLOBAL_PREVIOUS'), 'DATAGRID_PAGER_LABEL_NEXT' => _t('GLOBAL_NEXT'), 'DATAGRID_PAGER_LABEL_LAST' => _t('GLOBAL_LAST'), 'PIWI_NAME_AS_ID' => true);
    Piwi::exportConf($config);
}
예제 #9
0
파일: Image.php 프로젝트: Dulciane/jaws
 /**
  * Gets EXIF thumbnail
  *
  * @access  public
  * @param   string  $source Image path
  * @param   string  $unkown Unknown image to return if image doesn't have a thumb
  * @return  binary  Exif thumbnail
  */
 static function get_exif_thumbnail($source, $unknown)
 {
     if (strpos($source, '../')) {
         return false;
     }
     $ext = strtolower(substr($source, strrpos($source, '.') + 1));
     $valid_ext = array('jpg', 'jpeg');
     if (in_array($ext, $valid_ext)) {
         if (function_exists('exif_thumbnail') && filesize($source) > 0) {
             $image = exif_thumbnail($source, $width, $height, $type);
             if ($image !== false) {
                 header('Content-type: ' . image_type_to_mime_type($type));
                 return $image;
             }
         }
     }
     $unknown = Jaws::CheckImage($unknown);
     $ext = strtolower(substr($unknown, strrpos($unknown, '.') + 1));
     header('Content-type: image/' . $ext);
     return file_get_contents($unknown);
 }