Example #1
2
 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     if (!files()->setUploadDirectory()) {
         sml()->say("The file upload directory does not appear to be writable. Please create the folder and set proper permissions.");
     }
     $form = new Form('news', $id);
     if (!$id) {
         $form->setCurrentValue('timestamp', date("Y-m-d H:i:s"));
     }
     // if form has been submitted
     if ($form->isSubmitted()) {
         $file = files()->upload('pdf_filename');
         if (is_array($file) && !empty($file[0])) {
             $form->setCurrentValue('pdf_filename', $file[0]['file_name']);
         }
         if ($form->save($id)) {
             sml()->say('News entry has successfully been updated.');
             router()->redirect('view');
         }
     }
     // make sure the template has access to all current values
     $data['form'] = $form;
     template()->addCss('admin/datepicker.css');
     template()->addJs('admin/datepicker.js');
     template()->addJs('edit.js');
     template()->display($data);
 }
Example #2
0
function files($dir)
{
    $files = array();
    $dir = rtrim($dir, DIRECTORY_SEPARATOR);
    if (is_dir($dir)) {
        $handle = opendir($dir);
        while (false !== ($file = readdir($handle))) {
            if ($file == '.' or $file == '..') {
                continue;
            }
            $file = $dir . DIRECTORY_SEPARATOR . $file;
            if (is_dir($file)) {
                $files = array_merge($files, files($file));
            } else {
                if (preg_match('/\\.php$/', $file)) {
                    $files[] = $file;
                }
            }
        }
        closedir($handle);
    } elseif (is_file($dir)) {
        return array($dir);
    }
    return $files;
}
Example #3
0
function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS', 'php'), $include = array('flv', 'mp4', 'swf', '3gp', 'mp3', 'rbs', 'wmv'))
{
    // Initialize variables
    $arr = array();
    // Is the path a folder?
    if (!is_dir($path)) {
        ?>

		<script language="javascript" type="text/javascript">alert('Path is not a folder <?php 
        echo $path;
        ?>
'); </script>

		<?php 
        return false;
    }
    // read the source directory
    $handle = opendir($path);
    while (($file = readdir($handle)) !== false) {
        $dir = $path . DS . $file;
        $isDir = is_dir($dir);
        if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
            if ($isDir) {
                if ($recurse) {
                    if (is_integer($recurse)) {
                        $recurse--;
                    }
                    $arr2 = files($dir, $filter, $recurse, $fullpath);
                    $arr = array_merge($arr, $arr2);
                }
            } else {
                if (preg_match("/{$filter}/", $file)) {
                    $path_parts = pathinfo($path . DS . $file);
                    if (in_array($path_parts['extension'], $include)) {
                        if ($fullpath) {
                            $arr[] = $path . DS . $file;
                        } else {
                            $arr[] = $file;
                        }
                    }
                }
            }
        }
    }
    //closedir($handle);
    //asort($arr);
    return $arr;
Example #4
0
File: m3uh.php Project: sunny/m3uh
function files($dir, &$files = array())
{
    $handle = opendir($dir);
    while ($file = readdir($handle)) {
        if ($file == '.' or $file == '..') {
            continue;
        }
        $path = $dir . '/' . $file;
        if (is_dir($path)) {
            files($path, $files);
        } else {
            $files[] = $path;
        }
    }
    closedir($handle);
    return $files;
}
Example #5
0
function renewData($type, $classes, $list, $table)
{
    if (is_array($classes)) {
        foreach ($classes as $value) {
            $files = files($type, $value);
            foreach ($files as $item) {
                $size = getimagesize($item);
                if (!$size) {
                    $size[0] = 0;
                    $size[1] = 0;
                }
                $data = array('img_url' => $item, 'img_date' => date('Y-m-d   H:i:s', filectime($item)), 'img_caption' => get_basename($item), 'img_class' => $value, 'img_type' => $type, 'img_size' => filesize($item), 'img_width' => $size[0], 'img_height' => $size[1]);
                $index = array_search($item, $list);
                if ($index !== false) {
                    array_splice($list, $index, 1);
                } else {
                    $table->add($data);
                }
            }
        }
    }
}
Example #6
0
 /**
  * @abstract Saves single image and text area content to the database
  * @param array $section
  * @param integer $page_id
  * @return array
  * @access public
  */
 private function saveSection_imagetext($section, $page_id)
 {
     $section['show_title'] = isset($section['show_title']) ? $section['show_title'] : false;
     // upload the image and create an image
     $filename = '';
     $thm_name = '';
     $uploads = files()->upload('image_' . $section['next_id']);
     if (is_array($uploads) && isset($uploads[0]) && !empty($uploads[0])) {
         foreach ($uploads as $upload) {
             $filename = $upload['file_name'];
             $thm_name = str_replace($upload['file_extension'], '_thm' . $upload['file_extension'], $upload['file_name']);
             $thm_path = str_replace($upload['file_extension'], '_thm' . $upload['file_extension'], $upload['server_file_path']);
             if (!empty($upload['server_file_path'])) {
                 // resize original if needed
                 if (app()->config('text_image_maxwidth') || app()->config('text_image_maxheight')) {
                     $img_resize = Thumbnail::create($upload['server_file_path']);
                     $img_resize->adaptiveResize(app()->config('text_image_maxwidth'), app()->config('text_image_maxheight'));
                     $img_resize->save($upload['server_file_path']);
                 }
                 // create the smaller thumbnail
                 $thm_create = Thumbnail::create($upload['server_file_path']);
                 if (app()->config('text_image_crop_center')) {
                     $thm_create->adaptiveResize();
                 }
                 $thm_create->adaptiveResize(app()->config('text_image_thm_maxwidth'), app()->config('text_image_thm_maxheight'));
                 $thm_create->save($thm_path);
             }
         }
     } else {
         $filename = $section['image_filename'];
         $thm_name = $section['image_thumbname'];
     }
     // save the data back
     $ins_id = model()->open('section_imagetext_editor')->insert(array('page_id' => $page_id, 'title' => $section['title'], 'content' => $section['content'], 'show_title' => $section['show_title'], 'image_filename' => $filename, 'image_thumbname' => $thm_name, 'image_alt' => $section['image_alt'], 'template' => $section['template']));
     $sections[] = array('placement_group' => $section['placement_group'], 'type' => 'imagetext_editor', 'called_in_template' => $section['called_in_template'], 'id' => $ins_id);
     return $sections;
 }
Example #7
0
 public static function make($db, $what)
 {
     if (is_string($what)) {
         $file = APPLICATION_PATH . DS . 'models' . DS . 'Bigdata' . DS . 'views' . DS . $db->db . DS . ucfirst(I::lower($db->table)) . DS . I::camelize($what) . '.php';
         if (files()->exists($file)) {
             require_once $file;
             $class = '\\Thin\\' . ucfirst(I::lower($db->db)) . ucfirst(I::lower($db->table)) . 'View';
             return $class::make($db);
         } else {
             return $db;
         }
     } elseif (A::is($what)) {
         $nameview = 'view_' . $db->db . '_' . $db->table . '_' . sha1(serialize($what));
         $ageDb = $db->getage();
         $viewDb = Db::instance($db->db, $nameview);
         $ageView = $db->getage();
         $exists = strlen($db->cache()->get('dbRedis.views.' . $nameview)) ? true : false;
         if ($ageView < $ageDb || !$exists) {
             $viewDb->getCollection()->remove();
             foreach ($what as $wh) {
                 $op = 'AND';
                 if (count($wh) == 4) {
                     $op = $wh[3];
                     unset($wh[3]);
                 }
                 $db = $db->where($wh);
             }
             $res = $db->exec();
             foreach ($res as $row) {
                 $viewDb->saveView($row);
             }
             $db->cache()->set('dbRedis.views.' . $nameview, 1);
         }
         return $viewDb;
     }
 }
Example #8
0
 function htmlToPng($html, $name = null, $orientation = null, $count = 0)
 {
     $name = is_null($name) ? 'doc.pdf' : Inflector::urlize($name) . '.pdf';
     $orientation = is_null($orientation) ? 'portrait' : $orientation;
     $file = TMP_PUBLIC_PATH . DS . sha1(serialize(func_get_args())) . '.html';
     files()->put($file, $html);
     $pdf = str_replace('.html', '.pdf', $file);
     // $keep = lib('keep')->instance();
     $url = URLSITE . 'tmp/' . Arrays::last(explode('/', $file));
     $this->urlToPng($url);
 }
Example #9
0
 /**
  * Find list of files inside folder 
  */
 public function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))
 {
     // Initialize variables
     $arr = array();
     // Is the path a folder?
     if (!is_dir($path)) {
         return array();
     }
     // read the source directory
     $handle = opendir($path);
     while (($file = readdir($handle)) !== false) {
         $dir = $path . DIRECTORY_SEPARATOR . $file;
         $isDir = is_dir($dir);
         if ($file != '.' && $file != '..' && !in_array($file, $exclude)) {
             if ($isDir) {
                 if ($recurse) {
                     if (is_integer($recurse)) {
                         $recurse--;
                     }
                     $arr2 = files($dir, $filter, $recurse, $fullpath);
                     $arr = array_merge($arr, $arr2);
                 }
             } else {
                 if (preg_match("/{$filter}/", $file)) {
                     if ($fullpath) {
                         $arr[] = $path . '/' . $file;
                     } else {
                         $arr[] = $file;
                     }
                 }
             }
         }
     }
     closedir($handle);
     asort($arr);
     return $arr;
 }
