root/ip/tags/release_1_3_0_53/includes/db/mysql.php

111163
264
			{
264
			{
265
				$f = fopen($this->cache_folder . 'sql_history.' . PHP_EXT, 'a+');
265
				$f = fopen($this->cache_folder . 'sql_history.' . PHP_EXT, 'a+');
266
				@flock($f, LOCK_EX);
266
				@flock($f, LOCK_EX);
267
				@fwrite($f, date('Y/m/d - H:i:s') . ' => ' . $hash . "\n\n" . $query . "\n\n\n=========================\n\n");
267
				@fwrite($f, gmdate('Y/m/d - H:i:s') . ' => ' . $hash . "\n\n" . $query . "\n\n\n=========================\n\n");
268
				@flock($f, LOCK_UN);
268
				@flock($f, LOCK_UN);
269
				@fclose($f);
269
				@fclose($f);
270
			}
270
			}
...
...
696
	}
696
	}
697
697
698
	/**
698
	/**
699
	* Build IN or NOT IN sql comparison string, uses <> or = on single element arrays to improve comparison speed
700
	*
701
	* @access public
702
	* @param string $field name of the sql column that shall be compared
703
	* @param array $array array of values that are allowed (IN) or not allowed (NOT IN)
704
	* @param bool $negate true for NOT IN (), false for IN () (default)
705
	* @param bool $allow_empty_set If true, allow $array to be empty, this function will return 1=1 or 1=0 then. Default to false.
706
	*/
707
	function sql_in_set($field, $array, $negate = false, $allow_empty_set = false)
708
	{
709
		if (!sizeof($array))
710
		{
711
			if (!$allow_empty_set)
712
			{
713
				// Print the backtrace to help identifying the location of the problematic code
714
				$this->sql_error('No values specified for SQL IN comparison');
715
			}
716
			else
717
			{
718
				// NOT IN () actually means everything so use a tautology
719
				if ($negate)
720
				{
721
					return '1=1';
722
				}
723
				// IN () actually means nothing so use a contradiction
724
				else
725
				{
726
					return '1=0';
727
				}
728
			}
729
		}
730
731
		if (!is_array($array))
732
		{
733
			$array = array($array);
734
		}
735
736
		if (sizeof($array) == 1)
737
		{
738
			@reset($array);
739
			$var = current($array);
740
741
			return $field . ($negate ? ' <> ' : ' = ') . $this->sql_validate_value($var);
742
		}
743
		else
744
		{
745
			return $field . ($negate ? ' NOT IN ' : ' IN ') . '(' . implode(', ', array_map(array($this, 'sql_validate_value'), $array)) . ')';
746
		}
747
	}
748
749
	/**
699
	* Free memory from results
750
	* Free memory from results
700
	*/
751
	*/
701
	function sql_freeresult($query_id = 0)
752
	function sql_freeresult($query_id = 0)
...
...
770
		$f_content = '<' . '?php' . "\n";
821
		$f_content = '<' . '?php' . "\n";
771
		$f_content .= '/* SQL: ' . str_replace('*/', '*\/', $this->query_string) . ' */' . "\n\n";
822
		$f_content .= '/* SQL: ' . str_replace('*/', '*\/', $this->query_string) . ' */' . "\n\n";
772
		$f_content .= '/* UNIX TIME: ' . time() . ' */' . "\n\n";
823
		$f_content .= '/* UNIX TIME: ' . time() . ' */' . "\n\n";
773
		$f_content .= '/* TIME: ' . date('Y/m/d - H:i:s') . ' */' . "\n\n";
824
		$f_content .= '/* TIME: ' . gmdate('Y/m/d - H:i:s') . ' */' . "\n\n";
774
		//$f_content .= '$expired = (time() > ' . (time() + 86400) . ') ? true : false;' . "\n" . 'if ($expired) { return; }' . "\n\n";
825
		//$f_content .= '$expired = (time() > ' . (time() + 86400) . ') ? true : false;' . "\n" . 'if ($expired) { return; }' . "\n\n";
775
		$f_content .= '$set = ' . $data . ';' . "\n";
826
		$f_content .= '$set = ' . $data . ';' . "\n";
776
		$f_content .= '$cache_included = true;' . "\n" . 'return;' . "\n";
827
		$f_content .= '$cache_included = true;' . "\n" . 'return;' . "\n";