CakePHP project Issue(FCKEditor and Broken links) - php

I am working on a project which is auction site and it is actually
clone of www.swoop.com.
This clone is developed on CakePHP platform and I have a issues there.
I purchase that script from http://www.moneymakersnetwork.info/products/Swoopo-Clone-PHP-Script.html and there is a demo: http://demo.bidscout.net (username: demo, password: password1).
In that cms there is FCKEditor integrated and it is not working. It is
gives me that following error message:
The requested URL /js/fckeditor/editor/fckeditor.html was not found on
this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
And if I add new category it is come to a drop down list box and those
links are broken.
Ok, my host is like this: http://demosite.org/mysite/.
App and webroot folders are located in http://demosite.org/mysite/app and http://demosite.org/mysite/app/webroot.
I have a cofig.php file and it is look like this (http://demosite.org/mysite/app/config):
<?php
$config = array(
'Database' => array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'myuser',
'password' => 'mypassword',
'database' => 'mydb',
'prefix' => ''
),
'App' => array(
'encoding' => 'UTF-8',
'baseUrl' => '',
'base' => '',
'dir' => 'app',
'webroot' => 'webroot',
'name' => 'mysite',
'url' => 'http://demo.org/mysite/',
'timezone' => 'Asia/Jakarta',
'language' => 'en',
'email' => 'test#demo.com',
'theme' => 'ddbids',
'currency' => 'USD',
'pageLimit' => 100,
'bidHistoryLimit' => 10,
'remember_me' => '+30 days',
'auctionUpdateFrequency' => 1,
'timeSyncFrequency' => 9,
'gateway' => true,
'demoMode' => false,
'noAutobids' => false,
'cronTime' => 1,
'Image' => array(
'thumb_width' => 100,
'thumb_height' => 100,
'max_width' => 340,
'max_height' => 230
),
'Dob' => array(
'year_min' => date('Y') - 100,
'year_max' => date('Y') - 17
)
),
'Paypal' => array(
'url' => 'https://www.paypal.com/cgi-bin/webscr',
'email' => '',
'lc' => 'GB'
),
'Email' => array(
'delivery' => 'smtp',
'sendAs' => 'both',
'host' => 'localhost',
'port' => 25,
'timeout' => 60,
'username' => '',
'password' => ''
),
'Cache' => array(
//'disable' => true,
'check' => false,
'time' => '' // relative time such as +1 day, +2 months, +3 minutes
),
'debug' => 1
);
?>
I am very new to the CakePHP. Please help me.

Your problem is that (probably) the links are hard coded and expect your site to be at:
http://demosite.org/ instead of http://demosite.org/mysite/
this way your /js/fckeditor/editor/fckeditor.html can be found.
At least that's how it sounds to me this problem.

Just try this.
put the whole FCK folder in js FOLDER of in APP ie., APP/webroot/js/Editor

Related

The "" cache configuration does not exist

I am updating a project from CakePHP 3.5 to 4.0.
In one of my models, I am doing this:
public function afterSave(Event $event, EntityInterface $entity)
{
Cache::clear(false, 'dbResults');
}
This works in the "old" version of my project with CakePHP 3.5, but fails with CakePHP 4.0 with the error
The "" cache configuration does not exist.#0 /var/www/repo/public/vendor/cakephp/cakephp/src/Cache/Cache.php(230): Cake\Cache\Cache::_buildEngine('')
I don't understand why the code tries to search for a configuration with empty string "".
Here is the relevant part of my app.php config file:
'Cache' => [
'default' => [
'className' => 'File',
'prefix' => 'headless_',
'path' => CACHE,
'url' => env('CACHE_DEFAULT_URL', null),
],
'_cake_core_' => [
'className' => 'File',
'prefix' => 'headless_cake_core_',
'path' => CACHE . 'persistent/',
'serialize' => true,
'duration' => '+2 minutes',
'url' => env('CACHE_CAKECORE_URL', null),
],
'_cake_model_' => [
'className' => 'File',
'prefix' => 'headless_cake_model_',
'path' => CACHE . 'models/',
'serialize' => true,
'duration' => '+2 minutes',
'url' => env('CACHE_CAKEMODEL_URL', null),
],
'permissions' => [
'className' => 'File',
'prefix' => 'headless_',
'path' => CACHE . 'permissions/',
'url' => env('CACHE_PERMISSIONS_URL', null),
],
'dbResults' => [
'className' => 'File',
'prefix' => 'headless_',
'path' => CACHE . 'dbResults/',
'url' => env('CACHE_PERMISSIONS_URL', null),
'duration' => '+1440 minutes',
],
'pages' => [
'className' => 'File',
'prefix' => 'page_',
'path' => CACHE . 'pages/',
'serialize' => true,
'duration' => '+320 minutes',
],
'page_contents' => [
'className' => 'File',
'prefix' => 'pc_',
'path' => CACHE . 'page_contents/',
'serialize' => true,
'duration' => '+320 minutes',
],
],
In addition to that, in my bootstrap.php file I am doing
Cache::setConfig(Configure::consume('Cache'));
I don't understand why I get this error when everything seems to be properly configured.
Please update the following line
Cache::clear('dbResults');
In CakePHP 4, Cache::clear() accepts only one parameter as opposed to CakePHP 3. They removed the $check parameter. Unfortunately migration guide does not seem to be updated about this.
Reference:
https://book.cakephp.org/4/en/core-libraries/caching.html#clearing-cached-data

