public function getlinkAction()
 {
     // Parameter auslesen
     $link_to_page_id = Request::postParam('linkToPageId');
     $link_to_language_id = Request::postParam('linkToLanguageId');
     $link_to_anchor_name = Request::postParam('linkToAnchorName');
     // Parameter überprüfen
     if (!is_numeric($link_to_page_id) || $link_to_language_id == '') {
         $this->error(self::RESULT_ERROR_BAD_REQUEST);
         return;
     }
     $pages = new Pages();
     // Die absolute URL auslesen
     $absolute_url = $pages->getPageUrl($link_to_page_id, $link_to_language_id);
     // eine zum Stammverzeichnis des CMS relative URL daraus machen
     $base_url = Config::get()->baseUrl;
     $relative_url = UTF8String::substr($absolute_url, UTF8String::strlen($base_url), UTF8String::strlen($absolute_url));
     if ($link_to_anchor_name != '') {
         if ($relative_url != '') {
             $relative_url = rtrim($relative_url, '/') . '/';
         }
         $relative_url .= '#' . $link_to_anchor_name;
     }
     // Zurückgeben
     $this->success($relative_url);
 }
/**
 * Function: smarty_make_timestamp<br>
 * Purpose:  used by other smarty functions to make a timestamp from a string.
 *
 * @author   Monte Ohrt <monte at ohrt dot com>
 *
 * @param DateTime|int|UTF8String $string date object, timestamp or string that can be converted using strtotime()
 *
 * @return int
 */
function smarty_make_timestamp($string)
{
    if (empty($string)) {
        // use "now":
        return time();
    } elseif ($string instanceof DateTime) {
        return $string->getTimestamp();
    } elseif (strlen($string) == 14 && ctype_digit($string)) {
        // it is mysql timestamp format of YYYYMMDDHHMMSS?
        return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2), substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
    } elseif (is_numeric($string)) {
        // it is a numeric string, we handle it as timestamp
        return (int) $string;
    } else {
        // strtotime should handle it
        $time = strtotime($string);
        if ($time == -1 || $time === false) {
            // strtotime() was not able to parse $string, use "now":
            return time();
        }
        return $time;
    }
}
    public function getHtml()
    {
        $userGroups = $this->userGroups->getAll();
        $html = '';
        $yes = Translate::get('Yes');
        $no = Translate::get('No');
        if ($userGroups !== false) {
            if (count($userGroups) > 0) {
                foreach ($userGroups as $userGroup) {
                    $modules_text = '';
                    $modules = $this->userGroups->getAclResources($userGroup['id']);
                    if ($modules !== false) {
                        if (count($modules) > 0) {
                            foreach ($modules as $module_acl_resource_id) {
                                $module_acl_resource = Acl::getResourceDataById($module_acl_resource_id);
                                if ($module_acl_resource !== false) {
                                    $modules_text .= ($modules_text != '' ? ', ' : '') . $module_acl_resource['description'];
                                }
                            }
                        }
                    }
                    if (UTF8String::strlen($modules_text) > 75) {
                        $modules_text = UTF8String::substr($modules_text, 0, 75) . '...';
                    }
                    $html .= '
							<tr data-id="' . $userGroup['id'] . '">
								<td><input type="checkbox" name="usergroups[' . $userGroup['id'] . ']" value="1" id="usergroup_' . $userGroup['id'] . '"></td>
								<td>' . $userGroup['name'] . '</td>
								<td>' . $userGroup['level'] . '</td>
								<td>' . ($userGroup['action-create'] > 0 ? $yes : $no) . '</td>
								<td>' . ($userGroup['action-edit'] > 0 ? $yes : $no) . '</td>
								<td>' . ($userGroup['action-publish'] > 0 ? $yes : $no) . '</td>
								<td>' . ($userGroup['action-delete'] > 0 ? $yes : $no) . '</td>
								<td>' . $modules_text . '</td>
							</tr>
						';
                }
            }
        }
        return $html;
    }
