Beispiel #1
0
 public function getUserIP()
 {
     foreach (['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'] as $name) {
         if (isset($_SERVER[$name]) && Check::isIp($_SERVER[$name])) {
             return $_SERVER[$name];
         }
     }
     return null;
 }
Beispiel #2
0
 /**
  * 保存一个url快捷方式;
  *
  * @param $url
  * @param $attachmentName
  */
 public function saveUrl($url, $attachmentName)
 {
     if (!Check::isUrl($url)) {
         throw new InvalidValueException("Invalid varlue url");
     }
     $attachmentName = '.url' == substr($attachmentName, -4) ? $attachmentName : "{$attachmentName}.url";
     $content = "[InternetShortcut]\r\nURL={$url}\r\nIDList=\r\n[{000214A0-0000-0000-C000-000000000046}]\r\nProp3=19,2";
     return $this->sendContentAsFile($content, $attachmentName, 'application/octet-stream');
 }