コード例 #1
2
ファイル: Database.php プロジェクト: nbari/DALMP
 /**
  * Universally Unique Identifier v4
  *
  * @param  int   $b
  * @return UUID, if $b returns binary(16)
  */
 public function UUID($b = null)
 {
     if ($this->debug) {
         $this->debug->log(__METHOD__);
     }
     if (function_exists('uuid_create')) {
         $uuid = uuid_create();
     } else {
         $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
     }
     return $b ? pack('H*', str_replace('-', '', $uuid)) : $uuid;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function generate(EntityManager $em, $entity)
 {
     if (defined('PHP_WINDOWS_VERSION_BUILD')) {
         return substr(com_create_guid(), 1, 36);
     }
     return uuid_create(UUID_TYPE_RANDOM);
 }
コード例 #3
0
function companies_viewcontent_alm_customers_BeforeInsert(&$sender)
{
    $companies_viewcontent_alm_customers_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $companies_viewcontent;
    //Compatibility
    //End companies_viewcontent_alm_customers_BeforeInsert
    //Custom Code @26-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = uuid_create();
    global $lastguid;
    $lastguid = $guid;
    $userid = CCGetUserID();
    $businesspartner = CCGetFromPost("businesspartner", array());
    $businesspartner_list = "";
    foreach ($businesspartner as $partner) {
        $businesspartner_list .= $partner . ",";
    }
    $companies_viewcontent->alm_customers->businesspartner->SetValue($businesspartner_list);
    $companies_viewcontent->alm_customers->created_iduser->SetValue($userid);
    $companies_viewcontent->alm_customers->hidguid->SetValue($guid);
    $companies_viewcontent->alm_customers->assigned_to->SetValue($userid);
    // -------------------------
    //End Custom Code
    //Close companies_viewcontent_alm_customers_BeforeInsert @2-560BEAB8
    return $companies_viewcontent_alm_customers_BeforeInsert;
}
コード例 #4
0
ファイル: UUID.class.php プロジェクト: jlaprise/Pandra
 private static function instance()
 {
     if (!is_resource(self::$_uuid)) {
         uuid_create(&self::$_uuid);
     }
     return self::$_uuid;
 }
コード例 #5
0
 /**
  * Generates a universally unique identifier (UUID) according to RFC 4122.
  * The algorithm used here, might not be completely random.
  *
  * If php-uuid was installed it will be used instead to speed up the process.
  *
  * @return string The universally unique id
  * @todo Optionally generate type 1 and type 5 UUIDs.
  */
 public static function generateUUID()
 {
     if (is_callable('uuid_create')) {
         return strtolower(uuid_create(UUID_TYPE_RANDOM));
     }
     return (string) Uuid::uuid4();
 }
コード例 #6
0
ファイル: QuipCalendar.php プロジェクト: wittiws/quipxml
 /**
  * Initialize an empty calendar.
  * @param array $defaults
  * @return \QuipXml\Xml\QuipXmlElement
  */
 public static function loadEmpty($defaults = NULL)
 {
     $uid = function_exists('uuid_create') ? uuid_create() : uniqid('quip-cal-');
     $defaults = array_merge(array('uid' => $uid, 'name' => 'New Calendar', 'timezone' => 'Etc/UTC'), (array) $defaults);
     $ical = implode("\n", array('BEGIN:VCALENDAR', 'VERSION:2.0', 'PRODID:QuipCalendar', 'CALSCALE:GREGORIAN', 'UID:' . $defaults['uid'], 'X-WR-CALNAME:' . $defaults['name'], 'X-WR-TIMEZONE:' . $defaults['timezone'], 'END:VCALENDAR'));
     return QuipCalendar::loadIcal($ical);
 }
コード例 #7
0
ファイル: UuidGenerator.php プロジェクト: metro-q/metro
 public function generateId()
 {
     if (extension_loaded('uuid')) {
         return uuid_create();
     }
     // @codingStandardsIgnoreStart
     return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
     // @codingStandardsIgnoreEnd
 }
コード例 #8
0
ファイル: Uuid.php プロジェクト: highhair20/glo
 /**
  * generate
  *
  * v4
  */
 public static function generate()
 {
     if (!function_exists('uuid_create')) {
         return false;
     }
     uuid_create(&$context);
     uuid_make($context, UUID_MAKE_V4);
     uuid_export($context, UUID_FMT_STR, &$uuid);
     return trim($uuid);
 }
コード例 #9
0
ファイル: Encrypter.php プロジェクト: connwap135/ectouch
 /**
  * 生成UUID
  * @param  string $value 待解密字符串
  * @return string
  */
 public function getId()
 {
     if (function_exists('uuid_create') && !function_exists('uuid_make')) {
         $id = uuid_create(UUID_TYPE_DEFAULT);
     } elseif (function_exists('com_create_guid')) {
         $id = strtolower(trim(com_create_guid(), '{}'));
     } else {
         $id = $this->createId();
     }
     return $id;
 }
コード例 #10
0
ファイル: FromUuid.php プロジェクト: datasift/storyplayer
 public function generateUuid()
 {
     // what are we doing?
     $log = usingLog()->startAction("generate a UUID");
     // do we have the UUID extension?
     $uuid = uuid_create();
     // log it
     $log->endAction("'{$uuid}'");
     // all done
     return $uuid;
 }
コード例 #11
0
ファイル: UUIDWrapper.class.php プロジェクト: rolwi/koala
 /**
  * Generates version 5 UUID: SHA-1 hash of URL
  */
 public static function v5($i_url)
 {
     if (!function_exists('uuid_create')) {
         return false;
     }
     if (!strlen($i_url)) {
         $i_url = self::v1();
     }
     uuid_create(&$context);
     uuid_create(&$namespace);
     uuid_make($context, UUID_MAKE_V5, $namespace, $i_url);
     uuid_export($context, UUID_FMT_STR, &$uuid);
     return trim($uuid);
 }
コード例 #12
0
 /**
  * On long running deamons i've seen a lost resource. This checks the resource and creates it if needed.
  *
  */
 protected static function ensure()
 {
     if (is_resource(self::$uuidobject)) {
         return true;
     }
     if (!iHRIS_Module_UUID_Map::hasUUID()) {
         return false;
     }
     uuid_create(&self::$uuidobject);
     if (!is_resource(self::$uuidobject)) {
         return false;
     }
     return true;
 }
コード例 #13
0
ファイル: Uuid.php プロジェクト: netcon-source/apps
 /**
  * Generate a 36-character RFC 4122 UUID, without the urn:uuid: prefix.
  *
  * @see http://www.ietf.org/rfc/rfc4122.txt
  * @see http://labs.omniti.com/alexandria/trunk/OmniTI/Util/UUID.php
  */
 public function generate()
 {
     if (extension_loaded('uuid')) {
         $this->_uuid = uuid_create();
     } else {
         list($time_mid, $time_low) = explode(' ', microtime());
         $time_low = (int) $time_low;
         $time_mid = (int) substr($time_mid, 2) & 0xffff;
         $time_high = mt_rand(0, 0xfff) | 0x4000;
         $clock = mt_rand(0, 0x3fff) | 0x8000;
         $node_low = function_exists('zend_thread_id') ? zend_thread_id() : getmypid();
         $node_high = isset($_SERVER['SERVER_ADDR']) ? ip2long($_SERVER['SERVER_ADDR']) : crc32(php_uname());
         $node = bin2hex(pack('nN', $node_low, $node_high));
         $this->_uuid = sprintf('%08x-%04x-%04x-%04x-%s', $time_low, $time_mid, $time_high, $clock, $node);
     }
 }
function contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert(&$sender)
{
    $contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $contacts_subhobbies_maintcontent;
    //Compatibility
    //End contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert
    //Custom Code @13-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = uuid_create();
    $contacts_subhobbies_maintcontent->alm_customers_contacts_su->created_iduser->SetValue(CCGetUserID());
    $contacts_subhobbies_maintcontent->alm_customers_contacts_su->hidguid->SetValue($guid);
    // -------------------------
    //End Custom Code
    //Close contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert @2-71F6BE98
    return $contacts_subhobbies_maintcontent_alm_customers_contacts_su_BeforeInsert;
}
コード例 #15
0
function settings_maintcontent_options_BeforeInsert(&$sender)
{
    $settings_maintcontent_options_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $settings_maintcontent;
    //Compatibility
    //End settings_maintcontent_options_BeforeInsert
    //Custom Code @15-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = uuid_create();
    $settings_maintcontent->options->hidguid->SetValue($guid);
    $settings_maintcontent->options->created_iduser->SetValue(CCGetUserID());
    // -------------------------
    //End Custom Code
    //Close settings_maintcontent_options_BeforeInsert @5-59596C86
    return $settings_maintcontent_options_BeforeInsert;
}
コード例 #16
0
ファイル: UUID.php プロジェクト: jazzee/foundation
 /**
  * Generates version 4 UUID: random
  */
 public static function v4()
 {
     //try and use the PECL UUID library
     if (function_exists('uuid_create') and defined('UUID_TYPE_RANDOM')) {
         return \uuid_create(UUID_TYPE_RANDOM);
     }
     //if not we have to do it ourselfex becuase the PECL implementaiton is worthless
     $prBits = null;
     $fp = @fopen('/dev/urandom', 'rb');
     if ($fp !== false) {
         $prBits .= @fread($fp, 16);
         @fclose($fp);
     } else {
         // If /dev/urandom isn't available (eg: in non-unix systems), use mt_rand().
         $prBits = "";
         for ($cnt = 0; $cnt < 16; $cnt++) {
             $prBits .= chr(mt_rand(0, 255));
         }
     }
     $timeLow = bin2hex(substr($prBits, 0, 4));
     $timeMid = bin2hex(substr($prBits, 4, 2));
     $timeHiAndVersion = bin2hex(substr($prBits, 6, 2));
     $clockSeqHiAndReserved = bin2hex(substr($prBits, 8, 2));
     $node = bin2hex(substr($prBits, 10, 6));
     /**
      * Set the four most significant bits (bits 12 through 15) of the
      * $timeHiAndVersion field to the 4-bit version number from
      * Section 4.1.3.
      * @see http://tools.ietf.org/html/rfc4122#section-4.1.3
      */
     $timeHiAndVersion = hexdec($timeHiAndVersion);
     $timeHiAndVersion = $timeHiAndVersion >> 4;
     $timeHiAndVersion = $timeHiAndVersion | 0x4000;
     /**
      * Set the two most significant bits (bits 6 and 7) of the
      * $clockSeqHiAndReserved to zero and one, respectively.
      */
     $clockSeqHiAndReserved = hexdec($clockSeqHiAndReserved);
     $clockSeqHiAndReserved = $clockSeqHiAndReserved >> 2;
     $clockSeqHiAndReserved = $clockSeqHiAndReserved | 0x8000;
     return sprintf('%08s-%04s-%04x-%04x-%012s', $timeLow, $timeMid, $timeHiAndVersion, $clockSeqHiAndReserved, $node);
 }
コード例 #17
0
function resellers_maintcontent_alm_resellers_BeforeInsert(&$sender)
{
    $resellers_maintcontent_alm_resellers_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $resellers_maintcontent;
    //Compatibility
    //End resellers_maintcontent_alm_resellers_BeforeInsert
    //Custom Code @15-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = uuid_create();
    global $lastguid;
    $lastguid = $guid;
    $resellers_maintcontent->alm_resellers->created_iduser->SetValue(CCGetUserID());
    $resellers_maintcontent->alm_resellers->hidguid->SetValue($guid);
    // -------------------------
    //End Custom Code
    //Close resellers_maintcontent_alm_resellers_BeforeInsert @2-F1DAC32C
    return $resellers_maintcontent_alm_resellers_BeforeInsert;
}
function products_suite_maintcontent_alm_product_suites_BeforeInsert(&$sender)
{
    $products_suite_maintcontent_alm_product_suites_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $products_suite_maintcontent;
    //Compatibility
    //End products_suite_maintcontent_alm_product_suites_BeforeInsert
    //Custom Code @30-2A29BDB7
    // -------------------------
    // Write your own code here.
    $guid = uuid_create();
    global $lastguid;
    $lastguid = $guid;
    $products_suite_maintcontent->alm_product_suites->created_iduser->SetValue(CCGetUserID());
    $products_suite_maintcontent->alm_product_suites->hidguid->SetValue($guid);
    // -------------------------
    //End Custom Code
    //Close products_suite_maintcontent_alm_product_suites_BeforeInsert @2-29050226
    return $products_suite_maintcontent_alm_product_suites_BeforeInsert;
}
コード例 #19
0
ファイル: pecluuidimpl.php プロジェクト: noccy80/cherryphp
 /**
  * @brief Generate a UUID
  *
  * @param mixed $version The version to generate (default UUID_V4)
  * @param mixed $url The URL to use for V3 and V5 UUIDs.
  * @return string The UUID
  */
 public function generate($version = self::UUID_V4, $url = null)
 {
     // Implementation for pecl uuid
     $hu = null;
     switch ($version) {
         case self::UUID_V1:
             $uuid = \uuid_create(\UUID_TYPE_DCE);
             break;
         case self::UUID_V3:
             return null;
             break;
         case self::UUID_V4:
             $uuid = \uuid_create(\UUID_TYPE_RANDOM);
             break;
         case self::UUID_V5:
             return null;
             break;
         default:
             return null;
     }
     return trim($uuid);
 }
コード例 #20
0
ファイル: osspuuidimpl.php プロジェクト: noccy80/cherryphp
 /**
  * @brief Generate a UUID
  *
  * @param mixed $version The version to generate (default UUID_V4)
  * @param mixed $url The URL to use for V3 and V5 UUIDs.
  * @return string The UUID
  */
 public function generate($version = self::UUID_V4, $url = null)
 {
     // Implementation for ossp-uuid
     $hu = null;
     $ustr = null;
     switch ($version) {
         case self::UUID_V1:
             \uuid_create($hu);
             \uuid_make($hu, \UUID_MAKE_V1 | \UUID_MAKE_MC);
             break;
         case self::UUID_V3:
             \uuid_create($hu);
             if (!$url) {
                 return null;
             }
             $ns = null;
             \uuid_create($ns);
             \uuid_make($hu, \UUID_MAKE_V3, $ns, $url);
             \uuid_destroy($ns);
             break;
         case self::UUID_V4:
             \uuid_create($hu);
             \uuid_make($hu, \UUID_MAKE_V4);
             break;
         case self::UUID_V5:
             \uuid_create($hu);
             \uuid_create($ns);
             \uuid_make($hu, \UUID_MAKE_V5, $ns, $url);
             \uuid_destroy($ns);
             break;
         default:
             return null;
     }
     \uuid_export($hu, UUID_FMT_STR, $ustr);
     $uuid = $ustr;
     return trim($uuid);
 }
コード例 #21
0
function licensing_customerscontent_licensing_BeforeInsert(&$sender)
{
    $licensing_customerscontent_licensing_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $licensing_customerscontent;
    //Compatibility
    //End licensing_customerscontent_licensing_BeforeInsert
    //Custom Code @188-2A29BDB7
    // -------------------------
    // Write your own code here.
    $suiteId = $licensing_customerscontent->licensing->suite_code->GetValue();
    $params = array();
    $params["suite_id"] = $suiteId;
    $products = new Alm\Products();
    $suiteStatus = $products->getSuiteStatusById($params);
    //Check if suite status is active or legacy before adding any new licenses to a customer
    if ($suiteStatus["suiteStatus"] == "1" || $suiteStatus["suiteStatus"] == "2") {
        $guid = uuid_create();
        global $lastguid;
        $lastguid = $guid;
        $licensing_customerscontent->licensing->created_iduser->SetValue(CCGetUserID());
        $licensing_customerscontent->licensing->hidguid->SetValue($guid);
        //Customer ID for the license
        $customer_guid = trim($licensing_customerscontent->licensing->hidcustomer_guid->GetValue());
        $db = new clsDBdbConnection();
        $customer_id = CCDLookup("id", "alm_customers", "guid = '{$customer_guid}'", $db);
        $db->close();
        $licensing_customerscontent->licensing->hidcustomer_id->SetValue($customer_id);
        //Changing license status to active when inactive and grant,expdate,expirdate are present
        $grantNo = trim($licensing_customerscontent->licensing->grant_number->GetValue());
        $expDate = $licensing_customerscontent->licensing->expedition_date->GetValue();
        $expirDate = $licensing_customerscontent->licensing->expiration_date->GetValue();
        $licenseStatus = (int) $licensing_customerscontent->licensing->hidlicensestatus->GetValue();
        $licenseType = (int) $licensing_customerscontent->licensing->id_license_type->GetValue();
        $o = trim($licensing_customerscontent->licensing->hido->GetValue());
        $dguid = trim($licensing_customerscontent->licensing->hiddguid->GetValue());
        $params = array();
        $params["guid"] = $dguid;
        if ($o == "renew") {
            //Keeps the expired license guid reference on the new renewed license
            $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid);
        }
        //Making sure that perpetual licenses dont get expiration date values
        //And change status to active if grantnumber, expiration date have values
        //This changed, perpetuals will be autoactivated and user redirected to add the support license automatically
        if ($licenseStatus == 1 && strlen($grantNo) > 0 && count($expDate) > 1 && count($expirDate) > 1) {
            if ($licenseType == 7 || $licenseType == 12) {
                $licensing_customerscontent->licensing->expiration_date->SetValue("");
            }
            $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2");
            //If renewing and new license is activated, sets expired license as archived
            if ($o == "renew") {
                $products = new Alm\Products();
                $products->setLicenseArchivedByGuid($params);
            }
        } else {
            //Its a perpetual license
            if ($licenseStatus == 1 && ($licenseType == 7 || $licenseType == 12)) {
                $licensing_customerscontent->licensing->expiration_date->SetValue("");
                $licensing_customerscontent->licensing->hidlicensestatus->SetValue("2");
            }
        }
        //Checking if its an addsupport operation to set the support parent perpetual license
        $parentLicenseGuid = trim($licensing_customerscontent->licensing->hiddguid->GetValue());
        $o = trim($licensing_customerscontent->licensing->hido->GetValue());
        if ($o == "addsupport" && strlen($parentLicenseGuid) > 0) {
            $licensing_customerscontent->licensing->hidparent_license_guid->SetValue($parentLicenseGuid);
        }
        //Upgrade licensing
        $o = $licensing_customerscontent->licensing->hido->GetValue();
        if (strlen($dguid) > 0 && $o == "upgrade_license") {
            //Keeps the expired license guid reference on the new renewed license
            $licensing_customerscontent->licensing->hidexpired_license_guid->SetValue($dguid);
            $params = array();
            $params["guid"] = $dguid;
            $products = new Alm\Products();
            $products->setLicenseArchivedByGuid($params);
        }
    } else {
        global $CCSLocales;
        $licensing_customerscontent->licensing->InsertAllowed = false;
        $licensing_customerscontent->licensing->Errors->clear();
        $licensing_customerscontent->licensing->Errors->addError($CCSLocales->GetText("suite_status_notactivelegacy"));
    }
    // -------------------------
    //End Custom Code
    //Close licensing_customerscontent_licensing_BeforeInsert @154-8C89F39C
    return $licensing_customerscontent_licensing_BeforeInsert;
}
コード例 #22
0
ファイル: Server.php プロジェクト: klr2003/sourceread
 /**
  * generate Unique Universal IDentifier for lock token
  *
  * @param  void
  * @return string  a new UUID
  */
 function _new_uuid()
 {
     // use uuid extension from PECL if available
     if (function_exists("uuid_create")) {
         return uuid_create();
     }
     // fallback
     $uuid = md5(microtime() . getmypid());
     // this should be random enough for now
     // set variant and version fields for 'true' random uuid
     $uuid[12] = "4";
     $n = 8 + (ord($uuid[16]) & 3);
     $hex = "0123456789abcdef";
     $uuid[16] = $hex[$n];
     // return formated uuid
     return substr($uuid, 0, 8) . "-" . substr($uuid, 8, 4) . "-" . substr($uuid, 12, 4) . "-" . substr($uuid, 16, 4) . "-" . substr($uuid, 20);
 }
