Following the documenation here https://cloud.google.com/appengine/docs/standard/php/taskqueue/push/example
I decided to do a little testing of TaskQueues within my laravel application. Here is my current test code:
$task = new PushTask('/GoogleQueueTest/21',
['name' => 'john doe', 'action' => 'send_reminder']);
$task_name = $task->add();
return $task_name;
resulting in:
Remote implementation for taskqueue.BulkAdd failed
after alot of searching I cant seem to find why this is not working as expected.
Related
I have numerous sites and its becoming a nuisance keeping them all up to date, so I would ideally like to compile a list where I can display the version of each website automatically. So I can see at the drop of a hat which ones needs updated and so on.
I have remote access to all off their databases, I had thought about querying the wp_options table for the DB Version but that isn't specific enough when it comes to smaller version updates as far as I am aware.
Any thoughts?
Here's a demo plugin
<?php
/** Plugin Name: My JSON data **/
add_filter( 'query_vars', function( $qv ){
$qv[] = 'mydata';
return $qv;
});
add_action( 'template_redirect', function(){
$input = get_query_var( 'mydata' );
$secret = 'abcdefg'; // Edit this
if( ! empty( $input ) )
{
if( $secret === $input )
{
$data = array(
'version' => $GLOBALS['wp_version'],
'foo' => 'bar',
);
wp_send_json_success( $data );
}
else
{
wp_send_json_error();
}
}
} );
where example.com/?mydata=abcdefg gives
{"success":true,"data":{"version":"3.8.1","foo":"bar"}}
and example.com/?mydata=wrong shows:
{"success":false}
I wouldn't recommend trying to bridge a system to check WordPress, espiecally since the WordPress core since 3.7.1 comes with this functionality.
WordPress 3.7.1+ Auto Updates, so it would be best to upgrade all your WordPress sites - this would also be a great idea for security purposes.
What you might want to consider is removing any redundant plugins and have a plan for updating those plugins every few months too.
3rd-party plugins are usually the reason a site is vulnerable, more so than the core of WordPress. Fight the fire before it becomes a fire in the first place! Use less plugins or keep on top of them.
I try to use the zf2 db validator to check if a record does not exist.
I set the follow code in my controller:
$validator = new NoRecordExists(
array(
'table' => 'topics',
'field' => 'topic',
)
);
after this configuration I try to validate but I got 'an error occurred', can't find any other error output who can tell me more about this error.
var_dump($validator->isValid('test'));
If someone can give me some tips, would be great :)
thx
Have you set the DB Adapter?
You can pass it in the contructor or called setAdapter();
validator->setAdapter(
$this->getServiceLocator()->get('Zend\Db\Adapter\Adapter')
);
You could set this up in your service config to automatically inject the adapter for you.
I'm using CakePHP's Media view to force file downloads. My code is pretty much exactly like the example provided in the cookbook, which I'll paste here for your convenience:
<?php
class ExampleController extends AppController {
public function download () {
$this->viewClass = 'Media';
// Download app/outside_webroot_dir/example.zip
$params = array(
'id' => 'example.zip',
'name' => 'example',
'download' => true,
'extension' => 'zip',
'path' => APP . 'outside_webroot_dir' . DS
);
$this->set($params);
}
}
In the database, I have a field that keeps track of how many times the file was downloaded. I'm looking for a way to make sure that this number is as accurate as possible, so if a user's download gets cancelled or times out, the number does not increment. Is there some way for CakePHP's Media view to report that the download was, indeed, successful?
Detecting when a file has finished downloading is no easy task. This is something that would be done on the client side with javascript, but browsers do not give you any hooks for that.
There is a pretty clever solution here (setting a cookie and then looking for it with javascript), but it only tells you when the download has started.
i did lot of research on the web but i didnt find anything that could help me to use PDO in codeigniter. I saw in the change lof of CI 2.1.0(i think) that pdo driver was added to the framwork.
I ended up now with a database.php config file that looks like this:
$db['default']['hostname'] = 'mysql:host=myhostname;port=myport';
$db['default']['username'] = 'myusername';
$db['default']['password'] = 'mypassword';
$db['default']['database'] = 'mydb';
$db['default']['dbdriver'] = 'pdo';
So now(after a lot of wasted time to get the snippet above to work -.- ) i receive no error about connection, but HOW TO EXECUTE QUERY NOW? i cant figure out what syntax will work and how to build queries. Anyone have hints?
PS: if you're wordering about why i need pdo in ci, the answer is my boss want me to create a structured enviroment with:
CI 2.x + (done)
Smarty 3 (done)
PhpUnit (not yet)
PDO (not yet)
so if you have also any hints for integrate phpunit feels free to answer. Ty in advance
You use PDO the same way you use any other database driver in CodeIgniter. If you are still unsure then I would recommend reading the documentation on the Database Class.
You can issue standard queries by explicitly writing the query or you can use the Active Record Class (which is more of a query builder).
Here are some examples:
// Standard query
$results = $this->db->query('SELECT name, title, email FROM my_table');
// Active record
$this->db->select('name, title, email');
$results = $this->db->get('my_table');
As for integrating PHPUnit, have a look at https://github.com/cmillr/CI-PHPUnit (I haven't tested it myself) or look around the CodeIgniter forums. I've seen a ton of topics on integrating PHPUnit with CodeIgniter.
You need to change your config a little:
'dsn' => 'mysql:host=localhost;dbname=codeigniter',
//'hostname' => 'localhost',
'username' => 'codeigniter',
'password' => 'codeigniter',
'database' => 'codeigniter',
Notice we use dsn, not hostname.
After that, simply use your $this->db-> like you always do - the PDO driver will translate everything to PDO methods
A little dated, but the topic is lacking clear explanations & docs so I wrote this - hope it helps clarify for people:
http://codebyjeff.com/blog/2013/03/codeigniter-with-pdo
Browsing through GitHub and I found a pretty powerful CakePHP plugin called CakeDC Users that has a lot of features (Account verification, password reset, etc) for a creating a login/authentication system. I like it because it seems to be written by some of the actual CakePHP developers and it gets updated a lot but there seems to be absolutely zero documentation anywhere on it. I've just come across this plugin recently, since I was trying to see if there's a better way than "rolling" with my own solution. So I was wondering if anybody here has had experience with it and if so could point to some decent documentation online.
Edit There is some stuff at the bottom of the readme, but it hasn't been too intuitive for me.
Alternate question, if you don't use this plugin, is there a login/authentication plugin you use in CakePHP that you use for login/authentication?
I have ran into the same problem with using the CakeDC plugins, a lot of them have little/no documentation.
However, there is not "Zero" documentation for it, you can see how to set it up for the most part at the bottom of the github page in the read me. Also you need to put this inside your AppController::beforeFilter() method.
$this->Auth->authorize = 'controller';
$this->Auth->fields = array('username' => 'email', 'password' => 'passwd');
$this->Auth->loginAction = array('plugin' => 'users', 'controller' => 'users', 'action' => 'login', 'admin' => false);
$this->Auth->loginRedirect = '/';
$this->Auth->logoutRedirect = '/';
$this->Auth->authError = __('Sorry, but you need to login to access this location.', true);
$this->Auth->loginError = __('Invalid e-mail / password
combination. Please try again', true);
$this->Auth->autoRedirect = true;
$this->Auth->userModel = 'User';
$this->Auth->userScope = array('User.active' => 1);
if ($this->Auth->user()) {
$this->set('userData', $this->Auth->user());
$this->set('isAuthorized', ($this->Auth->user('id') != ''));
}
Also, you need an isAuthorized() function, something as simple as this will do:
public function isAuthorized() {
return true;
}
Additionally, you will need to allow the 'login' action (this will involve editing the plugin files). Just add 'login' to the $this->Auth->allow() in users_controller.php.
This question is pretty old now, but as it's not marked as resolved and we've been doing a lot on the documentation since then I think it's worth to update:
Documentation can be found here:
For the version 3+ of the framework
https://github.com/CakeDC/users/blob/master/Docs/Home.md
Tutorial > http://www.cakedc.com/jorge_gonzalez/2016/02/21/cakedc_users_plugin_for_cakephp_3_-_update
CakePHP Facebook login tutorial >
http://www.cakedc.com/jorge_gonzalez/2016/02/21/cakephp_facebook_login_using_cakedc_users_plugin_-_update_3_1_5
For the (old) version 2
https://github.com/CakeDC/users/blob/2.x/Docs/Home.md
After exhaustive search I found a tutorial on how to use CakeDC!
Here it is