예제 #1
0
 public function render(ddUploadify $up)
 {
     $widget_id = $this->getSlug() . '-input';
     $form = new BaseForm();
     $csrf_token = $form->getCSRFToken();
     $output = '<div class="container dd-img-upload-wrapper">';
     $output .= '<div id="fileQueue"></div>';
     $output .= '<input type="file" name="' . $up->getSlug() . '" id="' . $widget_id . '" />';
     $output .= '<p><a href="javascript:jQuery(\'#' . $widget_id . '\').uploadifyClearQueue()">Cancel All Uploads</a></p>';
     $output .= '<div class="swfupload-buttontarget">
     <noscript>
       We\'re sorry.  SWFUpload could not load.  You must have JavaScript enabled to enjoy SWFUpload.
     </noscript>
   </div>';
     $output .= '<script type="text/javascript">
     //<![CDATA[
     $(document).ready(function() {
       $(\'#' . $widget_id . ' \').uploadify({
         \'scriptData\': {\' ' . array_key($up->getSession()) . ' \': \' ' . array_value($up->getSession()) . ' \', \'_csrf_token\': \' ' . $csrf_token . ' \'},
         \'uploader\': \' ' . $up->getUploader() . ' \',
         \'cancelImg\': \'cancel.png\',
         \'auto\'      : true,
         \'script\': $(\'#' . $widget_id . '\').closest(\'form\').attr(\'action\')+\'/upload\',
         \'folder\': \'\',
         \'multi\': false,
         \'displayData\': \'speed \',
         \'fileDataName\': \' ' . $widget_id . ' \',
         \'simUploadLimit\': 2
       });
     });
     //]]>
   </script>';
     printf($output);
 }
예제 #2
0
 public function __invoke($app)
 {
     $config = $app['config'];
     $dbSettings = (array) $config->get('database');
     if (isset($dbSettings['dsn'])) {
         $dsn = $dbSettings['dsn'];
     } else {
         // generate the dsn
         $dsn = $dbSettings['type'] . ':host=' . $dbSettings['host'] . ';dbname=' . $dbSettings['name'];
     }
     $user = array_value($dbSettings, 'user');
     $password = array_value($dbSettings, 'password');
     try {
         $pdo = new \PDO($dsn, $user, $password);
     } catch (PDOException $e) {
         $app['logger']->emergency($e);
         die('Could not connect to database.');
     }
     if ($app['environment'] === Application::ENV_PRODUCTION) {
         $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
     } else {
         $pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     }
     return $pdo;
 }
예제 #3
0
 /**
  *
  * @return type 
  * @todo fix method setFromArray()
  */
 public function getFilterImap()
 {
     $format = "d-M-Y";
     // prepare value
     $value = (array) $this->_getDateValues($this->_operator, $this->_value);
     $timezone = array_value('timezone', $this->_options);
     foreach ($value as &$date) {
         $date = new Tinebase_DateTime($date);
         // should be in user timezone
         $date->setTimezone(new DateTimeZone($timezone));
     }
     switch ($this->_operator) {
         case 'within':
         case 'inweek':
             $return = "SINCE {$value[0]->format($format)} BEFORE {$value[1]->format($format)}";
             break;
         case 'before':
             $return = "BEFORE {$value[0]->format($format)}";
             break;
         case 'after':
             $return = "SINCE {$value[0]->format($format)}";
             break;
         case 'equals':
             // errado
             $return = "ON {$value[0]->format($format)}";
     }
     return $return;
 }
