How to use multi config in KCFinder - tinymce

I have Project A and Project B use KCFinder too. Now, i want to when run project A, it's use config:
$_CONFIG = array(
'uploadURL' => "Url Of Project A",
'uploadDir' => "Dir of Project A"
);
And when run project B, it's use config:
$_CONFIG = array(
'uploadURL' => "Url Of Project B",
'uploadDir' => "Dir of Project B"
);
My editor is Tinymce 4, I tried many different ways but it's always get default config (Project A)

This is a sample case I hope could help you. In my case, I am using a sub domain to store images rather than in main. Just to speed up loading. And worked on other sub domain as administration.
My main web is : mainweb.com and I store images in img.mainweb.com. The editor is in adm.mainweb.com with login. And the setting in localhost is :
'uploadURL' => "http://img.mainweb.com/blog/blog_content",
'uploadDir' => "D:/xampp/htdocs/mainweb/img/blog/blog_content",
Use real path on live server such as : /home/..user../www/folder1/folder2/ or other path depending on your server configuration. In your case, you can configure uploadURL with your Url http://..... and uploadDir with your real path directory.

Related

How to clear the OPcache on a BasicAuth protected environment with typo3/surf?

On a TYPO3 project I'm working the Production/Staging (or Production/Dev, or any other) environment is protected by HTTP BasicAuth (basic access authentication).
The instance get's deployed via typo3/surf.
At some point typo3/surf must create a temporary php file, which can be accessed
later: after the switch was done and the new deployment is reachable via the frontend.
How can I configure typo3/surf to access the previously generated OPcache clearing script via the frontend on a BasicAuth protected environment?
Configuring typo3/surf to reset the PHP OPcache1
Four steps are basically necessary to configure the OPcache clearing/reset script:
Set task options for \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask
Add task \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask the an early stage (e.g. package but definitely before transfer)
Set task options for \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask
Add task \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask after stage switch
Here are the necessary snippets for your onInitialize function2 within your deployment configuration script:
Set task options for the "Create Script Task":
Since the "Respect WebDirectory" patch, the path to the script must not to be configured manually as it automatically uses the right WebDirectory path (which is set via options beforhand).
If you are using an older typo3/surf version or you have any special requirement you can set option scriptBasePath to set the absolute path to the resulting file:
# In this example, I have to set the absolute path for the resulting php file.
# Since the deployment run in GitLab CI I get the path to the root of the project's GIT
# repository via the environment variable `CI_PROJECT_DIR`. Since the path to the webDirectory
# inside the GIT repository is `<GitRepoRootFOlder>/app/web` I add it manually and concatenate
# it as final string for the option `scriptBasePath`:
$workflow->setTaskOptions(\TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, [
'scriptBasePath' => \TYPO3\Flow\Utility\Files::concatenatePaths([getenv('CI_PROJECT_DIR'), '/app/web']),
]);
Set task options for the "Execute Task":
At this point, we provide username and password
$workflow->setTaskOptions('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask', [
'baseUrl' => $application->getOption('baseUrl'),
'stream_context' => [
'http' => [
'header' => 'Authorization: Basic '.base64_encode("username:password"),
],
],
]);
Activate both Tasks:
$workflow->beforeStage('transfer', \TYPO3\Surf\Task\Php\WebOpcacheResetCreateScriptTask::class, $application)
->afterStage('switch', \TYPO3\Surf\Task\Php\WebOpcacheResetExecuteTask::class, $application);
This answer shows only the necessary parts for the OPcache reset process!
Please check also the TYPO3 CMS deployment configuration example in the official documentation.
Footnotes
1 This answer is based on typo3/surf GIT branch dev-master, version 2.x
2 Example where to place the mentioned snippets:
$deployment->onInitialize(function () use ($deployment, $application) {
/** #var SimpleWorkflow $workflow */
$workflow = $deployment->getWorkflow();
# the mentioned snippets have to be placed next to your existing configuration
});

Undefined Error in Suite CRM

