function inverseHex($color) { $color = TRIM($color); $prependHash = FALSE; if (STRPOS($color, '#') !== FALSE) { $prependHash = TRUE; $color = STR_REPLACE('#', NULL, $color); } switch ($len = STRLEN($color)) { case 3: $color = PREG_REPLACE("/(.)(.)(.)/", "\\1\\1\\2\\2\\3\\3", $color); case 6: break; default: TRIGGER_ERROR("Invalid hex length ({$len}). Must be (3) or (6)", E_USER_ERROR); } if (!PREG_MATCH('/[a-f0-9]{6}/i', $color)) { $color = HTMLENTITIES($color); TRIGGER_ERROR("Invalid hex string #{$color}", E_USER_ERROR); } $r = DECHEX(255 - HEXDEC(SUBSTR($color, 0, 2))); $r = STRLEN($r) > 1 ? $r : '0' . $r; $g = DECHEX(255 - HEXDEC(SUBSTR($color, 2, 2))); $g = STRLEN($g) > 1 ? $g : '0' . $g; $b = DECHEX(255 - HEXDEC(SUBSTR($color, 4, 2))); $b = STRLEN($b) > 1 ? $b : '0' . $b; return ($prependHash ? '#' : NULL) . $r . $g . $b; }
/** * Execute a query binding in any passed `$data` and returning the result. * * * @param string $query The query to execute. * @param null|string|array The data to bind into the query. * * @return mixed * * @throws \Disco\exceptions\DBQuery */ public function query($query, $data = null) { try { if (!$data) { return parent::query($query); } //if $stmt = parent::prepare($query); if (!is_array($data)) { $data = array($data); } //if $stmt->execute($data); return $stmt; } catch (\PDOException $e) { TRIGGER_ERROR("DB:: Query Error | {$query}\n" . $e->getMessage() . "\n" . $e->getTraceAsString(), E_USER_WARNING); throw new \Disco\exceptions\DBQuery($e->getMessage(), (int) $e->getCode()); } //catch }