예제 #4
0
 public function index()
 {
     $this->load->library('pagination');
     $input = array('limit' => $this->input->get('limit') ?: 10, 'offset' => $this->input->get('per_page') ?: '');
     $order = $this->business->query($input);
     $pagination_config['base_url'] = site_url('business/index?limit=' . $input['limit']);
     $pagination_config['total_rows'] = array_value($order, 'count', 0);
     $pagination_config['per_page'] = $input['limit'];
     $pagination_config['next_link'] = '&raquo;';
     $pagination_config['prev_link'] = '&laquo;';
     $pagination_config['full_tag_open'] = '<div class="pagination"><ul>';
     $pagination_config['full_tag_close'] = '</ul></div>';
     $pagination_config['first_tag_open'] = '<li>';
     $pagination_config['first_tag_close'] = '</li>';
     $pagination_config['last_tag_open'] = '<li>';
     $pagination_config['last_tag_close'] = '</li>';
     $pagination_config['first_url'] = site_url('business/index');
     $pagination_config['cur_tag_open'] = '<li class="active"><a>';
     $pagination_config['cur_tag_close'] = '</a></li>';
     $pagination_config['next_tag_open'] = '<li>';
     $pagination_config['next_tag_close'] = '</li>';
     $pagination_config['prev_tag_open'] = '<li>';
     $pagination_config['prev_tag_close'] = '</li>';
     $pagination_config['num_tag_open'] = '<li>';
     $pagination_config['num_tag_close'] = '</li>';
     $pagination_config['page_query_string'] = true;
     $this->pagination->initialize($pagination_config);
     $data = array('list' => array_value($order, 'data', array()), 'count' => array_value($order, 'count', 0), 'input' => $input);
     $this->view($data);
 }
 public function send(array $message)
 {
     $to = (array) array_value($message, 'to');
     if (count($to) === 0) {
         return [];
     }
     return $this->mandrill->messages->send($message);
 }
예제 #6
0
 public function send(array $message)
 {
     $result = [];
     $to = (array) array_value($message, 'to');
     foreach ($to as $item) {
         $result[] = ['_id' => Utility::guid(false), 'email' => $item['email'], 'status' => 'sent'];
     }
     return $result;
 }
예제 #7
0
 /**
 	Executes the prepared statement.
 
 	@return	mixed	An instance of weeDatabaseDummyResult if the query returned rows or null.
 */
 public function execute()
 {
     // oci_execute triggers a warning when the statement could not be executed.
     @oci_execute($this->rStatement, OCI_DEFAULT) or burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), array_value(oci_error($this->rStatement), 'message')));
     $this->iNumAffectedRows = oci_num_rows($this->rStatement);
     if (oci_num_fields($this->rStatement) > 0) {
         // TODO: Check whether the silence operator is really required here.
         @oci_fetch_all($this->rStatement, $aRows, 0, -1, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
         return new weeDatabaseDummyResult($aRows);
     }
 }
예제 #8
0
 protected function _build_query($input)
 {
     $this->_build_base($input);
     if ($limit = array_value($input, 'limit')) {
         $offset = array_value($input, 'offset');
         $this->db->limit($limit, $offset);
     }
     $this->db->order_by('id DESC');
     $result = $this->db->get($this->_table_name);
     return $result->num_rows() ? $result->result_array() : array();
 }
예제 #9
0
 /**
 	Initialises a new mssql database.
 
 	This database driver accepts the following parameters:
 	 * host:		The server of the database as specified by mssql_connect.
 	 * user:		The username.
 	 * password:	The password.
 	 * dbname:		The name of the database.
 
 	@param	$aParams	The parameters of the database.
 	@throw	ConfigurationException	The MSSQL PHP extension is missing.
 	@throw	DatabaseException		The connection failed.
 */
 public function __construct($aParams = array())
 {
     function_exists('mssql_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'MSSQL'));
     // mssql_connect triggers a warning if the connection failed.
     // Don't use mssql_get_last_message here as it does not always return
     // something useful on connection failure.
     $this->rLink = mssql_connect(array_value($aParams, 'host'), array_value($aParams, 'user'), array_value($aParams, 'password'), true);
     $this->rLink !== false or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), array_value(error_get_last(), 'message')));
     if (isset($aParams['dbname'])) {
         $this->selectDb($aParams['dbname']);
     }
 }
예제 #10
0
 /**
  * Get the path based on a class name.
  *
  * @param  string		  	The class name
  *
  * @return string|false Returns the path on success FALSE on failure
  */
 public function findPath($classname, $basepath = null)
 {
     $path = false;
     /*
      * Exception rule for Exception classes
      *
      * Transform class to lower case to always load the exception class from the /exception/ folder.
      */
     if ($pos = strpos($classname, 'Exception')) {
         $filename = substr($classname, $pos + strlen('Exception'));
         $classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
     }
     $word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
     $parts = explode(' ', $word);
     if (array_shift($parts) == 'com') {
         //Switch the basepath
         if (!empty($basepath)) {
             $this->_basepath = $basepath;
         }
         $component = 'com_' . strtolower(array_shift($parts));
         $file = array_pop($parts);
         $path = null;
         if (count($parts)) {
             if ($parts[0] != 'view') {
                 foreach ($parts as $key => $value) {
                     $parts[$key] = KInflector::pluralize($value);
                 }
             } else {
                 $parts[0] = KInflector::pluralize($parts[0]);
             }
             $path = implode('/', $parts);
         }
         $path = '/components/' . $component . '/' . $path;
         $filepath = $path . '/' . $file . '.php';
         $basepath = $this->_basepath;
         if (array_value($parts, -1) == 'exceptions') {
             if (!file_exists($basepath . $filepath)) {
                 $filepath = $path . '/default.php';
             }
         }
         if (count($parts) == 2 && $parts[0] == 'domains') {
             if ($parts[1] == 'entities' && JPATH_SITE != $this->_basepath) {
                 //set the basepath of entities to the site
                 if (!file_exists($basepath . $filepath)) {
                     $basepath = JPATH_SITE;
                 }
             }
         }
         $path = $basepath . $filepath;
     }
     return $path;
 }
