PHP basename Examples

PHP basename - 30 examples found. These are the top rated real world PHP examples of basename extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
1
function ParseAllcontacts()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid)) {
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if ($unix->file_time_min($pidtime) < 120) {
        return;
    }
    @file_put_contents($pidtime, time());
    $ldap = new clladp();
    $suffix = $ldap->suffix;
    $arr = array("uid");
    $sr = @ldap_search($ldap->ldap_connection, "dc=organizations,{$suffix}", '(objectclass=userAccount)', $arr);
    if ($sr) {
        $hash = ldap_get_entries($ldap->ldap_connection, $sr);
        for ($i = 0; $i < $hash["count"]; $i++) {
            ParseContacts($hash[$i]["uid"][0]);
            if (system_is_overloaded(dirname(__FILE__))) {
                $unix->send_email_events(basename(__FILE__) . " Overloaded aborting task", "Zarafa contacts importation has been canceled due to overloaded system", "mailbox");
                return;
            }
            sleep(1);
        }
    }
}
Example #2
1
 function generatePDF()
 {
     // tempfolder
     $tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
     $tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
     if (is_dir($tmpFolder)) {
         Filesystem::removeFolder($tmpFolder);
     }
     if (!file_exists($tmpFolder)) {
         Filesystem::makeFolder($tmpFolder);
     }
     $baseFolderName = basename($tmpFolder);
     //Get site
     Requirements::clear();
     $link = Director::absoluteURL($this->pdfLink() . "/?view=1");
     $response = Director::test($link);
     $content = $response->getBody();
     $content = utf8_decode($content);
     $contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
     if (!file_exists($contentfile)) {
         // Write to file
         if ($fh = fopen($contentfile, 'w')) {
             fwrite($fh, $content);
             fclose($fh);
         }
     }
     return $contentfile;
 }
 public function setUp()
 {
     $_SERVER['REDIRECT_STATUS'] = "200";
     $_SERVER['HTTP_HOST'] = "slim";
     $_SERVER['HTTP_CONNECTION'] = "keep-alive";
     $_SERVER['HTTP_CACHE_CONTROL'] = "max-age=0";
     $_SERVER['HTTP_ACCEPT'] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
     $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3";
     $_SERVER['HTTP_ACCEPT_ENCODING'] = "gzip,deflate,sdch";
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en-US,en;q=0.8";
     $_SERVER['HTTP_ACCEPT_CHARSET'] = "ISO-8859-1,utf-8;q=0.7,*;q=0.3";
     $_SERVER['PATH'] = "/usr/bin:/bin:/usr/sbin:/sbin";
     $_SERVER['SERVER_SIGNATURE'] = "";
     $_SERVER['SERVER_SOFTWARE'] = "Apache";
     $_SERVER['SERVER_NAME'] = "slim";
     $_SERVER['SERVER_ADDR'] = "127.0.0.1";
     $_SERVER['SERVER_PORT'] = "80";
     $_SERVER['REMOTE_ADDR'] = "127.0.0.1";
     $_SERVER['DOCUMENT_ROOT'] = rtrim(dirname(__FILE__), '/');
     $_SERVER['SERVER_ADMIN'] = "you@example.com";
     $_SERVER['SCRIPT_FILENAME'] = __FILE__;
     $_SERVER['REMOTE_PORT'] = "55426";
     $_SERVER['REDIRECT_URL'] = "/";
     $_SERVER['GATEWAY_INTERFACE'] = "CGI/1.1";
     $_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1";
     $_SERVER['REQUEST_METHOD'] = "GET";
     $_SERVER['QUERY_STRING'] = "";
     $_SERVER['REQUEST_URI'] = "/";
     $_SERVER['SCRIPT_NAME'] = basename(__FILE__);
     $_SERVER['PHP_SELF'] = '/' . basename(__FILE__);
     $_SERVER['REQUEST_TIME'] = "1285647051";
     $_SERVER['argv'] = array();
     $_SERVER['argc'] = 0;
 }
