Page 1 of 1

PHP Warning

Posted: Wed Aug 30, 2017 1:59 am
by mrfifagamer
Hey,

I got this error on my log and I do not know how to fix it. Hopefully someone can help me out.

2017-08-29 3:48:29 - PHP Warning: is_dir() expects parameter 1 to be a valid path, string given in /home/fifafi1q/public_html/vqmod/vqcache/vq2-system_engine_action.php on line 17
2017-08-29 3:48:29 - PHP Warning: is_file() expects parameter 1 to be a valid path, string given in /home/fifafi1q/public_html/vqmod/vqcache/vq2-system_engine_action.php on line 27


This is my vq2-system_engine_action.php code:

Code: Select all

<?php
final class Action {
	private $file;
	private $class;
	private $method;
	private $args = array();

	public function __construct($route, $args = array()) {
		$path = '';

		// Break apart the route
		$parts = explode('/', str_replace('../', '', (string)$route));

		foreach ($parts as $part) {
			$path .= $part;

			if (is_dir(DIR_APPLICATION . 'controller/' . $path)) {
				$path .= '/';

				array_shift($parts);

				continue;
			}

			$file = DIR_APPLICATION . 'controller/' . str_replace(array('../', '..\\', '..'), '', $path) . '.php';

			if (is_file($file)) {
				$this->file = $file;

				$this->class = 'Controller' . preg_replace('/[^a-zA-Z0-9]/', '', $path);

				array_shift($parts);

				break;
			}
		}

		if ($args) {
			$this->args = $args;
		}

		$method = array_shift($parts);

		if ($method) {
			$this->method = $method;
		} else {
			$this->method = 'index';
		}
	}

	public function execute($registry) {
		// Stop any magical methods being called
		if (substr($this->method, 0, 2) == '__') {
			return false;
		}

		if (is_file($this->file)) {
			include_once(VQMod::modCheck($this->file));

			$class = $this->class;

			$controller = new $class($registry);

			if (is_callable(array($controller, $this->method))) {
				return call_user_func(array($controller, $this->method), $this->args);
			} else {
				return false;
			}
		} else {
			return false;
		}
	}
}
Thanks in advance! :)

Re: PHP Warning

Posted: Wed Aug 30, 2017 2:17 am
by yodapt
What have you changed recently?

Re: PHP Warning

Posted: Fri Sep 01, 2017 9:48 pm
by mrfifagamer
yodapt wrote:
Wed Aug 30, 2017 2:17 am
What have you changed recently?
I have not touched my code at all.

Re: PHP Warning

Posted: Fri Sep 01, 2017 10:14 pm
by yodapt
Well the error isnt on that file for sure, it is just triggered at the point a function in that file is needed.

Re: PHP Warning

Posted: Sat Sep 02, 2017 2:28 am
by MrPhil
Before the is_dir() call, print out DIR_APPLICATION and $path and see if they have any odd characters in them (both should be proper paths for your server's operating system). Maybe there's something bad about either or both of them. If they're empty or null, I don't think you'll get this error message.

Re: PHP Warning

Posted: Thu Sep 14, 2017 6:35 pm
by cssjunkie
Im getting this same problem now. I never had this error before. Today it started showing.

Re: PHP Warning

Posted: Thu Sep 14, 2017 9:55 pm
by MrPhil
If neither you nor a hacker changed the code, most likely your host just upgraded to a new PHP version. How old a version of OC are you running? Maybe it's not compatible with your new PHP version.

Re: PHP Warning

Posted: Wed Sep 20, 2017 10:36 am
by somjai007
Thanks for the info


gclub