예제 #11
0
파일: File.php 프로젝트: sledgehammer/mvc
 /**
  * @param array $options ['etag'=> bool, 'file_get_contents' => bool]
  */
 public function __construct($filename, $options = array('etag' => false))
 {
     $this->filename = $filename;
     $this->etag = array_value($options, 'etag');
     if (!file_exists($filename)) {
         if (basename($filename) == 'index.html') {
             $this->error = new HttpError(403);
         } else {
             $this->error = new HttpError(404);
         }
         return;
     }
     $last_modified = filemtime($filename);
     if ($last_modified === false) {
         $this->error = new HttpError(500);
         return;
     }
     if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
         $if_modified_since = strtotime(preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']));
         if ($if_modified_since >= $last_modified) {
             // Is the Cached version the most recent?
             $this->notModified = true;
             return;
         }
     }
     if ($this->etag) {
         $etag = md5_file($filename);
         if (array_value($_SERVER, 'HTTP_IF_NONE_MATCH') === $etag) {
             $this->notModified = true;
             return;
         }
         $this->headers[] = 'ETag: ' . md5_file($filename);
     }
     $this->notModified = false;
     if (is_dir($filename)) {
         $this->error = new HttpError(403);
         return;
     }
     $this->headers['Content-Type'] = \Sledgehammer\mimetype($filename);
     $this->headers['Last-Modified'] = gmdate('r', $last_modified);
     $filesize = filesize($filename);
     if ($filesize === false) {
         $this->error = new HttpError(500);
         return;
     }
     $this->headers['Content-Length'] = $filesize;
     // @todo Detecteer bestanden groter dan 2GiB, deze geven fouten.
     if (array_value($options, 'file_get_contents')) {
         $this->fileContents = file_get_contents($filename);
     }
 }
예제 #12
0
 /**
 	Initialises a new pgsql database.
 
 	This database driver accepts the same parameters as the ones allowed in the connection string
 	passed to pg_connect plus "encoding", which is the encoding used by the client as specified
 	by pg_set_client_encoding.
 
 	The default encoding is UNICODE.
 
 	@param	$aParams	The parameters of the database.
 	@see	http://php.net/pg_connect
 	@see	http://php.net/pg_set_client_encoding
 */
 public function __construct($aParams = array())
 {
     function_exists('pg_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'PostgreSQL'));
     $sEncoding = array_value($aParams, 'encoding', 'UNICODE');
     unset($aParams['encoding']);
     $sConnection = null;
     foreach ($aParams as $sKey => $sValue) {
         $sConnection .= $sKey . "='" . str_replace(array("'", "\\"), array("\\'", "\\\\"), $sValue) . "' ";
     }
     // pg_connect triggers a warning if the connection failed.
     $this->rLink = @pg_connect($sConnection, PGSQL_CONNECT_FORCE_NEW);
     $this->rLink === false and burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), array_value(error_get_last(), 'message')));
     pg_set_client_encoding($this->rLink, $sEncoding) != -1 or burn('InvalidArgumentException', sprintf(_WT('Encoding "%s" is invalid.'), $sEncoding));
 }