コード例 #23
0
ファイル: setuplib.php プロジェクト: janeklb/moodle
/**
 * Generate a uuid.
 *
 * Unique is hard. Very hard. Attempt to use the PECL UUID functions if available, and if not then revert to
 * constructing the uuid using mt_rand.
 *
 * It is important that this token is not solely based on time as this could lead
 * to duplicates in a clustered environment (especially on VMs due to poor time precision).
 *
 * @return string The uuid.
 */
function generate_uuid()
{
    $uuid = '';
    if (function_exists("uuid_create")) {
        $context = null;
        uuid_create($context);
        uuid_make($context, UUID_MAKE_V4);
        uuid_export($context, UUID_FMT_STR, $uuid);
    } else {
        // Fallback uuid generation based on:
        // "http://www.php.net/manual/en/function.uniqid.php#94959".
        $uuid = sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xfff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
    }
    return trim($uuid);
}
コード例 #24
0
ファイル: Client.php プロジェクト: shanehill00/webdfs
 /**
  * 
  * will fetch a file from the passed url and upload into webdfs
  * 
  * @param string $url
  * @param string $id
  * 
  * @return array the same data as returned by egtPaths( fileId ) 
  * 
  */
 public function fetchFileFromUrl($url, $id = null)
 {
     if (!$id) {
         $id = uuid_create();
     }
     // get the image from the url
     $filedir = sys_get_temp_dir();
     $tmpfname = tempnam($filedir, 'WebDFS');
     file_put_contents($tmpfname, file_get_contents($url));
     // now upload the file into web dfs
     $this->set($id, $tmpfname);
     // now we remove the tmp file
     unlink($tmpfname);
     // now get the details from getpaths and return them
     $details = $this->getPaths($id);
     $details['id'] = $id;
     return $details;
 }