Example #4
1
 /**
  * Compiles a template and writes it to a cache file, which is used for inclusion.
  *
  * @param string $file The full path to the template that will be compiled.
  * @param array $options Options for compilation include:
  *        - `path`: Path where the compiled template should be written.
  *        - `fallback`: Boolean indicating that if the compilation failed for some
  *                      reason (e.g. `path` is not writable), that the compiled template
  *                      should still be returned and no exception be thrown.
  * @return string The compiled template.
  */
 public static function template($file, array $options = array())
 {
     $cachePath = Libraries::get(true, 'resources') . '/tmp/cache/templates';
     $defaults = array('path' => $cachePath, 'fallback' => false);
     $options += $defaults;
     $stats = stat($file);
     $oname = basename(dirname($file)) . '_' . basename($file, '.php');
     $oname .= '_' . ($stats['ino'] ?: hash('md5', $file));
     $template = "template_{$oname}_{$stats['mtime']}_{$stats['size']}.php";
     $template = "{$options['path']}/{$template}";
     if (file_exists($template)) {
         return $template;
     }
     $compiled = static::compile(file_get_contents($file));
     if (is_writable($cachePath) && file_put_contents($template, $compiled) !== false) {
         foreach (glob("{$options['path']}/template_{$oname}_*.php", GLOB_NOSORT) as $expired) {
             if ($expired !== $template) {
                 unlink($expired);
             }
         }
         return $template;
     }
     if ($options['fallback']) {
         return $file;
     }
     throw new TemplateException("Could not write compiled template `{$template}` to cache.");
 }
Example #5
1
function mytheme_add_admin()
{
    global $themename, $shortname, $options;
    if ($_GET['page'] == basename(__FILE__)) {
        if ('save' == $_REQUEST['action']) {
            foreach ($options as $value) {
                if ($value['type'] != 'header') {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                }
            }
            foreach ($options as $value) {
                if (isset($_REQUEST[$value['id']])) {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                } else {
                    delete_option($value['id']);
                }
            }
            header("Location: themes.php?page=settings.php&saved=true");
            die;
        } else {
            if ('reset' == $_REQUEST['action']) {
                foreach ($options as $value) {
                    delete_option($value['id']);
                }
                header("Location: themes.php?page=settings.php&reset=true");
                die;
            }
        }
    }
    add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
Example #6
0
 /**
  * Returns the shortest path from $from to $to
  *
  * @param  string $from
  * @param  string $to
  * @param  bool   $directories if true, the source/target are considered to be directories
  * @return string
  */
 public function findShortestPath($from, $to, $directories = false)
 {
     if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
         throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
     }
     $from = lcfirst(rtrim(strtr($from, '\\', '/'), '/'));
     $to = lcfirst(rtrim(strtr($to, '\\', '/'), '/'));
     if ($directories) {
         $from .= '/dummy_file';
     }
     if (dirname($from) === dirname($to)) {
         return './' . basename($to);
     }
     $commonPath = $to;
     while (strpos($from, $commonPath) !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
         $commonPath = strtr(dirname($commonPath), '\\', '/');
     }
     if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
         return $to;
     }
     $commonPath = rtrim($commonPath, '/') . '/';
     $sourcePathDepth = substr_count(substr($from, strlen($commonPath)), '/');
     $commonPathCode = str_repeat('../', $sourcePathDepth);
     return $commonPathCode . substr($to, strlen($commonPath)) ?: './';
 }