예제 #13
0
 /**
 	Initialises a new mysqli database.
 
 	This database driver accepts the following parameters:
 	 * host:		The host of the database server.
 	 * user:		The user of the connection to the database.
 	 * password:	The password used by the user.
 	 * dbname:		The name of the database to select.
 	 * encoding:	The encoding to use for the database connection.
 
 	Refer to the documentation of mysqli::real_connect() to know the default values
 	of the `host`, `user` and `password` parameters.
 
 	@param	$aParams					The parameters of the database.
 	@throw	ConfigurationException		The MySQLi PHP extension is missing.
 	@throw	DatabaseException			Failed to connect to the database.
 	@throw	InvalidArgumentException	The given encoding is invalid.
 */
 public function __construct($aParams = array())
 {
     function_exists('mysqli_real_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'MySQLi'));
     $this->oDb = new mysqli();
     $this->oDb->init();
     // mysqli_real_connect returns false and triggers a warning if the connection failed.
     @$this->oDb->real_connect(array_value($aParams, 'host'), array_value($aParams, 'user'), array_value($aParams, 'password')) or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), $this->oDb->connect_error));
     if (isset($aParams['encoding'])) {
         $this->oDb->set_charset($aParams['encoding']) or burn('InvalidArgumentException', sprintf(_WT('Encoding "%s" is invalid.'), $aParams['encoding']));
     }
     if (isset($aParams['dbname'])) {
         $this->selectDb($aParams['dbname']);
     }
 }
예제 #14
0
 /**
 	Establish a simple connection to an LDAP server on a specified hostname and port, and bind to the LDAP directory with the specified RDN and password.
 	For binding anonymously, you don't need to specify RDN and password.
 
 	Parameters:
 		* host: The LDAP server.
 		* port: The port to connect.
 		* rdn: The Relative Distinguished Name.
 		* password: The password to use.
 
 	@param $aPrams List of parameters used to initalize the connection and authentication.
 	@throw ConfigurationException LDAP support must be enabled.
 	@throw InvalidArgumentException The host parameter must be specified.
 	@throw LDAPException If an error occurs.
 */
 public function __construct($aParams = array())
 {
     function_exists('ldap_connect') or burn('ConfigurationException', 'LDAP support is missing.');
     $this->aParams = $aParams;
     empty($aParams['host']) and burn('InvalidArgumentException', 'The host parameter must not be empty.');
     $this->rLink = ldap_connect($this->aParams['host'], array_value($this->aParams, 'port', 389));
     $this->rLink === false and burn('LDAPException', sprintf(_WT('Failed to connect to "%s".'), $this->aParams['host']));
     // OpenLDAP2 requires the protocol version to be set
     // TODO: test if this is compatible with other different LDAP servers
     ldap_set_option($this->rLink, LDAP_OPT_PROTOCOL_VERSION, 3);
     $b = ldap_bind($this->rLink, array_value($this->aParams, 'rdn'), array_value($this->aParams, 'password'));
     if ($b === false) {
         throw new LDAPException(sprintf(_WT('Could not bind the RDN "%s".'), array_value($this->aParams, 'rdn')) . "\n" . ldap_error($this->rLink), ldap_errno($this->rLink));
     }
 }
예제 #15
0
 /**
 	Change the locale used by the application.
 
 	@param $sLocale The new locale.
 */
 public function set($sLocale, $sCodeSet = 'UTF-8', $sModifier = null)
 {
     if (strlen($sLocale) == 2) {
         $sLocale = array_value($this->aLocaleMap, $sLocale, $sLocale);
     }
     if (strlen($sLocale) > 1) {
         if (!is_null($sCodeSet)) {
             $sLocale .= '.' . $sCodeSet;
         }
         if (!is_null($sModifier)) {
             $sLocale .= '@' . $sModifier;
         }
     }
     setlocale(LC_ALL, $sLocale) or burn('UnexpectedValueException', _WT('An error occurred while trying to set the locale.'));
 }