Example #10
0
function files($mass_dir)
{
    if ($dh = opendir($mass_dir)) {
        $files = array();
        $inner_files = array();
        while ($file = readdir($dh)) {
            if ($file != "." && $file != ".." && $file[0] != '.') {
                if (is_dir($mass_dir . "/" . $file)) {
                    $inner_files = files("{$mass_dir}/{$file}");
                    if (is_array($inner_files)) {
                        $files = array_merge($files, $inner_files);
                    }
                } else {
                    array_push($files, "{$mass_dir}/{$file}");
                }
            }
        }
        closedir($dh);
        return $files;
    }
}
Example #11
0
function files($dir, $display = 'block')
{
    $formats = explode(',', EDITABLE_FORMATS);
    $data = '<ul class="files" style="display:' . $display . '">';
    $files = array_slice(scandir($dir), 2);
    asort($files);
    foreach ($files as $key => $file) {
        if ($dir . DIRECTORY_SEPARATOR . $file == __FILE__ || SHOW_HIDDEN_FILES === false && substr($file, 0, 1) === '.') {
            continue;
        }
        $writable = is_writable($dir . DIRECTORY_SEPARATOR . $file) ? 'writable' : 'non-writable';
        if (is_dir($dir . DIRECTORY_SEPARATOR . $file)) {
            $data .= '<li class="dir ' . $writable . '"><a href="javascript:void(0);" onclick="return expandDir(this);" data-dir="' . str_replace(__DIR__ . '/', '', $dir . DIRECTORY_SEPARATOR . $file) . '">' . $file . '</a>' . files($dir . DIRECTORY_SEPARATOR . $file, 'none') . '</li>';
        } else {
            $is_editable = strpos($file, '.') === false || in_array(substr($file, strrpos($file, '.') + 1), $formats);
            $data .= '<li class="file ' . $writable . ' ' . ($is_editable ? 'editable' : null) . '">';
            if ($is_editable === true) {
                $data .= '<a href="javascript:void(0);" onclick="return openFile(this);" data-file="' . str_replace(__DIR__ . '/', '', $dir . DIRECTORY_SEPARATOR . $file) . '">';
            }
            $data .= $file;
            if ($is_editable) {
                $data .= '</a>';
            }
            if ($writable === 'writable') {
                $data .= ' <a href="javascript:void(0);" class="text-red visible-on-hover" onclick="return deleteFile(this);">[Delete]</a>';
            }
            $data .= '</li>';
        }
    }
    $data .= '</ul>';
    return $data;
}
Example #12
0
function center()
{
    // fatal session produced on failed login, and will display error message.
    if (isset($_SESSION[_SITE . 'fatal'])) {
        echo $_SESSION[_SITE . 'fatal'];
        unset($_SESSION[_SITE . 'fatal']);
    } else {
        global $categorySEF, $subcatSEF, $articleSEF;
        switch (true) {
            case isset($_GET['category']):
                $action = $categorySEF;
                break;
            case isset($_GET['action']):
                $action = $categorySEF == '404' ? $categorySEF : clean(cleanXSS($_GET['action']));
                break;
        }
        switch (true) {
            case isset($_POST['search_query']):
                search();
                return;
                break;
            case isset($_POST['comment']):
                comment('comment_posted');
                return;
                break;
            case isset($_POST['contactform']):
                contact();
                return;
                break;
            case isset($_POST['Loginform']):
                administration();
                return;
                break;
            case isset($_POST['submit_text']):
                processing();
                return;
                break;
        }
        if (_ADMIN) {
            switch ($action) {
                case 'administration':
                    administration();
                    return;
                    break;
                case 'snews_settings':
                    settings();
                    return;
                    break;
                case 'snews_categories':
                    admin_categories();
                    return;
                    break;
                case 'admin_category':
                    form_categories();
                    return;
                    break;
                case 'admin_subcategory':
                    form_categories('sub');
                    return;
                    break;
                case 'groupings':
                    admin_groupings();
                    return;
                    break;
                case 'admin_groupings':
                    form_groupings();
                    return;
                    break;
                case 'snews_articles':
                    admin_articles('article_view');
                    return;
                    break;
                case 'extra_contents':
                    admin_articles('extra_view');
                    return;
                    break;
                case 'snews_pages':
                    admin_articles('page_view');
                    return;
                    break;
                case 'admin_article':
                    form_articles('');
                    return;
                    break;
                case 'article_new':
                    form_articles('article_new');
                    return;
                    break;
                case 'extra_new':
                    form_articles('extra_new');
                    return;
                    break;
                case 'page_new':
                    form_articles('page_new');
                    return;
                    break;
                case 'editcomment':
                    edit_comment();
                    return;
                    break;
                case 'snews_files':
                    files();
                    return;
                    break;
                case 'process':
                    processing();
                    return;
                    break;
                case 'logout':
                    session_destroy();
                    echo '<meta http-equiv="refresh" content="2; url=' . _SITE . '">';
                    echo '<h2>' . l('log_out') . '</h2>';
                    return;
                    break;
            }
        }
        switch ($action) {
            case 'archive':
                archive();
                break;
            case 'sitemap':
                sitemap();
                break;
            case 'contact':
                contact();
                break;
            case 'login':
                login();
                break;
            case '404':
                echo l('error_404');
                break;
            default:
                articles();
                break;
        }
    }
}
Example #13
0
 /**
  * Enter description here...
  *
  * @param unknown_type $id
  */
 public function ajax_deleteImage($id)
 {
     $image = model()->open('contact_images', $id);
     $base = APPLICATION_PATH . DS . 'files' . DS . 'contacts' . DS . $image['contact_id'];
     files()->delete($base . DS . $image['filename_orig']);
     files()->delete($base . DS . $image['filename_thumb']);
     files()->delete($base);
     $model->delete('contact_images', $id);
     print 1;
 }