Example #7
0
 function load()
 {
     $this->values = array();
     if (JRequest::getCmd('from_display', false) == false) {
         $this->values[] = JHTML::_('select.option', '', JText::_('HIKA_INHERIT'));
     }
     $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     foreach ($this->default as $d) {
         $this->values[] = JHTML::_('select.option', $d, JText::_(strtoupper($d)));
     }
     if (version_compare(JVERSION, '1.6.0', '>=')) {
         $this->values[] = JHTML::_('select.optgroup', '-- ' . JText::_('FROM_HIKASHOP') . ' --');
     }
     $closeOpt = '';
     $values = $this->getLayout();
     foreach ($values as $value) {
         if (substr($value, 0, 1) == '#') {
             if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
                 $this->values[] = JHTML::_('select.optgroup', $closeOpt);
             }
             $value = substr($value, 1);
             $closeOpt = '-- ' . JText::sprintf('FROM_TEMPLATE', basename($value)) . ' --';
             $this->values[] = JHTML::_('select.optgroup', $closeOpt);
         } else {
             $this->values[] = JHTML::_('select.option', $value, $value);
         }
     }
     if (version_compare(JVERSION, '1.6.0', '>=') && !empty($closeOpt)) {
         $this->values[] = JHTML::_('select.optgroup', $closeOpt);
     }
 }
Example #8
0
/**
 * Register all files found in $dir as classes
 * Need to be named MyClass.php
 *
 * @param string $dir The dir to look in
 *
 * @return void
 * @since 1.8.0
 */
function elgg_register_classes($dir)
{
    $classes = elgg_get_file_list($dir, array(), array(), array('.php'));
    foreach ($classes as $class) {
        elgg_register_class(basename($class, '.php'), $class);
    }
}
Example #9
0
 /**
  * Renders audio player for the blog
  *
  * @since	5.0
  * @access	public
  * @param	string
  * @return	
  */
 public function renderAudioPlayer($uri, $options = array())
 {
     // Merge the options with the default options
     $options = array_replace_recursive(self::$defaultAudioOptions, $options);
     // Generate a random uid
     $uniqid = uniqid();
     $uid = 'audio-' . EBMM::getHash($uri . $uniqid);
     // Url to the audio
     $url = $this->normalizeURI($uri);
     // Get the track if there is no track provided
     if (!$options['track']) {
         $options['track'] = basename($url);
     }
     // Set a default artist if artist isn't set
     if (!$options['artist']) {
         $options['artist'] = JText::_('COM_EASYBLOG_BLOCKS_AUDIO_ARTIST');
     }
     $template = EB::template();
     $template->set('uid', $uid);
     $template->set('showTrack', $options['showTrack']);
     $template->set('showDownload', $options['showDownload']);
     $template->set('showArtist', $options['showArtist']);
     $template->set('autoplay', $options['autoplay']);
     $template->set('loop', $options['loop']);
     $template->set('artist', $options['artist']);
     $template->set('track', $options['track']);
     $template->set('url', $url);
     $output = $template->output('site/blogs/blocks/audio');
     return $output;
 }