예제 #16
0
function array_value($array)
{
    $html = "";
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            $html .= array_value($value, ++$count);
        } else {
            if ($key == 'full_name') {
                $html .= "<tr><td><a href='#' id='github_curl' title='" . $value . "'>" . $value . "</a></td>";
            }
            if ($key == 'created_at') {
                $html .= "<td>" . $value . "</td></tr>";
            }
        }
    }
    return $html;
}
예제 #17
0
function array_value($array)
{
    $html = "";
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            $html .= array_value($value, ++$count);
        } else {
            if ($key == 'full_name') {
                $html .= "<tr><td>" . $value . "</td><td><a href='#' id='github_curl' class='github_file' title='" . $value . "'>файлы</a></td><td><a href='#' id='github_curl' class='github_comment' title='" . $value . "'>комментарии</a></td>";
            }
            if ($key == 'created_at') {
                $html .= "<td>" . $value . "</td></tr>";
                //$value=date_parse($value);
                //$html.="<td>".(isset($value['year'])?$value['year']."-".$value['month']."-".$value['day']." ".$value['hour'].":".$value['minute'].":".$value['second']:"")."</td></tr>";
            }
        }
    }
    return $html;
}
예제 #18
0
 /**
 	Initialises a new mysql database.
 
 	This database driver accepts the following parameters:
 	 * host:		The host of the database server.
 	 * user:		The user of the connection to the database.
 	 * password:	The password used by the user.
 	 * dbname:		The name of the database to select.
 	 * encoding:	The encoding to use for the database connection. Defaults to 'utf8'.
 
 	Refer to the documentation of mysql_connect to know the default values
 	of the `host`, `user` and `password` parameters.
 
 	This class always opens a new link to the given database.
 
 	@param	$aParams					The parameters of the database.
 	@throw	ConfigurationException		The MySQL PHP extension is missing.
 	@throw	DatabaseException			Failed to connect to the database.
 	@throw	InvalidArgumentException	The given encoding is invalid.
 	@see	http://php.net/mysql_connect
 */
 public function __construct($aParams = array())
 {
     function_exists('mysql_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'MySQL'));
     // mysql_connect is silenced because it triggers a warning when the connection failed.
     $this->rLink = @mysql_connect(array_value($aParams, 'host'), array_value($aParams, 'user'), array_value($aParams, 'password'), true);
     $this->rLink !== false or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), mysql_error()));
     if (!isset($aParams['encoding'])) {
         $this->doQuery('SET NAMES utf8');
     } else {
         try {
             $this->query('SET NAMES ?', $aParams['encoding']);
         } catch (DatabaseException $e) {
             burn('InvalidArgumentException', sprintf(_WT('Encoding "%s" is invalid.'), $aParams['encoding']));
         }
     }
     if (isset($aParams['dbname'])) {
         $this->selectDb($aParams['dbname']);
     }
 }
예제 #19
0
 /**
 	Process the pipe.
 
 	This method should be called after the input of the pipe has been
 	sent into the output buffer.
 */
 public function process()
 {
     // Store LaTeX output in a temporary file
     $sTmpFilename = tempnam(null, null);
     file_put_contents($sTmpFilename, ob_get_clean());
     // Convert it to PDF
     $sTmpDir = sys_get_temp_dir();
     $sPdfLatex = 'cd ' . $sTmpDir . ' && pdflatex ' . array_value($this->aParams, 'options') . ' ' . $sTmpFilename;
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex1.log');
     exec($sPdfLatex . ' > ' . $sTmpDir . '/pdflatex2.log');
     // filesize will trigger a warning if the file couldn't be stat'd (usually because it doesn't exist).
     $iSize = @filesize($sTmpFilename . '.pdf');
     $iSize === false and burn('UnexpectedValueException', _WT(sprintf('The conversion of file "%s" from LaTeX to PDF failed.', $sTmpFilename)));
     // Send the PDF to the browser
     safe_header('Content-Length: ' . $iSize);
     readfile($sTmpFilename . '.pdf');
     // Cleanup the temporary directory
     exec('rm ' . $sTmpFilename . '*');
 }
예제 #20
0
 /**
  * Read meta records.
  *
  * @param string [$key] The name of the meta property, when ommitted getMeta() returns all meta fields in a assoc array.
  * @param mixed [$default] Default returnvalue, when ommitted getMeta() will throw an exception if the property doesn't exist.
  *
  * @return mixed
  */
 public function getMeta($key = null, $default = null)
 {
     if ($this->meta instanceof HasManyPlaceholder || $this->meta instanceof Collection) {
         $meta = $this->meta;
     } else {
         throw new Exception('implement support');
     }
     if ($key === null) {
         $data = [];
         foreach ($meta as $row) {
             if (array_key_exists($row->key, $data)) {
                 if (array_value($data, $row->key, 0) === '__MULTIRECORD__') {
                     $data[$row->key][] = $row->value;
                 } else {
                     $data[$row->key] = ['__MULTIRECORD__', $data[$row->key], $row->value];
                 }
             } else {
                 $data[$row->key] = $row->value;
             }
         }
         return $data;
     }
     $value = $meta->where(['key' => $key]);
     if (count($value) == 1) {
         foreach ($value as $metaField) {
             return $metaField->value;
         }
     } elseif (count($value) == 0) {
         if (func_num_args() > 1) {
             return $default;
         }
         throw new InfoException('Meta field: "' . $key . '" doesn\'t exist in ' . str_replace(__NAMESPACE__ . '\\Model\\', '', static::class) . ' ' . $this->id, 'Existing fields: ' . \Sledgehammer\quoted_human_implode(' or ', array_keys($meta->selectKey('key')->toArray())));
     }
     $data = ['__MULTIRECORD__'];
     foreach ($value as $row) {
         $data[] = $row->value;
     }
     return $data;
 }