コード例 #25
0
function products_maintcontent_alm_products_BeforeInsert(&$sender)
{
    $products_maintcontent_alm_products_BeforeInsert = true;
    $Component =& $sender;
    $Container =& CCGetParentContainer($sender);
    global $products_maintcontent;
    //Compatibility
    //End products_maintcontent_alm_products_BeforeInsert
    //Custom Code @34-2A29BDB7
    // -------------------------
    // Write your own code here.
    //Check if the suite is active before adding a product for it
    $suiteId = $products_maintcontent->alm_products->suite_code->GetValue();
    $params = array();
    $params["suite_id"] = $suiteId;
    $products = new Alm\Products();
    $suiteStatus = $products->getSuiteStatusById($params);
    //Check if suite status is active before adding any new product for it
    if ($suiteStatus["suiteStatus"] == "1" || $suiteStatus["suiteStatus"] == "2") {
        $guid = uuid_create();
        global $lastguid;
        $lastguid = $guid;
        $products_maintcontent->alm_products->created_iduser->SetValue(CCGetUserID());
        $products_maintcontent->alm_products->hidguid->SetValue($guid);
    } else {
        global $CCSLocales;
        $products_maintcontent->alm_products->InsertAllowed = false;
        $products_maintcontent->alm_products->Errors->clear();
        $products_maintcontent->alm_products->Errors->addError($CCSLocales->GetText("suite_status_notactive"));
    }
    // -------------------------
    //End Custom Code
    //Close products_maintcontent_alm_products_BeforeInsert @2-A4122BFF
    return $products_maintcontent_alm_products_BeforeInsert;
}
コード例 #26
0
function emit_message($subtopic, $message)
{
    global $config, $queue;
    # Re-implement some of the logc from fedmsg/core.py
    # We'll have to be careful to keep this up to date.
    $prefix = "org.fedoraproject." . $config['environment'] . ".wiki.";
    $topic = $prefix . $subtopic;
    $message_obj = array("topic" => $topic, "msg" => $message, "timestamp" => round(time(), 3), "msg_id" => date("Y") . "-" . uuid_create(), "username" => "apache", "i" => 1);
    if (array_key_exists('sign_messages', $config) and to_bool($config['sign_messages'])) {
        $message_obj = sign_message($message_obj);
    }
    $envelope = json_encode($message_obj);
    $queue->send($topic, ZMQ::MODE_SNDMORE);
    $queue->send($envelope);
}
コード例 #27
0
ファイル: Pecl.php プロジェクト: DrupalCamp-NYC/dcnyc16
 /**
  * {@inheritdoc}
  */
 public function generate()
 {
     return uuid_create(UUID_TYPE_DEFAULT);
 }
