コード例 #1
0
ファイル: guid.class.php プロジェクト: greatbody/cerl
function createGuid()
{
    $guid = new Guid();
    return $guid->toString();
}
コード例 #2
0
 /**
  * @param $topic
  * @param $type
  * @param $msg
  * @throws \Exception
  * @return bool
  */
 public function publish($topic, $type, $msg)
 {
     if (!$this->connected) {
         $this->connect();
     }
     if (!$this->greeted) {
         $this->greet();
     }
     if (!$this->jsonEnable) {
         $msgEntity = new \StringMessage();
         $msgHeader = new \Header();
         $msgHeader->set_groupId($this->group);
         $msgHeader->set_commit(true);
         $msgHeader->set_deliverLimit(100);
         $msgHeader->set_expiredTime(-1);
         $msgHeader->set_fly(false);
         $msgHeader->set_topic($topic);
         $guid = new Guid();
         $msgHeader->set_messageId($guid->toString());
         $msgHeader->set_messageType($type);
         $msgEntity->set_header($msgHeader);
         $msgEntity->set_body($msg);
         $send = $msgEntity->SerializeToString();
         if (function_exists('kiteq_request')) {
             list($data, $type) = kiteq_request($this->conn, $send, self::CMD_STRING_MESSAGE);
         } else {
             // 发送
             $this->innerSend($send, self::CMD_STRING_MESSAGE);
             // 接受
             list($type, $data) = $this->innerGet();
         }
         if ($type != self::CMD_MESSAGE_STORE_ACK) {
             throw new \Exception("kiteq 验证错误 MessageType {$type}");
         }
         $ack = new \MessageStoreAck();
         $ack->ParseFromString($data);
         if ($ack->getStatus() == false) {
             throw new \Exception($ack->getFeedback());
         }
         return $ack->getStatus();
     } else {
         $msgEntity = array();
         $msgHeader = array('groupId' => $this->group, 'commit' => true, 'deliverLimit' => 100, 'expiredTime' => -1, 'fly' => false, 'topic' => $topic, 'messageId' => uniqid(), 'messageType' => $type);
         $msgEntity['header'] = $msgHeader;
         $msgEntity['body'] = $msg;
         $send = json_encode($msgEntity);
         if (function_exists('kiteq_request')) {
             list($data, $type) = kiteq_request($this->conn, $send, self::CMD_STRING_MESSAGE | 0x80);
         } else {
             // 发送
             $this->innerSend($send, self::CMD_STRING_MESSAGE | 0x80);
             // 接受
             list($type, $data) = $this->innerGet();
         }
         if ($type != self::CMD_MESSAGE_STORE_ACK) {
             throw new \Exception("kiteq 验证错误 MessageType {$type}");
         }
         $ack = json_decode($data, true);
         if ($ack->getStatus() == false) {
             throw new \Exception($ack->getFeedback());
         }
         return $ack->getStatus();
     }
 }
コード例 #3
0
ファイル: guid.php プロジェクト: BGCX067/f2cont-svn-to-git
{
    var $guidText;
    function initialize()
    {
        $this->guidText = md5(uniqid(rand(), true));
        return $this->guidText;
    }
    function toString($separator = '', $case = false)
    {
        $str =& $this->guidText;
        if ($case) {
            switch ($case) {
                case 'uc':
                    $str = strtoupper($str);
                    break;
                case 'lc':
                    $str = strtolower($str);
                    break;
                default:
                    $str = $str;
            }
        }
        $str = substr($str, 0, 8) . $separator . substr($str, 8, 4) . $separator . substr($str, 12, 4) . $separator . substr($str, 16, 4) . $separator . substr($str, 20);
        return htmlspecialchars($str);
    }
}
$obj = new Guid();
for ($i = 0; $i < 14; $i++) {
    $obj->initialize();
    echo strtoupper($obj->toString('-')) . "<br/>";
}
コード例 #4
0
ファイル: uploadify.php プロジェクト: NodejsMAS/laner
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require_once '../utils/guid.php';
include_once "../utils/fileOpts.php";
$guid = new Guid($_SERVER["SERVER_NAME"], $_SERVER["SERVER_ADDR"]);
if (!empty($_FILES)) {
    $tempFile = $_FILES['Filedata']['tmp_name'];
    $targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';
    $fname = $_FILES['Filedata']['name'];
    $fext = substr($fname, strrpos($fname, "."));
    $fnew_name = $guid->toString() . $fext;
    $targetFile = str_replace('//', '/', $targetPath) . $fnew_name;
    // $fileTypes  = str_replace('*.','',$_REQUEST['fileext']);
    // $fileTypes  = str_replace(';','|',$fileTypes);
    // $typesArray = split('\|',$fileTypes);
    // $fileParts  = pathinfo($_FILES['Filedata']['name']);
    // if (in_array($fileParts['extension'],$typesArray)) {
    // Uncomment the following line if you want to make the directory if it doesn't exist
    // mkdir(str_replace('//','/',$targetPath), 0755, true);
    //chmod($tempFile 0777);
    move_uploaded_file($tempFile, $targetFile);
    echo "|" . $fnew_name . "|";
    //echo str_replace($_SERVER['DOCUMENT_ROOT'],'',$targetFile);
    // } else {
    // 	echo 'Invalid file type.';
    // }