예제 #21
0
 public function publish(\Exception $exception)
 {
     $exceptionStacksStrBuilder = new FileStringBuilder();
     $callStacksStrBuilder = new FileStringBuilder();
     header_remove();
     header('Content-Type: text/xml; charset=UTF-8', true, 500);
     $exceptionName = get_class($exception);
     $traceExceptions = $exception->getTrace();
     $callStacks = debug_backtrace();
     foreach ($traceExceptions as $traceException) {
         $stacksStr = "";
         if (array_key_exists('args', $traceException)) {
             $stacksStr = $this->argmentsToXml($traceException['args']);
         }
         $exceptionStacksStrBuilder->append(sprintf(self::EXCEPTION_STACK_FORMAT, array_value($traceException, 'class'), array_value($traceException, 'function'), array_value($traceException, 'line'), array_value($traceException, 'file'), $stacksStr));
     }
     //$callStacks = array_reverse($callStacks);
     foreach ($callStacks as $callStack) {
         $stacksStr = "";
         if (array_key_exists('args', $callStack)) {
             $stacksStr = $this->argmentsToXml($callStack['args']);
         }
         if (!array_key_exists('type', $callStack)) {
             $type = "unknown";
         } elseif ($callStack['type'] == "->") {
             $type = "method";
         } elseif ($callStack['type'] == "::") {
             $type = "static method";
         } elseif ($callStack['type'] == "") {
             $type = "function";
         }
         $class = array_key_exists('class', $callStack) ? $callStack['class'] : 'unknown';
         $callStacksStrBuilder->append(sprintf(self::CALL_STACK_FORMAT, $class, $callStack['function'], array_value($callStack, 'line'), $type, array_value($callStack, 'file'), $stacksStr));
     }
     $exceptionTraceStr = sprintf(self::EXCEPTIONS_WRAPPER_FORMAT, $exceptionName, $exception->getMessage(), $exception->getFile(), $exception->getCode(), $exception->getLine(), $exceptionStacksStrBuilder->toString());
     printf(self::XML_WRAPPER, $exceptionTraceStr, $callStacksStrBuilder->toString());
     exit;
 }
예제 #22
0
 /**
  * upright picture if it has exif orientation data
  */
 private function upright($img)
 {
     $exif = @exif_read_data($this->tmp_name);
     if ($exif === false || empty($exif)) {
         return $img;
     }
     $orientation = array_value($exif, array('Orientation'));
     switch ($orientation) {
         case 3:
         case 4:
             $img->rotateImage(new ImagickPixel('none'), 180);
             break;
         case 5:
         case 6:
             $img->rotateImage(new ImagickPixel('none'), 90);
             break;
         case 7:
         case 8:
             $img->rotateImage(new ImagickPixel('none'), 270);
             break;
     }
     return $img;
 }
예제 #23
0
 protected function eventEdit($aEvent)
 {
     $oResource = exResourceSet::instance()->fetch($aEvent['get']['r']);
     $oForm = new weeForm('resource', 'edit');
     $oForm->fill($oResource);
     if (isset($aEvent['post'])) {
         $aData = $oForm->filter($aEvent['post']);
         try {
             $oForm->validate($aData);
             $oResource->setFromArray($aData);
             $oResource->update();
             $this->update('replaceContent', '#msg', 'The resource has been successfully edited!');
         } catch (FormValidationException $e) {
             $this->update('replaceContent', '#msg', 'The submitted data is erroneous!');
             $oForm->fillErrors($e);
         }
         $oForm->fill($aData);
         if (array_value($aEvent, 'context') == 'xmlhttprequest') {
             $this->update('replace', 'form', $oForm);
         }
     }
     $this->set('form', $oForm);
 }