コード例 #28
0
 public function saveContactSubHobbies($params = array())
 {
     $result = array("status" => false, "message" => "", "result" => array());
     $subhobbie = $params["subhobbie"];
     $contact_guid = $params["contact_guid"];
     $parent_id = $params["parent_id"];
     if (strlen($contact_guid) > 0) {
         $db2 = new clsDBdbConnection();
         $subhobbies_list = "";
         foreach ($subhobbie as $hobbie) {
             $subhobbies_list .= $hobbie . ",";
         }
         //Check if subhobbies for the parent_id has been added for the contact
         $contact_id = CCDLookup("id", "alm_customers_contacts", "guid = '{$contact_guid}'", $db2);
         $parent_hobbie = (int) CCDLookup("1 as exist", "alm_customers_contacts_subhobbies_details", "contact_id = {$contact_id} and hobbie_id = {$parent_id}", $db2);
         $contact_hobbies = CCDLookup("hobbies", "alm_customers_contacts", "id = {$contact_id}", $db2);
         $contact_hobbies = trim($contact_hobbies, ",");
         $contact_hobbies = explode(",", $contact_hobbies);
         if (!in_array($parent_id, $contact_hobbies)) {
             $contact_hobbies[] = $parent_id;
         }
         $contact_hobbies = implode(",", $contact_hobbies);
         $sql2 = "update alm_customers_contacts set hobbies = '{$contact_hobbies}' where id = {$contact_id} ";
         $db2->query($sql2);
         if ($parent_hobbie == 1) {
             $sql2 = "update alm_customers_contacts_subhobbies_details set subhobbies = '{$subhobbies_list}' where contact_id = {$contact_id} and hobbie_id = {$parent_id}";
             $db2->query($sql2);
         } else {
             $guidDetail = uuid_create();
             $sql2 = "insert into alm_customers_contacts_subhobbies_details(guid,contact_id, hobbie_id, subhobbies) values('{$guidDetail}',{$contact_id}, {$parent_id}, '{$subhobbies_list}')";
             $db2->query($sql2);
         }
         $db2->close();
         $result["status"] = true;
         $result["message"] = "Command executed successfully";
         return $result;
     }
     return $result;
 }