Exemplo n.º 4
0
 public function getSearchResultForFrontend($search_string, $columns, $page_id, $language_id)
 {
     if (is_array($columns) && count($columns) == 0) {
         $columns = null;
     }
     if ($columns === null) {
         $columns = array();
         foreach ($this->fields as $field) {
             if (isset($field['dbFieldType'])) {
                 if ($field['dbFieldType'] == 'string') {
                     $columns[] = $field['id'];
                 }
             }
         }
     } else {
         $columns = array_map(function ($column_id) {
             return trim($column_id);
         }, $columns);
         $columns = array_filter($columns, function ($string) {
             return UTF8String::strlen($string) > 0;
         });
     }
     $sanitized_search_string = UTF8String::strtolower(trim($search_string));
     $search_array = array_filter(explode(' ', $sanitized_search_string), function ($string) {
         return UTF8String::strlen($string) > 0;
     });
     $result = array();
     if (count($columns) > 0 && count($search_array) > 0) {
         $rows = $this->getAllRowsForFrontend($page_id, $language_id);
         if ($rows !== false) {
             if (count($rows) > 0) {
                 foreach ($rows as $row) {
                     $row_contains_search_string = false;
                     foreach ($columns as $column_id) {
                         if (isset($row[$column_id])) {
                             if ($this->doesFieldValueContainSearchString($row[$column_id], $search_array)) {
                                 $row_contains_search_string = true;
                                 break;
                             }
                         }
                     }
                     if ($row_contains_search_string) {
                         $result[] = $row;
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 5
0
 public static function getCompleteUrl($uri, $protocol = null)
 {
     if ($protocol === null) {
         $protocol = Config::get()->standardProtocolForAbsoluteUrls;
     }
     $url = $uri;
     // Nur wenn Protokoll nicht angegeben ist...
     if (UTF8String::strpos($url, '://') === false) {
         // ggf. Server-Namen erg�nzen
         if (UTF8String::substr($url, 0, 1) == '/') {
             if ($_SERVER['HTTP_HOST'] !== '') {
                 $url = self::htmlEntities($_SERVER['HTTP_HOST']) . $url;
             } else {
                 $url = self::htmlEntities($_SERVER['SERVER_NAME']) . $url;
             }
         }
         // Protokoll erg�nzen
         $url = $protocol . $url;
     }
     return $url;
 }
 private function resizeImage($source, $parameters, $preview = false, $custom_settings = null)
 {
     // TODO *******
     //
     // Leider bietet diese drecks GD-Lib keine M�glichkeit, einen "out of memory"-Fehler zu umgehen,
     // oder vorauszusehen, wann ein Bild zu gro� f�r den Speicher ist.
     //
     // Daher sollte hier noch ein Mechanismus geschaffen werden, um voraus zu berechnen, wieviel Speicher
     // es brauchen wird, das Bild zu laden und einen Fehlercode zur�ckzugeben, falls der Speicher nicht reicht!
     // gew�nschte JPEG-Kompression feststellen
     $source_path_info = pathinfo($source);
     $source_ext = UTF8String::strtolower($source_path_info['extension']);
     if ($source_ext == 'jpg' || $source_ext == 'jpg' || $source_ext == 'jpe') {
         if ($this->isParameterPositiveNumber($parameters, 'jpegQuality')) {
             $jpeqQuality = $parameters['jpegQuality'];
         } else {
             $jpeqQuality = Config::get()->jpegQuality;
         }
     } else {
         $jpeqQuality = null;
     }
     // Erstmal keine Gr��en�nderung annehmen
     $mode = 'copy';
     // Pr�fen, ob maximal-Werte angegeben sind
     $max_width = 0;
     $max_height = 0;
     if ($this->isParameterPositiveNumber($parameters, 'maxWidth')) {
         $max_width = $parameters['maxWidth'];
     }
     if ($this->isParameterPositiveNumber($parameters, 'maxHeight')) {
         $max_height = $parameters['maxHeight'];
     }
     // Wenn Maximal-Werte gesetzt sind, Einpassung annehmen
     if ($max_width > 0 || $max_height > 0) {
         $mode = 'fitIn';
     }
     // Pr�fen, ob genaue Abmessungen gefordert sind
     $force_width = 0;
     $force_height = 0;
     if ($this->isParameterPositiveNumber($parameters, 'forceWidth')) {
         $force_width = $parameters['forceWidth'];
     }
     if ($this->isParameterPositiveNumber($parameters, 'forceHeight')) {
         $force_height = $parameters['forceHeight'];
     }
     // ggf. Benutzereingaben auswerten
     if ($custom_settings !== null) {
         // der Benutzer hat selbst eine Gr��e festgelegt...
         // diese Werte �berschreiben forceWidth und forceHeight
         if ($this->sanitizeBoolean($custom_settings['customSize'])) {
             if ($this->sanitizeInteger($custom_settings['width']) > 0) {
                 $force_width = $this->sanitizeInteger($custom_settings['width']);
             } else {
                 $force_width = 0;
             }
             if ($this->sanitizeInteger($custom_settings['height']) > 0) {
                 $force_height = $this->sanitizeInteger($custom_settings['height']);
             } else {
                 $force_height = 0;
             }
         }
         // der Benutzer hat einen Ausschnitt festgelegt oder die s/w option gew�hlt...
         if ($this->sanitizeBoolean($custom_settings['customCrop']) || $this->sanitizeBoolean($custom_settings['convertToBlackAndWhite'])) {
             $tmp_file = APPLICATION_ROOT . 'user-data/tmp/images/' . $this->getRandomFilenameWithTimeStamp($source);
             $tmp_image = WideImage::load($source);
             if ($this->sanitizeBoolean($custom_settings['customCrop'])) {
                 $tmp_image = $tmp_image->crop($this->sanitizeInteger($custom_settings['cropX1']), $this->sanitizeInteger($custom_settings['cropY1']), $this->sanitizeInteger($custom_settings['cropX2']) - $this->sanitizeInteger($custom_settings['cropX1']), $this->sanitizeInteger($custom_settings['cropY2']) - $this->sanitizeInteger($custom_settings['cropY1']));
             }
             if ($this->sanitizeBoolean($custom_settings['convertToBlackAndWhite'])) {
                 $tmp_image = $tmp_image->asGrayscale();
             }
             $this->saveImage($tmp_image, $tmp_file, $jpeqQuality);
             $tmp_image->destroy();
             $source = $tmp_file;
         }
     }
     // Wenn genaue Abmessungen gefordert sind, entsprechenden Modus setzen...
     if ($force_width > 0 && $force_height > 0) {
         $mode = 'exact';
     } elseif ($force_width > 0) {
         $mode = 'forceWidth';
     } elseif ($force_height > 0) {
         $mode = 'forceHeight';
     }
     // Tempor�ren Dateinamen erstellen
     $temp_file_name = $this->getRandomFilenameWithTimeStamp($source);
     $relative_path_to_dest_file = 'user-data/tmp/images/' . $temp_file_name;
     $absolute_path_to_dest_file = APPLICATION_ROOT . $relative_path_to_dest_file;
     // Je nach Modus Bild kopieren / ge�nderte Version speichern
     $result = true;
     try {
         switch ($mode) {
             case 'copy':
                 // keine Gr��en�nderung erfoderlich
                 $result = FileUtils::copyFile($source, $absolute_path_to_dest_file);
                 break;
             case 'exact':
                 // Gr��e genau vorgegeben
                 $image = WideImage::load($source);
                 $image_dimensions = $this->getDimensions($image);
                 $resized_image = $image->resize($force_width, $force_height, 'outside', 'any');
                 $resized_image_dimensions = $this->getDimensions($resized_image);
                 $image->destroy();
                 if ($resized_image->getWidth() > $force_width || $resized_image->getHeight() > $force_height) {
                     $crop_x = 0;
                     if ($resized_image->getWidth() > $force_width) {
                         $crop_x = floor(($resized_image->getWidth() - $force_width) / 2);
                     }
                     $crop_y = 0;
                     if ($resized_image->getHeight() > $force_height) {
                         $crop_y = floor(($resized_image->getHeight() - $force_height) / 2);
                     }
                     $cropped_image = $resized_image->crop($crop_x, $crop_y, $force_width, $force_height);
                     $resized_image->destroy();
                     $this->saveImage($cropped_image, $absolute_path_to_dest_file, $jpeqQuality);
                     $cropped_image->destroy();
                 } else {
                     if ($this->equalDimensions($image_dimensions, $resized_image_dimensions)) {
                         FileUtils::copyFile($source, $absolute_path_to_dest_file);
                     } else {
                         $this->saveImage($resized_image, $absolute_path_to_dest_file, $jpeqQuality);
                     }
                     $resized_image->destroy();
                 }
                 break;
             case 'forceWidth':
                 // Breite vorgegeben
                 $image = WideImage::load($source);
                 $image_dimensions = $this->getDimensions($image);
                 $resized_image = $image->resize($force_width, null, 'outside', 'any');
                 $resized_image_dimensions = $this->getDimensions($resized_image);
                 $image->destroy();
                 if ($max_height > 0 && $resized_image->getHeight() > $max_height) {
                     $crop_y = 0;
                     if ($resized_image->getHeight() > $max_height) {
                         $crop_y = floor(($resized_image->getHeight() - $max_height) / 2);
                     }
                     $cropped_image = $resized_image->crop(0, $crop_y, $force_width, $max_height);
                     $resized_image->destroy();
                     $this->saveImage($cropped_image, $absolute_path_to_dest_file, $jpeqQuality);
                     $cropped_image->destroy();
                 } else {
                     if ($this->equalDimensions($image_dimensions, $resized_image_dimensions)) {
                         FileUtils::copyFile($source, $absolute_path_to_dest_file);
                     } else {
                         $this->saveImage($resized_image, $absolute_path_to_dest_file, $jpeqQuality);
                     }
                     $resized_image->destroy();
                 }
                 break;
             case 'forceHeight':
                 // H�he vorgegeben
                 $image = WideImage::load($source);
                 $image_dimensions = $this->getDimensions($image);
                 $resized_image = $image->resize(null, $force_height, 'outside', 'any');
                 $resized_image_dimensions = $this->getDimensions($resized_image);
                 $image->destroy();
                 if ($max_width > 0 && $resized_image->getWidth() > $max_width) {
                     $crop_x = 0;
                     if ($resized_image->getWidth() > $max_width) {
                         $crop_x = floor(($resized_image->getWidth() - $max_width) / 2);
                     }
                     $cropped_image = $resized_image->crop($crop_x, 0, $max_width, $force_height);
                     $resized_image->destroy();
                     $this->saveImage($cropped_image, $absolute_path_to_dest_file, $jpeqQuality);
                     $cropped_image->destroy();
                 } else {
                     if ($this->equalDimensions($image_dimensions, $resized_image_dimensions)) {
                         FileUtils::copyFile($source, $absolute_path_to_dest_file);
                     } else {
                         $this->saveImage($resized_image, $absolute_path_to_dest_file, $jpeqQuality);
                     }
                     $resized_image->destroy();
                 }
                 break;
             case 'fitIn':
                 // in angegebenes Rechteck einpassen
                 $image = WideImage::load($source);
                 $image_dimensions = $this->getDimensions($image);
                 if ($max_width == 0) {
                     $max_width = null;
                 }
                 if ($max_height == 0) {
                     $max_height = null;
                 }
                 $resized_image = $image->resize($max_width, $max_height, 'inside', 'down');
                 $resized_image_dimensions = $this->getDimensions($resized_image);
                 $image->destroy();
                 if ($this->equalDimensions($image_dimensions, $resized_image_dimensions)) {
                     FileUtils::copyFile($source, $absolute_path_to_dest_file);
                 } else {
                     $this->saveImage($resized_image, $absolute_path_to_dest_file, $jpeqQuality);
                 }
                 $resized_image->destroy();
                 break;
         }
     } catch (WideImage_Exception $e) {
         $result = false;
     }
     // im Erfolgsfall zum Stammverzeichnis relativen Pfad zur�ckgeben
     if ($result) {
         // M�glicherweise wird das Bild nochmal von einem geladenen Plugin bearbeitet
         $plugin_parameters = array('source' => $source, 'parameters' => $parameters, 'preview' => $preview, 'customSettings' => $custom_settings);
         Plugins::call(Plugins::AFTER_IMAGE_RESIZE, $plugin_parameters, $relative_path_to_dest_file);
         return $relative_path_to_dest_file;
     } else {
         return false;
     }
 }
 public function sanitizeBoolean($boolish_string)
 {
     if (is_bool($boolish_string)) {
         return $boolish_string;
     } else {
         if (is_numeric($boolish_string)) {
             $boolish_int = (int) $boolish_string;
             if ($boolish_int != 0) {
                 return true;
             } else {
                 return false;
             }
         } else {
             $boolish_string = trim(UTF8String::strtolower($boolish_string));
             if ($boolish_string == 'true') {
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
 public function onDataEditorPluginPrepareForOutput($parameters, &$data)
 {
     if ($parameters['fieldType'] == 'link') {
         $edit_data = null;
         if (isset($data)) {
             if (is_array($data)) {
                 if (isset($data['url'])) {
                     if (is_string($data['url'])) {
                         $edit_data = array('url' => $data['url']);
                         if (isset($data['newWindow'])) {
                             $edit_data['newWindow'] = $data['newWindow'];
                         } else {
                             $edit_data['newWindow'] = 'auto';
                         }
                         $edit_data['type'] = 'external';
                         $auto_link_target = '';
                         if (UTF8String::strtolower(UTF8String::substr($data['url'], 0, UTF8String::strlen('link://'))) == 'link://') {
                             $edit_data['type'] = 'internal';
                         } elseif (UTF8String::strtolower(UTF8String::substr($data['url'], 0, UTF8String::strlen('download://'))) == 'download://') {
                             $edit_data['type'] = 'download';
                         }
                         switch ($edit_data['type']) {
                             case 'external':
                                 $edit_data['url'] = $data['url'];
                                 $auto_link_target = '_blank';
                                 break;
                             case 'internal':
                                 $edit_data['url'] = Config::get()->baseUrl . UTF8String::substr($data['url'], UTF8String::strlen('link://'));
                                 $auto_link_target = '';
                                 break;
                             case 'download':
                                 $edit_data['url'] = Config::get()->baseUrl . 'user-data/downloads/' . UTF8String::substr($data['url'], UTF8String::strlen('download://'));
                                 $auto_link_target = '_blank';
                                 $edit_data['path'] = APPLICATION_ROOT . 'user-data/downloads/' . urldecode(UTF8String::substr($data['url'], UTF8String::strlen('download://')));
                                 $path_info = pathinfo($edit_data['path']);
                                 $edit_data['basename'] = isset($path_info['basename']) ? $path_info['basename'] : '';
                                 $edit_data['extension'] = isset($path_info['extension']) ? $path_info['extension'] : '';
                                 $edit_data['filename'] = isset($path_info['filename']) ? $path_info['filename'] : '';
                                 if (file_exists($edit_data['path'])) {
                                     $edit_data['filesize'] = @filesize($edit_data['path']);
                                 }
                                 break;
                             default:
                                 break;
                         }
                         switch ($edit_data['newWindow']) {
                             case 'yes':
                                 $edit_data['target'] = '_blank';
                                 break;
                             case 'no':
                                 $edit_data['target'] = '';
                                 break;
                             default:
                                 $edit_data['target'] = $auto_link_target;
                                 break;
                         }
                     }
                 }
             }
         }
         $data = $edit_data;
     }
 }
Exemplo n.º 9
0
            $action = 'default';
        }
        $method = $action . 'Action';
        // Datei inkludieren
        require_once APPLICATION_ROOT . 'system/core/backend/controllers/' . $folder . '/' . $file;
        // Prüfen, ob Klasse existiert
        if (!class_exists($class)) {
            Helpers::fatalError('Page not found (class "' . $class . '" doesn\'t exist in system/core/backend/controllers/' . $folder . '/' . $file . ')!', true);
        }
        // Klasse instanziieren
        $controller = new $class($module);
        // Prüfen, ob Methode existiert
        if (!method_exists($controller, $method)) {
            Helpers::fatalError('Page not found (class-method "' . $method . '" doesn\'t exist in class "' . $class . '" ist in system/core/backend/controllers/' . $folder . '/' . $file . ')!', true);
        }
        // View erzeugen und mit Controller verbinden
        $view = new View();
        $view->assignTemplate(APPLICATION_ROOT . 'system/core/backend/views/' . $folder . '/' . UTF8String::strtolower($file));
        $view->assign('baseUrl', Config::get()->baseUrl);
        $view->assign('moduleUrl', Config::get()->baseUrl . 'admin/' . $folder . '/' . $module . '/');
        $view->assign('publicUrl', Config::get()->baseUrl . 'system/core/backend/public/');
        $view->assign('backendLanguage', $language_id);
        $controller->assignView($view);
        // Action-Methode ausführen
        $controller->callActionMethod($action);
        // Ausgabe des Views...
        if ($controller->getView() != null) {
            $controller->getView()->output();
        }
    }
}
Exemplo n.º 10
0
 public function extract($path_string, &$data = null)
 {
     if ($data === null) {
         $data = $this->getArray();
     }
     if (!is_array($data)) {
         return null;
     }
     $path = $this->getPathFromString($path_string);
     $pointer =& $data;
     $counter = 0;
     if (count($path) > 0) {
         foreach ($path as $key) {
             $index = $key;
             if (UTF8String::substr($key, 0, 1) == '[') {
                 if (UTF8String::substr($key, -1, 1) == ']') {
                     $number = $this->extendedTrim(UTF8String::substr($key, 1, UTF8String::strlen($key) - 2));
                     if (is_numeric($number)) {
                         $index = (int) $number;
                     }
                 }
             }
             if (isset($pointer[$index])) {
                 $pointer =& $pointer[$index];
                 if ($counter == count($path) - 1) {
                     return $pointer;
                 }
             } else {
                 break;
             }
             $counter++;
         }
     }
     return null;
 }
Exemplo n.º 11
0
 public static function parse()
 {
     if (!self::$parsed) {
         // Request String speichern
         self::$request_uri = $_SERVER['REQUEST_URI'];
         // Prüfen, ob HTTPs verwendet wird
         self::$request_secure = false;
         if (isset($_SERVER['HTTPS'])) {
             if ($_SERVER['HTTPS'] != '') {
                 self::$request_secure = true;
             }
         }
         // Den Teil, der von interesse ist, extrahieren
         // Wenn die baseUrl z.B. http://www.pixelproduction.de/cms/ lautet,
         // und der entsprechende Request-URI /cms/admin/bla/,
         // dann schneiden wir das /cms am Anfang heraus, da uns ja nur das /admin/bla/ interessiert...
         // So kann man das CMS in einem beliebigen Unter-Verzeichnis auf dem Server installieren
         // und alles funktioniert trotzdem :-)
         $base_request_string = self::extractRequestUri(Config::get()->baseUrl);
         if (UTF8String::substr(self::$request_uri, 0, UTF8String::strlen($base_request_string)) != $base_request_string) {
             die('Fehlerhafter REQUEST_URI oder fehlerhafte Konfiguration. Bitte wenden Sie sich an den Administrator dieser Website.');
         } else {
             self::$request_uri = UTF8String::substr(self::$request_uri, UTF8String::strlen($base_request_string), UTF8String::strlen(self::$request_uri));
         }
         // Die URI in ihre bestandteile (Pfad, Parameter, Anker) zerlegen
         // Laut PHP Doku muss es eine absolute, vollständige URL sein, ist aber egal, weil wir Protokoll und Server sowieso ignorieren,
         // also nehmen wir einfach irgeneinen Server an...
         $url = parse_url('http://www.pixelproduction.de/' . self::$request_uri);
         // Den Pfad auslesen und in seine Teile zerlegen und in Array ablegen
         self::$request_path = array();
         if (isset($url['path'])) {
             $url_path = trim($url['path'], '/');
             if ($url_path != '') {
                 self::$request_path = explode('/', $url_path);
             }
         }
         // ggf. die GET-Parameter in Array ablegen
         self::$request_parameters = array();
         if (isset($url['query'])) {
             $query = explode('&', $url['query']);
             if (is_array($query)) {
                 foreach ($query as $parameter) {
                     $key_value_pair = explode('=', $parameter);
                     if (is_array($key_value_pair)) {
                         if (isset($key_value_pair[0])) {
                             self::$request_parameters[$key_value_pair[0]] = '';
                             if (isset($key_value_pair[1])) {
                                 self::$request_parameters[$key_value_pair[0]] = $key_value_pair[1];
                             }
                         }
                     }
                 }
             }
         }
         // Herausfinden, ob das Frontend oder das Backend angefordert wird
         self::$front_end = true;
         if (count(self::$request_path) > 0) {
             // Wenn der erste Teil nach der Basis-URL "admin" ist, dann geht's zum Back-End, ansonsten zum Front-End
             $firstPathSegment = strtolower(self::$request_path[0]);
             self::$front_end = !in_array($firstPathSegment, array('admin', 'pm:api'));
             if ($firstPathSegment == 'admin') {
                 // Das "admin" braucht man nicht als ersten Teil, da man ja dann sowieso weiß, dass man sich im Backend befindet...
                 array_splice(self::$request_path, 0, 1);
             }
             if ($firstPathSegment == 'pm:api') {
                 self::$request_path[0] = 'api';
             }
         }
         self::$parsed = true;
     }
 }
Exemplo n.º 12
0
 public function getUniqueName($parent_id, $preferred_name)
 {
     $preferred_name = $this->normalizeName($preferred_name);
     $pos_of_hyphen = UTF8String::strrpos($preferred_name, '-');
     if ($pos_of_hyphen !== false) {
         if ($pos_of_hyphen > 0) {
             $number_part = UTF8String::substr($preferred_name, $pos_of_hyphen + 1);
             if (is_numeric($number_part)) {
                 $preferred_name = UTF8String::substr($preferred_name, 0, $pos_of_hyphen);
             }
         }
     }
     if ($this->isValidName($preferred_name)) {
         if (!$this->nameExists($parent_id, $preferred_name)) {
             return $preferred_name;
         } else {
             $existing = Db::get('SELECT id, name FROM [prefix]pages WHERE `name` LIKE :pattern', array(':pattern' => $preferred_name . '-%'));
             $highest_number = 0;
             if ($existing !== false) {
                 if (count($existing) > 0) {
                     foreach ($existing as $element) {
                         $number_part = UTF8String::substr($element['name'], UTF8String::strlen($preferred_name . '-'));
                         if (is_numeric($number_part)) {
                             if ((int) $number_part > $highest_number) {
                                 $highest_number = (int) $number_part;
                             }
                         }
                     }
                 }
             }
             if ($highest_number < 2) {
                 $highest_number = 2;
             } else {
                 $highest_number++;
             }
             if (!$this->nameExists($parent_id, $preferred_name . '-' . $highest_number)) {
                 return $preferred_name . '-' . $highest_number;
             }
         }
     }
     return md5(uniqid(rand(0, 99999), true));
 }
 private function getRandomFilename($orig_filename)
 {
     $info = pathinfo($orig_filename);
     $ext = UTF8String::strtolower($info['extension']);
     return md5(uniqid() . time() . rand(1, 99999)) . '.' . $ext;
 }
/**
 * Simple function to demonstrate how to control file access using "accessControl" callback.
 * This method will disable accessing files/folders starting from  '.' (dot)
 *
 * @param  UTF8String $attr attribute name (read|write|locked|hidden)
 * @param  UTF8String $path file path relative to volume root directory started with directory separator
 *
 * @return bool|null
 **/
function access($attr, $path, $data, $volume)
{
    return UTF8String::strpos(basename($path), '.') === 0 ? !($attr == 'read' || $attr == 'write') : null;
    // else elFinder decide it itself
}