westdc-zf1/vendor/Westdc/MetadataSync/Handle/OutlinkHandle.php

56 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Westdc\Metadata\Handle;
use Sookon\Helpers\PDO as Pdo;
use Sookon\Helpers\Config;
use Sookon\Helpers\View as view;
use Sookon\Mail\Mail;
use Sookon\Search\Search;
use Zend\EventManager\EventInterface;
use Westdc\Metadata\Event\OutlinkEvent as Event;
class OutlinkHandle implements Event
{
private $db;
private $config;
function __construct($db = NULL)
{
$this->db = new Pdo();
$this->config = Config::get();
}
//检查字段
public function checkParam(EventInterface $e){
$data = $e->getParam('data');
if(!is_array($data))
{
return "参数错误";
}
if(empty($data['url']))
{
return "请填写要跳转的目标地址";
}
if(!preg_match("/(http|ftp|https):\/\/(.*)/i",$data['url']))
{
return "请填写完整的url必须包含协议名称例如 https://www.google.com.hk";
}
return true;
}//checkParam
//处理字段
public function processData(EventInterface $e)
{
$data = $e->getParam('data');
return $data;
}
}