Example #10
0
 /**
  * Парсит пути
  */
 private function init_paths()
 {
     $filter = new filter();
     $this->dir = substr($filter->server('PHP_SELF'), 0, 0 - strlen(basename($filter->server('PHP_SELF'))));
     $this->root = $this->dir;
     $this->link = substr($filter->server('REQUEST_URI'), strlen($this->dir));
 }
 public static function clearCache()
 {
     if (!is_dir(CACHE_PATH)) {
         return;
     }
     try {
         $dirIterator = new RecursiveDirectoryIterator(CACHE_PATH);
         $iterator = new RecursiveIteratorIterator($dirIterator, RecursiveIteratorIterator::CHILD_FIRST);
         foreach ($iterator as $path) {
             switch (true) {
                 case '.' == basename($path->__toString()):
                 case '..' == basename($path->__toString()):
                 case '...' == basename($path->__toString()):
                     break;
                 case $path->isDir():
                     rmdir($path->__toString());
                     break;
                 default:
                     unlink($path->__toString());
                     break;
             }
         }
         rmdir(CACHE_PATH);
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #12
0
 /**
  * Get Global Application CMS accessibility scope.
  *
  * @access public
  * @static
  * @uses   Core\Config()
  *
  * @return array
  */
 public static function getAccessibilityScope()
 {
     $scope = glob(Core\Config()->paths('mode') . 'controllers' . DIRECTORY_SEPARATOR . '*.php');
     $builtin_scope = array('CMS\\Controllers\\CMS');
     $builtin_actions = array();
     $accessibility_scope = array();
     foreach ($builtin_scope as $resource) {
         $builtin_actions = array_merge($builtin_actions, get_class_methods($resource));
     }
     $builtin_actions = array_filter($builtin_actions, function ($action) {
         return !in_array($action, array('create', 'show', 'edit', 'delete', 'export'), true);
     });
     foreach ($scope as $resource) {
         $resource = basename(str_replace('.php', '', $resource));
         if ($resource !== 'cms') {
             $controller_name = '\\CMS\\Controllers\\' . $resource;
             $controller_class = new \ReflectionClass($controller_name);
             if (!$controller_class->isInstantiable()) {
                 continue;
             }
             /* Create instance only if the controller class is instantiable */
             $controller_object = new $controller_name();
             if ($controller_object instanceof CMS\Controllers\CMS) {
                 $accessibility_scope[$resource] = array_diff(get_class_methods($controller_name), $builtin_actions);
                 array_push($accessibility_scope[$resource], 'index');
                 foreach ($accessibility_scope[$resource] as $key => $action_with_acl) {
                     if (in_array($action_with_acl, $controller_object->skipAclFor, true)) {
                         unset($accessibility_scope[$resource][$key]);
                     }
                 }
             }
         }
     }
     return $accessibility_scope;
 }
/** 
 * Write a information message 
 * 
 * @param $msg Message to write to console.
 * @access public
 */
function writeMsg($msg)
{
    global $VERBOSE;
    if ($VERBOSE) {
        echo basename(__FILE__) . ": [INFO] " . $msg . "\n";
    }
}
Example #14
0
 /**
  * {@inheritdoc}
  */
 public function resize($imagePath, array $size, $mode, $force = false)
 {
     $cacheKey = $this->getCacheKey($size, $mode);
     $filename = basename($imagePath);
     if (false === $force && $this->imageCache->contains($filename, $cacheKey)) {
         return $this->imageCache->getRelativePath($filename, $cacheKey);
     }
     $cacheAbsolutePath = $this->imageCache->getAbsolutePath($filename, $cacheKey);
     $imagine = new Imagine();
     $imagineImage = $imagine->open($this->filesystem->getRootDir() . $imagePath);
     $imageSize = array($imagineImage->getSize()->getWidth(), $imagineImage->getSize()->getHeight());
     $boxSize = $this->resizeHelper->getBoxSize($imageSize, $size);
     $box = $this->getBox($boxSize[0], $boxSize[1]);
     if (ImageResizerInterface::INSET === $mode) {
         $imageSizeInBox = $this->resizeHelper->getImageSizeInBox($imageSize, $boxSize);
         $imagineImage->resize($this->getBox($imageSizeInBox[0], $imageSizeInBox[1]));
         $palette = new RGB();
         $box = $imagine->create($box, $palette->color($this->color, $this->alpha));
         $imagineImage = $box->paste($imagineImage, $this->getPointInBox($imageSizeInBox, $boxSize));
     } else {
         $imagineImage = $imagineImage->thumbnail($box);
     }
     $this->filesystem->mkdir(dirname($cacheAbsolutePath));
     $imagineImage->save($cacheAbsolutePath, ImageOptionHelper::getOption($filename));
     return $this->imageCache->getRelativePath($filename, $cacheKey);
 }
Example #15
0
 protected function _beforeSave()
 {
     $value = $this->getValue();
     $value = basename($value);
     $this->setValue($value);
     return $this;
 }
Example #16
0
 function upload($source, $target)
 {
     if ($this->error()) {
         return 0;
     }
     $old_dir = $this->ftp_pwd();
     $dirname = dirname($target);
     $filename = basename($target);
     if (!$this->ftp_chdir($dirname)) {
         if ($this->ftp_mkdir($dirname)) {
             $this->ftp_chmod($dirname);
             if (!$this->ftp_chdir($dirname)) {
                 $this->set_error(FTP_ERR_CHDIR);
             }
             $this->ftp_put('index.htm', getglobal('setting/attachdir') . '/index.htm', FTP_BINARY);
         } else {
             $this->set_error(FTP_ERR_MKDIR);
         }
     }
     $res = 0;
     if (!$this->error()) {
         if ($fp = @fopen($source, 'rb')) {
             $res = $this->ftp_fput($filename, $fp, FTP_BINARY);
             @fclose($fp);
             !$res && $this->set_error(FTP_ERR_TARGET_WRITE);
         } else {
             $this->set_error(FTP_ERR_SOURCE_READ);
         }
     }
     $this->ftp_chdir($old_dir);
     return $res ? 1 : 0;
 }
 public function importTranslations($replace = false)
 {
     $counter = 0;
     foreach ($this->files->directories($this->app->langPath()) as $langPath) {
         $locale = basename($langPath);
         foreach ($this->files->files($langPath) as $file) {
             $info = pathinfo($file);
             $group = $info['filename'];
             if (in_array($group, $this->config['exclude_groups'])) {
                 continue;
             }
             $translations = \Lang::getLoader()->load($locale, $group);
             if ($translations && is_array($translations)) {
                 foreach (array_dot($translations) as $key => $value) {
                     $value = (string) $value;
                     $translation = Translation::firstOrNew(array('locale' => $locale, 'group' => $group, 'key' => $key));
                     // Check if the database is different then the files
                     $newStatus = $translation->value === $value ? Translation::STATUS_SAVED : Translation::STATUS_CHANGED;
                     if ($newStatus !== (int) $translation->status) {
                         $translation->status = $newStatus;
                     }
                     // Only replace when empty, or explicitly told so
                     if ($replace || !$translation->value) {
                         $translation->value = $value;
                     }
                     $translation->save();
                     $counter++;
                 }
             }
         }
     }
     return $counter;
 }
Example #18
0
 public function dwld()
 {
     $this->min();
     if (is_numeric($this->getParam("id"))) {
         $this->download->newDownload();
         if ($this->download->getIsLocal()) {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header('Content-Description: File Transfer');
             header('Content-Type: application/octet-stream');
             header('Content-Disposition: attachment; filename="' . basename($url) . '";');
             readfile($url);
         } else {
             $url = OWEB_DIR_DATA . "/downloads/" . $this->download->getUrl();
             header("Content-Disposition: attachment; filename=" . basename($url));
             header("Content-Type: application/force-download");
             header("Content-Type: application/octet-stream");
             header("Content-Type: application/download");
             header("Content-Description: File Transfer");
             header("Content-Length: " . filesize($url));
             flush();
             // this doesn't really matter.
             $fp = fopen($url, "r");
             while (!feof($fp)) {
                 echo fread($fp, 65536);
                 flush();
                 // this is essential for large downloads
             }
             fclose($fp);
         }
     } else {
         throw new \Model\downloads\exception\DownloadCantBeFind("No Download ID given");
     }
 }
 /**
  * Get Test Files
  *
  * @param null $directory
  * @param null $excludes
  * @return array
  */
 public static function getTestFiles($directory = null, $excludes = null)
 {
     if (is_array($directory)) {
         $files = array();
         foreach ($directory as $d) {
             $files = array_merge($files, self::getTestFiles($d, $excludes));
         }
         return array_unique($files);
     }
     if ($excludes !== null) {
         $excludes = self::getTestFiles((array) $excludes);
     }
     if ($directory === null || $directory !== realpath($directory)) {
         $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
         $directory = str_replace(DS . DS, DS, $basePath . $directory);
     }
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
     $files = array();
     while ($it->valid()) {
         if (!$it->isDot()) {
             $file = $it->key();
             if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
                 $files[] = $file;
             }
         }
         $it->next();
     }
     return $files;
 }
 function onParseContentBlock($page, $name, $text, $shortcut)
 {
     $output = NULL;
     if ($name == "fotorama" && $shortcut) {
         list($pattern, $style, $nav, $autoplay) = $this->yellow->toolbox->getTextArgs($text);
         if (empty($style)) {
             $style = $this->yellow->config->get("fotoramaStyle");
         }
         if (empty($nav)) {
             $nav = $this->yellow->config->get("fotoramaNav");
         }
         if (empty($autoplay)) {
             $autoplay = $this->yellow->config->get("fotoramaAutoplay");
         }
         if (empty($pattern)) {
             $files = $page->getFiles(true);
         } else {
             $images = $this->yellow->config->get("imageDir");
             $files = $this->yellow->files->index(true, true)->match("#{$images}{$pattern}#");
         }
         if (count($files)) {
             $page->setLastModified($files->getModified());
             $output = "<div class=\"" . htmlspecialchars($style) . "\" data-nav=\"" . htmlspecialchars($nav) . "\" data-autoplay=\"" . htmlspecialchars($autoplay) . "\" data-loop=\"true\">\n";
             foreach ($files as $file) {
                 list($width, $height) = $this->yellow->toolbox->detectImageInfo($file->fileName);
                 $output .= "<img src=\"" . htmlspecialchars($file->getLocation()) . "\" width=\"" . htmlspecialchars($width) . "\" height=\"" . htmlspecialchars($height) . "\" alt=\"" . basename($file->getLocation()) . "\" title=\"" . basename($file->getLocation()) . "\" />\n";
             }
             $output .= "</div>";
         } else {
             $page->error(500, "Fotorama '{$pattern}' does not exist!");
         }
     }
     return $output;
 }
Example #21
0
 /**
  * add method
  *
  * @return void
  */
 public function add()
 {
     // debug($_FILES);
     // debug($this->request->data);
     // exit;
     $file_path = "img/";
     $file_path = $file_path . basename($_FILES['UploadedFile']['name']);
     if (move_uploaded_file($_FILES['UploadedFile']['tmp_name'], $file_path)) {
         echo "success";
     } else {
         echo "fail";
     }
     $response = array();
     if ($this->request->is('post')) {
         $this->Company->create();
         $this->request->data['image_path'] = $file_path;
         $this->request->data['image_name'] = $_FILES['UploadedFile']['name'];
         if ($this->Company->save($this->request->data)) {
             //$this->Session->setFlash(__('The company has been saved.'));
             $response['success'] = true;
             return $this->_sendJson($response);
         } else {
             //$this->Session->setFlash(__('The company could not be saved. Please, try again.'));
         }
         exit;
     }
 }
Example #22
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (count($arguments['name'])) {
         $files = array();
         foreach ($arguments['name'] as $name) {
             $finder = sfFinder::type('file')->follow_link()->name(basename($name) . 'Test.php');
             $files = array_merge($files, $finder->in(sfConfig::get('sf_test_dir') . '/unit/' . dirname($name)));
         }
         if ($allFiles = $this->filterTestFiles($files, $arguments, $options)) {
             foreach ($allFiles as $file) {
                 include $file;
             }
         } else {
             $this->logSection('test', 'no tests found', null, 'ERROR');
         }
     } else {
         require_once __DIR__ . '/sfLimeHarness.class.php';
         $h = new sfLimeHarness(array('force_colors' => isset($options['color']) && $options['color'], 'verbose' => isset($options['trace']) && $options['trace'], 'test_path' => sfConfig::get('sf_cache_dir') . '/lime'));
         $h->addPlugins(array_map(array($this->configuration, 'getPluginConfiguration'), $this->configuration->getPlugins()));
         $h->base_dir = sfConfig::get('sf_test_dir') . '/unit';
         // filter and register unit tests
         $finder = sfFinder::type('file')->follow_link()->name('*Test.php');
         $h->register($this->filterTestFiles($finder->in($h->base_dir), $arguments, $options));
         $ret = $h->run() ? 0 : 1;
         if ($options['xml']) {
             file_put_contents($options['xml'], $h->to_xml());
         }
         return $ret;
     }
 }