Example #14
0
 function pdfFile($html, $name = null, $orientation = null, $count = 0)
 {
     $name = is_null($name) ? 'doc.pdf' : Inflector::urlize($name) . '.pdf';
     $orientation = is_null($orientation) ? 'portrait' : $orientation;
     $file = TMP_PUBLIC_PATH . DS . sha1(serialize(func_get_args())) . '.html';
     files()->put($file, $html);
     $pdf = str_replace('.html', '.pdf', $file);
     // $keep = lib('keep')->instance();
     $url = 'http://www.zelift.com/tmp/' . Arrays::last(explode('/', $file));
     $cnt = dwn('http://apphuge.uk/pdf.php?url=' . urlencode($url) . '&orientation=' . $orientation);
     // if (!strlen($cnt) && $count < 5) {
     //     return pdfFile($html, $name, $orientation, $count++);
     // }
     // if (!strlen($cnt) && $count >= 5) {
     //     exception('pdf', 'Le pdf est erroné et ne peut être créé.');
     // }
     files()->delete($file);
     return $cnt;
 }
Example #15
0
 /**
  * Upload image and auto create thumbnail.
  *
  * @param $field
  * @param $path
  * @param null $width
  * @param null $height
  * @return string
  *
  * @require "intervention/images:~2"
  */
 function upload_image($field, $path, $width = null, $height = null)
 {
     $file = input()->file($field);
     $filename = get_random_filename($file);
     if (!is_null($width) && !is_null($height)) {
         $thumbnailPath = $path . '/thumbnail/';
         if (!files()->isDirectory($thumbnailPath)) {
             files()->makeDirectory($thumbnailPath);
         }
         $filenPath = public_path($thumbnailPath . $filename);
         Image::make($file->getRealPath())->resize($width, $height)->save($filenPath);
     }
     $file->move($path, $filename);
     return $filename;
 }
