저자: Nick Sagona, III (nick@popphp.org)
예제 #1
0
 public function testDecode()
 {
     $f = new File(__DIR__ . '/../tmp/test.sql');
     $s = Sql::decode($f->read());
     $keys = array('id', 'username', 'password', 'email', 'access');
     $this->assertEquals(9, count($s));
     $this->assertEquals($keys, array_keys($s['row_1']));
 }
예제 #2
0
 /**
  * Install config method
  *
  * @param mixed  $form
  * @param string $docRoot
  * @return void
  */
 public function config($form, $docRoot = null)
 {
     if (null === $docRoot) {
         $docRoot = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH;
     }
     // Get config file contents
     $cfgFile = new File($docRoot . '/config.php');
     $config = $cfgFile->read();
     // Get DB interface and type
     if (strpos($form->db_adapter, 'Pdo') !== false) {
         $dbInterface = 'Pdo';
         $dbType = strtolower(substr($form->db_adapter, strrpos($form->db_adapter, '\\') + 1));
     } else {
         $dbInterface = html_entity_decode($form->db_adapter, ENT_QUOTES, 'UTF-8');
         $dbType = null;
     }
     // If DB is SQLite
     if (strpos($form->db_adapter, 'Sqlite') !== false) {
         touch($docRoot . $form->content_path . '/.htphire.sqlite');
         $relativeDbName = "__DIR__ . '" . $form->content_path . '/.htphire.sqlite';
         $dbName = realpath($docRoot . $form->content_path . '/.htphire.sqlite');
         $dbUser = null;
         $dbPassword = null;
         $dbHost = null;
         $installFile = $dbName;
         chmod($dbName, 0777);
     } else {
         $relativeDbName = null;
         $dbName = $form->db_name;
         $dbUser = $form->db_username;
         $dbPassword = $form->db_password;
         $dbHost = $form->db_host;
         $installFile = null;
     }
     $dbPrefix = $form->db_prefix;
     // Set config values
     $config = str_replace("define('CONTENT_PATH', '/phire-content');", "define('CONTENT_PATH', '" . $form->content_path . "');", $config);
     $config = str_replace("define('APP_URI', '/phire');", "define('APP_URI', '" . $form->app_uri . "');", $config);
     $config = str_replace("define('DB_INTERFACE', '');", "define('DB_INTERFACE', '" . $dbInterface . "');", $config);
     $config = str_replace("define('DB_TYPE', '');", "define('DB_TYPE', '" . $dbType . "');", $config);
     $config = str_replace("define('DB_NAME', '');", "define('DB_NAME', " . (null !== $relativeDbName ? $relativeDbName : "'" . $dbName) . "');", $config);
     $config = str_replace("define('DB_USER', '');", "define('DB_USER', '" . $dbUser . "');", $config);
     $config = str_replace("define('DB_PASS', '');", "define('DB_PASS', '" . $dbPassword . "');", $config);
     $config = str_replace("define('DB_HOST', '');", "define('DB_HOST', '" . $dbHost . "');", $config);
     $config = str_replace("define('DB_PREFIX', '');", "define('DB_PREFIX', '" . $dbPrefix . "');", $config);
     $this->data['configWritable'] = is_writable($docRoot . '/config.php');
     if ($form instanceof \Pop\Form\Form) {
         // Store the config values in session in case config file is not writable.
         $sess = Session::getInstance();
         $sess->config = serialize(htmlentities($config, ENT_QUOTES, 'UTF-8'));
         $sess->app_uri = $form->app_uri;
     }
     if ($this->data['configWritable']) {
         $cfgFile->write($config)->save();
     }
     // Install the database
     $sqlFile = __DIR__ . '/../../../data/phire.' . str_replace(array('pdo\\', 'mysqli'), array('', 'mysql'), strtolower($form->db_adapter)) . '.sql';
     $db = array('database' => $dbName, 'username' => $dbUser, 'password' => $dbPassword, 'host' => $dbHost, 'prefix' => $dbPrefix, 'type' => str_replace('\\', '_', $form->db_adapter));
     Dbs::install($dbName, $db, $sqlFile, $installFile, true);
     if (stripos($form->db_adapter, 'Pdo\\') !== false) {
         $adapter = 'Pdo';
         $type = strtolower(substr($form->db_adapter, strpos($form->db_adapter, '\\') + 1));
     } else {
         $adapter = $form->db_adapter;
         $type = null;
     }
     // Set the default system config
     $db = Db::factory($adapter, array('database' => $dbName, 'username' => $dbUser, 'password' => $dbPassword, 'host' => $dbHost, 'type' => $type));
     // Get server info
     if (isset($_SERVER) && isset($_SERVER['SERVER_SOFTWARE'])) {
         $server = new Server();
         $os = $server->getOs() . ' (' . $server->getDistro() . ')';
         $srv = $server->getServer() . ' ' . $server->getServerVersion();
         $domain = $_SERVER['HTTP_HOST'];
         $doc = $_SERVER['DOCUMENT_ROOT'];
     } else {
         $os = '';
         $srv = '';
         $domain = '';
         $doc = '';
     }
     // Set the system configuration
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . \Phire\Project::VERSION . "' WHERE setting = 'system_version'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->escape($domain) . "' WHERE setting = 'system_domain'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->escape($doc) . "' WHERE setting = 'system_document_root'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->escape($os) . "' WHERE setting = 'server_operating_system'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->escape($srv) . "' WHERE setting = 'server_software'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->version() . "' WHERE setting = 'database_version'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . PHP_VERSION . "' WHERE setting = 'php_version'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . date('Y-m-d H:i:s') . "' WHERE setting = 'installed_on'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "config SET value = '" . $db->adapter()->escape($form->language) . "' WHERE setting = 'default_language'");
     $db->adapter()->query("UPDATE " . $db->adapter()->escape($dbPrefix) . "user_types SET password_encryption = '" . $db->adapter()->escape((int) $form->password_encryption) . "' WHERE id = 2001");
 }