Example #23
0
function simple_upload_csv_products_file()
{
    $upload_feedback = '';
    if (isset($_FILES['product_csv']) && $_FILES['product_csv']['size'] > 0) {
        $arr_file_type = wp_check_filetype(basename($_FILES['product_csv']['name']));
        $uploaded_file_type = $arr_file_type['ext'];
        $allowed_file_type = 'csv';
        if ($uploaded_file_type == $allowed_file_type) {
            $wp_uploads_dir = wp_upload_dir();
            $filepath = $wp_uploads_dir['basedir'] . '/simple-products.csv';
            if (move_uploaded_file($_FILES['product_csv']['tmp_name'], $filepath)) {
                simple_import_product_from_csv();
            } else {
                $upload_feedback = '<div class="al-box warning">' . __('There was a problem with your upload.', 'al-ecommerce-product-catalog') . '</div>';
            }
        } else {
            $upload_feedback = '<div class="al-box warning">' . __('Please upload only CSV files.', 'al-ecommerce-product-catalog') . '</div>';
        }
        echo $upload_feedback;
    } else {
        $url = sample_import_file_url();
        echo '<form method="POST" enctype="multipart/form-data"><input type="file" accept=".csv" name="product_csv" id="product_csv" /><input type="submit" class="button" value="' . __('Import Products', 'al-ecommerce-product-catalog') . '" /></form>';
        echo '<div class="al-box info"><p>' . __("The CSV fields should be in following order: Image URL, Product Name, Product Price, Product Categories, Short Description, Long Description.", "al-ecommerce-product-catalog") . '</p><p>' . __("The first row should contain the field names. Semicolon should be used as the CSV separator.", "al-ecommerce-product-catalog") . '</p><a href="' . $url . '" class="button-primary">' . __('Download CSV Template', 'al-ecommerce-product-catalog') . '</a></div>';
    }
}
Example #24
0
 /**
  * Return book's short name
  *
  * @return string
  */
 public function getShortName()
 {
     if ($this->short_name === null) {
         $this->short_name = str_replace('_', '-', basename($this->path));
     }
     return $this->short_name;
 }
