Need help with Zend_Form_Element_Captcha in localhost and web hosting environment - zend-framework

Currently I'm develping a web application using Zend framework.
My problem is that I have to write 2 set of codes for the captcha element for my localhost (window environment running XAMPP ) and web hosting (linux environment).
My question is that is there a better way to code it, so that it works both my localhost and web hosting environment? At the moment is just so annoying to keep changing the codes when I upload to the web host enviroment.
Thanks so much in advance. :)
Here is my code for my web hosting environment
array('captcha' => array(
'captcha' => 'Image',
'wordLen' => 3,
'timeout' => 600,
'font' => '../font/arial.ttf',
'imgurl' => '../images/captcha/',
'fontsize' =>20,
'expiration' =>20,
'lineNoiseLevel' =>0,
'DotNoiseLevel' =>10,
)
)
);
It work perfectly on the web host but if i run it in my localhost window environment i get blank captcha the text doesn't get generated.
This is what i currently have for my localhost and its work fine.
array('captcha' => array(
'captcha' => 'Image',
'wordLen' => 3,
'timeout' => 600,
'font' => 'C:\WINDOWS\Fonts\arial.ttf',
'imgurl' => 'http://localhost/images/captcha',
'fontsize' =>20,
'expiration' =>20,
'lineNoiseLevel' =>0,
'DotNoiseLevel' =>10,
)
)
);

Use APPLICATION_PATH for the font .
From http://framework.zend.com/manual/en/zend.captcha.adapters.html the default is "./images/captcha/" . So not needed.
Hope it helps you.

Related

external distributed memcache not workking

this is my first post on here.
I installed the latest version of Nextcloud (19.0.0) on one machine and try to split all the services to different vm's. that means DB (mariadb), Storage, redis (for file locking), memcached (distributed cache) on different machines, all of which are running Ubuntu 20.04 LTS. This setup is a bit janky, but it helps me better understand, how each service functions. The DB-Server and Redis are working fine. Now I want to get memcached to work. as soon as i add the parameters i get an internal server error. this is what I have in my config.php
array (
0 => '10.10.10.45',
1 => 'nextcloudtest.test.lan',
),
'datadirectory' => '/nextcloud-data',
'dbtype' => 'mysql',
'version' => '19.0.0.12',
'overwrite.cli.url' => 'https://nextcloudtest.test.lan',
'htaccess.RewriteBase' => '/',
'dbname' => 'nextcloud',
'dbhost' => '10.10.10.49',
'dbport' => '3306',
'dbtableprefix' => 'oc_',
'mysql.utf8mb4' => true,
'dbuser' => 'nextcloud',
'dbpassword' => 'password',
'installed' => true,
// 'memcache.local' => '\OC\Memcache\APCu',
'memcache.distributed' => '\\OC\Memcache\\Memcached',
'memcached_servers' => array(
array('10.10.10.47', 11211),
),
'memcache.locking' => '\\OC\\Memcache\\Redis',
'filelocking.enabled' => 'true',
'redis' =>
array (
'host' => '10.10.10.46',
'port' =>6379,
'timeout' => 0.0,
),
);
Then i get this error in the nextcloud.log
\\OC\\Memcache\\Memcached not available for distributed cache","Code":0
I did set the bind address in the memcached.conf to 0.0.0.0 so it accepts all incoming connections and also added a rule to the firewall to allow incoming connections on port 11211.
I hope you guys cane give me some tipps.

how to change default module in Zend 2

I am new to ZendFeamerwork version 2. I could easily change the default controller in Zend1 but it seems very difficult to me to find out how to change default module in Zend2.
I searched over google but there is no easy solution.
I just created a module named "CsnUser" I can access this module via the following url
http://localhost/zcrud/public/csn-user/
I want csn-user to load instead of "application" module i.e url should be
http://localhost/zcrud/public/
or
http://localhost/zcrud/
Please let me know how to get this done.
Based on #Hoolis comment:
You have to set that action on this route
'home' => array(
'type' => 'Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'That\Namespace\CsnUser',
'action' => 'index'
)
)
)
)
In the skeleton application this route is set in the Application Module, but you can move this somewhere or edit it.

