public function SetCaptchaCode($sid = false) { $max = count($this->arChars); $this->code = ""; for ($i = 0; $i < $this->codeLength; $i++) { $this->code .= $this->arChars[rand(1, $max) - 1]; } $this->sid = $sid === false ? $this->Generate32RandomString() : $sid; CCaptcha::Add(array("CODE" => $this->code, "ID" => $this->sid)); }