Owncloud - wrong url on activation links

I have problem with Owncloud. After creating a new user, email sended to that user was with private IP address, not with domain name. Example verification link:
http://192.168.3.103:4490/index.php/index.php/settings/users/setpassword/form/728851077702434409735/some.username
I would like to repair that. It need to be in format
https://cloud.mydomain.pl:4490/index.php/index.php/settings/users/setpassword/form/728851077702434409735/some.username
Owncloud config below
$CONFIG = array (
'instanceid' => 'xxx',
'passwordsalt' => 'xxx',
'secret' => 'xxx',
'trusted_domains' =>
array (
1 => 'mydomain',
2 => 'cloud',
3 => 'https://cloud.mydomain.pl:44900',
4 => '192.168.3.103:4490',
),
'datadirectory' => '/var/www/html/data',
'overwrite.cli.url' => 'https://cloud.mydomain.pl:44900',
'overwritecondaddr' => '^192\\.168\\.3\\.103$',
'dbtype' => 'sqlite3',
'version' => '10.6.0.0',
'logtimezone' => 'UTC',
'installed' => true,
'loglevel' => 0,
// LOGGING
// "log_type" => "owncloud",
// "logfile" => "owncloud.log",
// "loglevel" => "0",
// "logdateformat" => "F d, Y H:i:s",
// "mail_smtpdebug" => true;
'maintenance' => false,
'theme' => '',
'mail_domain' => 'mydomain.pl',
'mail_from_address' => 'admin',
'mail_smtpmode' => 'smtp',
'mail_smtpsecure' => 'ssl',
'mail_smtpauth' => 1,
'mail_smtpauthtype' => 'LOGIN',
'mail_smtphost' => 'mydomain.pl',
'mail_smtpport' => '465',
'mail_smtpname' => 'admin#mydomain.pl',
'mail_smtppassword' => 'xxx',
);
Right after 'overwrite.cli.url' add:
'overwritehost' => 'cloud.mydomain.pl',

Get Values of Multidimensional array inside of another array

Hi i am having this structure:
$GLOBALS['config'] = array(
'mysql' => array(
'host' => 'localhost',
'username' => 'root',
'password' => 'root',
'dbname' => 'database'
),
'session' => array(
'session_name' => 'user'
),
'remember' => array(
'cookie_name' => 'hash',
'cookie_expiry' => 604800
),
'folder' => array(
'root' => 'backend',
'header' => 'head',
'views' => 'views'
),
'database' => array(
'names' => 'utf8mb4',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'driver' => 'pdo'
),
'url' => array(
'base_url' => 'http://www.example.com/backend/',
'document_root' => $_SERVER['DOCUMENT_ROOT'] . "/backend"
),
'languages' => array(
'english' => 'en',
'german' => 'de',
'greek' => 'gr'
),
'headers' => array(
'404' => 'HTTP/1.0 404 Not Found',
'401' => 'HTTP/1.0 401 Unauthorized',
'500' => 'HTTP/1.0 500 Internal Server Error',
'403' => 'HTTP/1.0 403 Forbidden'
),
'title' => array(
'login' => 'Admin Dashboard',
'register' => 'Admin Dashboard | User Registration',
)
);
and i want in the url/base_url to be like this
'base_url' => 'http://www.example.com/'.$GLOBALS['config']['folder']['root'].'/'
so if i change folder i only have to change the name in only place, but i get a Syntax error like:
Notice: Undefined index: config in C:\xampp-php56\htdocs\backend\core\init.php on line 31
Is possible what i am trying to do? and if possible how?
You can't access another array index while you're still defining the array. Your statement defining the array hasn't completed yet, the array isn't available for access until the initial statement is finished.
You need to setup your array as much as you can first, and then go back and add the array elements that reference other array indexes.
So first just create your big array like you're doing, without the base_url.
$GLOBALS['config'] = array(
...
);
Now go back and add the url/base_url, you can now access the array index of config.
$GLOBALS['config']['url']['base_url'] = 'http://www.example.com/'.$GLOBALS['config']['folder']['root'].'/';
Example: https://3v4l.org/M7itf
Missed dot
'base_url' => 'http://www.example.com/'.$GLOBALS['config']['folder']['root'].'/'