ZfcUserDoctrineMongoODM Configuration examples

I am trying to configure ZendFramwork 2 to use MongoDB as the storage for user Authentication.
I already have installed what I believe are the correct modules and have a correctly installed instance of ZF2 running on Nginx. I also have an instance of Mongo running and I am already using this for another project. The modules declaration in application.config.php looks like this
'modules' => array(
'Application',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineMongoODM',
'DoctrineModule',
'DoctrineMongoODMModule'
)
Documentation is a bit thin on how to configure the system to get it working. Can anyone provide any code fragments around configuring the database settings to allow Mongo to run with ZfcUser, this is where I am at a loss now.
Any help, clues or cheat sheets would be greatly appreciated.
Darren Breeze
Have a look at Doctrine Mongo ODM module readme https://github.com/doctrine/DoctrineMongoODMModule :
copy
vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist
into your application's config/autoload directory, rename it to
module.doctrine-mongo-odm.local.php and make the appropriate changes.
With this config file you can configure your mongo connection, add
extra annotations to register, add subscribers to the event manager,
add filters to the filter collection, and drivers to the driver chain.
So you have something like this at your autoload config:
<?php
return array(
'doctrine' => array(
'connection' => array(
'odm_default' => array(
'server' => 'localhost',
'port' => '27017',
// 'connectionString' => null,
// 'user' => null,
// 'password' => null,
// 'dbname' => null,
// 'options' => array()
),
),
....
'configuration' => array(
'odm_default' => array(
... 'default_db' => 'myappdb',
)
)
So tune it and try to register at user/register. Collection name is user by default.

Zf2 + Doctrine 2 Authentication Adapter with Multiple or Alternate Columns

I am working on a site in which user can enter two email address(primary and secondary) along with password.
If user enters his primary email and password, he gets logged in successfully.
But, what I am trying to provide is if user enters his secondary email instead of primary, even then he gets logged in. And the problem I am getting is how to create an alternate Doctrine Auth Adapter or something like that.
this is what I have done in my module.config.php:
'doctrine' => array(
'driver' => array(
__NAMESPACE__ . '_driver' => array(
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
),
'orm_default' => array(
'drivers' => array(
__NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
)
)
),
'authentication' => array(
'orm_default' => array(
'object_manager' => 'Doctrine\ORM\EntityManager',
'identity_class' => 'User\Entity\LoginDetails',
'identity_property' => 'primary_email',
'credential_property' => 'password',
),
),
)
Is there any option to add an identity property which will be alternative ?
I am using Zend framework 2 and Doctrine 2
Is there any option to add an identity property which will be alternative ?
No, there is no such option built-in to DoctrineModule.
Consider extending DoctrineModule\Authentication\Adapter\ObjectRepository to override the authenticate() method.
Then, at minimum, you'll want to replace the default adapter with your new more different one. If you look at the various factories in DoctrineModule, you should be off to a good start.
Basically, one of your modules will want to override the doctrine.authenticationadapter.[orm|odm]_default configuration key in the ServiceManager. That will cause DoctrineModule to inject your extended ObjectRepository into the AuthenticationService in place of you the default one.

Drupal 7 form managed file default value not working

I'm using druapl 7 form to allow users to upload images for a slideshow. The managed file is working great to upload and save the files and I can see the entries in the database. All is good when nothing is there. But when the form is reloaded, I cannot get the the default value working for the uploaded image.
$form['slideshow_0_slide_0_fieldset']['slideshow_0_slide_0_image'] = array(
'#name' => "files[slideshow_0_slide_0_image]",
'#type' => 'managed_file',
'#size' => '25',
'#title' => t('Image 0'),
'#upload_location' => 'public://',
'#default_value' => variable_get( $managed_file_fid, '' )
);
I've also tried this without success:
'#default_value' => file_load( $managed_file_fid, '' )
What am I missing here to get the default value working?