Example #16
0
function files($path, $recursive = false)
{
    $it = new DirectoryIterator($path);
    $files = array();
    while ($it->valid()) {
        if (is_file($it->getPathname()) && !$it->isDot() && $it->getFilename() != '.git') {
            $files[] = $recursive ? $it->getPathname() : $it->getFilename();
        } elseif (is_dir($it->getPathname()) && !$it->isDot() && $it->getFilename() != '.git' && $recursive) {
            $files = array_merge($files, files($it->getPathname(), $recursive));
        }
        $it->next();
    }
    return $files;
}
Example #17
0
function writeTest()
{
    $out = "<?php\ndefine('RUNNING_TESTS', true);\nrequire __DIR__ . '/cakephp2.0-tests.php';\n\n";
    $out .= "class Cakephp20HookTest extends PHPUnit_Framework_TestCase {\n\n\tfunction testTestCase() {\n";
    foreach (files() as $file) {
        $data = testCase($file);
        if (!$data) {
            continue;
        }
        $out .= "\n\t\t\$result = testCase('{$file}');\n";
        if (!$data['testFile']) {
            $out .= "\t\t\$this->assertFalse(\$result['testFile']);\n";
            continue;
        }
        $out .= "\t\t\$this->assertEquals('{$data['category']}', \$result['category']);\n";
        $out .= "\t\t\$this->assertEquals('{$data['case']}', \$result['case']);\n";
        $out .= "\t\t\$this->assertEquals('{$data['testFile']}', \$result['testFile']);\n";
    }
    $out .= "\t}\n}";
    file_put_contents('cakephp2.0-tests.test.php', $out);
    echo $out;
}
Example #18
0
 /**
  * @abstract Scans the theme directory for available tempaltes
  * @return array
  * @access public
  */
 public function sectionTemplates($rel_path = false, $recursive = true)
 {
     $path = APPLICATION_PATH . '/themes/' . app()->settings->getConfig('active_theme');
     $path .= $rel_path ? '/' . $rel_path : '';
     $files = files()->dirList($path);
     $page_templates = array();
     foreach ($files as $file) {
         $dir = $path . '/' . $file;
         // if the file found is a directory, look inside it
         if (is_dir($dir)) {
             if ($recursive) {
                 $subfiles = files()->dirList($dir);
                 foreach ($subfiles as $subfile) {
                     $fileinfo = $this->parseTemplateFile($dir, $subfile);
                     if ($fileinfo) {
                         array_push($page_templates, $fileinfo);
                     }
                 }
             }
         } else {
             $fileinfo = $this->parseTemplateFile($path, $file);
             if ($fileinfo) {
                 array_push($page_templates, $fileinfo);
             }
         }
     }
     // sort the values
     $volume = array();
     foreach ($page_templates as $key => $row) {
         $volume[$key] = $row['NAME'];
     }
     array_multisort($volume, $page_templates);
     return $page_templates;
 }
