/** * Get faces * * @param string $file Picture filename * @throws Horde_Exception */ protected function _getFaces($file) { if (!Horde_Util::loadExtension('facedetect')) { throw new Ansel_Exception('You do not have the facedetect extension enabled in PHP'); } return face_detect($file, $this->_defs); }
/** */ protected function _changePassword($user, $oldpass, $newpass) { if (!Horde_Util::loadExtension('expect')) { throw new Passwd_Exception(_("expect extension cannot be loaded")); } // Set up parameters foreach (array('logfile', 'loguser', 'timeout') as $val) { if (isset($this->_params[$val])) { ini_set('expect.' . $val, $this->_params[$val]); } } // Open connection $call = sprintf('ssh %s@%s %s', $user, $this->_params['host'], $this->_params['program']); if (!($this->_stream = expect_popen($call))) { throw new Passwd_Exception(_("Unable to open expect stream")); } // Log in $this->_ctl('(P|p)assword.*', _("Could not login to system (no password prompt)")); // Send login password fwrite($this->_stream, $oldpass . "\n"); // Expect old password prompt $this->_ctl('((O|o)ld|login|current).* (P|p)assword.*', _("Could not start passwd program (no old password prompt)")); // Send old password fwrite($this->_stream, $oldpass . "\n"); // Expect new password prompt $this->_ctl('(N|n)ew.* (P|p)assword.*', _("Could not change password (bad old password?)")); // Send new password fwrite($this->_stream, $newpass . "\n"); // Expect reenter password prompt $this->_ctl("((R|r)e-*enter.*(P|p)assword|Retype new( UNIX)? password|(V|v)erification|(V|v)erify|(A|a)gain).*", _("New password not valid (too short, bad password, too similar, ...)")); // Send new password fwrite($this->_stream, $newpass . "\n"); // Expect successfully message $this->_ctl('((P|p)assword.* changed|successfully)', _("Could not change password.")); }
/** * Const'r * * @see Horde_Image_Base::_construct */ public function __construct($params, $context = array()) { if (!Horde_Util::loadExtension('imagick')) { throw new Horde_Image_Exception('Required PECL Imagick extension not found.'); } parent::__construct($params, $context); ini_set('imagick.locale_fix', 1); $this->_imagick = new Imagick(); if (!empty($params['filename'])) { $this->loadFile($params['filename']); } elseif (!empty($params['data'])) { $this->loadString($params['data']); } else { $this->_width = max(array($this->_width, 1)); $this->_height = max(array($this->_height, 1)); try { $this->_imagick->newImage($this->_width, $this->_height, $this->_background); } catch (ImagickException $e) { throw new Horde_Image_Exception($e); } } try { $this->_imagick->setImageFormat($this->_type); } catch (ImagickException $e) { throw new Horde_Image_Exception($e); } }
/** * Get an image signature from an arbitrary file. Currently used when * searching for faces that appear in a user-supplied image. * * @param integer $filename Image filename to check * * @return binary vector signature */ public function getSignatureFromFile($filename) { if ($GLOBALS['conf']['faces']['search'] == 0 || Horde_Util::loadExtension('libpuzzle') === false) { return ''; } return puzzle_fill_cvec_from_file($filename); }
/** * Constructor. * * @see $_config * * @param array $config Configuration array. */ public function __construct($config = array()) { if (!Horde_Util::loadExtension('ldap')) { throw new Horde_Ldap_Exception('No PHP LDAP extension'); } $this->setConfig($config); $this->bind(); }
/** * Returns decoded image data * * @param string $data The image data * @param string $encoding The encoding type for the image data. * (none, base64, or binhex) * @param string $compression The compression type for the image data. * (none, gzip, or lzf) * @param boolean $upload Process direction (true of encode/compress or false if decode/decompress) * * @return string The decoded/encoded image data */ protected function _getImageData($data, $encoding = 'none', $compression = 'none', $upload = true) { switch ($encoding) { case 'base64': $data = $upload ? base64_decode($data) : base64_encode($data); break; case 'binhex': $data = $upload ? pack('H*', $data) : unpack('H*', $data); } switch ($compression) { case 'gzip': if (Horde_Util::loadExtension('zlib')) { return $upload ? gzuncompress($data) : gzcompress($data); } break; case 'lzf': if (Horde_Util::loadExtension('lzf')) { return $upload ? lzf_decompress($data) : lzf_compress($data); } break; default: return $data; } }
/** * Generate HTML for a face's tile * * @param integer $face The face id. * * @return string The generated HTML */ public static function getFaceTile($face) { $faces = $GLOBALS['injector']->getInstance('Ansel_Faces'); if (!is_array($face)) { $face = $faces->getFaceById($face, true); } $face_id = $face['face_id']; // The HTML to display the face image. $imghtml = sprintf("<img src=\"%s\" class=\"bordered-facethumb\" id=\"%s\" alt=\"%s\" />", $faces->getFaceUrl($face['image_id'], $face_id), 'facethumb' . $face_id, htmlspecialchars($face['face_name'])); $img_view_url = Ansel::getUrlFor('view', array('gallery' => $face['gallery_id'], 'view' => 'Image', 'image' => $face['image_id'], 'havesearch' => false)); // Build the actual html $html = '<div id="face' . $face_id . '"><table><tr><td>' . $img_view_url->link() . $imghtml . '</a></td><td>'; if (!empty($face['face_name'])) { $html .= Horde::url('faces/face.php')->add('face', $face['face_id'])->link() . $face['face_name'] . '</a><br />'; } // Display the face name or a link to claim the face. if (empty($face['face_name']) && $GLOBALS['conf']['report_content']['driver']) { $html .= Horde::url('faces/claim.php')->add('face', $face_id)->link(array('title' => _("Do you know someone in this photo?"))) . _("Claim") . '</a>'; } // Link for searching for similar faces. if (Horde_Util::loadExtension('libpuzzle') !== false) { $html .= Horde::url('faces/search/image_search.php')->add('face_id', $face_id)->link() . _("Find similar") . '</a>'; } $html .= '</td></tr></table></div>'; return $html; }
/** */ public function __construct($app, $params = array()) { parent::__construct($app, $params); $this->enabled = Horde_Util::loadExtension('soap'); $this->_name = _("EU VAT identification"); }