how to install Crawler-Detect given the instructions? - php

Sorry in advance if it the questions seems too basic. But I want to know how to install "Crawler-Detect" in my xampp and online server?
The instructions are given in the git link at: https://github.com/JayBizzle/Crawler-Detect
I just don't know how to install them. no one else seem to be having problem with this.
So far I have tried to download the package, place it where my project is, required the class like any regular class in php and run it. this error occured:
Fatal error: Class 'CrawlerDetect' not found in H:\xampp\htdocs\viralagain\theme\crawl.php on line 5
Then installed the composer package and run the command:
composer require jaybizzle/crawler-detect 1.*
This Error occured:
Fatal error: Class 'Jaybizzle\CrawlerDetect\CrawlerDetect' not found in H:\xampp\htdocs\viralagain\theme\crawl.php on line 5
Then in my composer.js (In The project directory) I added the
"jaybizzle/crawler-detect" :"1.*"
Same error.
Crawl.php:
<?php
require "Jaybizzle/src/CrawlerDetect.php";
use Jaybizzle\CrawlerDetect\CrawlerDetect;
$CrawlerDetect = new CrawlerDetect;
// Check the user agent of the current 'visitor'
if($CrawlerDetect->isCrawler()) {
// true if crawler user agent detected
echo "</br> [BOT DETECTED]";
}else{
echo "not a bot";
}
echo $botname = $CrawlerDetect->getMatches();
?>

I have changed the CrawlerDetect's source and test it.
download it from here:
http://www.parsebazar.com/#files/CrawlerDetect.zip
sample:
require "CrawlerDetect.php";
$CrawlerDetect = new CrawlerDetect;
// Check the user agent of the current 'visitor'
if($CrawlerDetect->isCrawler()) {
echo 'robot'; // true if crawler user agent detected
} else {
echo 'visitor';
}

Related

Invalid Run Id After running drupal page using XHProf

I have installed the Drupal XHProf 7.x-1.0-beta2 module and enabled it on the Modules page of my site.
I have turned enabled the use of the module at Configuration -> Development -> XHProf settings (/admin/config/development/xhprof) by checking ON " Enable profiling of all page views and drush requests. "
Now what?
When I visit a page and click "XHProf output" at the bottom of the page, I get this error:
" Run #51b789ae8cea0: Invalid Run Id = 51b789ae8cea0 "
And the list of the "Top 100 functions" is totally empty. I am a bit lost as to what I should be seeing or where to go from here. Any help greatly appreciated.
please refer error screenshot
Go to your backend folder structure.create a folder named xhprof in your server, inside tmp folder in your server like 10.20.4.123/tmp
on clicking "XHProf output" at the bottom of the page.it will display output.
Looking at the code that returns this error it's a file exists check. I changed $run_desc to output the full filename vs the run id.
if (!file_exists($file_name)) {
xhprof_error("Could not find file $file_name");
$run_desc = "Invalid Run Id = $file_name";
return null;
}
In my case for a run id of 617064cfe0f71 it was looking for a filename formatted like
617064cfe0f71.xhprof.xhprof
The filename is derived from this function
private function file_name($run_id, $type) {
$file = "$run_id.$type." . $this->suffix;
...
}
It's a permission issue,just set chmod 777 for your xhprof output directory.

Cannot import Google App Engine Api

All I need from my server is to be able to send emails to my users when they forget their password. I try the code below after installing the Google App Engine SDK for PHP and it gives me the error
Fatal error: require_once(): Failed opening required
'google/appengine/api/mail/Message.php' (include_path='.:') in
/Library/WebServer/Documents/AppEngine/testMail.php on line 2
This is my code:
require_once 'google/appengine/api/mail/Message.php';
use google\appengine\api\mail\Message;
try {
$message = new Message();
$message->setSender('test#gmail.com');
$message->addTo('test#example.com');
$message->setSubject('Example email');
$message->setTextBody('Hello, world!');
$message->send();
echo 'Mail Sent';
} catch (InvalidArgumentException $e) {
echo 'There was an error';
}
I'm thinking that I did not install the engine properly but I'm lost at this point. Any ideas?
Well, two things. First of all, you don't need the require_once statement. At least I've never had to use that (maybe you did need it in older versions of GAE but as far as I know, it isn't needed. Your php script is currently trying to open a directory that doesn't exist in your project.) All you need is the use google\appengine\api\mail\Message; statement.
Secondly, when you setSender, you need to make sure that your email 'test#gmail.com' is a registered email in your google app engine app -> otherwise no actual email will get sent.
Hope that helps.

