I am trying to use sitecake www.sitecake.com on my website. I installed it using the instructions here http://sitecake.com/install.html and tested it on the about page.
The PHP is misbehaving, and unfortunately I an at a loss on what the problem is. I've searched for the different PHP errors for a couple days now and came up with one solution for part of the problem, but I still can't get it to work correctly.
After I installed sitecake and added the line to the top of the about page, I got this error when I tried to access the page:
PHP Error Message
PHP Code:
Warning: realpath() [function.realpath]: open_basedir restriction in
effect. File(/usr/local/apache/htdocs) is not within the allowed
path(s): (/home/:/usr/lib/php:/tmp) in
/home/a5940384/public_html/sitecake/server/config.php on line 12
PHP Error Message
PHP Code:
Warning: substr_compare() [function.substr-compare]: The length must
be greater than zero in
/home/a5940384/public_html/sitecake/server/config.php on line 14
An error occurred
Application error
Exception information:
PHP Code:
Message: file_exists() [function.file-exists]: open_basedir
restriction in effect. File(/usr/local/apache/htdocs//about.php) is
not within the allowed path(s): (/home/:/usr/lib/php:/tmp) Stack trace:
#0 /home/a3779563/public_html/sitecake/server/application/services/impl/basic/PageTemplateImpl.php(30): Bootstrap::globalErrorHandler(2, 'file_exists() [...', '/home/a3779563/...', 30, Array)
#1 /home/a3779563/public_html/sitecake/server/application/services/impl/basic/RenderServiceImpl.php(54): PageTemplateImpl->setPageRequest('/usr/local/apac...')
#2 /home/a3779563/public_html/sitecake/server/application/services/impl/basic/RenderServiceImpl.php(23): RenderServiceImpl->renderResponse('/index.php')
#3 /home/a3779563/public_html/sitecake/server/application/controllers/RenderController.php(13): RenderServiceImpl->render()
#4 /home/a3779563/public_html/sitecake/server/library/Zend/Controller/Action.php(513): RenderController->renderAction('/index.php', false)
#5 /home/a3779563/public_html/sitecake/server/library/Zend/Controller/Dispatcher/Standard.php(295): Zend_Controller_Action->dispatch()
#6 /home/a3779563/public_html/sitecake/server/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch('renderAction')
#7 /home/a3779563/public_html/sitecake/server/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 /home/a3779563/public_html/sitecake/server/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#9 /home/a3779563/public_html/sitecake/server/sitecake_entry.php(47): Zend_Application->run()
#10 /home/a3779563/public_html/index.php(1): include('/home/a3779563/...')
#11 {main}
Request Parameters:
array ( 'controller' => 'render', 'action' => 'render', )
I was able to fix these errors by replacing
PHP Code:
$doc_root= $_SERVER['DOCUMENT_ROOT'];
on lines 12 and 23
with
PHP Code:
$doc_root = dirname(_FILE_);
in sitecake/server/config.php (found that fix on the forum while searching for open_basedir restrictions)
Here's the whole config.php script in question after the change:
PHP Code:
<?php
define( 'CONTENT_DIR', dirname(dirname(SITECAKE_SERVER_BASE_DIR)).DS.'sitecake-content');
define( 'APP_TMP_DIR', CONTENT_DIR.DS.'temp' );
define('LICENSE_PATH', dirname(SITECAKE_SERVER_BASE_DIR).DS.'license.key');
define( 'CREDENTIAL_FILE', SITECAKE_SERVER_BASE_DIR.DS.'credential.php' );
define( 'SITECAKE_EDITOR_CONFIG_FILE', dirname(SITECAKE_SERVER_BASE_DIR).DS.'editor.cfg' );
# define( 'SITECAKE_BASE_RELATIVE_URL', '/' );
if ( !defined('SITECAKE_BASE_RELATIVE_URL') )
{
$doc_root = dirname(_FILE_);
$entryDir = realpath(dirname(dirname(SITECAKE_SERVER_BASE_DIR)));
if ( substr_compare($entryDir, $docRootDir, 0, strlen($docRootDir)) != 0 ) die('Unable to determine SITECAKE_BASE_RELATIVE_URL');
define( 'SITECAKE_BASE_RELATIVE_URL', str_replace('\\', '/', substr($entryDir, strlen($docRootDir))));
}
define( 'SERVICE_URL', SITECAKE_BASE_RELATIVE_URL.'/sitecake/server/sitecake_entry.php' );
define( 'SITECAKE_PUBLIC_MANAGER_URL', SITECAKE_BASE_RELATIVE_URL.'/sitecake/client/publicmanager/publicmanager.nocache.js' );
define( 'SITECAKE_CONTENT_MANAGER_URL', SITECAKE_BASE_RELATIVE_URL.'/sitecake/client/contentmanager/contentmanager.nocache.js' );
define( 'CONTENT_BASE_URL', SITECAKE_BASE_RELATIVE_URL.'/sitecake-content');
define( '$doc_root = dirname(_FILE_);'] );
define( 'PHP_TEMPLATE', false );
define( 'TEMPLATE_CACHING', true );
$applicationIncludes = array(
realpath(APPLICATION_PATH),
realpath(APPLICATION_PATH.DS.'controllers'),
realpath(APPLICATION_LIBRARY_PATH),
realpath(APPLICATION_PATH.DS.'services'.DS.'impl'.DS.'onesite'),
realpath(APPLICATION_PATH.DS.'services'.DS.'impl'.DS.'basic'),
realpath(APPLICATION_PATH.DS.'services'),
get_include_path(),
);
?>
and was able to access the site, but when I try to log in to sitecake I get this error in the log in box:
Parse error: syntax error, unexpected ']' in /home/a3779563/public_html/sitecake/server/config.php on line 23
I can' find anything for PHP errors that is helpful, so now I'm at a loss.
Any ideas on how to use site cake with 000webhost?
If you made it this far thanks for reading!
the URL for the site: http://nave.net23.net/
You have PHP safe mode in place on that server (which looks like it might be some shared host server by the looks of your /home/a5940384/public_html directory structure,
For whatever reason that app wants to look for files in /usr/local/apache/htdocs. So you probably will need to look through all the code to find out why it thinks that is your base directory. Maybe find out where SITECAKE_SERVER_BASE_DIR is defined as this seems to be the main constant used for calculating file paths.
Shared hosting is the devil's business.
I'd just turn off base_dir for starters if you can. Note, disabling safe_mode would not prevent the base_dir stuff.
As for the error you are getting now its simply telling you that there is a syntax error. Now I am not seeing it in what you posted. Maybe you fixed it locally but not on server yet?
Related
So basically I have been looking for a solution for like two days straight and nothing seems to be helping.
I am using Roundcube mail client with IMAP, postfixadmin and dovecot and whenever I try to upload attachments, I get an internal server error.
Here is something I managed to catch in logs:
[11-Nov-2021 01:41:27 UTC] PHP Fatal error: Uncaught TypeError: fclose(): Argument #1 ($stream) must be of type resource, null given in /var/www/roundcube/program/lib/Roundcube/rcube_imap_generic.php:430
Stack trace:
#0 /var/www/roundcube/program/lib/Roundcube/rcube_imap_generic.php(430): fclose()
#1 /var/www/roundcube/program/lib/Roundcube/rcube_imap_generic.php(1149): rcube_imap_generic->closeSocket()
#2 /var/www/roundcube/program/lib/Roundcube/rcube_imap.php(215): rcube_imap_generic->closeConnection()
#3 /var/www/roundcube/program/lib/Roundcube/rcube.php(1038): rcube_imap->close()
#4 /var/www/roundcube/program/include/rcmail.php(921): rcube->shutdown()
#5 [internal function]: rcmail->shutdown()
#6 {main}
thrown in /var/www/roundcube/program/lib/Roundcube/rcube_imap_generic.php on line 430
There are a lot of settings all around the server so if you think that you need some of them for debugging, just ask and I'll happily put them here
EDIT: I made a quick video with all the things going on. You can see that upload "failed" with internal server error message, but after refreshing the page, attachment is there and it's being sent with email, and after receiving that email, I can't see attachment preview in email, but when I click on it I can see it and download it.
After a few long days, I finally managed to figure this out on my own, and it's really simple. So what's happening is that rounducbe is trying to close file that doesn't exist.
So, to all of you who are facing with the same problem, to fix this you have to edit file "path/to/roundcube/program/lib/Roundcube/rcube_imap_generic.php" on line 430
Change this:
protected function closeSocket()
{
#fclose($this->fp);
$this->fp = null;
}
Into this:
protected function closeSocket()
{
if($this->fp){
#fclose($this->fp);
}
$this->fp = null;
}
I have a wordpress site which has installed EasySMTP plugin.
I have a real cron task and I have unactive wp simulated cron.
My cron is running, but inside it I want to make a mail send and is not working.
In my log, I see this:
[20-Apr-2017 14:46:02 UTC] PHP Fatal error: Uncaught exception 'phpmailerException' with message 'Invalid address: (setFrom) wordpress#[domain]' in /home/user/public_html/wp-includes/class-phpmailer.php:1023
Stack trace:
#0 /home/user/public_html/wp-includes/pluggable.php(352): PHPMailer->setFrom('wordpress#[domain...', 'WordPress', false)
#1 /home/user/public_html/wp-content/plugins/innovation-factory/includes/php/functions.php(350): wp_mail('msolla#domain...', 'Tienes 1 ideas ...', '\n\t\t<html>\n\t\t<bo...', Array)
#2 /home/user/public_html/wp-content/plugins/innovation-factory/innovation-factory.php(301): enviarNotificacion('msolla#domain...', 'Tienes 1 ideas ...', NULL, Array, '\n\t\t<html>\n\t\t<bo...')
#3 [internal function]: do_this_hourly()
#4 /home/user/public_html/wp-includes/class-wp-hook.php(298): call_user_func_array('do_this_hourly', Array)
#5 /home/user/public_html/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)
#6 /home/des in /home/user/public_html/wp-includes/class-phpmailer.php on line 1023
Obviusly I have other smtp configuration in EasySMTP. In fact, I have an smtp hosted in other server with other domain diferent to de web page domain.
If I call do_this_hourly() function out of the cron, it sends correctly the emails. I need do something different to mail in cron tasks? Maybe that wp-cron.php not load EasySMTP yet?
My cron is programmed with this command:
php /home/user/public_html/wp-cron.php
Thanks!
This seems to come from the fact that $_SERVER['SERVER_NAME'] is not set when mail is sent using cron via crontab, cli or some other command line script.
$_SERVER['SERVER_NAME'] throws a notice, $sitename is an empty string, and $from_email is simply 'wordpress#'.
WordPress does at least give you a chance to set the $from_email before it attempts to send, in which case I've added a filter which seems to work for me.
add_filter( 'wp_mail_from', function( $from_email ) {
// Domain ends with an #. Append the domain from the site url.
if ( substr( $from_email, -1 ) === '#' ) {
// Trim protocol, double forward slash, preceeding www, port, and remaind of request uri.
$from_email .= preg_replace( '#^(?:[hftps]*:)?//(?:www\.)?|[:/?].*$#i', '', get_site_url() );
}
return $from_email;
} );
$_SER
the problem is, that php doesn't get the $_SERVER[ 'SERVER_NAME' ] when executed via crontab. And that's why the phpmailer throws that exception.
I solved it by passing the variable manually in crontab. F.e:
*/15 * * * * export SERVER_NAME="server.domain.name" && php /var/www/clients/client2/web8/web/wp-base/wp-cron.php
A detailed description of this problem can be found here https://www.ask-sheldon.com/wordpress-cron-using-wp_mail-function/.
I am develloping graphs for connection logs of a website. Logs are parsed by logstash and served via elasticsearch.
I've develloped some graphs, nothing outstanding nor hard, but working.
Friday I started elasticsearch, and every script I wrote to get the data fail when I send the query.
My first thought was that I somehow modified the query, so I printed it and send it to elasticsearch (with plugin head). The query was fine and I have result.
I tried purging logs from logstash and elasticsearch, and restarting to feed them from known good data... Didn't fix anything.
Tried to see if the config has any error, used a backup of a working one, didn't work either.
As last hope, I tried to print PHP errors, and I do get an exception thrown from deep inside of elasticsearch:
Fatal error: Uncaught exception 'Guzzle\Http\Exception\ServerErrorResponseException' with message 'Server error response [status code] 500 [reason phrase]
Internal Server Error [url] http://localhost:9200/empreinte_index/mobile/_search' in /home/empreinte/vendor/guzzle/guzzle/src/Guzzle/Http/Exception/BadResponseException.php:43
Stack trace:
#0 /home/empreinte/vendor/guzzle/guzzle/src/Guzzle/Http/Message/Request.php(145): Guzzle\Http\Exception\BadResponseException::factory(Object(Guzzle\Http\Message\EntityEnclosingRequest), Object(Guzzle\Http\Message\Response))
#1 [internal function]: Guzzle\Http\Message\Request::onRequestError(Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#2 /home/empreinte/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php(164): call_user_func(Array, Object(Guzzle\Common\Event), 'request.error', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 /home/empreinte/vendor/symfony/event-dispatcher/Symfony in /home/empreinte/vendor/elasticsearch/elasticsearch/src/Elasticsearch/Connections/GuzzleConnection.php on line 238
So this seems to comfort the idea that my codes are fine, but I can't find what did I done wrong, nor where to search.
Here is a minimal example of the script I use:
<?php
echo "Days";
require '/home/empreinte/vendor/autoload.php';
$client = new Elasticsearch\Client();
$Query['index'] = 'empreinte_index';
$Query['type'] = 'web';
echo ".";
//Building the timeframe needed. For brevity, using hardcoded data.
$timeframe = "{"from" : "1404165600", "to" : "1404252000" },{"from" : "1404252000", "to" : "1404338400" }";
echo ".";
$Query['body']='
{
"aggs" :
{
"temps" :
{
"range" :
{
"field" : "time",
"ranges" : ['.$timeframe.']
},
"aggs" :
{
"new_users" :
{
"terms" :
{
"field" : "is_newuser"
}
}
}
}
}
}';
echo ".";
$result = $client->search($Query);
//Parse the data to get them in usable form for graphs
echo "OK</br>";
?>
Which output "Days...", And the exception if PHP is set to display it.
(If requested, I'll post the config file and some logs).
How can I fix this? Where can I find a similar error from which I can find a fix? What does mean the error?
If you check the response it looks like a request problem: 'request.error'
When you construct the timeframe you use double quotes to construct the string but also within the string, this can be a problem as well.
I do not really think this is the problem, but try to loose the quotes around the longs representing time stamps.
Finally try to print the query and try the query in a tool like sense from elasticsearch or the head plugin or the kopf plugin.
Hope that helps
I have searched this a lot and none of the solutions has worked so far, so I guess I really need to troubleshoot to see what the problem is:
When I browse our website www.theprinterdepo.com, it works fine on chrome, ie or firefox.
However when I go to the admin on www.theprinterdepo.com/admin on Internet explorer, then it shows the 500 internal server error, and after that if I try to use Internet Explorer to www.theprinterdepo.com, it shows the same error. At the same time I can be in Google Chrome or Firefox surfing the site and it works without a problem.
It takes ages to load on Internet Explorer when it works. while on chrome still loads perfect.
I set chmod 755 in index.php.
I added this on index.php
if ($_SERVER['REMOTE_ADDR'] == '83.134.93.212') { Mage::setIsDeveloperMode(true); ini_set('display_errors', 1); }
I got this
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 60: parser error : Opening and ending tag mismatch: config line 28 and confg in /home/theprint/public_html/lib/Varien/Simplexml/Config.php on line 510
#0 [internal function]: mageCoreErrorHandler(2, 'simplexml_load_...', '/home/theprint/...', 510, Array)
#1 /home/theprint/public_html/lib/Varien/Simplexml/Config.php(510): simplexml_load_string('loadString('loadFile('/home/theprint/...')
#4 /home/theprint/public_html/app/code/core/Mage/Admin/Model/Config.php(59): Mage_Core_Model_Config->loadModulesConfiguration('adminhtml.xml', Object(Varien_Simplexml_Config))
Line 510 correspond to this:
public function loadString($string)
{
if (is_string($string)) {
$xml = simplexml_load_string($string, $this->_elementClass);
if ($xml instanceof Varien_Simplexml_Element) {
$this->_xml = $xml;
return true;
}
} else {
Mage::logException(new Exception('"$string" parameter for simplexml_load_string is not a string'));
}
return false;
}
Since your error is Opening and ending tag mismatch: one of the quickest way to debug this is to disable all custom module/layout.xml modification and then reenable them one by one, until you find the xml that causing this error.
by editing that config file I was able to ech the path and find the xml failing, the start tag was and the end tag was
I fixed that and then it started to work
When the server has a MySQL config or other error it prints the MySQL user name and password to the browser. This is a security risk in that if the SQL db is unavailable it will also print the password to the browser.
In this example I intentionally set the password incorrectly, here is the output:
Fatal error: Uncaught exception
'PDOException' with message
'SQLSTATE[28000] [1045] Access denied
for user 'username'#'localhost' (using
password: YES)' in
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php:129
Stack trace: #0
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php(129):
PDO->__construct('mysql:host=loca...',
'drupal', 'password', Array) #1
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Mysql.php(96):
Zend_Db_Adapter_Pdo_Abstract->_connect() #2
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Abstract.php(459):
Zend_Db_Adapter_Pdo_Mysql->_connect() #3
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php(238):
Zend_Db_Adapter_Abstract->query('DESCRIBE
site_...', Array) #4
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Mysql.php(156):
Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBEsite_...') #5
/usr/local/zend/share/ZendFramework/library/Zend/Db/Table/Abstract.php(823):
Zend_Db_Adapter_Pdo_Mysq in
/usr/local/zend/share/ZendFramework/library/Zend/Db/Adapter/Pdo/Abstract.php
on line 144
Here is the current config code in the index.php file
global $db;
if ($CFG->flagDBAdapters) {
foreach ($config->db as $config_name => $database) {
$dbAdapters[$config_name] = Zend_Db::factory($database->adapter,
$database->config->toArray());
if ((boolean) $database->default) {
Zend_Db_Table::setDefaultAdapter($dbAdapters[$config_name]);
$db = $dbAdapters[$config_name];
}
}
Zend_Registry::set('dbAdapters', $dbAdapters);
I tried reading more about PDO and inserting
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
That just resulted in a different error
Fatal error: Call to undefined method
Zend_Db_Adapter_Pdo_Mysql::setAttribute()
in
/usr/local/zend/apache2/htdocs/source/index.php
on line 301
Can anyone help point me in the right direction as to what I should be looking for?
Well it's more like Zend Framework related question rather than general PHP issue.
So, ZF should have it's own ways to disable such behavior.
As of PHP, the display_errors setting sould be always turned off on the production server
You can use set_error_handler to specify your own error handler, which should display something much more user-friendly in production while displaying more detailed debugging data during development/testing.
putting the # symbol in front of a statement suppresses errors from being outputed.