* $url - The site's webpage URL * $description - A short info on the site. Max 50 chars * $redirect_url - Contains all the redirect URls separated by a newline */ public static function register($title, $url, $description, $redirect_url) { global $who; $urlParts = parse_url($url); $urlHost = $urlParts['host']; $sql = self::$OP->dbh->prepare("SELECT COUNT(`id`) FROM `opth_sites` WHERE `url` = ? OR `title` LIKE ?"); $sql->execute(array($urlHost, "%{$title}%")); if ($sql->fetchColumn() != 0) { return "exists"; } else { /** * Make an API Key and API Secret string */ $api_key = self::$OP->randStr(40); $api_secret = hash("sha256", self::$OP->randStr(50)); $sql = self::$OP->dbh->prepare("INSERT INTO `opth_sites` (`uid`, `api_key`, `api_secret`, `title`, `url`, `description`, `redirect_url`) VALUES (?, ?, ?, ?, ?, ?, ?)"); $success = $sql->execute(array($who, $api_key, $api_secret, $title, $url, $description, $redirect_url)); if ($sql->rowCount() != 0) { return true; } else { return false; } } } } Opth::init();