예제 #24
0
 public function send(array $message)
 {
     // build recipients
     $to = [];
     $bcc = [];
     $toIncoming = (array) array_value($message, 'to');
     foreach ($toIncoming as $item) {
         $type = array_value($item, 'type');
         if ($type == 'bcc') {
             $bcc[$item['email']] = $item['name'];
         } else {
             $to[$item['email']] = $item['name'];
         }
     }
     if (count($to) === 0) {
         return [];
     }
     $fromEmail = array_value($message, 'from_email');
     $fromName = array_value($message, 'from_name');
     $swiftMessage = Swift_Message::newInstance()->setFrom([$fromEmail => $fromName])->setTo($to)->setBcc($bcc)->setSubject($message['subject'])->setBody($message['html'], 'text/html');
     if (isset($message['text'])) {
         $swiftMessage->addPart($message['text'], 'text/plain');
     }
     if (isset($message['headers']) && is_array($message['headers'])) {
         $headers = $swiftMessage->getHeaders();
         foreach ($message['headers'] as $k => $v) {
             $headers->addTextHeader($k, $v);
         }
     }
     $sent = $this->swift->send($swiftMessage);
     $result = [];
     foreach ($message['to'] as $item) {
         $result[] = ['_id' => Utility::guid(false), 'email' => $item['email'], 'status' => $sent ? 'sent' : 'rejected'];
     }
     return $result;
 }
예제 #25
0
파일: form.php 프로젝트: utumdol/codeseed
/**
 * get default value for form.
 * form에서 입력값을 출력할 경우에만 사용하도록 합니다.
 * 
 * form_value($obj, $prop1, $prop2, ...) means $obj->prop1->prop2.
 * form_value($arr, $idx1, $idx2, ...) means $arr[$idx1][$idx2].
 */