Fatal error: Class 'Hybrid_Logger' not found in /hybridauth/Hybrid/Endpoint.php on line 165

I am drying to deploy HyBridAuth as a plugin in my website . my fucntion looks something like this .
function authenticatewith( $provider ){
ini_set('display_errors','on');
//includes
$config = dirname(__FILE__) . '/hybridauth-2.1.2/hybridauth/config.php';
require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );
$provider_name = $provider;
//$config = $this->getconfig($id);
try{
// initialize Hybrid_Auth with a given file
$hybridauth = new Hybrid_Auth( $config );
// try to authenticate with the selected provider
$adapter = $hybridauth->authenticate( $provider_name );
// then grab the user profile
$user_profile = $adapter->getUserProfile();
}
catch( Exception $e ){
echo "Error: please try again!";
echo "Original error message: " . $e->getMessage();
}
echo "USer Details: ";
var_dump($user_profile);
}
I am running into a fatal error when I try to access any of the provider .
Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php on line 165
I get no links for this problem in stack I though I will raise this here.
Thanks & Regards
Before doing anything else, make sure you are using session_start().
Since using session_start() will throw an error of level E_NOTICE if a session has already been started, a better approach would be:
if(session_id() == '') {
session_start();
}
And keep in mind that if the user's browser does not have cookies enabled, you will have issues with HybridAuth because of the default value of the PHP setting session.use_cookies
session.use_cookies = 1 //PHP uses cookies by default
A beta user for a project I'm working on reported seeing this error - and for a long time I was unable to replicate the error. After long hours of debugging, it turned out to be a browser configuration error that was specific to the user (cookies were disabled). Not sure if it will solve your problem, but it's worth mentioning that the error:
Fatal error: Class 'Hybrid_Logger' not found in hybridauth/Hybrid/Endpoint.php
Can also be caused due to browser-specific settings (such as disabled cookies).
References:
http://php.net/manual/en/function.session-start.php
http://php.net/manual/en/session.security.php
This error occur if you cannot access the config.php or if the base_url is wrong or if you are trying to access the remote application service ( facebook , or else ) from localhost... You should then use a live domaine working online , to do so you have to add the following line to your windows/system32/drivers/etc/hosts if you are under windows and /etc/hosts if you are in unix based system :
127.0.0.1 your-domaine.extension
where extension is one of the following : com , net or anything else that could work
this method is applied if you have not a working domain for your application
otherwise you need to specify your www domain for this to work properly...
hope its helpfull
I had the exact same error, I discovered that the session global variable didn't have the required values ("CONFIG") and it was because I set the base_url to a different than the one from which I was testing. To be more specific: I was accessing with www.mywebsite.com and the base_url was set to just mywebsite.com. Fixed it by setting base_url to www.mywebsite.com.
I also recommend to redirect to www like this: .htaccess - how to force "www." in a generic way?
require_once( "hybridauth-2.1.2/hybridauth/Hybrid/Auth.php" );
does not contain the full path like the include of config.php does.
Use session_start();
before any other things you do..

Amazon Web Services (AWS) SDK 1.6 - PHP - Returns absolutely nothing

Just trying to get past the first hurdle with AWS.
We've had to use the older verion of the SDK - 1.6.2 because our servers all run PHP 5.2 which doesn't have namespace support.
I have created my config file and popped my deets in, I am including the sdk.class.php etc like so:
$file = $_SERVER['DOCUMENT_ROOT']."/lib/aws-sdk-1.6.2/sdk.class.php";
if (file_exists($file)) {
require_once ($file);
$ec2 = new AmazonEC2();
$response = $ec2->describe_availability_zones();
print_r($response);
} else {
die('No file');
}
In here I am also dumping the response but for every call I do to whichever service I just get a completely blank response. Not a zero, no blank array, not even the word null.
Without any output to view I am completely stumped. Any ideas on how to even get it to tell me where the problem could be would be amazing.
Thanks!