コード例 #29
0
 public function preCreate(Datastore $oDB, Datastore_Record $oRecord)
 {
     if (!$oRecord->getUniqueId()) {
         $oRecord->setUniqueId(uuid_create(UUID_TYPE_TIME));
     }
     return true;
 }
コード例 #30
-1
ファイル: Uuid.php プロジェクト: x59/horde-support
 /**
  * Generate a 36-character RFC 4122 UUID, without the urn:uuid: prefix.
  *
  * @see http://www.ietf.org/rfc/rfc4122.txt
  * @see http://labs.omniti.com/alexandria/trunk/OmniTI/Util/UUID.php
  */
 public function generate()
 {
     $this->_uuid = null;
     if (extension_loaded('uuid')) {
         if (function_exists('uuid_export')) {
             // UUID extension from http://www.ossp.org/pkg/lib/uuid/
             if (uuid_create($ctx) == UUID_RC_OK && uuid_make($ctx, UUID_MAKE_V4) == UUID_RC_OK && uuid_export($ctx, UUID_FMT_STR, $str) == UUID_RC_OK) {
                 $this->_uuid = $str;
                 uuid_destroy($ctx);
             }
         } else {
             // UUID extension from http://pecl.php.net/package/uuid
             $this->_uuid = uuid_create();
         }
     }
     if (!$this->_uuid) {
         list($time_mid, $time_low) = explode(' ', microtime());
         $time_low = (int) $time_low;
         $time_mid = (int) substr($time_mid, 2) & 0xffff;
         $time_high = mt_rand(0, 0xfff) | 0x4000;
         $clock = mt_rand(0, 0x3fff) | 0x8000;
         $node_low = function_exists('zend_thread_id') ? zend_thread_id() : getmypid();
         $node_high = isset($_SERVER['SERVER_ADDR']) ? ip2long($_SERVER['SERVER_ADDR']) : crc32(php_uname());
         $node = bin2hex(pack('nN', $node_low, $node_high));
         $this->_uuid = sprintf('%08x-%04x-%04x-%04x-%s', $time_low, $time_mid, $time_high, $clock, $node);
     }
 }