예제 #3
0
파일: Pdf.php 프로젝트: nicksagona/PopPHP
 /**
  * Save the PDF directly to the server.
  *
  * @param  string  $to
  * @param  boolean $append
  * @throws Exception
  * @return \Pop\Pdf\Pdf
  */
 public function save($to = null, $append = false)
 {
     // Format and finalize the PDF.
     $this->finalize();
     parent::save($to, $append);
     return $this;
 }
예제 #4
0
 /**
  * Constructor
  *
  * Instantiate the file writer object.
  *
  * @param  string $file
  * @param  array  $types
  * @return \Pop\Log\Writer\File
  */
 public function __construct($file, $types = null)
 {
     parent::__construct($file, $types);
 }
예제 #5
0
 /**
  * Static method to update field values
  *
  * @param array   $fields
  * @param int     $modelId
  * @param string  $method
  * @param string  $dir
  * @return void
  */
 public static function update(array $fields, $modelId, $method = 'POST', $dir = null)
 {
     $config = static::factory()->config();
     $docRoot = $_SERVER['DOCUMENT_ROOT'];
     $basePath = BASE_PATH;
     if (isset($fields['site_id'])) {
         $site = Table\Sites::findById((int) $fields['site_id']);
         if (isset($site->id)) {
             $docRoot = $site->document_root;
             $basePath = $site->base_path;
         }
     }
     if (null === $dir) {
         $dir = $docRoot . $basePath . CONTENT_PATH . DIRECTORY_SEPARATOR . 'media';
     }
     $valueAry = array();
     $postKeys = $_POST ? self::getPostKeys() : array();
     $fileKeys = $_FILES ? self::getFileKeys() : array();
     $keys = array_merge($postKeys, $fileKeys);
     sort($keys);
     $groups = Table\FieldValues::getGroups($keys);
     // Get history count, if applicable
     $historyCount = null;
     // Check for an overriding config setting
     if (file_exists($_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/extensions/modules/config/phire.php')) {
         $fldCfg = (include $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/extensions/modules/config/phire.php');
         $encOptions = $fldCfg['Phire']->encryptionOptions->asArray();
         $historyCount = isset($fldCfg['Phire']->history) ? (int) $fldCfg['Phire']->history : null;
     } else {
         $fldCfg = (include __DIR__ . '/../../../config/module.php');
         $encOptions = $fldCfg['Phire']->encryptionOptions->asArray();
         $historyCount = isset($fldCfg['Phire']->history) ? (int) $fldCfg['Phire']->history : null;
     }
     // Save new dynamic fields (not files)
     foreach ($fields as $key => $value) {
         if (strpos($key, 'field_') !== false && !isset($_FILES[$key])) {
             $id = self::getFieldId($key);
             if ($method == 'POST' && $_POST || $method == 'GET') {
                 // If it's a dynamic field value, store in array
                 if (strpos($key, 'field_' . $id . '_cur_') !== false) {
                     if (!isset($valueAry[$id])) {
                         $valueAry[$id] = array($value);
                     } else {
                         $valueAry[$id][] = $value;
                     }
                     // Else, save the non-dynamic field value
                 } else {
                     if (strpos($key, 'new_') === false) {
                         $f = Table\Fields::findById($id);
                         $field = Table\FieldValues::findById(array($id, $modelId));
                         $realValue = isset($_POST['field_' . $id]) ? $value : null;
                         // If existing field, update
                         if (isset($field->field_id)) {
                             if (!empty($realValue) && $realValue != '[Encrypted]') {
                                 $realValue = self::encrypt($realValue, $f->encryption, $encOptions);
                             }
                             // If history tracking is available for this field, update history
                             if (null !== $historyCount && $historyCount > 0) {
                                 $f = Table\Fields::findById($field->field_id);
                                 if (isset($f->id) && strpos($f->type, '-history') !== false) {
                                     $oldValue = json_decode($field->value, true);
                                     // If value is different that the last value
                                     if ($realValue != $oldValue) {
                                         $ts = null !== $field->timestamp ? $field->timestamp : time() - 300;
                                         if (null !== $field->history) {
                                             $history = json_decode($field->history, true);
                                             $history[$ts] = $oldValue;
                                             if (count($history) > $historyCount) {
                                                 $history = array_slice($history, 1, $historyCount, true);
                                             }
                                             $field->history = json_encode($history);
                                         } else {
                                             $field->history = json_encode(array($ts => $oldValue));
                                         }
                                     }
                                 }
                             }
                             $field->value = json_encode($realValue);
                             $field->timestamp = time();
                             $field->update();
                             // Else, save new field
                         } else {
                             $realValue = self::encrypt($realValue, $f->encryption, $encOptions);
                             $f = new Table\FieldValues(array('field_id' => $id, 'model_id' => $modelId, 'value' => json_encode($realValue), 'timestamp' => time()));
                             $f->save();
                         }
                     }
                 }
             }
         }
     }
     // Check for current files
     if ($_FILES) {
         foreach ($_FILES as $key => $value) {
             if (strpos($key, 'field_') !== false) {
                 $id = self::getFieldId($key);
                 // If it's a dynamic field value, store in array
                 if (strpos($key, 'cur_') !== false) {
                     $fileName = '';
                     if ($value['tmp_name'] != '') {
                         $num = substr($key, strrpos($key, '_') + 1) - 1;
                         $fv = Table\FieldValues::findById(array($id, $modelId));
                         // If file exists and is being replaced, remove it
                         if (isset($fv->field_id)) {
                             $fValue = json_decode($fv->value, true);
                             if (isset($fValue[$num])) {
                                 if ($_FILES) {
                                     \Phire\Model\Media::remove($fValue[$num], $docRoot . $basePath);
                                 }
                             }
                         }
                         $fileName = File::checkDupe($value['name'], $dir);
                         File::upload($value['tmp_name'], $dir . DIRECTORY_SEPARATOR . $fileName, $config->media_max_filesize, $config->media_allowed_types);
                         chmod($dir . DIRECTORY_SEPARATOR . $fileName, 0777);
                         if ($_FILES && preg_match(\Phire\Model\Media::getImageRegex(), $fileName)) {
                             \Phire\Model\Media::process($fileName, $config, $dir);
                         }
                     } else {
                         $num = substr($key, strrpos($key, '_') + 1) - 1;
                         $fv = Table\FieldValues::findById(array($id, $modelId));
                         if (isset($fv->field_id)) {
                             $fValue = json_decode($fv->value, true);
                             if (isset($fValue[$num])) {
                                 $fileName = $fValue[$num];
                             }
                         }
                     }
                     if (!isset($valueAry[$id])) {
                         $valueAry[$id] = array($fileName);
                     } else {
                         $valueAry[$id][] = $fileName;
                     }
                     // Else, save the non-dynamic field value
                 } else {
                     if (strpos($key, 'new_') === false) {
                         $fileName = '';
                         if ($value['tmp_name'] != '') {
                             $fileName = File::checkDupe($value['name'], $dir);
                             File::upload($value['tmp_name'], $dir . DIRECTORY_SEPARATOR . $fileName, $config->media_max_filesize, $config->media_allowed_types);
                             chmod($dir . DIRECTORY_SEPARATOR . $fileName, 0777);
                             if ($_FILES && preg_match(\Phire\Model\Media::getImageRegex(), $fileName)) {
                                 \Phire\Model\Media::process($fileName, $config, $dir);
                             }
                         }
                         if ($fileName != '') {
                             $f = Table\Fields::findById($id);
                             $fileName = self::encrypt($fileName, $f->encryption, $encOptions);
                             $field = Table\FieldValues::findById(array($id, $modelId));
                             // If file field value exists, update
                             if (isset($field->field_id)) {
                                 if ($_FILES) {
                                     \Phire\Model\Media::remove(json_decode($field->value, true), $docRoot . $basePath);
                                 }
                                 $field->value = json_encode($fileName);
                                 $field->timestamp = time();
                                 $field->update();
                                 // Else, save new
                             } else {
                                 $f = new Table\FieldValues(array('field_id' => $id, 'model_id' => $modelId, 'value' => json_encode($fileName), 'timestamp' => time()));
                                 $f->save();
                             }
                         }
                     }
                 }
             }
         }
     }
     // Remove any fields that have been marked for deletion
     foreach ($_POST as $key => $value) {
         if (strpos($key, 'rm_fields_') !== false) {
             $ids = substr($key, 10);
             $num = substr($ids, strrpos($ids, '_') + 1) - 1;
             $ids = substr($ids, 0, strrpos($ids, '_'));
             $ids = explode('_', $ids);
             foreach ($ids as $id) {
                 $f = Table\Fields::findById($id);
                 // If it's a file, remove the file too
                 if (isset($f->id) && $f->type == 'file') {
                     $fv = Table\FieldValues::findById(array($id, $modelId));
                     if (isset($fv->field_id)) {
                         $fValue = json_decode($fv->value, true);
                         if (is_array($fValue) && isset($fValue[$num])) {
                             if ($_FILES) {
                                 \Phire\Model\Media::remove($fValue[$num], $docRoot . $basePath);
                             }
                         } else {
                             if ($_FILES) {
                                 \Phire\Model\Media::remove($fValue, $docRoot . $basePath);
                             }
                         }
                     }
                 }
                 if (null !== $num && isset($valueAry[$id]) && isset($valueAry[$id][$num])) {
                     unset($valueAry[$id][$num]);
                 } else {
                     $fv = Table\FieldValues::findById(array($id, $modelId));
                     if (isset($fv->field_id)) {
                         $fv->delete();
                     }
                 }
             }
         }
         // Remove any non-dynamic single files
         if (strpos($key, 'rm_file_') !== false) {
             $id = substr($key, strrpos($key, '_') + 1);
             if (isset($value[0])) {
                 if ($_FILES) {
                     \Phire\Model\Media::remove($value[0], $docRoot . $basePath);
                 }
             }
             $fv = Table\FieldValues::findById(array($id, $modelId));
             if (isset($fv->field_id)) {
                 $fv->delete();
             }
         }
     }
     // Removal clean-up
     foreach ($_POST as $key => $value) {
         if (strpos($key, 'rm_fields_') !== false) {
             $ids = substr($key, 10);
             $ids = substr($ids, 0, strrpos($ids, '_'));
             $ids = explode('_', $ids);
             foreach ($ids as $id) {
                 if (isset($valueAry[$id])) {
                     $valueAry[$id] = array_values($valueAry[$id]);
                 }
             }
         }
     }
     // Check for new dynamic field values (not files)
     if ($_POST) {
         foreach ($_POST as $k => $v) {
             if (strpos($k, 'field_') !== false && !isset($_FILES[$k])) {
                 $id = self::getFieldId($k);
                 // If it's a dynamic field value, store in array
                 if (strpos($k, 'field_' . $id . '_new_') !== false) {
                     if (!isset($valueAry[$id])) {
                         $valueAry[$id] = array($v);
                     } else {
                         $valueAry[$id][] = $v;
                     }
                 }
             }
         }
     }
     // Get new files
     if ($_FILES) {
         foreach ($_FILES as $key => $value) {
             if (strpos($key, 'field_') !== false) {
                 $id = self::getFieldId($key);
                 // If it's a dynamic field value, store in array
                 if (strpos($key, 'new_') !== false) {
                     $fileName = '';
                     if ($value['tmp_name'] != '') {
                         $fileName = File::checkDupe($value['name'], $dir);
                         File::upload($value['tmp_name'], $dir . DIRECTORY_SEPARATOR . $fileName, $config->media_max_filesize, $config->media_allowed_types);
                         chmod($dir . DIRECTORY_SEPARATOR . $fileName, 0777);
                         if ($_FILES && preg_match(\Phire\Model\Media::getImageRegex(), $fileName)) {
                             \Phire\Model\Media::process($fileName, $config, $dir);
                         }
                     }
                     if (!isset($valueAry[$id])) {
                         $valueAry[$id] = array($fileName);
                     } else {
                         $valueAry[$id][] = $fileName;
                     }
                 }
             }
         }
     }
     // Save the new dynamic field values
     if (count($valueAry) > 0) {
         // Clean up, check for empties
         foreach ($groups as $group) {
             if (isset($group['fields']) && isset($group['fields'][0]) && isset($valueAry[$group['fields'][0]])) {
                 $keys = array_keys($valueAry[$group['fields'][0]]);
                 foreach ($keys as $key) {
                     $i = 0;
                     $removal = array();
                     foreach ($group['fields'] as $id) {
                         if (isset($valueAry[$id][$key])) {
                             if ($valueAry[$id][$key] == '----' || empty($valueAry[$id][$key]) || is_array($valueAry[$id][$key]) && count($valueAry[$id][$key]) == 1 && empty($valueAry[$id][$key][0])) {
                                 $f = Table\Fields::findById($id);
                                 if (isset($f->id) && $f->type == 'file') {
                                     $fv = Table\FieldValues::findById(array($id, $modelId));
                                     if (isset($fv->field_id)) {
                                         $fValue = json_decode($fv->value, true);
                                         if (isset($fValue[$key])) {
                                             $valueAry[$id][$key] = $fValue[$key];
                                         }
                                     }
                                 }
                                 $i++;
                             }
                         } else {
                             if (isset($valueAry[$id])) {
                                 if (is_array($valueAry[$id]) && count($valueAry[$id]) == 0) {
                                     $i++;
                                 } else {
                                     if (is_array($valueAry[$id]) && count($valueAry[$id]) == 1 && (empty($valueAry[$id][0]) || $valueAry[$id][0] == '----')) {
                                         $i++;
                                     }
                                 }
                             }
                         }
                     }
                     if ($i == count($group['fields'])) {
                         foreach ($valueAry as $k => $v) {
                             if (in_array($k, $group['fields'])) {
                                 unset($valueAry[$k][$key]);
                                 if (isset($valueAry[$k]) && count($valueAry[$k]) == 0) {
                                     $removal[] = $k;
                                     unset($valueAry[$k]);
                                 }
                             }
                         }
                     }
                     sort($removal);
                     // Final clean up of empties
                     if (count($removal) > 0) {
                         foreach ($groups as $grp) {
                             if (in_array($removal, $grp)) {
                                 foreach ($removal as $id) {
                                     $fv = Table\FieldValues::findById(array($id, $modelId));
                                     if (isset($fv->field_id)) {
                                         $fv->delete();
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         foreach ($valueAry as $key => $value) {
             $valueAry[$key] = array_values($value);
         }
         // Either update existing field values or save new ones
         foreach ($valueAry as $id => $value) {
             $f = Table\Fields::findById($id);
             $field = Table\FieldValues::findById(array($id, $modelId));
             if (isset($field->field_id)) {
                 if (!empty($value) && $value != '[Encrypted]') {
                     $value = self::encrypt($value, $f->encryption, $encOptions);
                 } else {
                     $value = json_decode($field->value, true);
                 }
                 $field->value = json_encode($value);
                 $field->timestamp = time();
                 $field->update();
             } else {
                 $value = self::encrypt($value, $f->encryption, $encOptions);
                 $f = new Table\FieldValues(array('field_id' => $id, 'model_id' => $modelId, 'value' => json_encode($value), 'timestamp' => time()));
                 $f->save();
             }
         }
     }
 }
예제 #6
0
 /**
  * Constructor
  *
  * Instantiate the archive object
  *
  * @param  string $archive
  * @param  string $password
  * @param  string $prefix
  * @return \Pop\Archive\Archive
  */
 public function __construct($archive, $password = null, $prefix = 'Pop\\Archive\\Adapter\\')
 {
     $this->allowed = self::formats();
     parent::__construct($archive);
     $this->setAdapter($password, $prefix);
 }
예제 #7
0
 /**
  * Save the code object to disk.
  *
  * @param  string $to
  * @param  boolean $append
  * @return void
  */
 public function save($to = null, $append = false)
 {
     $this->render(true);
     parent::save($to, $append);
 }
예제 #8
0
파일: Svg.php 프로젝트: nicksagona/PopPHP
 /**
  * Method to output the SVG image.
  *
  * @param  boolean $download
  * @return void
  */
 public function output($download = false)
 {
     $dom = new \DOMDocument('1.0');
     $dom->preserveWhiteSpace = false;
     $dom->formatOutput = true;
     $dom->loadXML($this->resource->asXML());
     $this->output = $dom->saveXML();
     parent::output($download);
 }
예제 #9
0
<?php

require_once '../../bootstrap.php';
use Pop\File\File;
try {
    $file = File::upload($_FILES['upload_file']['tmp_name'], '../tmp/' . $_FILES['upload_file']['name']);
    echo 'The file has been successfully uploaded.<br />' . PHP_EOL;
    print_r($file);
} catch (\Exception $e) {
    echo $e->getMessage();
}
예제 #10
0
 /**
  * Constructor
  *
  * Instantiate a font file object based on a pre-existing font file on disk.
  *
  * @param  string $font
  * @throws Exception
  * @return \Pop\Font\AbstractFont
  */
 public function __construct($font)
 {
     if (!file_exists($font)) {
         throw new Exception('The font file does not exist.');
     }
     $this->flags = new \ArrayObject(array('isFixedPitch' => false, 'isSerif' => false, 'isSymbolic' => false, 'isScript' => false, 'isNonSymbolic' => false, 'isItalic' => false, 'isAllCap' => false, 'isSmallCap' => false, 'isForceBold' => false), \ArrayObject::ARRAY_AS_PROPS);
     parent::__construct($font);
 }
예제 #11
0
 /**
  * Constructor
  *
  * Instantiate an image file object based on either a pre-existing
  * image file on disk, or a new image file.
  *
  * @param  string                          $img
  * @param  int|string                      $w
  * @param  int|string                      $h
  * @param  \Pop\Color\Space\ColorInterface $color
  * @param  array                           $types
  * @return \Pop\Image\AbstractImage
  */
 public function __construct($img, $w = null, $h = null, ColorInterface $color = null, $types = null)
 {
     parent::__construct($img, $types);
 }
예제 #12
0
파일: pop.php 프로젝트: nicksagona/PopPHP
     } else {
         if (!file_exists($argv[2])) {
             echo Install::cliError(2);
             // Else, check if the output file ends in '.php'
         } else {
             if (strtolower(substr($argv[3], -4)) != '.php') {
                 echo Install::cliError(3);
                 // Else, generate the class map file
             } else {
                 echo 'Generating class map file \'' . $argv[3] . '\' from source folder \'' . $argv[2] . '\'' . PHP_EOL;
                 Classmap::generate($argv[2], $argv[3]);
                 // Add project to the bootstrap file
                 $input = Install::cliInput('Add classmap to the bootstrap file? (Y/N) ');
                 if ($input == 'y') {
                     $location = Install::getBootstrap();
                     $bootstrap = new File($location . '/bootstrap.php');
                     $bootstrap->write("\$autoloader->loadClassMap('" . addslashes(realpath($argv[3])) . "');" . PHP_EOL . PHP_EOL, true)->save();
                 }
                 echo 'Done.' . PHP_EOL . PHP_EOL;
             }
         }
     }
     // Else, install project
 } else {
     if ($argv[1] == '-i' || $argv[1] == '--install') {
         // Check if the project install file argument was passed
         if (empty($argv[2])) {
             echo Install::cliError(4);
             // Else, run the install process
         } else {
             echo 'Installing Project' . PHP_EOL;
예제 #13
0
파일: dupe.php 프로젝트: nicksagona/PopPHP
<?php

require_once '../../bootstrap.php';
use Pop\File\File;
try {
    $filename = File::checkDupe('upload.php');
    echo $filename;
} catch (\Exception $e) {
    echo $e->getMessage();
}
예제 #14
0
 public function testWriteSaveAndDelete()
 {
     if (file_exists(__DIR__ . '/../tmp/file.txt')) {
         unlink(__DIR__ . '/../tmp/file.txt');
     }
     $f = new File(__DIR__ . '/../tmp/file.txt');
     $f->write('123')->write('456', true)->save();
     $f->setPermissions(0777);
     $this->fileExists(__DIR__ . '/../tmp/file.txt');
     $this->assertEquals('123456', $f->read());
     $this->assertEquals(6, $f->getSize());
     $this->assertEquals('text/plain', $f->getMime());
     $f->delete();
     $this->assertFalse(file_exists(__DIR__ . '/../tmp/file.txt'));
 }