unable to connect using SSH2

I am using phpseclib in my project. I have installed it and am testing it using the following piece of code which is similar to the example here.
Updated Code:
1 require("Net/SSH2.php");
2
3 if (!class_exists('Net_SSH2')) die("Class Net_SSH2 doesn't exist!");
4
5 $ssh = new Net_SSH2('***'); // the host IP address
6
7 if (!method_exists($ssh, 'Net_SSH2')) die("Net_SSH2 class doesn't have Net_SSH2 method!");
8
9 if (!$ssh->login('***', '***')) { // (verified) username and password
10 echo "LOG: " . $ssh->getLog() . "<br>";
11 exit('Login failed!');
12 }
Code Update 2:
1 require("Net/SSH2.php");
2
3 define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
4
5 if (!class_exists('Net_SSH2')) die("Class Net_SSH2 doesn't exist!");
6
7 $ssh = new Net_SSH2('***'); // the host IP address
8
9 if (!method_exists($ssh, 'Net_SSH2')) die("Net_SSH2 class doesn't have Net_SSH2 method!");
10
11 if (!$ssh->login('***', '***')) { // (verified) username and password
12 echo "LOG: " . $ssh->getLog() . "<br>";
13 echo "ALL ERRORS: ";
14 print_r($ssh->getErrors());
15 echo "<br>LAST ERROR: " . $ssh->getLastError() . "<br>";
16 exit('Login failed!');
17 }
It exits at line # 16. getLog() gives nothing so it is hard to know where the problem is. I had the login credentials tested using PuTTY. It is not able to login to other servers either. I am not able to understand what is causing the problem.
Any help would be highly appreciated!
Net_SSH2 is not a function, this is a class and constructor within this class.
So 3rd line should be
if (!class_exists('Net_SSH2')) die("Class Net_SSH2 doesn't exist!");
If you wanna check further if Net_SSH2 method exists in class Net_SSH2 after line 5 you can add this:
if (!method_exists($ssh, 'Net_SSH2')) die("Net_SSH2 class doesn't have Net_SSH2 method");
If you hit the "Enable Logging" button on the link you provided you'll see that the following is done right after Net/SSH2.php is included:
define('NET_SSH2_LOGGING', NET_SSH2_LOG_COMPLEX);
Try that.
Try doing this at the top of your PHP script:
error_reporting(E_USER_NOTICE);
Setting error_reporting to 0 suppresses user_error so it's quite possible your PHP setup is just suppressing the error. eg.
error_reporting(E_USER_NOTICE);
user_error('zzzz', E_USER_NOTICE);
vs.
error_reporting(0);
user_error('zzzz', E_USER_NOTICE);
Of course you could change your line 3 to:
if( !class_exists('Net_SSH2')...
But I would suggest you throw in some Exception handling. When using the PHPSecLib, I had nothing but issues, so I created this SSH2 Class which does require the PHP SSH2 Extension to be installed.
You should try calling: getLog() to find out why it's failing.
echo $ssh->getLog();
I ended up hosting my code on the server (server B) that I was trying to connect. The same code worked in the opposite direction (I could connect to the server A where my code previously was)! I ended up concluding that the server A has environmental issues.
I appreciate those were helping me here!
Given the latest comments, I assume your code exists at line 8 (where the Net_SSH2() object is instantiated)...
I just had a very similar issue where, once deployed, include() would work but check_exists() and instantiating a new Net_SSH2 object would fail... But parsing my php file (before deployment) with the php command line tool would work fine...
So the problem was on the server (Apache in my case): the directory where phpseclib was installed had permissions set so that I could not even cd to it.
As it happened, my hoem made deploying script was simply copying the files on the server and setting odd permissions so that the SSH2.php was not accessible.
Perhaps you have a similar problem here?

Categories