Zend Framework 2 and Doctrine 2 - Configuration for multiple databases

I pasted the code from the configuration.md file to
module.config.php
'doctrine' => array(
'connection' => array(
'orm_crawler' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'root',
'password' => 'root',
'dbname' => 'crawler',
'driverOptions' => array(
1002 => 'SET NAMES utf8'
),
)
)
),
'configuration' => array(
'orm_crawler' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'driver' => 'orm_crawler',
'generate_proxies' => true,
'proxy_dir' => 'data/DoctrineORMModule/Proxy',
'proxy_namespace' => 'DoctrineORMModule\Proxy',
'filters' => array()
)
),
'driver' => array(
'Crawler_Driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(
__DIR__ . '/../src/Crawler/Entity'
)
),
'orm_crawler' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\DriverChain',
'drivers' => array(
'Crawler\Entity' => 'Crawler_Driver'
)
),
),
'entitymanager' => array(
'orm_crawler' => array(
'connection' => 'orm_crawler',
'configuration' => 'orm_crawler'
)
),
'eventmanager' => array(
'orm_crawler' => array()
),
'sql_logger_collector' => array(
'orm_crawler' => array(),
),
'entity_resolver' => array(
'orm_crawler' => array()
),
),
```
Module.php
public function getServiceConfig()
{
return array(
'factories' => array(
'doctrine.authenticationadapter.orm_crawler' => new \DoctrineModule\Service\Authentication\AdapterFactory('orm_crawler'),
'doctrine.authenticationstorage.orm_crawler' => new \DoctrineModule\Service\Authentication\StorageFactory('orm_crawler'),
'doctrine.authenticationservice.orm_crawler' => new \DoctrineModule\Service\Authentication\AuthenticationServiceFactory('orm_crawler'),
'doctrine.connection.orm_crawler' => new \DoctrineORMModule\Service\DBALConnectionFactory('orm_crawler'),
'doctrine.configuration.orm_crawler' => new \DoctrineORMModule\Service\ConfigurationFactory('orm_crawler'),
'doctrine.entitymanager.orm_crawler' => new \DoctrineORMModule\Service\EntityManagerFactory('orm_crawler'),
'doctrine.driver.orm_crawler' => new \DoctrineModule\Service\DriverFactory('orm_crawler'),
'doctrine.eventmanager.orm_crawler' => new \DoctrineModule\Service\EventManagerFactory('orm_crawler'),
'doctrine.entity_resolver.orm_crawler' => new \DoctrineORMModule\Service\EntityResolverFactory('orm_crawler'),
'doctrine.sql_logger_collector.orm_crawler' => new \DoctrineORMModule\Service\SQLLoggerCollectorFactory('orm_crawler'),
'doctrine.mapping_collector.orm_crawler' => function (\Zend\ServiceManager\ServiceLocatorInterface $sl) {
$em = $sl->get('doctrine.entitymanager.orm_crawler');
return new \DoctrineORMModule\Collector\MappingCollector($em->getMetadataFactory(), 'orm_crawler_mappings');
},
'DoctrineORMModule\Form\Annotation\AnnotationBuilder' => function(\Zend\ServiceManager\ServiceLocatorInterface $sl) {
return new \DoctrineORMModule\Form\Annotation\AnnotationBuilder($sl->get('doctrine.entitymanager.orm_crawler'));
},
),
);
}
I'm getting the following error:
C:\xampp\vhosts\zf2-trade\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.php:529
Message:
Zend\Mvc\Controller\PluginManager::get was unable to fetch or create an instance for getServiceManager
What am I doing wrong? Please help.
Regards Matthew
Mac, welcome to stackoverflow! You don't need to define custom factories for each connection respectively. DoctrineORMModule already handles this job for us.
When you need the entity managers, get it from service locator instance by using their names in the alias like this:
$this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
or
$this->getServiceLocator()->get('doctrine.entitymanager.orm_alternative');
I'm sharing one of my current application's database configuration which currently uses both PostgreSQL and MySQL connections.
<?php
return array(
'doctrine' => array(
'connection' => array(
// Default DB connection
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOPgSql\Driver',
'params' => array(
'host' => '1.2.3.4',
'user' => 'pdbuser',
'port' => '5432',
'password' => '****',
'dbname' => 'mydb',
'driver' => 'pdo_pgsql',
),
),
// Alternative DB connection
'orm_alternative' => array(
'driverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => '4.5.6.7',
'user' => 'dbuser',
'port' => '3306',
'password' => '****',
'dbname' => 'mydb',
'driver' => 'pdo_mysql',
),
),
),
// Entity Manager instantiation settings
'entitymanager' => array(
'orm_default' => array(
'connection' => 'orm_default',
'configuration' => 'orm_default',
),
'orm_alternative' => array(
'connection' => 'orm_alternative',
'configuration' => 'orm_alternative',
),
),
// Use array cache locally, also auto generate proxies on development environment.
'configuration' => array(
'orm_default' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
),
'orm_alternative' => array(
'metadata_cache' => 'array',
'query_cache' => 'array',
'result_cache' => 'array',
'hydration_cache' => 'array',
'generate_proxies' => true,
),
),
),
);
You can easily merge this configuration with yours.
Hope it helps.
#edigu answer works perfectly fine but in some cases, it gives
"Following error: Zend\ServiceManager\ServiceManager:: get was unable to fetch or create an instance for doctrine.connection.orm_crawle"
So to resolve this we may change in the Entity Manager settings
'entitymanager' => array(
'orm_default' => array(
'connection' => 'orm_default',
'configuration' => 'orm_default',
),
'orm_alternative' => array(
'connection' => 'orm_alternative',
'configuration' => 'orm_default', //<--use parent configurations
),
),
for refernece check here
#foozy: this is exactly what I'm looking. With
./vendor/bin/doctrine-module orm:schema-tool:update --force
you can now update or create the database schema.
My question: how to define which entity should be created in which db?
Regards Andrea

In yii,why can't I get all parameters using yii::app()->getParams() method?

In my program,I called getParams() method,but only got 10 parameters.In my main.php configuration file,there is more,why?
Here is the params part of the main.php
'params'=>array(
'adminEmail'=>'webmaster#example.com',
'AccountDB' => 'db_account_dev',
'orderDB' => 'db_order_dev',
'staticPath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR,
'commonDB' => 'db_common',
'payDB' => 'db_pay_dev',
'crmDB' => 'db_crm_dev',
'queue' => array(
'email' => array(
array(
'host' => '127.0.0.1',
'port' => 11300,
),
),
'sms' => array(
array(
'host' => '127.0.0.1',
'port' => 11330,
),
),
'sale_record' => array(
array(
'host' => '192.168.0.201',
'port' => 11300,
),
),
),
'discuz' => array(
'DBName' => 'db_ultrax',
'TablePrefix' => 'pre_',
'authKey' => '00fefan5JEvKdiEQ',
),
'freight' => require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'freight.php'),
'allowCheckTaskSubId' => 224,
'allowCheckEmail' => 242,
'allowCheckPass' => 243,
'codFee' => 10,
'cancelFee' => 10,
)
However,the method only returns some items
adminEmail=>webmaster#example.com
orderDB=>db_order_dev
payDB=>db_pay
AccountDB=>db_account
commonDB=>db_common
freight=>Array
codFee=>10
saleRoleId=>9
saleManager=>11
growth=>Array
I have got the answer.
The configuration file of console application is protected/config/console.php
while the configuration file of web application is protected/config/main.php
They are different!
The above codes from a console application

Categories