function form_value()
{
    $args = func_get_args();
    if (empty($args)) {
        return null;
    }
    $props = array_slice($args, 1);
    if (empty($props)) {
        return $args;
    }
    // 사용자가 입력한 수정값 보존을 위해 플래시(1회성 세션)에서 우선 검색한다.
    $flash = Context::get('flash');
    $old_params = array_value($flash->get('_old_params'), $props);
    if (isset($old_params)) {
        return $old_params;
    }
    if (is_array($args[0])) {
        return array_value($args[0], array_slice($args, 1));
    }
    if (is_object($args[0])) {
        return object_value($args[0], array_slice($args, 1));
    }
    return null;
}
예제 #26
0
파일: user.php 프로젝트: zhangjmy/xibbs
    $header['title'] = '用户管理';
    $pagesize = 20;
    $srchtype = param(2);
    $keyword = trim(urldecode(param(3)));
    $page = param(4, 0);
    $cond = array();
    if ($keyword) {
        !in_array($srchtype, array('uid', 'username', 'mobile', 'email', 'gid', 'create_ip')) and $srchtype = 'uid';
        $cond[$srchtype] = $srchtype == 'create_ip' ? ip2long($keyword) : $keyword;
    }
    $n = user_count($cond);
    $page = page($page, $n, $pagesize);
    $userlist = user_find($cond, array('uid' => -1), $page, $pagesize);
    $pagehtml = pages("admin/user-list-{$srchtype}-" . urlencode($keyword) . '-{page}.htm', $n, $page, $pagesize);
    foreach ($userlist as &$_user) {
        $_user['group'] = array_value($grouplist, $_user['gid'], '');
    }
    include "./admin/view/user_list.htm";
} elseif ($action == 'create') {
    if ($method == 'GET') {
        $header['title'] = '用户创建';
        include "./admin/view/user_create.htm";
    } elseif ($method == 'POST') {
        $mobile = param('mobile');
        $email = param('email');
        $username = param('username');
        $password = param('password');
        $gid = param('gid');
        $mobile and !is_mobile($mobile, $err) and message(1, $err);
        $email and !is_email($email, $err) and message(2, $err);
        $username and !is_username($username, $err) and message(3, $err);
예제 #27
0
        }
        return $files;
    }
    function kib_format($size_in_bytes, $precision = 2, $pad_length = 7)
    {
        $number = number_format($size_in_bytes / 1024, $precision, '.', '');
        return str_pad($number, $pad_length, ' ', STR_PAD_LEFT) . ' KiB';
    }
}
$modules = Framework::getModules();
$files = array();
// Scanning $module/public/ folders
foreach ($modules as $module => $info) {
    $module_path = $info['path'];
    if (is_dir($module_path . 'public')) {
        if (array_value($info, 'app')) {
            $prefix = '';
        } else {
            $prefix = $module . '/';
        }
        minifyAppendFiles($files, $module_path . 'public/', $prefix);
    }
}
$minifyCacheFolder = TMP_DIR . 'minify/';
//rmdirs($minifyCacheFolder); rmdir($minifyCacheFolder);
$totalFullSize = array('javascript' => 0, 'css' => 0, 'images' => 0, 'total' => 0);
$totalMinifiedSize = $totalFullSize;
foreach ($files as $filename => $pathname) {
    $minifiedPathname = $minifyCacheFolder . $filename;
    $extension = strtolower(file_extension($filename));
    if ($extension === 'css') {
function forgotPassword()
{
    global $SETTINGS, $TABLE_PREFIX, $PROGRAM_DIR;
    $GLOBALS['sentEmail'] = false;
    // Lookup username or email
    if (@$_REQUEST['usernameOrEmail']) {
        security_dieUnlessPostForm();
        security_dieUnlessInternalReferer();
        security_dieOnInvalidCsrfToken();
        disableInDemoMode('', 'forgotPassword.php', false);
        // send emails
        $escapedNameOrEmail = mysql_escape($_REQUEST['usernameOrEmail']);
        $matchingUsers = mysql_select('accounts', "'{$escapedNameOrEmail}' IN(`username`,`email`)");
        foreach ($matchingUsers as $user) {
            // get reset url
            $resetBaseUrl = array_value(explode('?', thisPageUrl()), 0);
            $resetCode = _generatePasswordResetCode($user['num']);
            $resetUrl = "{$resetBaseUrl}?menu=resetPassword&userNum=" . $user['num'] . "&resetCode={$resetCode}";
            // send message - v2.50 switched to emailTemplate_loadFromDB()
            $emailHeaders = emailTemplate_loadFromDB(array('template_id' => 'CMS-PASSWORD-RESET', 'placeholders' => array('user.num' => $user['num'], 'user.email' => $user['email'], 'resetUrl' => $resetUrl)));
            $errors = sendMessage($emailHeaders);
            if ($errors) {
                alert("Mail Error: " . nl2br($errors));
            }
            //
            $GLOBALS['sentEmail'] = true;
        }
    }
    // display errors
    if (array_key_exists('usernameOrEmail', $_REQUEST) && @$_REQUEST['usernameOrEmail'] == '') {
        alert(t("No username or email specified!"));
    }
    if (@$_REQUEST['usernameOrEmail'] && !$GLOBALS['sentEmail']) {
        alert(t("No matching username or email was found!"));
    }
    //
    showInterface('forgotPassword.php', false);
    exit;
}
예제 #29
0
파일: forum.php 프로젝트: 994724435/Ride
     empty($forum) and message(11, '版块不存在');
     $brief = param('brief', '', FALSE);
     $accesson = param('accesson', 0);
     $moduids = param('moduids');
     $seo_title = param('seo_title');
     $seo_keywords = param('seo_keywords');
     $grouplist = group_list_cache();
     if ($accesson) {
         $allowread = param('allowread', array(0));
         $allowthread = param('allowthread', array(0));
         $allowpost = param('allowpost', array(0));
         $allowagree = param('allowagree', array(0));
         $allowattach = param('allowattach', array(0));
         $allowdown = param('allowdown', array(0));
         foreach ($grouplist as $gid => $v) {
             $access = array('allowread' => array_value($allowread, $gid, 0), 'allowthread' => array_value($allowthread, $gid, 0), 'allowpost' => array_value($allowpost, $gid, 0), 'allowagree' => array_value($allowagree, $gid, 0), 'allowattach' => array_value($allowattach, $gid, 0), 'allowdown' => array_value($allowdown, $gid, 0));
             forum_access_replace($fid, $gid, $access);
         }
     } else {
         forum_access_delete_by_fid($fid);
     }
     $arr['accesson'] = $accesson;
     $arr['brief'] = $brief;
     $arr['moduids'] = $moduids;
     $arr['seo_title'] = $seo_title;
     $arr['seo_keywords'] = $seo_keywords;
 }
 if (empty($forum)) {
     $arr['fid'] = $fid;
     $r = forum_create($arr);
     $r !== FALSE ? message(0, '创建成功') : message(11, '创建失败');
예제 #30
0
 /**
  * Gets one or all query parameters.
  *
  * @param string $index
  *
  * @return mixed
  */
 public function getQuery($index = false)
 {
     return $index ? array_value($this->query, $index) : $this->query;
 }