當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zone::retrieveID方法代碼示例

本文整理匯總了PHP中Zone::retrieveID方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zone::retrieveID方法的具體用法?PHP Zone::retrieveID怎麽用?PHP Zone::retrieveID使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zone的用法示例。


在下文中一共展示了Zone::retrieveID方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addDELEGATERecord

 /**
  * Add a delegation to the current zone
  *
  *@access private
  *@param string $delegatefrom lower limit of range
  *@param string $delegateto upper limit of range
  *@param string $delegateuser user to delegate zone to
  *@param int $ttl ttl value for this record
  *@return string text of result (Adding DELEGATE Record... Ok)
  */
 function addDELEGATERecord($delegatefrom, $delegateto, $delegateuser, $ttl)
 {
     global $db, $html, $l;
     $i = 0;
     $result = "";
     while (list($key, $value) = each($delegatefrom)) {
         if (!empty($value)) {
             $result .= sprintf($l['str_primary_adding_delegate_x'], xssafe($value), xssafe($delegateto[$i])) . "... ";
             if (!ereg('^[0-9]+$', $value)) {
                 $this->error = sprintf($l['str_primary_bad_lower_limit_x'], xssafe($value));
             } else {
                 if (!ereg('^[0-9]+$', $delegateto[$i]) || $delegateto[$i] > 255) {
                     $this->error = sprintf($l['str_primary_bad_upper_limit_x'], xssafe($delegateto[$i]));
                 } else {
                     // check if lower if below upper
                     if (!($value <= $delegateto[$i])) {
                         $this->error = sprintf($l['str_primary_bad_limits_x_x'], xssafe($value), xssafe($delegateto[$i]));
                     } else {
                         if (empty($delegateuser[$i])) {
                             $this->error = $l['str_primary_no_user_for_delegation'];
                         } else {
                             // check if user is in DB or not
                             $newuserid = $this->user->RetrieveId(addslashes($delegateuser[$i]));
                             if ($this->user->error) {
                                 $this->error = $this->user->error;
                             } else {
                                 if (!$newuserid) {
                                     $this->error = sprintf($l['str_primary_delegate_user_x_doesnot_exist'], xssafe($delegateuser[$i]));
                                 } else {
                                     // user exists
                                     // check if items inside this range are already registered or not
                                     $query = "SELECT val1 FROM dns_record WHERE zoneid='" . $this->zoneid . "' AND type='DELEGATE'";
                                     $res = $db->query($query);
                                     if ($db->error()) {
                                         $this->error = $l['str_trouble_with_db'];
                                     } else {
                                         while ($line = $db->fetch_row($res)) {
                                             list($from, $to) = split('-', $line[0]);
                                             if ($from <= $value && $to >= $value || $from >= $value && $from <= $delegateto[$i]) {
                                                 $this->error = sprintf($l['str_primary_delegate_bad_limits_x_x_overlaps_existing_x_x'], xssafe($value), xssafe($delegateto[$i]), xssafe($from), xssafe($to));
                                             }
                                         }
                                         if (!$this->error) {
                                             $ttlval = $this->fixDNSTTL($ttl[$i]);
                                             $query = "INSERT INTO dns_record (zoneid, type, val1, val2, ttl)\n                          VALUES ('" . $this->zoneid . "', 'DELEGATE', '" . mysql_real_escape_string($value . "-" . $delegateto[$i]) . "','" . mysql_real_escape_string($delegateuser[$i]) . "','" . $ttlval . "')";
                                             $db->query($query);
                                             if ($db->error()) {
                                                 $this->error = $l['str_trouble_with_db'];
                                             } else {
                                                 // create zone, affect it to delegateuser
                                                 // Can NOT use standard create way because
                                                 // of EXIST check. BUG: can not insert userlog
                                                 $query = "INSERT INTO dns_zone (zone,zonetype,userid) VALUES ('" . mysql_real_escape_string($value . "-" . $delegateto[$i] . "." . $this->zonename) . "','P','" . $newuserid . "')";
                                                 $res = $db->query($query);
                                                 if ($db->error()) {
                                                     $this->error = $l['str_trouble_with_db'];
                                                 } else {
                                                     // create dns_confprimary records
                                                     // NO - user has to modify it manually
                                                     // create NS records
                                                     $nskeys = array_keys($this->ns);
                                                     while ($nskey = array_shift($nskeys)) {
                                                         $query = "INSERT INTO dns_record\n                                (zoneid,type,val1,val2,ttl)\n                                VALUES ('" . $this->zoneid . "',\n                                'SUBNS','" . mysql_real_escape_string($value) . "-" . mysql_real_escape_string($delegateto[$i]) . "','" . mysql_real_escape_string($nskey) . "','" . $this->fixDNSTTL($this->nsttl[$nskey]) . "')";
                                                         $res = $db->query($query);
                                                         if ($db->error()) {
                                                             $this->error = $l['str_trouble_with_db'];
                                                         }
                                                     }
                                                     // create CNAME records
                                                     $newzone = new Zone($value . "-" . $delegateto[$i] . "." . $this->zonename, 'P', '', $newuserid);
                                                     $newzone->retrieveID($value . "-" . $delegateto[$i] . "." . $this->zonename, 'P');
                                                     for ($cnamecounter = $value; $cnamecounter <= $delegateto[$i]; $cnamecounter++) {
                                                         $query = "INSERT INTO dns_record\n                                (zoneid, type, val1, val2,ttl)\n                                VALUES\n                                ('" . $this->zoneid . "',\n                                'CNAME', '" . $cnamecounter . "',\n                                '" . $cnamecounter . "." . mysql_real_escape_string($value) . "-" . mysql_real_escape_string($delegateto[$i]) . "." . $this->zonename . ".'," . "'" . $ttlval . "')";
                                                         $db->query($query);
                                                         if ($db->error()) {
                                                             $this->error = $l['str_trouble_with_db'];
                                                         }
                                                     }
                                                     // end for each CNAME
                                                     if (!$this->error) {
                                                         $result .= $l['str_primary_ok'] . "<br>\n";
                                                     }
                                                 }
                                             }
                                         }
                                         // no error
                                     }
                                     // else db error
                                 }
                                 // user exists
//.........這裏部分代碼省略.........
開發者ID:RzeszowPL,項目名稱:freedns,代碼行數:101,代碼來源:primary.php


注:本文中的Zone::retrieveID方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。