Example #19
0
/**
 * Uses is a pretty wrapper around include and require.  Gives everything a more namespace vibe.
 * 
 * The first component of the uses, is one of the following path specifiers:
 * 
 * 	- app			Application path
 * 	- application	Application path
 *  - sys			The system path
 *  - system		The system path
 *  - vendor		The vendor path
 *  - model			The path to the app's models
 *  - channel		The path to the app's data channels
 *  - control		Path to either the system controls or the app controls
 *  				(Will try the system controls first, then the app controls) 
 * 
 * For example, to load the Controller class which is in /sys/app/controller.php you would
 * do the following:
 * 
 * <code>
 * uses('system.app.controller');
 * </code>
 * 
 * Can support wildcards:
 * 
 * <code>
 * uses('system.data.validators.*');
 * </code>
 * 
 * @param string $namespace
 */
function uses($namespace)
{
	$altpath=null;
	
	$parts=explode('.',$namespace);
	$type=array_shift($parts);
	$path='';
	
	switch($type)
	{
		case 'app':
		case 'application':
			$path=PATH_APP;
			break;
		case 'sys':
		case 'system':
			$path=PATH_SYS;
			break;
		case 'vendor':
			$path=PATH_VENDOR;
			break;
		case 'model':
			$path=PATH_APP.'model/';
			break;
		case 'channel':
			$path=PATH_APP.'channel/';
			break;
		case 'control':
			$path=PATH_SYS.'control/';
			$altpath=PATH_APP.'control/';
			break;
		case 'screen':
			$path=PATH_APP.'screen/';
			$altpath=PATH_SYS.'app/screen/';
			break;
		case 'helper':
			$path=PATH_APP.'helper/';
			$altpath=PATH_SYS.'app/helper/';
			break;
	}
	
	
	if ($parts[count($parts)-1]=="*")
	{
		array_pop($parts);
		$namespace=implode('/',$parts);
		
		$files=array();
		
		$files=files($path.$namespace);
		foreach($files as $file)
			require_once($file);
	}
	else
	{
		$namespace=implode('/',$parts);
		
		if ($altpath)
			if (!file_exists($path.$namespace.EXT))
				$path=$altpath;
		
		require_once($path.$namespace.EXT);
	}
}
Example #20
0
} elseif ($img) {
    img($img);
} elseif ($gf) {
    grab($gf);
} elseif ($dir) {
    files($dir);
} else {
    switch ($act) {
        case "phpinfo":
            phpinfo();
            break;
        case "sql":
            sql();
            break;
        case "files":
            files($dir);
            break;
        case "email":
            email();
            break;
        case "cmd":
            cmd();
            break;
        case "upload":
            upload();
            break;
        case "tools":
            tools();
            break;
        case "sqllogin":
            sqllogin();
Example #21
0
        return $payhost;
    }
    return false;
}
switch ($action) {
    case 'county':
        getCountys();
        break;
    case 'vcode':
        getVcode();
        break;
    case 'upload':
        uploadFile($uri);
        break;
    case 'files':
        files();
        break;
    case 'dxyzm':
        dxyzm();
        break;
    case 'cleartmpuserphone':
        clearTmpUserPhone();
        break;
    case 'getOrder':
        getOrder();
        break;
    case 'orderNotify':
        orderNotify();
        break;
    default:
        ABase::toJson(1, 'Error code 404');
    if (!preg_match('@\\.php$@', $file) || preg_match('@(config|test_app)[\\\\/]@', $file)) {
        return false;
    }
    if (preg_match('@tests[\\\\/]@', $file)) {
        if (!preg_match('@\\Test\\.php$@', $file)) {
            return false;
        }
        $file = str_replace('Test.php', '.php', $file);
        if (preg_match('@.*lib[\\\\/]Cake[\\\\/]@', $file)) {
            return preg_replace('@.*tests[\\\\/]cases[\\\\/]@', 'lib' . DS . 'Cake' . DS, $file);
        }
        return preg_replace('@.*tests[\\\\/]cases[\\\\/]@', '', $file);
    }
    return $file;
}
$files = files();
$filename_pattern = '/\\.(php)$/';
$toTest = array();
$exit_status = 0;
foreach ($files as $file) {
    $file = testFile($file);
    if (!$file) {
        continue;
    }
    $toTest[$file] = true;
}
foreach ($toTest as $file) {
    $output = array();
    $cmd = "cake test {$file}";
    echo "{$cmd}\n";
    exec($cmd, $output, $return);
Example #23
0
 /**
  * @abstract Users sets up their database / config file here
  * @access public
  */
 public function setup($retry = false)
 {
     // define the form
     $form->addFields(array('db_username', 'db_password', 'db_database', 'db_hostname'));
     // process the form if submitted
     if ($form->isSubmitted('post', 'submit')) {
         // validation
         if (!$form->isFilled('db_username')) {
             $form->addError('db_username', 'You must enter a username');
         }
         if (!$form->isFilled('db_database')) {
             $form->addError('db_database', 'You must enter a database name.');
         }
         if (!$form->isFilled('db_hostname')) {
             $form->addError('db_hostname', 'You must enter a hostname or ip address.');
         }
         // if no error, proceed with setting up config file
         if (!$form->error()) {
             // save the config to a file
             $fill = "<?php\n";
             $fill .= '$config[\'db_hostname\'] = \'' . $form->cv('db_hostname') . "';\n";
             $fill .= '$config[\'db_database\'] = \'' . $form->cv('db_database') . "';\n";
             $fill .= '$config[\'db_username\'] = \'' . $form->cv('db_username') . "';\n";
             $fill .= '$config[\'db_password\'] = \'' . $form->cv('db_password') . "';\n";
             $fill .= '?>';
             // check if we can write the config file ourselves
             if (touch(APPLICATION_PATH . DS . 'config.php')) {
                 files()->useFile(APPLICATION_PATH . DS . 'config.php');
                 if (!files()->write($fill, 'w')) {
                     $this->paste_config($fill);
                     exit;
                 }
             } else {
                 $this->paste_config($fill);
                 exit;
             }
         }
     }
     // if the config file exists and db connection works, send on
     if (!app()->checkUserConfigExists() || $retry) {
         template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php');
         template()->addView(template()->getModuleTemplateDir() . DS . 'setup_config.tpl.php');
         template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php');
         template()->display();
     } else {
         app()->router->redirect('account');
     }
 }
Example #24
0
         $oBrick->src = $oFile->filename;
         $oBrick->alt = post('alt');
         $oBrick->local = true;
     } else {
         $oBrick->src = post('src');
         $oBrick->alt = post('alt');
         $oBrick->local = post('local');
     }
     break;
 case 'image':
     if (array_access(files('image_file'), 'error') != 4) {
         if (array_access(files('image_file'), 'error') > 0) {
             die('Error transmitting file !');
         }
         // TODO
         $oFile = CMSFile::factory(files('image_file'));
         $oFile->basename = genUID();
         if (!$oFile->saveTo(ROOT . 'contents/')) {
             die("Save uploaded file error.");
         }
         if ($oFile->isImage()) {
             $oFile->resize($oBrick->width, $oBrick->height, CMSImage::RESIZE_CROP);
             $oFile->save();
         }
         $oBrick->src = $oFile->filename;
         $oBrick->alt = post('alt');
         $oBrick->local = true;
     } else {
         $oBrick->src = post('src');
         $oBrick->alt = post('alt');
         $oBrick->local = post('local');
Example #25
0
 /**
  * Writes a new message to the log file
  * @param string $message
  * @access public
  */
 public function write($message = '(empty message)', $mode = 'a')
 {
     if ($this->on) {
         files()->useFile($this->full_path);
         if (is_array($message) || is_object($message)) {
             files()->write(print_r($message, true) . "\n", $mode);
         } else {
             files()->write(preg_replace('/[\\t]+/', '', trim($message)) . "\n", $mode);
         }
     }
 }