Example #25
0
 public function setUp()
 {
     parent::SetUp();
     $className = $this->getClassName();
     $sampleName = substr($className, 0, -4);
     $this->url = self::baseUrl() . basename(__DIR__) . '/' . $sampleName . '.php';
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function prepareRow(Row $row)
 {
     $row->setSourceProperty('filename', basename($row->getSourceProperty('picture')));
     $row->setSourceProperty('file_directory_path', $this->filePath);
     $row->setSourceProperty('temp_directory_path', $this->tempFilePath);
     return parent::prepareRow($row);
 }
Example #27
0
/**
 * On modifie les URLS des images dans le corps de l'article
 */
function filtre_picture($content, $url, $id)
{
    $matches = array();
    $processing_pictures = array();
    // list of processing image to avoid processing the same pictures twice
    preg_match_all('#<\\s*(img)[^>]+src="([^"]*)"[^>]*>#Si', $content, $matches, PREG_SET_ORDER);
    foreach ($matches as $i => $link) {
        $link[1] = trim($link[1]);
        if (!preg_match('#^(([a-z]+://)|(\\#))#', $link[1])) {
            $absolute_path = get_absolute_link($link[2], $url);
            $filename = basename(parse_url($absolute_path, PHP_URL_PATH));
            $directory = create_assets_directory($id);
            $fullpath = $directory . '/' . $filename;
            if (in_array($absolute_path, $processing_pictures) === true) {
                // replace picture's URL only if processing is OK : already processing -> go to next picture
                continue;
            }
            if (download_pictures($absolute_path, $fullpath) === true) {
                $content = str_replace($matches[$i][2], $fullpath, $content);
            }
            $processing_pictures[] = $absolute_path;
        }
    }
    return $content;
}
    /**
     * testDump
     */
    public function testDump()
    {
        $settings = array('Site' => array('title' => 'Croogo - Test (Edited)'), 'Reading' => array('date_time_format' => 'Y m d', 'nodes_per_page' => 20), 'Nested' => array('StringValue' => 'Is Fine', 'AnotherArray' => array('should' => 'be', 'persisted' => 'correctly')), 'Hook' => array('someKey' => 'value', 'model_properties' => array('ignored', 'to', 'oblivion'), 'controller_properties' => array('ignored', 'to', 'oblivion')));
        $this->CroogoJsonReader->dump(basename($this->testFile), $settings);
        $expected = <<<END
{
\\s+"Site": {
\\s+"title": "Croogo - Test \\(Edited\\)"
\\s+},
\\s+"Reading": {
\\s+"date_time_format": "Y m d",
\\s+"nodes_per_page": 20
\\s+},
\\s+"Nested": {
\\s+"StringValue": "Is Fine",
\\s+"AnotherArray": {
\\s+"should": "be",
\\s+"persisted": "correctly"
\\s+}
\\s+},
\\s+"Hook": {
\\s+"someKey": "value"
\\s+}
}
END;
        $this->assertRegExp($expected, file_get_contents($this->testFile));
    }
 public function build($args = array())
 {
     $options = $this->build_options($args);
     $this->fill_versions();
     $this->fill_types();
     if (isset($options['dependencies']) && $options['dependencies']) {
         $this->load_dependencies();
     }
     $this->check_extenders();
     foreach ($this->extenders as $key => $extender) {
         if ($inc_file = $this->installer_file($extender)) {
             include_once $inc_file;
             $class = $this->classify($extender['name']);
             $params = isset($extender['params']) ? $extender['params'] : array();
             call_user_func(array($class, 'install'), $this->package, $params);
         } else {
             $this->errors[] = 'Can\'t find extension "' . $extender['name'] . '" in extender directory';
             unset($this->extenders[$key]);
         }
     }
     $this->filename = self::tmp_path . basename($this->package->get_filename());
     $this->package->close();
     unset($this->config);
     unset($this->package);
 }
Example #30
0
 protected function getWriteableEtcMessages()
 {
     $messages = array();
     if ($this->mHelper('config')->isWriteableMessageEnabled() === true) {
         $etcDir = Mage::getConfig()->getOptions()->getEtcDir();
         $files = glob($etcDir . DS . '*.xml');
         $showMessage = false;
         $etcFiles = array();
         foreach ($files as $file) {
             if (strpos(basename($file), 'Extendware_') === 0) {
                 $etcFiles[] = $file;
             }
         }
         if (empty($etcFiles) === false) {
             $showMessage = is_writeable($etcDir) === false || is_readable($etcDir) === false;
             if ($showMessage === false) {
                 foreach ($etcFiles as $file) {
                     if (is_readable($file) === false or is_writeable($file) === false) {
                         $showMessage = true;
                         break;
                     }
                 }
             }
         }
         if ($showMessage === true) {
             $messages[] = array('label' => $this->__('Warning'), 'text' => 'Directory and files in <i>[Magento base]/app/etc/</i> needs to be writeable for Extendware Core to function properly.');
         }
     }
     return $messages;
 }