when user add element from toolbox undefined instant of new panel and new row. How to solve this error.
Screenshot :
Make sure you are using correct .htaccess
Go to Admin > Repair and do a "Quick Repair & Rebuild". Execute any changes shown at the bottom of the page.
If that doesn't work, go to Admin > Repair and do "Rebuild .htaccess file" and afterwards, Admin > Repair and do a "Quick Repair & Rebuild" again.
Try deleting inside the cache folder, check for cache folder permission in my case i change to 775, delte empty the .htaccess file (don't delete the file),go to admin ->repair->quick repair & built and also rebuilt .htaccess file, log out and try login again. Check config file for this value :
'default_permissions' =>
array (
'dir_mode' => 1528,
'file_mode' => 493,
'user' => 'daemon', -> check and change to your Apache user config
'group' => 'daemon', -> check and change to your Apache user Group
),
installation folder must be specified in the right location look for :
'site_url' => 'http://suitecrm.com', ->change to your url
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/1137-undefined-text

Zend Framework 3 share doctrine models between modules of the same project

I am new into Zend Framework 3 programming.
Previously we create a project having all database table's mapping included in one particulare module.
Now, we need to create another module into the same project. So we would like to put outside from the first module the database mapping objects in order to shared tha classes between the both modules.
I try to create a new module only for the mapping, but without succes. The namespaces doesn't existes.
After I look for solution like using ServiceManager, but I didn't really understand how to used it.
Do you know if there is another solution than using a ServiceManager ? And if not, have I change all my previous code using objects included simply with the key word use, in order to use the ServiceManager ?
Thanks.
Finaly in my solution I create a module containing only the sources files for the doctrine mapping under src directory.
/module
/MyApplication
/src
/config
/module.config.php
/Common
/src
/DoctrinMapping
/Entities
composer.json
In composer.json I put :
"autoload": {
"psr-4": {
"MyApplication\\": "module/MyApplication/src/"
,"Common\\":"module/Common/src/"
}
}
At the project root I execute the commande line :
composer dump-autoload
After into module.config.php of the my specifique application I define the doctrine reference as :
,'doctrine' =>
[
'driver' =>
[
'common_entities' =>
[
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,'cache' => 'array'
,'paths' => array(__DIR__ . '/../../Common/src/DoctrineMapping/Entities')
],
'orm_default' =>
[
'drivers' =>
[
'Common\DoctrineMapping\Entities' => 'common_entities'
]
]
]
]
That works, but I don't know if this is the best solution to apply.

Getting moodle version info, no admin access

Is there a way to obtain version info for a moodle site using only "teacher" level access? It seems as though this ability was removed in versions 1.9.7 and above. I'm trying to automate the process of uploading tests and having the version info would be rather handy.
In order to see the current version of moodle you just need to read this file:
http://yourmoodlesite/lib/upgrade.txt
Here's more information about it:
https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/upgrade.txt
Sorry, these instructions may seem somewhat obscure, but it's the only way I could find to get the version of Moodle with only "teacher" level access.
As a teacher, you should be able to create a backup of any of your courses (though this capability may have been removed in the Moodle you're using). Backups are just zip files, but instead have a .mbz extension. If you change this extension to .zip, you'll be able to extract the zip. With the zip extracted, open "moodle_backup.xml", in there you should find the "moodle_release" item somewhere near the top, giving you the version of Moodle used to create the backup.
Being a TA, I didn't want to mess around with backups which sounds weird but given my unique position, reasonable (to me).
On the implementation of moodle I use, with TA privilege, a link to moodle docs is present at the bottom of the page and if you open this link, it takes you to the moodle docs page with moodle_url/moodle_version/___.
Maybe this is peculiar to my system, but I believe it's a default setting thing.
The most dirty way to do so when no admin or file access, is doing differs from public files between versions. As example, index.php file can be 1024Kb lenght on v1.x and 1033Kb lenght on version 1.2.
Also, check for existance/non existance of a set of files is a common way (css, html, js, icon, etc)
I will edit this again if i find a specific solution.
First edit:
For versions 19 or above, you can check version direcly from readme.txt file at https://github.com/moodle/moodle/blob/MOODLE_19_STABLE/README.txt
If you don't even have an account on the instance, you may still be able to find out the version. Any authentication errors in the API will return an error message of the form:
[{
"error":true,
"exception":{
"message":"Course or activity not accessible.",
"errorcode":"requireloginerror",
"link":"https:\/\/moodle.example.com\/",
"moreinfourl":"http:\/\/docs.moodle.org\/36\/en\/error\/moodle\/requireloginerror"
}
}]
And the moreinfourl contains an approximate version number (in this case 3.6). For me, this page was requested when I visited the login page for the instance - a POST request to
https://moodle.example.com/lib/ajax/service.php?sesskey=JQrdIcgMn4&info=core_fetch_notifications
My helper function here:
https://gist.github.com/tigusigalpa/af051a9112512b1b0369572b5dbea2fd
function checkMoodleVersion($version, $checkfor = 'all', $compare = '<=') {
global $CFG;
$versions = [
'3.1' => [
'version' => '2016052300',
'release' => '3.1'
],
'3.2' => [
'version' => '2016120500',
'release' => '3.2'
],
'3.3' => [
'version' => '2017051500',
'release' => '3.3'
],
'3.4' => [
'version' => '2017111300',
'release' => '3.4'
],
'3.5' => [
'version' => '2018051700',
'release' => '3.5'
],
'3.6' => [
'version' => '2018120300',
'release' => '3.6'
]
];
switch ($checkfor) {
case 'all':
if (isset($versions[$version]['version'])) {
return version_compare($versions[$version]['version'], $CFG->version, $compare) &&
version_compare($version, $CFG->release, $compare);
}
break;
case 'version':
case 'release':
if (isset($versions[$version][$checkfor])) {
return version_compare($versions[$version][$checkfor], $CFG->$checkfor, $compare);
}
break;
}
return false;
}
Not by default as this could be used to harvest out of date moodle sites.
You could create a script to do this fairly easily, eg:
<?php
require_once('config.php');
echo 'Version: '.$CFG->version;
echo 'Humand readable release: '.$CFG->release;

Zend_Form - The mimetype of file 'foto.jpg' could not be detected

I have a Zend_Form with file element like this:
->addElement('file', 'image', array(
'required' => false,
'label' => 'Venue Image',
'validators' => array(
array('IsImage', false),
array('Size', false, '2097152'),
array('Upload', false),
),
))
And when I'm using localhost the image is uploaded successfully. But when I move to my hosting the validation error shows for image field. The mimetype of file 'foto.jpg' could not be detected. What can be the reason of this?
same thing happened to me, this was crazy stuff, more than 2 hours trying to figure out what's wrong, here is how to fix it:
install fileinfo extension on linux:
pecl install fileinfo
then you need to add to your php.ini this line:
extension=fileinfo.so
restart your apache and you are done!
*if you server is freeBSD you have to do this:
cd /usr/ports/sysutils/pecl-fileinfo/
make install
If you are using XAMPP and localhost just open your php.ini file and uncomment:
extension=php_fileinfo.dll
From the comments in the ZF Reference Guide:
In order to make IsImage working (and maybe all other mime related validators) on Zend Server on win32 I had to replace "magic.mime" supplied on Zend Server ("\etc") by the one on Apache ("\conf" , file is called "magic") (don't forget to restart Apache).
If it still doesn't work then you could try with these alternatives:
$element->addValidator('Mimetype', false, 'image/jpg');
or
$element->addValidator('Extension', false, 'jpg');